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