FS2_Open
Open source remastering of the Freespace 2 engine
scoring.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) Volition, Inc. 1999. All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell
5  * or otherwise commercially exploit the source or things you created based on the
6  * source.
7  *
8 */
9 
10 
11 
12 #ifndef _SCORING_HEADER_FILE
13 #define _SCORING_HEADER_FILE
14 
15 #include <time.h>
16 
17 #include "globalincs/globals.h"
18 #include "globalincs/pstypes.h"
19 
20 class player;
21 class ship;
22 class object;
23 
24 #define NUM_MEDALS_FS2 18
25 #define NUM_MEDALS_FS1 16
26 extern int Num_medals;
27 
28 #define NUM_RANKS 10
29 
30 #define RANK_ENSIGN 0
31 #define RANK_LT_JUNIOR 1
32 #define RANK_LT 2
33 #define RANK_LT_CMDR 3
34 #define RANK_CMDR 4
35 #define RANK_CAPTAIN 5
36 #define RANK_COMMODORE 6
37 #define RANK_REAR_ADMIRAL 7
38 #define RANK_VICE_ADMIRAL 8
39 #define RANK_ADMIRAL 9
40 
41 #define MAX_FREESPACE1_RANK RANK_COMMODORE
42 #define MAX_FREESPACE2_RANK RANK_ADMIRAL
43 
44 
45 /*
46  The ins and outs of when/where stats are stored and retreived - BE SURE TO FOLLOW THESE GUIDELINES
47 
48  SINGLE PLAYER :
49  scoring_level_init() is called from game_level_init(). This zeroes out mission specific stats
50  scoring_level_close() is called from the debriefing screen when the player hits accept. This saves the mission
51  stats to alltime stats, and updates any campaign stats
52  NOTE : in single player mode, if the player is going back to replay an old mission, the stats shouldn't be
53  stored again
54 
55  MULTI PLAYER :
56  scoring_level_init() is called in game_level_init() again.
57  init_multiplayer_stats() is called on all computers in the game when moving _into_ the MISSION_SYNC state
58 
59  scoring_level_close() is called on all machines when the host selects accept. If the host is not on the standalone
60  he sends a packet to all players indicating that they should save their data. If he _is_ on the standalone, he should
61  send only to the standalone, and then it rebroadcasts the packet ot everyone else.
62 */
63 
64 
65 typedef struct rank_stuff {
66  char name[NAME_LENGTH]; // name of this rank
67  SCP_map<int, char*> promotion_text; // text to display when promoted to this rank
68  int points; // points needed to reach this rank
69  char bitmap[MAX_FILENAME_LEN]; // bitmap of this rank medal
71 } rank_stuff;
72 
73 #define STATS_FLAG_INVALID (1<<0)
74 #define STATS_FLAG_CAMPAIGN (1<<1)
75 #define STATS_FLAG_MULTIPLAYER (1<<2)
76 
78 {
79 public:
80  int flags;
81 
82  // All-time total
83  int score; // all time score
84  int rank; // all time rank
85  SCP_vector<int> medal_counts; // all time medal counts
86 
87  int kills[MAX_SHIP_CLASSES]; // only valid kills (i.e. not on friendlies).
88  int assists; // alltime assists
89  int kill_count; // total alltime kills
90  int kill_count_ok; // total valid alltime kills (no friendlies)
91  unsigned int p_shots_fired; // primary weapon shots fired
92  unsigned int s_shots_fired; // secondary weapon shots fired
93 
94  unsigned int p_shots_hit; // primary weapon shots hit
95  unsigned int s_shots_hit; // secondary weapon shots hit
96 
97  unsigned int p_bonehead_hits; // alltime primary friendly hits
98  unsigned int s_bonehead_hits; // alltime secondary friendly hits
99  int bonehead_kills; // alltime friendly kills
100 
101  unsigned int missions_flown; // total # of missions flown
102  unsigned int flight_time; // total # of flight hours the player has
103  _fs_time_t last_flown; // last time the player has flown
104  _fs_time_t last_backup; // so we can easily call scoring_level_backout()
105 
106  // Mission total
107  int m_medal_earned; // which medal (if any) earned this mission
108  SCP_vector<int> m_badge_earned; // which badge(s) was(/were) earned. Calculated after mission is over
109  int m_promotion_earned; // was a promotion earned. Calculated after mission is over
110 
111  int m_score;
112  int m_kills[MAX_SHIP_CLASSES]; // this will represent all kills in the mission (bonehead or not)
113  int m_okKills[MAX_SHIP_CLASSES]; // this will be only the "valid" kills the player made
114  int m_kill_count; // total kills for this mission
115  int m_kill_count_ok; // total (non-friendly) kills for this mission
116  int m_assists; // player assits for the mission
117  unsigned int mp_shots_fired; // primary shots fired for the mission
118  unsigned int ms_shots_fired; // secondary shots fired for the mission
119  unsigned int mp_shots_hit; // primary shots hit for the mission
120  unsigned int ms_shots_hit; // secondary shots hit for the mission
121  unsigned int mp_bonehead_hits; // primary friendly hits for the mission
122  unsigned int ms_bonehead_hits; // secondary friendly hits for the mission
123  int m_bonehead_kills; // # of friendly kills for the mission
124  int m_player_deaths; // player deaths for the mission (really only useful for multiplayer)
125 
126  int m_dogfight_kills[MAX_PLAYERS]; // kills by player for multiplayer dogfight
127 
130 
131  void init();
132  void assign(const scoring_struct &s);
133 
134 };
135 
136 extern rank_stuff Ranks[NUM_RANKS];
137 
138 void parse_rank_tbl();
139 void scoring_level_init( scoring_struct *score );
140 void scoring_level_close(int accepted = 1);
142 void scoring_do_accept( scoring_struct *score );
143 
144 // function to give a medal to a player if he earned it
146 
147 void scoring_add_damage(object *ship_obj,object *other_obj,float damage);
148 void scoring_add_damage_to_weapon(object *weapon_obj,object *other_obj,float damage);
149 int scoring_eval_kill(object *ship_obj);
150 int scoring_eval_kill_on_weapon(object *weapon_obj, object *other_obj);
151 void scoring_eval_assists(ship *sp,int killer_sig, bool enemy_player = false);
152 
153 // bash the passed player to the specified rank
154 void scoring_bash_rank(player *pl,int rank);
155 
156 // eval a hit on an object (for primary and secondary hit purposes)
157 void scoring_eval_hit(object *hit_obj, object *other_obj, int from_blast = 0);
158 
159 // get a scaling factor for adding/subtracting from mission score
161 
162 #endif
#define MAX_FILENAME_LEN
Definition: pstypes.h:324
int kill_count_ok
Definition: scoring.h:90
void scoring_eval_hit(object *hit_obj, object *other_obj, int from_blast=0)
Definition: scoring.cpp:1188
int scoring_eval_kill_on_weapon(object *weapon_obj, object *other_obj)
Definition: scoring.cpp:858
void scoring_level_close(int accepted=1)
Definition: scoring.cpp:432
float scoring_get_scale_factor()
Definition: scoring.cpp:1447
int kills[MAX_SHIP_CLASSES]
Definition: scoring.h:87
int points
Definition: scoring.h:68
void scoring_backout_accept(scoring_struct *score)
Definition: scoring.cpp:378
unsigned int mp_shots_fired
Definition: scoring.h:117
unsigned int mp_bonehead_hits
Definition: scoring.h:121
int m_kills[MAX_SHIP_CLASSES]
Definition: scoring.h:112
int m_bonehead_kills
Definition: scoring.h:123
_fs_time_t last_flown
Definition: scoring.h:103
long _fs_time_t
Definition: pstypes.h:55
int kill_count
Definition: scoring.h:89
unsigned int ms_bonehead_hits
Definition: scoring.h:122
void scoring_bash_rank(player *pl, int rank)
Definition: scoring.cpp:1470
void scoring_add_damage(object *ship_obj, object *other_obj, float damage)
Definition: scoring.cpp:492
unsigned int s_shots_fired
Definition: scoring.h:92
unsigned int mp_shots_hit
Definition: scoring.h:119
int Num_medals
Definition: medals.cpp:30
SCP_vector< int > m_badge_earned
Definition: scoring.h:108
unsigned int ms_shots_fired
Definition: scoring.h:118
int m_kill_count_ok
Definition: scoring.h:115
void scoring_add_damage_to_weapon(object *weapon_obj, object *other_obj, float damage)
Definition: scoring.cpp:1351
unsigned int missions_flown
Definition: scoring.h:101
Definition: player.h:85
int m_okKills[MAX_SHIP_CLASSES]
Definition: scoring.h:113
int m_promotion_earned
Definition: scoring.h:109
unsigned int p_shots_fired
Definition: scoring.h:91
#define MAX_SHIP_CLASSES
Definition: globals.h:48
int scoring_eval_kill(object *ship_obj)
Definition: scoring.cpp:590
Definition: bmpman.h:101
GLdouble s
Definition: Glext.h:5321
#define MAX_PLAYERS
Definition: pstypes.h:32
rank_stuff Ranks[NUM_RANKS]
Definition: scoring.cpp:45
SCP_vector< int > medal_counts
Definition: scoring.h:85
Definition: ship.h:534
int m_dogfight_kills[MAX_PLAYERS]
Definition: scoring.h:126
void scoring_do_accept(scoring_struct *score)
Definition: scoring.cpp:329
Definition: object.h:141
void scoring_check_medal(scoring_struct *sc)
void assign(const scoring_struct &s)
Definition: scoring.cpp:173
GLuint const GLchar * name
Definition: Glext.h:5608
void scoring_eval_assists(ship *sp, int killer_sig, bool enemy_player=false)
Definition: scoring.cpp:1104
unsigned int flight_time
Definition: scoring.h:102
struct rank_stuff rank_stuff
int m_medal_earned
Definition: scoring.h:107
#define NAME_LENGTH
Definition: globals.h:15
void parse_rank_tbl()
Definition: scoring.cpp:58
unsigned int p_shots_hit
Definition: scoring.h:94
unsigned int p_bonehead_hits
Definition: scoring.h:97
SCP_map< int, char * > promotion_text
Definition: scoring.h:67
#define NUM_RANKS
Definition: scoring.h:28
int m_player_deaths
Definition: scoring.h:124
void scoring_level_init(scoring_struct *score)
Definition: scoring.cpp:223
int bonehead_kills
Definition: scoring.h:99
scoring_struct(const scoring_struct &s)
Definition: scoring.h:129
int m_kill_count
Definition: scoring.h:114
char promotion_voice_base[MAX_FILENAME_LEN]
Definition: scoring.h:70
unsigned int ms_shots_hit
Definition: scoring.h:120
unsigned int s_shots_hit
Definition: scoring.h:95
unsigned int s_bonehead_hits
Definition: scoring.h:98
_fs_time_t last_backup
Definition: scoring.h:104