2 * Copyright (C) Volition, Inc. 1999. All rights reserved.
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
10 * $Logfile: /Freespace2/code/Playerman/Player.h $
15 * Header file for player information
18 * Revision 1.2 2002/06/09 04:41:14 relnev
19 * added copyright header
21 * Revision 1.1.1.1 2002/05/03 03:28:12 root
25 * 18 9/12/99 1:27p Jefff
26 * upped debug player_mission_failure_limit to 5
28 * 17 9/07/99 10:50a Jefff
30 * 16 9/06/99 9:43p Jefff
31 * skip mission support
33 * 15 8/29/99 4:18p Andsager
34 * New "burst" limit for friendly damage. Also credit more damage done
35 * against large friendly ships.
37 * 14 8/27/99 10:36a Dave
38 * Impose a 2% penalty for hitting the shield balance key.
40 * 13 8/02/99 9:13p Dave
43 * 12 7/21/99 8:10p Dave
44 * First run of supernova effect.
46 * 11 7/19/99 7:20p Dave
47 * Beam tooling. Specialized player-killed-self messages. Fixed d3d nebula
50 * 10 6/16/99 4:06p Dave
51 * New pilot info popup. Added new draw-bitmap-as-poly function.
53 * 9 5/21/99 5:03p Andsager
54 * Add code to display engine wash death. Modify ship_kill_packet
56 * 8 5/18/99 10:08a Andsager
57 * Modified single maximum range before blown up to also be multi
60 * 7 3/28/99 12:37p Dave
61 * Tentative beginnings to warpin effect.
63 * 6 3/24/99 4:05p Dave
64 * Put in support for assigning the player to a specific squadron with a
65 * specific logo. Preliminary work for doing pos/orient checksumming in
66 * multiplayer to reduce bandwidth.
68 * 5 1/14/99 6:06p Dave
69 * 100% full squad logo support for single player and multiplayer.
71 * 4 12/14/98 12:13p Dave
72 * Spiffed up xfer system a bit. Put in support for squad logo file xfer.
75 * 3 11/12/98 12:13a Dave
76 * Tidied code up for multiplayer test. Put in network support for flak
79 * 2 10/07/98 10:53a Dave
82 * 1 10/07/98 10:50a Dave
84 * 96 9/17/98 3:08p Dave
85 * PXO to non-pxo game warning popup. Player icon stuff in create and join
86 * game screens. Upped server count refresh time in PXO to 35 secs (from
89 * 95 5/19/98 12:19p Mike
92 * 94 5/09/98 4:52p Lawrance
93 * Implement padlock view (up/rear/left/right)
95 * 93 5/04/98 5:52p Comet
96 * Fixed bug with Galatea/Bastion selection when finishing missions.
98 * 92 4/25/98 3:49p Lawrance
99 * Save briefing auto-advance pref
101 * 91 4/21/98 11:55p Dave
102 * Put in player deaths statskeeping. Use arrow keys in the ingame join
103 * ship select screen. Don't quit the game if in the debriefing and server
106 * 90 4/20/98 6:07p Hoffoss
107 * Added code to track if player is stationed on the galatea or the
110 * 89 4/08/98 10:34p Allender
111 * make threat indicators work in multiplayer. Fix socket problem (once
114 * 88 4/05/98 7:43p Lawrance
115 * fix up saving/restoring of link status and auto-target/match-speed.
117 * 87 4/01/98 7:42p Lawrance
118 * Enable auto-targeting by default when a new pilot is created.
120 * 86 3/31/98 4:42p Allender
121 * mission objective support for team v. team mode. Chatbox changes to
122 * make input box be correct length when typing
124 * 85 3/30/98 6:27p Dave
125 * Put in a more official set of multiplayer options, including a system
126 * for distributing netplayer and netgame settings.
128 * 84 3/27/98 3:59p Hoffoss
129 * Due to everyone using different assumptions about what a length define
130 * means, changed code to account for safest assumption.
132 * 83 3/24/98 4:25p Lawrance
133 * Make finding out if player killed self easier and more reliable
135 * 82 3/19/98 5:35p Lawrance
136 * Correctly inform player if killed by ship explosion.
138 * 81 3/16/98 5:54p Lawrance
139 * Play cargo scanning sound
141 * 80 3/10/98 5:08p Allender
142 * fixed up multiplayer death messages (I hope). changes in object update
145 * 79 3/07/98 3:49p Lawrance
146 * store killer species in player struct
148 * 78 3/05/98 10:16p Lawrance
149 * Add 'save_flags' to player struct to save/restore certain player flags
160 #include "missionload.h"
161 #include "hudtarget.h" // for targeting hotkey lists
162 #include "ship.h" // for targeting subobjects
163 #include "missioncampaign.h" // for mission/campaign stuff
164 #include "scoring.h" // for scoring/stats
165 #include "keycontrol.h" // for button_info
166 #include "multi_options.h"
169 #define CALLSIGN_LEN 28 // shortened from 32 to allow .plr to be attached without exceeding MAX_FILENAME_LEN
170 #define SHORT_CALLSIGN_PIXEL_W 80 // max width of short_callsign[] in pixels
171 #define MAX_KEYED_TARGETS 8 // number of hot keys available to assign targets to
173 // player image defines
174 #define PLAYER_PILOT_PIC_W 160
175 #define PLAYER_PILOT_PIC_H 120
177 #define PLAYER_SQUAD_PIC_W 128
178 #define PLAYER_SQUAD_PIC_H 128
180 // player flags follow
181 #define PLAYER_FLAGS_MATCH_TARGET (1<<0) // currently matching speed with selected target
182 #define PLAYER_FLAGS_MSG_MODE (1<<1) // is the player in messaging mode?
183 #define PLAYER_FLAGS_AUTO_TARGETING (1<<2) // is auto targeting on?
184 #define PLAYER_FLAGS_AUTO_MATCH_SPEED (1<<3) // is auto speed matching on?
185 #define PLAYER_FLAGS_STRUCTURE_IN_USE (1<<4) // is this structure in use -- for multiplayer games
186 #define PLAYER_FLAGS_PROMOTED (1<<5) // possibly set in mission to automatically give player promotion
187 #define PLAYER_FLAGS_IS_MULTI (1<<6) // this is a multiplayer pilot
188 #define PLAYER_FLAGS_DIST_WARNING (1<<7) // is this player under warning for being too far from battle
189 #define PLAYER_FLAGS_FORCE_MISSION_OVER (1<<8) // mission is being forced over for this player
190 #define PLAYER_FLAGS_LINK_PRIMARY (1<<9) // primary weapons were linked last mission
191 #define PLAYER_FLAGS_LINK_SECONDARY (1<<10) // secondary weapons were linked last mission
192 #define PLAYER_FLAGS_NO_CHECK_ALL_ALONE_MSG (1<<11) // player can't receive 'you're all alone...' message from Terran Command
193 #define PLAYER_FLAGS_KILLED_BY_EXPLOSION (1<<12) // player was killed by an instantaneous area-effect explosion
194 #define PLAYER_FLAGS_HAS_PLAYED_PXO (1<<13) // this pilot has at least played PXO once in the past.
195 #define PLAYER_FLAGS_DIST_TO_BE_KILLED (1<<14) // the pilot has been warned about distance and will be killed after message finishes playing
196 #define PLAYER_FLAGS_KILLED_BY_ENGINE_WASH (1<<15) // player was killed by engine wash
197 #define PLAYER_FLAGS_KILLED_SELF_UNKNOWN (1<<16) // player died by his own hand
198 #define PLAYER_FLAGS_KILLED_SELF_MISSILES (1<<17) // player died by his own missile
199 #define PLAYER_FLAGS_KILLED_SELF_SHOCKWAVE (1<<18) // player died by his own shockwave
201 #define PLAYER_KILLED_SELF ( PLAYER_FLAGS_KILLED_SELF_MISSILES | PLAYER_FLAGS_KILLED_SELF_SHOCKWAVE )
203 #define PCM_NORMAL 0 // normal flying mode
204 #define PCM_WARPOUT_STAGE1 1 // speed up to 40 km/s
205 #define PCM_WARPOUT_STAGE2 2 // flying towards and through warp hole
206 #define PCM_WARPOUT_STAGE3 3 // through warp hole, waiting for it to disapper.
207 #define PCM_SUPERNOVA 4 // supernova. lock everything to where it is.
209 // number of times dude can fail a mission in a session before
210 // having the opportunity to skip it
212 #define PLAYER_MISSION_FAILURE_LIMIT 5
214 #define PLAYER_MISSION_FAILURE_LIMIT 5
215 #endif // RELEASE_REAL
218 typedef struct campaign_stats {
219 char campaign_name[MAX_FILENAME_LEN+1]; // insurance
220 scoring_struct stats;
223 typedef struct player {
224 char callsign[CALLSIGN_LEN + 1];
225 char short_callsign[CALLSIGN_LEN + 1]; // callsign truncated to SHORT_CALLSIGN_PIXEL_W pixels
226 int short_callsign_width; // useful for mutliplayer chat boxes.
227 char image_filename[MAX_FILENAME_LEN]; // filename of the image for this pilot
228 char squad_filename[MAX_FILENAME_LEN]; // filename of the squad image for this pilot
229 char squad_name[NAME_LENGTH + 1]; // pilot's squadron name
230 int num_campaigns; // tells how many array entries in the campaigns field
231 char current_campaign[MAX_FILENAME_LEN]; // Name of the currently active campaign, or zero-length string if none
232 campaign_info *campaigns; // holds information regarding all active campaigns the player is playing
233 int readyroom_listing_mode;
239 htarget_list keyed_targets[MAX_KEYED_TARGETS]; // linked list of hot-keyed targets
240 int current_hotkey_set; // currently hotkey set in use, -1 if none
242 vector lead_target_pos; // (x,y,z) of the lead target indicator
243 int lead_target_cheat; // whether cheat for firing at lead indicator is active
244 int lead_indicator_active; // flag that indicates the lead indicator is enabled
246 int lock_indicator_x; // 2D screen x-coordinate of the lock indicator
247 int lock_indicator_y; // 2D screen y-coordinate of the lock indicator
248 int lock_indicator_start_x; // 2D screen x-coordinate of where lock indicator originated
249 int lock_indicator_start_y; // 2D screen y-coordinate of where lock indicator originated
250 int lock_indicator_visible; // flag indicating if the lock indicator is on screen or not
251 float lock_time_to_target; // time left (in milliseconds) before minimum time to lock elapsed
252 float lock_dist_to_target; // distance from lock indicator to target (in pixels)
254 int last_ship_flown_si_index; // ship info index of ship most recently flown on a mission
256 int objnum; // object number for this player
257 button_info bi; // structure that holds bit vectors for button presses
258 control_info ci; // control info structure for this player
259 scoring_struct stats; // scoring and stats info for the player (points to multi_stats or single_stats)
261 int friendly_hits; // Number of times hit a friendly ship this mission.
262 float friendly_damage; // Total friendly damage done in mission. Diminishes over time.
263 fix friendly_last_hit_time; // Missiontime of last hit on friendly. Used to decay friendly damage.
264 fix last_warning_message_time; // Time at which last message to player was sent regarding friendly damage.
266 int control_mode; // Used to determine what mode player control is in. For worm holes mainly.
267 int saved_viewer_mode; // used to save viewer mode when warping out
269 int check_warn_timestamp; // Timestamp used to determine when to check for possible warning,
270 // done so we don't check each frame
272 int distance_warning_count; // Number of distance warings
274 int distance_warning_time; // Time at which distance warning was given
276 int allow_warn_timestamp; // Timestamp used to regulate how often a player might receive
277 // warning messages about ships attacking.
278 int warn_count; // number of attack warnings player has received this mission
279 float damage_this_burst; // amount of damage done this frame to friendly craft
280 int repair_sound_loop; // Sound id for ship repair looping sound, this is in the player
281 // file since the repair sound only plays when Player ship is getting repaired
283 int cargo_scan_loop; // Sound id for scanning cargo looping sound
285 int praise_count; // number of praises received this mission
286 int allow_praise_timestamp; // timestamp marking time until next praise is allowed
287 int praise_delay_timestamp; // timestamp used to delay a praise by a second or two
289 int ask_help_count; // number of praises received this mission
290 int allow_ask_help_timestamp; // timestamp marking time until next 'ask help' is allowed
292 int scream_count; // number of wingman screams received this mission
293 int allow_scream_timestamp; // timestamp marking time until next wingman scream is allowed
295 int subsys_in_view; // set to -1 when this information needs to be re-evaluated
296 int request_repair_timestamp; // timestamp marking time until next time we can be informed of a repair ship getting called in
298 int cargo_inspect_time; // time that current cargo has been inspected for
299 int target_is_dying; // The player target is dying, set to -1 if no target
300 int current_target_sx; // Screen x-pos of current target (or subsystem if applicable)
301 int current_target_sy; // Screen y-pos of current target (or subsystem if applicable)
302 int target_in_lock_cone; // Is the current target in secondary weapon lock cone?
303 ship_subsys *locking_subsys; // Subsystem pointer that missile lock is trying to seek
304 int locking_subsys_parent; // objnum of the parent of locking_subsystem
305 int locking_on_center; // boolean, whether missile lock is trying for center of ship or not
307 int killer_objtype; // type of object that killed player
308 int killer_species; // Species which killed player
309 int killer_weapon_index; // weapon used to kill player (if applicable)
310 char killer_parent_name[NAME_LENGTH]; // name of parent object that killed the player
312 int check_for_all_alone_msg; // timestamp to check for playing of 'all alone' msg
314 int update_dumbfire_time; // when to update dumbfire threat indicators
315 int update_lock_time; // when to update lock threat indicators
316 int threat_flags; // threat flags
317 int auto_advance; // auto-advance through briefing?
319 multi_local_options m_local_options; // options for local player in multiplayer mode (ignore for single player pilots)
320 multi_server_options m_server_options; // options for netgame host/server in multiplayer mode
322 int insignia_texture; // player's insignia bitmap (or -1 if none). should correspond to squad filename
323 // NOTE : this bitmap is in TEXTURE format. do not try to use this bitmap to
324 // render in screen format
325 int tips; // show tips or not
327 int shield_penalty_stamp; // timestamp for when we can next apply a shield balance penalty
329 int failures_this_session; // number of times dude has failed the mission he is on this session
330 ubyte show_skip_popup; // false if dude clicked "don't show this again" -- persists for current mission only
333 extern player Players[MAX_PLAYERS];
335 extern int Player_num; // player num of person playing on this machine
336 extern player_t *Player; // pointer to my information
337 //extern control_info PlayerControls;
339 extern void player_init(); // initialization per level
340 extern void player_level_init();
341 extern void player_controls_init(); // initialize Descent style controls for use in various places
342 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
343 extern void player_clear_speed_matching();
345 void player_set_pilot_defaults(player *p);
347 int player_process_pending_praise();
348 float player_farthest_weapon_range();
349 void player_save_target_and_weapon_link_prefs();
350 void player_restore_target_and_weapon_link_prefs();
352 // functions for controlling looping sounds associated with the player
353 void player_stop_looped_sounds();
354 void player_maybe_start_repair_sound();
355 void player_stop_repair_sound();
356 void player_stop_cargo_scan_sound();
357 void player_maybe_start_cargo_scan_sound();
359 // will attempt to load an insignia bitmap and set it as active for the player
360 void player_set_squad_bitmap(player *p, const char *fname);
363 void player_set_squad(player *p, const char *squad_name);
365 int player_inspect_cargo(float frametime, char *outstr);
368 extern int use_descent; // player is using descent-style physics
369 extern void toggle_player_object(); // toggles between descent-style ship and player ship
372 extern void read_player_controls( object *obj, float frametime);
373 extern void player_control_reset_ci( control_info *ci );
375 char *player_generate_death_text( player *player_p, char *text );
376 void player_show_death_message();
377 void player_maybe_fire_turret(object *objp);
378 void player_maybe_play_all_alone_msg();
379 void player_set_next_all_alone_msg_timestamp();
381 void player_get_padlock_orient(matrix *eye_orient);
382 void player_display_packlock_view();
384 // get the player's eye position and orient
385 void player_get_eye(vector *eye_pos, matrix *eye_orient);
387 //=============================================================
388 //===================== PLAYER WARPOUT STUFF ==================
389 #define TARGET_WARPOUT_SPEED 40.0f // speed you need to be going to warpout
390 #define TARGET_WARPOUT_MATCH_PERCENT 0.05f // how close to TARGET_WARPOUT_SPEED you need to be
391 #define MINIMUM_PLAYER_WARPOUT_TIME 3.0f // How long before you can press 'ESC' to abort warpout
393 extern float Warpout_time; // Declared in Freespace.cpp
394 extern int Warpout_forced; // If non-zero, bash the player to speed and go through effect
395 //=============================================================