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