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
197 #define PLAYER_FLAGS_KILLED_BY_ENGINE_WASH (1<<15) // player was killed by engine wash
198 #define PLAYER_FLAGS_KILLED_SELF_UNKNOWN (1<<16) // player died by his own hand
199 #define PLAYER_FLAGS_KILLED_SELF_MISSILES (1<<17) // player died by his own missile
200 #define PLAYER_FLAGS_KILLED_SELF_SHOCKWAVE (1<<18) // player died by his own shockwave
202 #define PLAYER_FLAGS_USING_LOCAL_STATS (1<<15) // not playing PXO games
203 #define PLAYER_FLAGS_USING_PXO_STATS (1<<16) // playing PXO games
204 #define PLAYER_FLAGS_KILLED_BY_ENGINE_WASH (1<<17) // player was killed by engine wash
205 #define PLAYER_FLAGS_KILLED_SELF_UNKNOWN (1<<18) // player died by his own hand
206 #define PLAYER_FLAGS_KILLED_SELF_MISSILES (1<<19) // player died by his own missile
207 #define PLAYER_FLAGS_KILLED_SELF_SHOCKWAVE (1<<20) // player died by his own shockwave
210 #define PLAYER_KILLED_SELF ( PLAYER_FLAGS_KILLED_SELF_MISSILES | PLAYER_FLAGS_KILLED_SELF_SHOCKWAVE )
212 #define PCM_NORMAL 0 // normal flying mode
213 #define PCM_WARPOUT_STAGE1 1 // speed up to 40 km/s
214 #define PCM_WARPOUT_STAGE2 2 // flying towards and through warp hole
215 #define PCM_WARPOUT_STAGE3 3 // through warp hole, waiting for it to disapper.
216 #define PCM_SUPERNOVA 4 // supernova. lock everything to where it is.
218 // number of times dude can fail a mission in a session before
219 // having the opportunity to skip it
221 #define PLAYER_MISSION_FAILURE_LIMIT 5
223 #define PLAYER_MISSION_FAILURE_LIMIT 5
224 #endif // RELEASE_REAL
227 typedef struct campaign_stats {
228 char campaign_name[MAX_FILENAME_LEN+1]; // insurance
229 scoring_struct stats;
232 typedef struct player {
233 char callsign[CALLSIGN_LEN + 1];
234 char short_callsign[CALLSIGN_LEN + 1]; // callsign truncated to SHORT_CALLSIGN_PIXEL_W pixels
235 int short_callsign_width; // useful for mutliplayer chat boxes.
236 char image_filename[MAX_FILENAME_LEN]; // filename of the image for this pilot
237 char squad_filename[MAX_FILENAME_LEN]; // filename of the squad image for this pilot
238 char squad_name[NAME_LENGTH + 1]; // pilot's squadron name
239 int num_campaigns; // tells how many array entries in the campaigns field
240 char current_campaign[MAX_FILENAME_LEN]; // Name of the currently active campaign, or zero-length string if none
241 campaign_info *campaigns; // holds information regarding all active campaigns the player is playing
242 int readyroom_listing_mode;
248 htarget_list keyed_targets[MAX_KEYED_TARGETS]; // linked list of hot-keyed targets
249 int current_hotkey_set; // currently hotkey set in use, -1 if none
251 vector lead_target_pos; // (x,y,z) of the lead target indicator
252 int lead_target_cheat; // whether cheat for firing at lead indicator is active
253 int lead_indicator_active; // flag that indicates the lead indicator is enabled
255 int lock_indicator_x; // 2D screen x-coordinate of the lock indicator
256 int lock_indicator_y; // 2D screen y-coordinate of the lock indicator
257 int lock_indicator_start_x; // 2D screen x-coordinate of where lock indicator originated
258 int lock_indicator_start_y; // 2D screen y-coordinate of where lock indicator originated
259 int lock_indicator_visible; // flag indicating if the lock indicator is on screen or not
260 float lock_time_to_target; // time left (in milliseconds) before minimum time to lock elapsed
261 float lock_dist_to_target; // distance from lock indicator to target (in pixels)
263 int last_ship_flown_si_index; // ship info index of ship most recently flown on a mission
265 int objnum; // object number for this player
266 button_info bi; // structure that holds bit vectors for button presses
267 control_info ci; // control info structure for this player
268 scoring_struct stats; // scoring and stats info for the player (points to multi_stats or single_stats)
270 int friendly_hits; // Number of times hit a friendly ship this mission.
271 float friendly_damage; // Total friendly damage done in mission. Diminishes over time.
272 fix friendly_last_hit_time; // Missiontime of last hit on friendly. Used to decay friendly damage.
273 fix last_warning_message_time; // Time at which last message to player was sent regarding friendly damage.
275 int control_mode; // Used to determine what mode player control is in. For worm holes mainly.
276 int saved_viewer_mode; // used to save viewer mode when warping out
278 int check_warn_timestamp; // Timestamp used to determine when to check for possible warning,
279 // done so we don't check each frame
281 int distance_warning_count; // Number of distance warings
283 int distance_warning_time; // Time at which distance warning was given
285 int allow_warn_timestamp; // Timestamp used to regulate how often a player might receive
286 // warning messages about ships attacking.
287 int warn_count; // number of attack warnings player has received this mission
288 float damage_this_burst; // amount of damage done this frame to friendly craft
289 int repair_sound_loop; // Sound id for ship repair looping sound, this is in the player
290 // file since the repair sound only plays when Player ship is getting repaired
292 int cargo_scan_loop; // Sound id for scanning cargo looping sound
294 int praise_count; // number of praises received this mission
295 int allow_praise_timestamp; // timestamp marking time until next praise is allowed
296 int praise_delay_timestamp; // timestamp used to delay a praise by a second or two
298 int ask_help_count; // number of praises received this mission
299 int allow_ask_help_timestamp; // timestamp marking time until next 'ask help' is allowed
301 int scream_count; // number of wingman screams received this mission
302 int allow_scream_timestamp; // timestamp marking time until next wingman scream is allowed
304 int subsys_in_view; // set to -1 when this information needs to be re-evaluated
305 int request_repair_timestamp; // timestamp marking time until next time we can be informed of a repair ship getting called in
307 int cargo_inspect_time; // time that current cargo has been inspected for
308 int target_is_dying; // The player target is dying, set to -1 if no target
309 int current_target_sx; // Screen x-pos of current target (or subsystem if applicable)
310 int current_target_sy; // Screen y-pos of current target (or subsystem if applicable)
311 int target_in_lock_cone; // Is the current target in secondary weapon lock cone?
312 ship_subsys *locking_subsys; // Subsystem pointer that missile lock is trying to seek
313 int locking_subsys_parent; // objnum of the parent of locking_subsystem
314 int locking_on_center; // boolean, whether missile lock is trying for center of ship or not
316 int killer_objtype; // type of object that killed player
317 int killer_species; // Species which killed player
318 int killer_weapon_index; // weapon used to kill player (if applicable)
319 char killer_parent_name[NAME_LENGTH]; // name of parent object that killed the player
321 int check_for_all_alone_msg; // timestamp to check for playing of 'all alone' msg
323 int update_dumbfire_time; // when to update dumbfire threat indicators
324 int update_lock_time; // when to update lock threat indicators
325 int threat_flags; // threat flags
326 int auto_advance; // auto-advance through briefing?
328 multi_local_options m_local_options; // options for local player in multiplayer mode (ignore for single player pilots)
329 multi_server_options m_server_options; // options for netgame host/server in multiplayer mode
331 int insignia_texture; // player's insignia bitmap (or -1 if none). should correspond to squad filename
332 // NOTE : this bitmap is in TEXTURE format. do not try to use this bitmap to
333 // render in screen format
334 int tips; // show tips or not
336 int shield_penalty_stamp; // timestamp for when we can next apply a shield balance penalty
338 int failures_this_session; // number of times dude has failed the mission he is on this session
339 ubyte show_skip_popup; // false if dude clicked "don't show this again" -- persists for current mission only
342 extern player Players[MAX_PLAYERS];
344 extern int Player_num; // player num of person playing on this machine
345 extern player_t *Player; // pointer to my information
346 //extern control_info PlayerControls;
348 extern void player_init(); // initialization per level
349 extern void player_level_init();
350 extern void player_controls_init(); // initialize Descent style controls for use in various places
351 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
352 extern void player_clear_speed_matching();
354 void player_set_pilot_defaults(player *p);
356 int player_process_pending_praise();
357 float player_farthest_weapon_range();
358 void player_save_target_and_weapon_link_prefs();
359 void player_restore_target_and_weapon_link_prefs();
361 // functions for controlling looping sounds associated with the player
362 void player_stop_looped_sounds();
363 void player_maybe_start_repair_sound();
364 void player_stop_repair_sound();
365 void player_stop_cargo_scan_sound();
366 void player_maybe_start_cargo_scan_sound();
368 // will attempt to load an insignia bitmap and set it as active for the player
369 void player_set_squad_bitmap(player *p, const char *fname);
372 void player_set_squad(player *p, const char *squad_name);
374 int player_inspect_cargo(float frametime, char *outstr, const int max_outstr);
377 extern int use_descent; // player is using descent-style physics
378 extern void toggle_player_object(); // toggles between descent-style ship and player ship
381 extern void read_player_controls( object *obj, float frametime);
382 extern void player_control_reset_ci( control_info *ci );
384 char *player_generate_death_text(player *player_p, char *text , const int max_dtlen);
385 void player_show_death_message();
386 void player_maybe_fire_turret(object *objp);
387 void player_maybe_play_all_alone_msg();
388 void player_set_next_all_alone_msg_timestamp();
390 void player_get_padlock_orient(matrix *eye_orient);
391 void player_display_packlock_view();
393 // get the player's eye position and orient
394 void player_get_eye(vector *eye_pos, matrix *eye_orient);
396 //=============================================================
397 //===================== PLAYER WARPOUT STUFF ==================
398 #define TARGET_WARPOUT_SPEED 40.0f // speed you need to be going to warpout
399 #define TARGET_WARPOUT_MATCH_PERCENT 0.05f // how close to TARGET_WARPOUT_SPEED you need to be
400 #define MINIMUM_PLAYER_WARPOUT_TIME 3.0f // How long before you can press 'ESC' to abort warpout
402 extern float Warpout_time; // Declared in Freespace.cpp
403 extern int Warpout_forced; // If non-zero, bash the player to speed and go through effect
404 //=============================================================