Debian Codegraph @

Descent3/player.h

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/Main/player.h $
21 * $Revision: 101 $
22 * $Date: 9/29/01 5:34p $
23 * $Author: Kevin $
24 *
25 * Header for player.cpp
26 *
27 * $Log: /DescentIII/Main/player.h $
28 *
29 * 101 9/29/01 5:34p Kevin
30 * hack to prevent the observermode powerup stealing cheat/bug
31 *
32 * 100 5/20/99 2:48a Matt
33 * Auto-waypoints now stored & used per player. Manual waypoints will all
34 * players, once Jason makes it work.
35 *
36 * 99 4/24/99 6:45p Jeff
37 * added functions for theif so he can steal things other than weapons
38 *
39 * 98 4/14/99 3:57a Jeff
40 * fixed case mismatch in #includes
41 *
42 * 97 4/06/99 6:02p Matt
43 * Added score system
44 *
45 * 96 4/05/99 3:34p Matt
46 * Cleaned up player start flags
47 *
48 * 95 4/05/99 10:54a Matt
49 * Added auto-waypoint system
50 *
51 * 94 3/08/99 5:14p Jason
52 * added delay to player respawn after death
53 *
54 * 93 3/02/99 5:50p Kevin
55 * Ouch. Duplicate structures existed and were conflicting.
56 *
57 * 92 2/25/99 8:55p Jeff
58 * Inventory supports level change persistant items. Inventory supports
59 * time-out objects. Inventory Reset changed (takes a level of reset
60 * now). Quad lasers stay across level change (single player). Guidebot
61 * bug fixed (now back in ship on level start). Quads time out when
62 * spewed. Invulnerability and cloak powerups no longer use game
63 * event/callbacks, so they can be saved in game saves (moved to
64 * MakePlayerInvulnerable and MakeObjectInvisible)
65 *
66 * 91 2/11/99 1:22a Jeff
67 * made function to switch a player into AI mode, converted code that did
68 * this to call this function.
69 *
70 * 90 2/09/99 6:53p Jeff
71 * implemented 'typing inidcator' in multiplayer...players that are typing
72 * messages have an icon on them
73 *
74 * 89 2/08/99 3:06a Jeff
75 * added a function to reset a player's control type
76 *
77 * 88 1/31/99 7:26p Matt
78 * Renamed a bunch of functions to have HUD capitalized
79 *
80 * 87 1/21/99 11:15p Jeff
81 * pulled out some structs and defines from header files and moved them
82 * into seperate header files so that multiplayer dlls don't require major
83 * game headers, just those new headers. Side effect is a shorter build
84 * time. Also cleaned up some header file #includes that weren't needed.
85 * This affected polymodel.h, object.h, player.h, vecmat.h, room.h,
86 * manage.h and multi.h
87 *
88 * 86 1/19/99 9:20a Kevin
89 * Added afterburner masking
90 *
91 * 85 1/18/99 6:18p Kevin
92 * Added controller masking to DALLAS
93 *
94 * 84 1/13/99 2:29a Chris
95 * Massive AI, OSIRIS update
96 *
97 * 83 12/01/98 3:35p Matt
98 * Got rear view working.
99 *
100 * 82 11/23/98 1:50p Jason
101 * added thruster sounds
102 *
103 * 81 11/13/98 4:25p Jason
104 * changes for better weapon effects
105 *
106 * 80 11/13/98 12:30p Jason
107 * changes for weapons
108 *
109 * 79 11/11/98 7:18p Jeff
110 * changes made so that a dedicated server's team is always -1 (team game
111 * or not)
112 *
113 * 78 11/03/98 6:16p Chris
114 * Starting to make on/off and spray weapons accessable to robots
115 *
116 * 77 9/23/98 2:55p Chris
117 * Improved auto-leveling and added newbie leveling
118 *
119 * 76 9/17/98 3:03p Jason
120 * added lightning and invul hit effects
121 *
122 * 75 9/16/98 5:10p Jason
123 * added first pass at thrid-person camera system
124 *
125 * 74 9/11/98 12:26p Jason
126 * got energy to shield and fusion damage working in multiplayer
127 *
128 * 73 9/10/98 12:18p Jason
129 * more changes to afterburner/thrust effect
130 *
131 * 72 8/28/98 1:34p Matt
132 * Added code to reset the waypoint when starting a new level, and while I
133 * was at it cleaned up the new level start sequencing.
134 *
135 * 71 8/24/98 2:45p Jason
136 * added team start position stuff
137 *
138 * 70 8/24/98 12:24p Jason
139 * added waypoints and player start position flags
140 *
141 * 69 8/19/98 6:27p Chris
142 * Added a last_fired_time for the player (used for AI and cloaking)
143 *
144 * 68 8/16/98 12:19a Jeff
145 * added energy->shields function
146 *
147 * 67 8/10/98 2:21p Jeff
148 * changes made due to adding flag for inventory reset
149 *
150 * 66 8/06/98 2:44p Jeff
151 * added ship permissions functions (first round)
152 *
153 * 65 8/03/98 5:56p Jason
154 * got fusion cannon working correctly
155 *
156 * 64 7/31/98 1:55p Jason
157 * added a function for custom textures
158 *
159 * 63 7/31/98 11:51a Jason
160 * added player ship choosing to multiplayer games
161 *
162 * 62 7/22/98 3:16p Jason
163 * added observer mode
164 *
165 * 61 7/20/98 6:39p Jason
166 * first attempt at getting player visibilty stuff working in multiplayer
167 *
168 * 60 7/20/98 10:42a Jason
169 * added more player scalars, plus afterburner changes
170 *
171 * 59 7/15/98 2:33p Jason
172 * added scalar variables for various player skills
173 *
174 * 58 7/03/98 3:09p Jeff
175 * added counter measures inventory
176 *
177 * 57 7/02/98 6:30p Jason
178 * added some multiplayer stuff for Jeff
179 *
180 * 56 6/29/98 3:08p Jason
181 * added on/off weapons
182 *
183 * 55 6/25/98 5:17p Jason
184 * added multiple colored balls for players
185 *
186 * 54 6/25/98 12:45p Jeff
187 * fixed callsign length, it was too int16_t
188 *
189 * 53 5/26/98 7:49p Samir
190 * E3 version has a long afterburner.
191 *
192 * 52 5/25/98 8:17p Matt
193 * Moved MAX_PLAYER_WEAPONS fromw weapon.h to player.h, so that the latter
194 * doesn't need to include the former, drastically speeding build times
195 * when weapon.h is changed.
196 *
197 * 51 5/12/98 5:09p Kevin
198 * Added fields to player to keep more mastertracker stats
199 *
200 * 50 5/04/98 4:04p Chris
201 * Minestone checkin' -- energy effect and more AI functionality
202 *
203 * 49 5/01/98 6:50p Samir
204 * changed death sequence to fall on melee kill (single player) and death
205 * camera improvements.
206 *
207 * 48 4/30/98 2:53p Kevin
208 * added suicide to players
209 *
210 * 47 4/30/98 1:15p Kevin
211 * Added lifetime deaths and kills for MT
212 *
213 * 46 4/30/98 11:32a Chris
214 * ClearWB to WBClear
215 *
216 * 45 4/29/98 12:51p Kevin
217 * Added mastertracker values
218 *
219 * 44 4/27/98 1:14p Jason
220 * cleaned up afterburner stuff
221 *
222 * 43 4/17/98 1:59p Jason
223 * added cool object effects
224 *
225 * 42 4/13/98 12:42p Jason
226 * changed afterburner effect
227 *
228 * 41 4/09/98 5:18p Jason
229 * got guided working in multiplayer
230 *
231 * 40 4/09/98 2:23p Jason
232 * added guided/afterburner stuff
233 *
234 * 39 4/06/98 12:14p Jason
235 * changes to multiplayer
236 *
237 * 38 4/03/98 12:28p Jason
238 * fixed confusion with clients changing rooms in multiplayer
239 *
240 * 37 4/01/98 2:13p Jason
241 * added PlayerChangeShip
242 *
243 * 36 4/01/98 12:02p Jason
244 * incremental checkin for rendering changes
245 *
246 * 35 3/31/98 11:15a Jason
247 * added the ability for player objects to cast light
248 *
249 * 34 3/20/98 5:51p Jason
250 * more changes for multiplayer
251 *
252 * 33 3/20/98 3:54p Chris
253 * Working on adding sounds to the game. :)
254 *
255 * 32 3/20/98 2:59p Chris
256 * Added a wall hit sound for the player and added support for a base
257 * volume for 3d sounds
258 *
259 * 31 3/18/98 5:45p Jason
260 * more multiplayer script integration
261 *
262 * 30 3/17/98 3:25p Jason
263 * added number of team functions
264 *
265 * 29 3/17/98 11:22a Jason
266 * added GetGoalRoom functions
267 *
268 * 28 3/16/98 3:53p Jason
269 * added team field to player struct
270 *
271 * 27 2/17/98 3:41p Matt
272 * Revamped weapon system and got sounds for spray and fusion weapons
273 * working. Still need to implements getting continuous & cutoff sounds
274 * from player ship.
275 *
276 * 26 2/11/98 4:54p Jeff
277 * Moved the inventory into the Player struct
278 *
279 * 25 2/06/98 6:07p Jason
280 * made multiplayer objects get deleted in single-player mode
281 *
282 * 24 2/05/98 3:03p Matt
283 * Changed comment
284 *
285 * 23 1/28/98 1:12p Jason
286 * took shields field out of Player struct
287 *
288 * 22 1/28/98 12:00p Jason
289 * more changes for multiplayer
290 *
291 * 21 1/23/98 6:25p Jason
292 * Got spray weapons working
293 *
294 * 20 1/23/98 11:21a Jason
295 * incremental multiplayer checkin
296 *
297 * 19 1/21/98 6:09p Jason
298 * Got player deaths working in multiplayer
299 *
300 * 18 1/21/98 3:08p Samir
301 * Added slot to StartPlayerExplosion.
302 *
303 * 17 1/21/98 1:11p Jason
304 * incremental checkin for multiplayer
305 *
306 * 16 1/20/98 6:35p Samir
307 * Death sequence more multiplayer friendly?
308 *
309 * 15 1/20/98 6:01p Jason
310 * first pass at getting multiplayer deaths working
311 *
312 * 14 1/07/98 6:39p Jason
313 * Fixed player object number stuff
314 *
315 * 13 12/18/97 3:49p Jason
316 * a new first pass at networking!
317 *
318 * 12 11/14/97 2:59p Mark
319 * FROM JASON:changed the way paging weapons and player weapons work
320 *
321 * 11 11/04/97 6:18p Chris
322 * Added support so that the player ship uses the robot's firing dialog.
323 *
324 * 10 10/22/97 7:26p Samir
325 * Player death mostly working. Damn hangup still occurs. Freaky.
326 *
327 * 9 10/21/97 3:16p Samir
328 * Death with explosions (not customized yet.)
329 *
330 * 8 10/08/97 6:36p Samir
331 * Except for player explosions, player death cycle implemented. May
332 * change due to asthetics.
333 *
334 * 7 10/03/97 11:59a Samir
335 * Take care of setting player weapon usage stats.
336 *
337 * 6 10/01/97 4:51p Samir
338 * Moved ApplyDamagePlayer to damage.cpp
339 *
340 * 5 9/17/97 11:35a Samir
341 * BIG SEGMENT RIPOUT
342 *
343 * 4 9/12/97 4:16p Samir
344 * Added cloaking and invulnerability.
345 *
346 * 3 9/05/97 2:34p Samir
347 * Simple player death should work.
348 *
349 * 2 9/05/97 12:26p Samir
350 * Player takes damage, and dies.
351 *
352 * 7 5/06/97 12:53p Matt
353 * Save over terrain flag with start position in player struct
354 *
355 * 6 4/23/97 6:06p Jason
356 * made player ship and weapons work correctly together (first pass)
357 *
358 * 5 4/17/97 2:55p Jason
359 * added many D2 like fields to the player structure
360 *
361 * 4 4/02/97 4:00p Jason
362 * added ship_index field to player struct
363 *
364 * 3 4/01/97 10:49p Matt
365 * Deleted obsolete player_ship stuff, and added player stuff
366 *
367 * $NoKeywords: $
368 */
369
370 #ifndef _PLAYER_H
371 #define _PLAYER_H
372
373 #include "pstypes.h"
374 #include "Inventory.h"
375
376 #include "robotfirestruct.h"
377 #include "object_external_struct.h"
378 #include "player_external_struct.h"
379 #include "player_external.h"
380
381 #define MAX_WAYPOINTS 25
382
383 #define INITIAL_LIVES 3 // start off with 3 lives
384
385 // For energy to shields conversion
386 #define CONVERTER_RATE 20.0f // 10 units per second xfer rate
387 #define CONVERTER_SCALE 2.0f // 2 units energy -> 1 unit shields
388 #define CONVERTER_SOUND_DELAY 0.5f // play every half second
389
390 // How long afterburner lasts before it has to be recharged
391 #ifdef E3_DEMO
392 #define AFTERBURN_TIME 5000.0
393 #else
394 #define AFTERBURN_TIME 5.0
395 #endif
396
397 // Player start position flags
398 #define PSPF_RED 1
399 #define PSPF_BLUE 2
400 #define PSPF_GREEN 4
401 #define PSPF_YELLOW 8
402
403 struct player_pos_suppress {
404 int room;
405 float expire_time;
406 int ignored_pos;
407 bool active;
408 };
409
410 #define PLAYER_POS_HACK_TIME 10
411
412 extern player_pos_suppress Player_pos_fix[MAX_PLAYERS];
413
414 struct team {
415 char name[CALLSIGN_LEN + 1];
416 int score;
417 };
418
419 extern int Player_num;
420 extern int Default_ship_permission;
421
422 // the object which is the person playing the game
423 extern object *Player_object;
424
425 extern int Num_teams, Team_game;
426 extern player Players[];
427 extern team Teams[];
428 extern float HudNameTan;
429 extern int Current_waypoint;
430
431 extern bool Player_has_camera;
432 extern int Player_camera_objnum;
433 extern uint32_t Players_typing; // information about which players are typing messages (to display an icon)
434
435 extern float Player_shields_saved_from_last_level;
436 extern float Player_energy_saved_from_last_level;
437
438 // How long a player must be dead before he can respawn
439 #define DEATH_RESPAWN_TIME 3.0f
440 extern float Total_time_dead;
441
442 // Stuff for the new score info on the HUD
443 extern int Score_added; // the recently-added amount
444 extern float Score_added_timer; // how long the added value will be displayed
445 #define SCORE_ADDED_TIME 2.0 // how long new score info stays on the screen
446
447 // Sets up players array
448 void InitPlayers();
449
450 // Look for player objects & set player starts
451 extern void FindPlayerStarts();
452
453 // Resets all the properties a player ship to the default values
454 // Pass in what kind of reset the inventory should do INVRESET_
455 void InitPlayerNewShip(int slot, int inven_reset);
456
457 // makes the player invulnerable
458 void MakePlayerInvulnerable(int slot, float time, bool play_sound_and_message = false);
459
460 // makes the player invulnerable
461 void MakePlayerVulnerable(int slot);
462
463 // Performs the player death sequence.
464 void InitiatePlayerDeath(object *playerobj, bool melee = false, int fate = -1);
465
466 // Forces end to player death
467 void EndPlayerDeath(int slot);
468
469 // Detaches a subobject from the player ship
470 void DeadPlayerShipHit(object *obj, vector *hitpt, float magnitude);
471
472 // Do actions for the player each frame
473 void DoPlayerFrame();
474
475 // Force player to explode (this should be called to intercept the death sequencer's control of explosions
476 void StartPlayerExplosion(int slot);
477
478 // Resets the player object in a mine to stop moving
479 void ResetPlayerObject(int slot, bool f_reset_pos = true);
480
481 // Makes the player into an AI controlled physics object
482 void PlayerSetControlToAI(int slot, float velocity = 75.0f);
483
484 // Resets a player's control type back to it's default setting
485 void ResetPlayerControlType(int slot);
486
487 void InitPlayerNewGame(int slot);
488
489 // Called from a single player game to get rid of all multiplayer ships
490 void DeleteMultiplayerObjects();
491
492 // Sets the maximum number of teams in a game
493 void SetMaxTeams(int num);
494
495 // Returns the goal room of the passed in team
496 int GetGoalRoomForTeam(int teamnum);
497
498 // Returns the goal room of the passed in player
499 int GetGoalRoomForPlayer(int slot);
500
501 // Moves a player to a specified start position
502 void PlayerMoveToStartPos(int slot, int start_slot);
503
504 // Returns a random player starting position
505 int PlayerGetRandomStartPosition(int slot);
506
507 // Increases the team score by an amount, returning the new total
508 int IncTeamScore(int, int);
509
510 // Resets the scores for all the teams
511 void ResetTeamScores();
512
513 // Sets the lighting that a player will cast
514 void PlayerSetLighting(int slot, float dist, float r, float g, float b);
515
516 // Sets a wacky rotating ball around the player ship
517 void PlayerSetRotatingBall(int slot, int num, float speed, float *r, float *g, float *b);
518
519 // Gets the position of a given ball in world coords
520 void PlayerGetBallPosition(vector *dest, int slot, int num);
521
522 // Spews the inventory of the passed in player object
523 void PlayerSpewInventory(object *obj, bool spew_energy_and_shield = true, bool spew_nonspewable = false);
524
525 // Changes the ship a particular player is flying
526 void PlayerChangeShip(int slot, int ship_index);
527
528 // Called when a player is entering a new level
529 void InitPlayerNewLevel(int slot);
530
531 // Sets the FOV range at which the hud names will come on
532 void PlayerSetHUDNameFOV(int fov);
533
534 // Switches a player object to observer mode
535 void PlayerSwitchToObserver(int slot, int observer_mode, int piggy_objnum = 0);
536
537 // Stops a player from observing
538 void PlayerStopObserving(int slot);
539
540 // Sets the players custom texture. If filename=NULL then sets to no texture
541 // Returns 1 if filename was successfully loaded, else 0
542 int PlayerSetCustomTexture(int slot, char *filename);
543
544 // Chooses the style of death a player is going to use
545 int PlayerChooseDeathFate(int slot, float damage, bool melee);
546
547 // Sets/Clears a permission for a ship on a given player
548 // if pnum is -1 then all players will be set, else player is the player number
549 // returns true on success
550 bool PlayerSetShipPermission(int pnum, char *ship_name, bool allowed);
551
552 // Resets the ship permissions for a given player
553 // pass false for set_default if you don't want the default ship allowed
554 bool PlayerResetShipPermissions(int pnum, bool set_default);
555
556 // Returns true if the given ship is allowed to be chosen for a pnum
557 bool PlayerIsShipAllowed(int pnum, char *ship_name);
558 bool PlayerIsShipAllowed(int pnum, int ship_index);
559
560 // Performs the energy->shields tranfer (for the powerup) given the playernum, call this while player
561 // is holding down the e->s key.
562 void DoEnergyToShields(int pnum);
563
564 // Stop sounds for this player
565 void PlayerStopSounds(int slot);
566
567 // Sets the start position that the player will respawn at
568 void PlayerAddWaypoint(int index);
569
570 // Resets the waypoints (for new level)
571 void ResetWaypoint();
572
573 // Find all the waypoint objects and add them to the list of waypoints
574 void MakeAtuoWaypointList();
575
576 // Sets the auto-waypoint in the object's room to be current
577 void SetAutoWaypoint(object *objp);
578
579 // Returns the team (0 to 3) of the given player
580 static inline int PlayerGetTeam(int pnum) {
581 if (Players[pnum].team == -1) {
582 // special "no-team" for Dedicated server
583 return 0; // fake a red team
584 }
585
586 return Players[pnum].team;
587 }
588
589 // Add the player's score
590 void PlayerScoreAdd(int playernum, int points);
591
592 // steals an item from the given player
593 void ThiefStealItem(int player_object_handle, int item);
594 // returns a stolen item to a player
595 void ThiefReturnItem(int player_object_handle, int item);
596 // returns true if a player has the specified item to be stolen
597 bool ThiefPlayerHasItem(int player_object_handle, int item);
598 #endif