Open source remastering of the Freespace 2 engine
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 */
12 #ifndef _PLAYER_H
13 #define _PLAYER_H
15 #include "globalincs/globals.h"
16 #include "hud/hudtarget.h" // for targeting hotkey lists
17 #include "io/keycontrol.h" // for button_info
18 #include "localization/localize.h"
19 #include "network/multi_options.h"
20 #include "parse/sexp.h"
21 #include "physics/physics.h"
22 #include "stats/scoring.h" // for scoring/stats
24 struct campaign_info;
26 #define MAX_KEYED_TARGETS 8 // number of hot keys available to assign targets to
28 // player image defines
29 #define PLAYER_PILOT_PIC_W 160
30 #define PLAYER_PILOT_PIC_H 120
32 #define PLAYER_SQUAD_PIC_W 128
33 #define PLAYER_SQUAD_PIC_H 128
35 // player flags follow
36 #define PLAYER_FLAGS_MATCH_TARGET (1<<0) // currently matching speed with selected target
37 #define PLAYER_FLAGS_MSG_MODE (1<<1) // is the player in messaging mode?
38 #define PLAYER_FLAGS_AUTO_TARGETING (1<<2) // is auto targeting on?
39 #define PLAYER_FLAGS_AUTO_MATCH_SPEED (1<<3) // is auto speed matching on?
40 #define PLAYER_FLAGS_STRUCTURE_IN_USE (1<<4) // is this structure in use -- for multiplayer games
41 #define PLAYER_FLAGS_PROMOTED (1<<5) // possibly set in mission to automatically give player promotion
42 #define PLAYER_FLAGS_IS_MULTI (1<<6) // this is a multiplayer pilot
43 #define PLAYER_FLAGS_DIST_WARNING (1<<7) // is this player under warning for being too far from battle
44 #define PLAYER_FLAGS_FORCE_MISSION_OVER (1<<8) // mission is being forced over for this player
45 #define PLAYER_FLAGS_LINK_PRIMARY (1<<9) // primary weapons were linked last mission
46 #define PLAYER_FLAGS_LINK_SECONDARY (1<<10) // secondary weapons were linked last mission
47 #define PLAYER_FLAGS_NO_CHECK_ALL_ALONE_MSG (1<<11) // player can't receive 'you're all alone...' message from Terran Command
48 #define PLAYER_FLAGS_KILLED_BY_EXPLOSION (1<<12) // player was killed by an instantaneous area-effect explosion
49 #define PLAYER_FLAGS_HAS_PLAYED_PXO (1<<13) // this pilot has at least played PXO once in the past.
50 #define PLAYER_FLAGS_DIST_TO_BE_KILLED (1<<14) // the pilot has been warned about distance and will be killed after message finishes playing
51 #define PLAYER_FLAGS_KILLED_BY_ENGINE_WASH (1<<15) // player was killed by engine wash
52 #define PLAYER_FLAGS_KILLED_SELF_UNKNOWN (1<<16) // player died by his own hand
53 #define PLAYER_FLAGS_KILLED_SELF_MISSILES (1<<17) // player died by his own missile
54 #define PLAYER_FLAGS_KILLED_SELF_SHOCKWAVE (1<<18) // player died by his own shockwave
58 #define PCM_NORMAL 0 // normal flying mode
59 #define PCM_WARPOUT_STAGE1 1 // speed up to 40 km/s
60 #define PCM_WARPOUT_STAGE2 2 // flying towards and through warp hole
61 #define PCM_WARPOUT_STAGE3 3 // through warp hole, waiting for it to disapper.
62 #define PCM_SUPERNOVA 4 // supernova. lock everything to where it is.
64 // 'lua game control' settings
65 #define LGC_NORMAL (1<<0) // normal controls
66 #define LGC_STEERING (1<<1) // allow lua to fully override steering controls
67 #define LGC_FULL (1<<2) // allow lua to fully override controls
69 #define LGC_B_NORMAL (1<<3) // allow lua to keep recording button commands
70 #define LGC_B_OVERRIDE (1<<4) // allow lua to override current button commands
71 #define LGC_B_ADDITIVE (1<<5) // allow lua add current lua button commands to current commands
73 #define LGC_B_POLL_ALL (1<<6) // tell game code to pass all button commands to lua.
75 // number of times dude can fail a mission in a session before
76 // having the opportunity to skip it
80 typedef struct campaign_stats {
81  char campaign_name[MAX_FILENAME_LEN+1]; // insurance
85 class player
86 {
87 public:
88  void reset();
89  void assign(const player *pl);
92  char short_callsign[CALLSIGN_LEN + 1]; // callsign truncated to SHORT_CALLSIGN_PIXEL_W pixels
93  int short_callsign_width; // useful for mutliplayer chat boxes.
95  char image_filename[MAX_FILENAME_LEN+1]; // filename of the image for this pilot
96  char s_squad_filename[MAX_FILENAME_LEN+1]; // filename of the squad image for this pilot
97  char s_squad_name[NAME_LENGTH + 1]; // pilot's squadron name
98  char m_squad_filename[MAX_FILENAME_LEN+1]; // filename of the squad image for this pilot (multiplayer)
99  char m_squad_name[NAME_LENGTH + 1]; // pilot's squadron name (multiplayer)
101  char current_campaign[MAX_FILENAME_LEN+1]; // Name of the currently active campaign, or zero-length string if none
104  int flags;
107  htarget_list keyed_targets[MAX_KEYED_TARGETS]; // linked list of hot-keyed targets
108  int current_hotkey_set; // currently hotkey set in use, -1 if none
110  vec3d lead_target_pos; // (x,y,z) of the lead target indicator
111  int lead_target_cheat; // whether cheat for firing at lead indicator is active
112  int lead_indicator_active; // flag that indicates the lead indicator is enabled
114  int lock_indicator_x; // 2D screen x-coordinate of the lock indicator
115  int lock_indicator_y; // 2D screen y-coordinate of the lock indicator
116  int lock_indicator_start_x; // 2D screen x-coordinate of where lock indicator originated
117  int lock_indicator_start_y; // 2D screen y-coordinate of where lock indicator originated
118  int lock_indicator_visible; // flag indicating if the lock indicator is on screen or not
119  float lock_time_to_target; // time left (in milliseconds) before minimum time to lock elapsed
120  float lock_dist_to_target; // distance from lock indicator to target (in pixels)
122  int last_ship_flown_si_index; // ship info index of ship most recently flown on a mission
124  int objnum; // object number for this player
125  button_info bi; // structure that holds bit vectors for button presses
126  control_info ci; // control info structure for this player
127  scoring_struct stats; // scoring and stats info for the player (points to multi_stats or single_stats)
129  int friendly_hits; // Number of times hit a friendly ship this mission.
130  float friendly_damage; // Total friendly damage done in mission. Diminishes over time.
131  fix friendly_last_hit_time; // Missiontime of last hit on friendly. Used to decay friendly damage.
132  fix last_warning_message_time; // Time at which last message to player was sent regarding friendly damage.
134  int control_mode; // Used to determine what mode player control is in. For worm holes mainly.
135  int saved_viewer_mode; // used to save viewer mode when warping out
137  int check_warn_timestamp; // Timestamp used to determine when to check for possible warning,
138  // done so we don't check each frame
140  int distance_warning_count; // Number of distance warings
141  int distance_warning_time; // Time at which distance warning was given
143  int allow_warn_timestamp; // Timestamp used to regulate how often a player might receive
144  // warning messages about ships attacking.
145  int warn_count; // number of attack warnings player has received this mission
146  float damage_this_burst; // amount of damage done this frame to friendly craft
148  int repair_sound_loop; // Sound id for ship repair looping sound, this is in the player
149  // file since the repair sound only plays when Player ship is getting repaired
150  int cargo_scan_loop; // Sound id for scanning cargo looping sound
152  int praise_count; // number of praises received this mission
153  int allow_praise_timestamp; // timestamp marking time until next praise is allowed
154  int praise_delay_timestamp; // timestamp used to delay a praise by a second or two
156  int ask_help_count; // number of times wingmen have asked for help this mission
157  int allow_ask_help_timestamp; // timestamp marking time until next 'ask help' is allowed
159  int scream_count; // number of wingman screams received this mission
160  int allow_scream_timestamp; // timestamp marking time until next wingman scream is allowed
162  int low_ammo_complaint_count; // number of complaints about low ammo received in this mission
163  int allow_ammo_timestamp; // timestamp marking time until next 'low ammo' complaint is allowed
165  int praise_self_count; // number of boasts about kills received in this mission
166  int praise_self_timestamp; // timestamp marking time until next boast is allowed
168  int subsys_in_view; // set to -1 when this information needs to be re-evaluated
169  int request_repair_timestamp; // timestamp marking time until next time we can be informed of a repair ship getting called in
171  int cargo_inspect_time; // time that current cargo has been inspected for
172  int target_is_dying; // The player target is dying, set to -1 if no target
173  int current_target_sx; // Screen x-pos of current target (or subsystem if applicable)
174  int current_target_sy; // Screen y-pos of current target (or subsystem if applicable)
175  int target_in_lock_cone; // Is the current target in secondary weapon lock cone?
176  ship_subsys *locking_subsys; // Subsystem pointer that missile lock is trying to seek
177  int locking_subsys_parent; // objnum of the parent of locking_subsystem
178  int locking_on_center; // boolean, whether missile lock is trying for center of ship or not
180  int killer_objtype; // type of object that killed player
181  int killer_species; // Species which killed player
182  int killer_weapon_index; // weapon used to kill player (if applicable)
183  char killer_parent_name[NAME_LENGTH]; // name of parent object that killed the player
185  int check_for_all_alone_msg; // timestamp to check for playing of 'all alone' msg
187  int update_dumbfire_time; // when to update dumbfire threat indicators
188  int update_lock_time; // when to update lock threat indicators
189  int threat_flags; // threat flags
190  int auto_advance; // auto-advance through briefing?
192  multi_local_options m_local_options; // options for local player in multiplayer mode (ignore for single player pilots)
193  multi_server_options m_server_options; // options for netgame host/server in multiplayer mode
195  int insignia_texture; // player's insignia bitmap (or -1 if none). should correspond to squad filename
196  // NOTE : this bitmap is in TEXTURE format. do not try to use this bitmap to
197  // render in screen format
198  int tips; // show tips or not
200  int shield_penalty_stamp; // timestamp for when we can next apply a shield balance penalty
202  int failures_this_session; // number of times dude has failed the mission he is on this session
203  ubyte show_skip_popup; // false if dude clicked "don't show this again" -- persists for current mission only
205  // player-persistent variables - Goober5000
208  SCP_string death_message; // Goober5000
210  control_info lua_ci; // copy of control info for scripting purposes (not to disturb real controls).
211  button_info lua_bi; // copy of button info for scripting purposes (not to disturb real controls).
212  button_info lua_bi_full; // gets all the button controls, not just the ones usually allowed
214  int player_was_multi; // 1 if the player file was last used in Multiplayer
216  char language[LCL_LANG_NAME_LEN+1]; // language the pilot was created with
217 };
219 extern player Players[MAX_PLAYERS];
221 extern int Player_num; // player num of person playing on this machine
222 extern player *Player; // pointer to my information
223 //extern control_info PlayerControls;
225 extern int Player_use_ai;
226 extern int view_centering;
227 extern angles chase_slew_angles; // The viewing angles in which viewer_slew_angles will chase to.
229 extern void player_init(); // initialization per level
230 extern void player_level_init();
231 extern void player_controls_init(); // initialize Descent style controls for use in various places
232 extern void player_match_target_speed(char *no_target_text=NULL, char *match_off_text=NULL, char *match_on_text=NULL); // call to continually match speed with selected target
233 extern void player_clear_speed_matching();
235 extern int lua_game_control; // defines the level of control set to lua scripting
244 // functions for controlling looping sounds associated with the player
251 // will attempt to load an insignia bitmap and set it as active for the player
252 void player_set_squad_bitmap(player *p, char *fnamem, bool ismulti);
254 // set squadron
255 void player_set_squad(player *p, char *squad_name);
257 int player_inspect_cargo(float frametime, char *outstr);
259 extern int use_descent; // player is using descent-style physics
260 extern void toggle_player_object(); // toggles between descent-style ship and player ship
262 extern void read_player_controls( object *obj, float frametime);
263 extern void player_control_reset_ci( control_info *ci );
265 void player_generate_death_message(player *player_p);
267 void player_maybe_fire_turret(object *objp);
274 // get the player's eye position and orient
277 //=============================================================
278 //===================== PLAYER WARPOUT STUFF ==================
279 #define PLAYER_WARPOUT_SPEED 40.0f // speed you need to be going to warpout
280 #define TARGET_WARPOUT_MATCH_PERCENT 0.05f // how close to TARGET_WARPOUT_SPEED you need to be
281 #define MINIMUM_PLAYER_WARPOUT_TIME 3.0f // How long before you can press 'ESC' to abort warpout
283 extern float Warpout_time; // Declared in freespace.cpp
284 extern int Warpout_forced; // If non-zero, bash the player to speed and go through effect
285 //=============================================================
288 #endif
void player_maybe_play_all_alone_msg()
int ask_help_count
Definition: player.h:156
void player_init()
Definition: pstypes.h:324
void player_maybe_fire_turret(object *objp)
float player_farthest_weapon_range()
void player_set_squad_bitmap(player *p, char *fnamem, bool ismulti)
char campaign_name[MAX_FILENAME_LEN+1]
Definition: player.h:81
char s_squad_name[NAME_LENGTH+1]
Definition: player.h:97
void player_generate_death_message(player *player_p)
void player_display_padlock_view()
int use_descent
control_info ci
Definition: player.h:126
int flags
Definition: player.h:104
char image_filename[MAX_FILENAME_LEN+1]
Definition: player.h:95
int saved_viewer_mode
Definition: player.h:135
int killer_species
Definition: player.h:181
int scream_count
Definition: player.h:159
void player_clear_speed_matching()
multi_server_options m_server_options
Definition: player.h:193
float lock_time_to_target
Definition: player.h:119
void player_stop_looped_sounds()
int check_for_all_alone_msg
Definition: player.h:185
int allow_warn_timestamp
Definition: player.h:143
void player_get_padlock_orient(matrix *eye_orient)
int cargo_inspect_time
Definition: player.h:171
int insignia_texture
Definition: player.h:195
int current_hotkey_set
Definition: player.h:108
Definition: pstypes.h:88
void player_set_squad(player *p, char *squad_name)
void player_stop_cargo_scan_sound()
int subsys_in_view
Definition: player.h:168
char s_squad_filename[MAX_FILENAME_LEN+1]
Definition: player.h:96
int distance_warning_count
Definition: player.h:140
Definition: player.h:26
int update_lock_time
Definition: player.h:188
char m_squad_name[NAME_LENGTH+1]
Definition: player.h:99
int update_dumbfire_time
Definition: player.h:187
int Player_use_ai
int cargo_scan_loop
Definition: player.h:150
std::basic_string< char, std::char_traits< char >, std::allocator< char > > SCP_string
Definition: vmallocator.h:21
void reset()
object * objp
Definition: lua.cpp:3105
char callsign[CALLSIGN_LEN+1]
Definition: player.h:91
int repair_sound_loop
Definition: player.h:148
SCP_string death_message
Definition: player.h:208
void assign(const player *pl)
int shield_penalty_stamp
Definition: player.h:200
void player_level_init()
float lock_dist_to_target
Definition: player.h:120
player Players[MAX_PLAYERS]
void read_player_controls(object *obj, float frametime)
int low_ammo_complaint_count
Definition: player.h:162
int friendly_hits
Definition: player.h:129
fix friendly_last_hit_time
Definition: player.h:131
Definition: player.h:85
int auto_advance
Definition: player.h:190
int target_is_dying
Definition: player.h:172
int target_in_lock_cone
Definition: player.h:175
char current_campaign[MAX_FILENAME_LEN+1]
Definition: player.h:101
int allow_ammo_timestamp
Definition: player.h:163
int lua_game_control
int readyroom_listing_mode
Definition: player.h:102
control_info lua_ci
Definition: player.h:210
int warn_count
Definition: player.h:145
int allow_praise_timestamp
Definition: player.h:153
int last_ship_flown_si_index
Definition: player.h:122
int praise_delay_timestamp
Definition: player.h:154
int current_target_sy
Definition: player.h:174
void toggle_player_object()
int tips
Definition: player.h:198
int lock_indicator_x
Definition: player.h:114
int threat_flags
Definition: player.h:189
multi_local_options m_local_options
Definition: player.h:192
void player_show_death_message()
button_info lua_bi_full
Definition: player.h:212
Definition: pstypes.h:32
int failures_this_session
Definition: player.h:202
matrix eye_orient
Definition: fredrender.cpp:112
float friendly_damage
Definition: player.h:130
void player_maybe_start_repair_sound()
ubyte show_skip_popup
Definition: player.h:203
int current_target_sx
Definition: player.h:173
int save_flags
Definition: player.h:105
int killer_objtype
Definition: player.h:180
int view_centering
int lock_indicator_y
Definition: player.h:115
long fix
Definition: pstypes.h:54
unsigned char ubyte
Definition: pstypes.h:62
char killer_parent_name[NAME_LENGTH]
Definition: player.h:183
int objnum
Definition: player.h:124
int Warpout_forced
Definition: fredstubs.cpp:176
angles chase_slew_angles
int lock_indicator_start_y
Definition: player.h:117
int control_mode
Definition: player.h:134
char language[LCL_LANG_NAME_LEN+1]
Definition: player.h:216
float Warpout_time
Definition: fredstubs.cpp:177
int allow_scream_timestamp
Definition: player.h:160
void player_set_pilot_defaults(player *p)
scoring_struct stats
Definition: player.h:82
int player_process_pending_praise()
See if there is a praise message to deliver to the player. We want to delay the praise messages a bit...
void player_match_target_speed(char *no_target_text=NULL, char *match_off_text=NULL, char *match_on_text=NULL)
float damage_this_burst
Definition: player.h:146
int allow_ask_help_timestamp
Definition: player.h:157
Definition: globals.h:31
int lead_target_cheat
Definition: player.h:111
Definition: pstypes.h:606
Definition: globals.h:15
void player_restore_target_and_weapon_link_prefs()
int request_repair_timestamp
Definition: player.h:169
player * Player
int distance_warning_time
Definition: player.h:141
void player_maybe_start_cargo_scan_sound()
ship_subsys * locking_subsys
Definition: player.h:176
camid player_get_cam()
GLfloat GLfloat p
Definition: Glext.h:8373
Definition: localize.h:31
int player_was_multi
Definition: player.h:214
fix last_warning_message_time
Definition: player.h:132
void player_control_reset_ci(control_info *ci)
int lock_indicator_visible
Definition: player.h:118
GLsizei GLsizei GLuint * obj
Definition: Glext.h:5619
SCP_vector< sexp_variable > variables
Definition: player.h:206
void player_controls_init()
int player_inspect_cargo(float frametime, char *outstr)
vec3d lead_target_pos
Definition: player.h:110
button_info lua_bi
Definition: player.h:211
int killer_weapon_index
Definition: player.h:182
void player_save_target_and_weapon_link_prefs()
void player_stop_repair_sound()
int locking_on_center
Definition: player.h:178
int praise_self_count
Definition: player.h:165
htarget_list keyed_targets[MAX_KEYED_TARGETS]
Definition: player.h:107
char m_squad_filename[MAX_FILENAME_LEN+1]
Definition: player.h:98
int short_callsign_width
Definition: player.h:93
int check_warn_timestamp
Definition: player.h:137
struct campaign_stats campaign_stats
int praise_count
Definition: player.h:152
int lock_indicator_start_x
Definition: player.h:116
button_info bi
Definition: player.h:125
int locking_subsys_parent
Definition: player.h:177
char short_callsign[CALLSIGN_LEN+1]
Definition: player.h:92
int praise_self_timestamp
Definition: player.h:166
void player_set_next_all_alone_msg_timestamp()
scoring_struct stats
Definition: player.h:127
int Player_num
int lead_indicator_active
Definition: player.h:112