]> icculus.org git repositories - btb/d2x.git/blob - main/player.h
handle missing exit sequence components gracefully
[btb/d2x.git] / main / player.h
1 /* $Id: player.h,v 1.3 2003-03-01 03:56:55 btb Exp $ */
2 /*
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
13 */
14
15 #ifndef _PLAYER_H
16 #define _PLAYER_H
17
18 #include "inferno.h"
19 #include "fix.h"
20 #include "vecmat.h"
21 #include "weapon.h"
22
23 #define MAX_PLAYERS 8
24 #define MAX_MULTI_PLAYERS MAX_PLAYERS+3
25
26 // Initial player stat values
27 #define INITIAL_ENERGY  i2f(100)    //100% energy to start
28 #define INITIAL_SHIELDS i2f(100)    //100% shields to start
29
30 #define MAX_ENERGY      i2f(200)    //go up to 200
31 #define MAX_SHIELDS     i2f(200)
32
33 #define INITIAL_LIVES               3   //start off with 3 lives
34
35 // Values for special flags
36 #define PLAYER_FLAGS_INVULNERABLE   1   // Player is invincible
37 #define PLAYER_FLAGS_BLUE_KEY       2   // Player has blue key
38 #define PLAYER_FLAGS_RED_KEY        4   // Player has red key
39 #define PLAYER_FLAGS_GOLD_KEY       8   // Player has gold key
40 #define PLAYER_FLAGS_FLAG           16  // Player has his team's flag
41 #define PLAYER_FLAGS_UNUSED         32  //
42 #define PLAYER_FLAGS_MAP_ALL        64  // Player can see unvisited areas on map
43 #define PLAYER_FLAGS_AMMO_RACK      128 // Player has ammo rack
44 #define PLAYER_FLAGS_CONVERTER      256 // Player has energy->shield converter
45 #define PLAYER_FLAGS_MAP_ALL_CHEAT  512 // Player can see unvisited areas on map normally
46 #define PLAYER_FLAGS_QUAD_LASERS    1024    // Player shoots 4 at once
47 #define PLAYER_FLAGS_CLOAKED        2048    // Player is cloaked for awhile
48 #define PLAYER_FLAGS_AFTERBURNER    4096    // Player's afterburner is engaged
49 #define PLAYER_FLAGS_HEADLIGHT      8192    // Player has headlight boost
50 #define PLAYER_FLAGS_HEADLIGHT_ON   16384   // is headlight on or off?
51
52 #define AFTERBURNER_MAX_TIME    (F1_0*5)    // Max time afterburner can be on.
53 #define CALLSIGN_LEN                8       // so can use as filename (was: 12)
54
55 // Amount of time player is cloaked.
56 #define CLOAK_TIME_MAX          (F1_0*30)
57 #define INVULNERABLE_TIME_MAX   (F1_0*30)
58
59 #define PLAYER_STRUCT_VERSION   17        //increment this every time player struct changes
60
61 //defines for teams
62 #define TEAM_BLUE   0
63 #define TEAM_RED    1
64
65 //When this structure changes, increment the constant SAVE_FILE_VERSION
66 //in playsave.c
67 typedef struct player {
68         // Who am I data
69         char    callsign[CALLSIGN_LEN+1];   // The callsign of this player, for net purposes.
70         ubyte   net_address[6];         // The network address of the player.
71         byte    connected;              // Is the player connected or not?
72         int     objnum;                 // What object number this player is. (made an int by mk because it's very often referenced)
73         int     n_packets_got;          // How many packets we got from them
74         int     n_packets_sent;         // How many packets we sent to them
75
76         //  -- make sure you're 4 byte aligned now!
77
78         // Game data
79         uint    flags;                  // Powerup flags, see below...
80         fix     energy;                 // Amount of energy remaining.
81         fix     shields;                // shields remaining (protection)
82         ubyte   lives;                  // Lives remaining, 0 = game over.
83         byte    level;                  // Current level player is playing. (must be signed for secret levels)
84         ubyte   laser_level;            // Current level of the laser.
85         byte    starting_level;         // What level the player started on.
86         short   killer_objnum;          // Who killed me.... (-1 if no one)
87         ushort  primary_weapon_flags;   // bit set indicates the player has this weapon.
88         ushort  secondary_weapon_flags; // bit set indicates the player has this weapon.
89         ushort  primary_ammo[MAX_PRIMARY_WEAPONS];  // How much ammo of each type.
90         ushort  secondary_ammo[MAX_SECONDARY_WEAPONS]; // How much ammo of each type.
91
92         ushort  pad; // Pad because increased weapon_flags from byte to short -YW 3/22/95
93
94         //  -- make sure you're 4 byte aligned now
95
96         // Statistics...
97         int     last_score;             // Score at beginning of current level.
98         int     score;                  // Current score.
99         fix     time_level;             // Level time played
100         fix     time_total;             // Game time played (high word = seconds)
101
102         fix     cloak_time;             // Time cloaked
103         fix     invulnerable_time;      // Time invulnerable
104
105         short   KillGoalCount;          // Num of players killed this level
106         short   net_killed_total;       // Number of times killed total
107         short   net_kills_total;        // Number of net kills total
108         short   num_kills_level;        // Number of kills this level
109         short   num_kills_total;        // Number of kills total
110         short   num_robots_level;       // Number of initial robots this level
111         short   num_robots_total;       // Number of robots total
112         ushort  hostages_rescued_total; // Total number of hostages rescued.
113         ushort  hostages_total;         // Total number of hostages.
114         ubyte   hostages_on_board;      // Number of hostages on ship.
115         ubyte   hostages_level;         // Number of hostages on this level.
116         fix     homing_object_dist;     // Distance of nearest homing object.
117         byte    hours_level;            // Hours played (since time_total can only go up to 9 hours)
118         byte    hours_total;            // Hours played (since time_total can only go up to 9 hours)
119 } __pack__ player;
120
121 #define N_PLAYER_GUNS 8
122
123 typedef struct player_ship {
124         int         model_num;
125         int     expl_vclip_num;
126         fix     mass,drag;
127         fix     max_thrust,reverse_thrust,brakes;       //low_thrust
128         fix     wiggle;
129         fix     max_rotthrust;
130         vms_vector gun_points[N_PLAYER_GUNS];
131 } player_ship;
132
133 extern int N_players;   // Number of players ( >1 means a net game, eh?)
134 extern int Player_num;  // The player number who is on the console.
135
136 extern player Players[MAX_PLAYERS+4];   // Misc player info
137 extern player_ship *Player_ship;
138
139
140 //version 16 structure
141
142 #define MAX_PRIMARY_WEAPONS16   5
143 #define MAX_SECONDARY_WEAPONS16 5
144
145 typedef struct player16 {
146         // Who am I data
147         char    callsign[CALLSIGN_LEN+1];   // The callsign of this player, for net purposes.
148         ubyte   net_address[6];         // The network address of the player.
149         byte    connected;              // Is the player connected or not?
150         int     objnum;                 // What object number this player is. (made an int by mk because it's very often referenced)
151         int     n_packets_got;          // How many packets we got from them
152         int     n_packets_sent;         // How many packets we sent to them
153
154         //  -- make sure you're 4 byte aligned now!
155
156         // Game data
157         uint    flags;                  // Powerup flags, see below...
158         fix     energy;                 // Amount of energy remaining.
159         fix     shields;                // shields remaining (protection)
160         ubyte   lives;                  // Lives remaining, 0 = game over.
161         byte    level;                  // Current level player is playing. (must be signed for secret levels)
162         ubyte   laser_level;            // Current level of the laser.
163         byte    starting_level;         // What level the player started on.
164         short   killer_objnum;          // Who killed me.... (-1 if no one)
165         ubyte   primary_weapon_flags;   // bit set indicates the player has this weapon.
166         ubyte   secondary_weapon_flags; // bit set indicates the player has this weapon.
167         ushort  primary_ammo[MAX_PRIMARY_WEAPONS16];    // How much ammo of each type.
168         ushort  secondary_ammo[MAX_SECONDARY_WEAPONS16];// How much ammo of each type.
169
170         //  -- make sure you're 4 byte aligned now
171
172         // Statistics...
173         int     last_score;             // Score at beginning of current level.
174         int     score;                  // Current score.
175         fix     time_level;             // Level time played
176         fix     time_total;             // Game time played (high word = seconds)
177
178         fix     cloak_time;             // Time cloaked
179         fix     invulnerable_time;      // Time invulnerable
180
181         short   net_killed_total;       // Number of times killed total
182         short   net_kills_total;        // Number of net kills total
183         short   num_kills_level;        // Number of kills this level
184         short   num_kills_total;        // Number of kills total
185         short   num_robots_level;       // Number of initial robots this level
186         short   num_robots_total;       // Number of robots total
187         ushort  hostages_rescued_total; // Total number of hostages rescued.
188         ushort  hostages_total;         // Total number of hostages.
189         ubyte   hostages_on_board;      // Number of hostages on ship.
190         ubyte   hostages_level;         // Number of hostages on this level.
191         fix     homing_object_dist;     // Distance of nearest homing object.
192         byte    hours_level;            // Hours played (since time_total can only go up to 9 hours)
193         byte    hours_total;            // Hours played (since time_total can only go up to 9 hours)
194 } __pack__ player16;
195
196 /*
197  * reads a player_ship structure from a CFILE
198  */
199 void player_ship_read(player_ship *ps, CFILE *fp);
200
201 #endif