[Add] Combat rating based on mass of pilots killed. -- [Add] Player name.

This commit is contained in:
Allanis 2013-02-24 18:18:52 +00:00
parent 84558ae2c9
commit 439fce48c8
6 changed files with 54 additions and 9 deletions

View File

@ -7,6 +7,7 @@
#include "pause.h" #include "pause.h"
#include "pilot.h" #include "pilot.h"
#include "space.h" #include "space.h"
#include "player.h"
#include "menu.h" #include "menu.h"
#define MENU_WIDTH 120 #define MENU_WIDTH 120
@ -89,8 +90,9 @@ void info_menu(void) {
"Combat Rating:\n"); "Combat Rating:\n");
snprintf(str, 128, snprintf(str, 128,
"Foobar\n" "%s\n"
"Luser\n"); "%s\n",
player_name, player_rating());
window_addText(wid, 120, 20, window_addText(wid, 120, 20,
INFO_WIDTH-120-BUTTON_WIDTH, INFO_HEIGHT-60, INFO_WIDTH-120-BUTTON_WIDTH, INFO_HEIGHT-60,

View File

@ -21,7 +21,9 @@ static unsigned int pilot_id = PLAYER_ID;
Pilot** pilot_stack = NULL; // Not static, it is used in player.c and weapon.c and ai.c Pilot** pilot_stack = NULL; // Not static, it is used in player.c and weapon.c and ai.c
int pilots = 0; int pilots = 0;
static int mpilots = 0; static int mpilots = 0;
extern Pilot* player; extern Pilot* player;
extern unsigned int combat_rating;
// Stack of fleets. // Stack of fleets.
static Fleet* fleet_stack = NULL; static Fleet* fleet_stack = NULL;
@ -177,8 +179,8 @@ static void pilot_shootWeapon(Pilot* p, PilotOutfit* w, const unsigned int t) {
} }
// Damage the pilot. // Damage the pilot.
void pilot_hit(Pilot* p, const Solid* w,const double damage_shield, void pilot_hit(Pilot* p, const Solid* w, const unsigned int shooter,
const double damage_armour) { const double damage_shield, const double damage_armour) {
double dam_mod; double dam_mod;
@ -197,8 +199,16 @@ void pilot_hit(Pilot* p, const Solid* w,const double damage_shield,
dam_mod = damage_armour/p->armour_max; dam_mod = damage_armour/p->armour_max;
} }
else { else {
// We are officially dead.
p->armour = 0.; p->armour = 0.;
dam_mod = 0.; dam_mod = 0.;
if(!pilot_isFlag(p, PILOT_DEAD)) {
pilot_setFlag(p, PILOT_DEAD);
// Adjust the combat rating based on pilot mass.
if(shooter == PLAYER_ID) combat_rating += MAX(1, p->ship->mass/50);
}
} }
vect_cadd(&p->solid->vel, vect_cadd(&p->solid->vel,

View File

@ -29,7 +29,8 @@
#define PILOT_HYP_BEGIN (1<<6) // Pilot is starting engines. #define PILOT_HYP_BEGIN (1<<6) // Pilot is starting engines.
#define PILOT_HYPERSPACE (1<<7) // Pilot is in hyperspace. #define PILOT_HYPERSPACE (1<<7) // Pilot is in hyperspace.
#define PILOT_DISABLED (1<<9) // Pilot is disabled. #define PILOT_DISABLED (1<<9) // Pilot is disabled.
#define PILOT_DELETE (1<<10) // Pilot will get delete asap. #define PILOT_DEAD (1<<10) // Pilot is on it's death bed.
#define PILOT_DELETE (1<<15) // Pilot will get delete asap.
// Just makes life simpler. // Just makes life simpler.
#define pilot_isPlayer(p) ((p)->flags & PILOT_PLAYER) #define pilot_isPlayer(p) ((p)->flags & PILOT_PLAYER)
@ -105,7 +106,7 @@ Fleet* fleet_get(const char* name);
// MISC. // MISC.
void pilot_shoot(Pilot* p, const unsigned int target, const int secondary); void pilot_shoot(Pilot* p, const unsigned int target, const int secondary);
void pilot_hit(Pilot* p, const Solid* w, void pilot_hit(Pilot* p, const Solid* w, const unsigned int shooter,
const double damage_shield, const double damage_armour); const double damage_shield, const double damage_armour);
void pilot_setAmmo(Pilot* p); void pilot_setAmmo(Pilot* p);
double pilot_face(Pilot* p, const float dir); double pilot_face(Pilot* p, const float dir);

View File

@ -31,12 +31,17 @@
// Player stuff. // Player stuff.
Pilot* player = NULL; // extern in pilot.h Pilot* player = NULL; // extern in pilot.h
unsigned int credits = 0; // Player global properties.
char* player_name = NULL; // Player name.
unsigned int credits = NULL; // Ze monies.
unsigned int combat_rating = 0; // Ze rating.
unsigned int player_flags = 0; // Player flags. unsigned int player_flags = 0; // Player flags.
// Input.c
double player_turn = 0.; // Turn velocity from input. double player_turn = 0.; // Turn velocity from input.
double player_acc = 0.; // Accel velocity from input. double player_acc = 0.; // Accel velocity from input.
unsigned int player_target = PLAYER_ID; // Targetted pilot. unsigned int player_target = PLAYER_ID; // Targetted pilot.
static int planet_target = -1; // Targetted planet. static int planet_target = -1; // Targetted planet.
// Internal.
static int hyperspace_target = -1; // Target hyperspace route. static int hyperspace_target = -1; // Target hyperspace route.
static double hyperspace_flash = 0.; static double hyperspace_flash = 0.;
@ -158,6 +163,8 @@ void player_new(void) {
else if(xml_isNode(tmp, "y")) y = xml_getFloat(tmp); else if(xml_isNode(tmp, "y")) y = xml_getFloat(tmp);
} while((tmp = tmp->next)); } while((tmp = tmp->next));
} }
else if(xml_isNode(cur, "combat_rating"))
combat_rating = xml_getInt(cur);
} while((cur = cur->next)); } while((cur = cur->next));
} }
}while((node = node->next)); }while((node = node->next));
@ -213,6 +220,28 @@ void player_clear(void) {
hyperspace_target = -1; hyperspace_target = -1;
} }
static char* player_ratings[] = {
"None",
"Smallfry",
"Minor",
"Average",
"Major",
"Fearsom",
"Godlike"
};
const char* player_rating(void) {
if(combat_rating == 0) return player_ratings[0];
else if(combat_rating < 50) return player_ratings[1];
else if(combat_rating < 200) return player_ratings[2];
else if(combat_rating < 500) return player_ratings[3];
else if(combat_rating < 1000) return player_ratings[4];
else if(combat_rating < 2500) return player_ratings[5];
else if(combat_rating < 10000) return player_ratings[6];
else return player_ratings[7];
}
// Render the background player stuff, namely planet target // Render the background player stuff, namely planet target
void player_renderBG(void) { void player_renderBG(void) {
double x, y; double x, y;

View File

@ -16,8 +16,10 @@
// The player. // The player.
extern Pilot* pilot; extern Pilot* pilot;
extern char* player_name;
extern unsigned int player_flags; extern unsigned int player_flags;
extern unsigned int credits; extern unsigned int credits;
extern unsigned int combat_rating;
typedef enum { RADAR_RECT, RADAR_CIRCLE } RadarShape; // For render functions. typedef enum { RADAR_RECT, RADAR_CIRCLE } RadarShape; // For render functions.
@ -34,6 +36,7 @@ void player_renderBG(void); // Render BG layer.
void player_message(const char* fmt, ...); void player_message(const char* fmt, ...);
void player_clear(void); void player_clear(void);
void player_warp(const double x, const double y); void player_warp(const double x, const double y);
const char* player_rating(void);
// Keybind actions. // Keybind actions.
void player_setRadarRel(int mod); void player_setRadarRel(int mod);

View File

@ -243,7 +243,7 @@ static void weapon_hit(Weapon* w, Pilot* p, WeaponLayer layer) {
pilot_setFlag(p, PILOT_HOSTILE); pilot_setFlag(p, PILOT_HOSTILE);
// Let the ship know that is should take some kind of damage. // Let the ship know that is should take some kind of damage.
pilot_hit(p, w->solid, w->outfit->damage_shield, w->outfit->damage_armour); pilot_hit(p, w->solid, w->parent, w->outfit->damage_shield, w->outfit->damage_armour);
// We don't need the weapon particle any longer. // We don't need the weapon particle any longer.
weapon_destroy(w, layer); weapon_destroy(w, layer);
} }