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