]> icculus.org git repositories - btb/d2x.git/blob - main/wall.h
portability
[btb/d2x.git] / main / wall.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 #ifndef _WALL_H
15 #define _WALL_H
16
17 #include "inferno.h"
18 #include "segment.h"
19 #include "object.h"
20 #include "cfile.h"
21
22 //#include "vclip.h"
23
24 #define MAX_WALLS                                       254     // Maximum number of walls
25 #define MAX_WALL_ANIMS                  60              // Maximum different types of doors
26 #define MAX_DOORS                                       90              // Maximum number of open doors
27
28 // Various wall types.
29 #define WALL_NORMAL                             0       // Normal wall
30 #define WALL_BLASTABLE                  1       // Removable (by shooting) wall
31 #define WALL_DOOR                                       2       // Door 
32 #define WALL_ILLUSION                   3       // Wall that appears to be there, but you can fly thru
33 #define WALL_OPEN                                       4               // Just an open side. (Trigger)
34 #define WALL_CLOSED                             5               // Wall.  Used for transparent walls.
35 #define WALL_OVERLAY                            6               // Goes over an actual solid side.  For triggers 
36 #define WALL_CLOAKED                            7               // Can see it, and see through it
37
38 // Various wall flags.
39 #define WALL_BLASTED                            1       // Blasted out wall.
40 #define WALL_DOOR_OPENED                2       // Open door. 
41 #define WALL_DOOR_LOCKED                8               // Door is locked.
42 #define WALL_DOOR_AUTO                  16              // Door automatically closes after time.
43 #define WALL_ILLUSION_OFF               32              // Illusionary wall is shut off.
44 #define WALL_WALL_SWITCH                64              // This wall is openable by a wall switch.
45 #define WALL_BUDDY_PROOF                128     // Buddy assumes he cannot get through this wall.
46
47 // Wall states
48 #define WALL_DOOR_CLOSED                0               // Door is closed
49 #define WALL_DOOR_OPENING               1               // Door is opening.
50 #define WALL_DOOR_WAITING               2               // Waiting to close
51 #define WALL_DOOR_CLOSING               3               // Door is closing
52 #define WALL_DOOR_OPEN                  4               // Door is open, and staying open
53 #define WALL_DOOR_CLOAKING              5               // Wall is going from closed -> open
54 #define WALL_DOOR_DECLOAKING    6               // Wall is going from open -> closed
55
56 //note: a door is considered opened (i.e., it has WALL_OPENED set) when it 
57 //is more than half way open.  Thus, it can have any of OPENING, CLOSING, 
58 //or WAITING bits set when OPENED is set.
59
60 #define KEY_NONE                                        1
61 #define KEY_BLUE                                        2
62 #define KEY_RED                            4
63 #define KEY_GOLD                                   8
64
65 #define WALL_HPS                                        100*F1_0                // Normal wall's hp
66 #define WALL_DOOR_INTERVAL              5*F1_0          // How many seconds a door is open
67
68 #define DOOR_OPEN_TIME                  i2f(2)          // How long takes to open
69 #define DOOR_WAIT_TIME                  i2f(5)          // How long before auto door closes
70
71 #define MAX_CLIP_FRAMES                 50
72
73 // WALL_IS_DOORWAY flags.
74 #define WID_FLY_FLAG                                    1
75 #define WID_RENDER_FLAG                         2
76 #define WID_RENDPAST_FLAG                       4
77 #define WID_EXTERNAL_FLAG                       8
78 #define WID_CLOAKED_FLAG                        16
79
80 //@@//  WALL_IS_DOORWAY return values                   F/R/RP
81 //@@#define WID_WALL                                            2       // 0/1/0                wall
82 //@@#define WID_TRANSPARENT_WALL                6       //      0/1/1           transparent wall
83 //@@#define WID_ILLUSORY_WALL                   3       //      1/1/0           illusory wall
84 //@@#define WID_TRANSILLUSORY_WALL      7       //      1/1/1           transparent illusory wall
85 //@@#define WID_NO_WALL                                 5       //      1/0/1           no wall, can fly through
86 //@@#define WID_EXTERNAL                                        8       // 0/0/0/1      don't see it, dont fly through it
87
88 #define MAX_STUCK_OBJECTS       32
89
90 typedef struct stuckobj {
91     short   objnum, wallnum;
92     int     signature;
93 } stuckobj;
94
95 //Start old wall structures
96
97 typedef struct v16_wall {
98         byte    type;               // What kind of special wall.
99         byte    flags;              // Flags for the wall.
100         fix     hps;                // "Hit points" of the wall.
101         byte    trigger;            // Which trigger is associated with the wall.
102         byte    clip_num;           // Which animation associated with the wall.
103         byte    keys;
104 } v16_wall;
105
106 typedef struct v19_wall {
107         int     segnum,sidenum;     // Seg & side for this wall
108         byte    type;               // What kind of special wall.
109         byte    flags;              // Flags for the wall.
110         fix     hps;                // "Hit points" of the wall.
111         byte    trigger;            // Which trigger is associated with the wall.
112         byte    clip_num;           // Which animation associated with the wall.
113         byte    keys;
114         int linked_wall;            // number of linked wall
115 } v19_wall;
116
117 typedef struct v19_door {
118         int     n_parts;            // for linked walls
119         short   seg[2];             // Segment pointer of door.
120         short   side[2];            // Side number of door.
121         short   type[2];            // What kind of door animation.
122         fix     open;               // How long it has been open.
123 } v19_door;
124
125 //End old wall structures
126
127 typedef struct wall {
128         int     segnum,sidenum;     // Seg & side for this wall
129         fix     hps;                // "Hit points" of the wall.
130         int     linked_wall;        // number of linked wall
131         ubyte   type;               // What kind of special wall.
132         ubyte   flags;              // Flags for the wall.
133         ubyte   state;              // Opening, closing, etc.
134         byte    trigger;            // Which trigger is associated with the wall.
135         byte    clip_num;           // Which animation associated with the wall.
136         ubyte   keys;               // which keys are required
137         byte    controlling_trigger;// which trigger causes something to happen here.  Not like "trigger" above, which is the trigger on this wall.
138                                 //  Note: This gets stuffed at load time in gamemine.c.  Don't try to use it in the editor.  You will be sorry!
139         byte    cloak_value;        // if this wall is cloaked, the fade value
140 } wall;
141
142 typedef struct active_door {
143         int     n_parts;            // for linked walls
144         short   front_wallnum[2];   // front wall numbers for this door
145         short   back_wallnum[2];    // back wall numbers for this door
146         fix     time;               // how long been opening, closing, waiting
147 } active_door;
148
149 typedef struct cloaking_wall {
150         short       front_wallnum;  // front wall numbers for this door
151         short       back_wallnum;   // back wall numbers for this door
152         fix     front_ls[4];        // front wall saved light values
153         fix     back_ls[4];         // back wall saved light values
154         fix     time;               // how long been cloaking or decloaking
155 } __pack__ cloaking_wall;
156
157 //wall clip flags
158 #define WCF_EXPLODES    1       //door explodes when opening
159 #define WCF_BLASTABLE   2       //this is a blastable wall
160 #define WCF_TMAP1       4       //this uses primary tmap, not tmap2
161 #define WCF_HIDDEN      8       //this uses primary tmap, not tmap2
162
163 typedef struct {
164         fix     play_time;
165         short   num_frames;
166         short   frames[MAX_CLIP_FRAMES];
167         short   open_sound;
168         short   close_sound;
169         short   flags;
170         char    filename[13];
171         char    pad;
172 } wclip;
173
174 extern char     Wall_names[7][10];
175
176 //#define WALL_IS_DOORWAY(seg,side) wall_is_doorway(seg, side)
177
178 #define WALL_IS_DOORWAY(seg,side) (((seg)->children[(side)] == -1) ? WID_RENDER_FLAG : ((seg)->children[(side)] == -2) ? WID_EXTERNAL_FLAG : ((seg)->sides[(side)].wall_num == -1) ? (WID_FLY_FLAG|WID_RENDPAST_FLAG) : wall_is_doorway((seg), (side)))
179
180 extern wall Walls[MAX_WALLS];                   // Master walls array
181 extern int Num_walls;                                   // Number of walls
182
183 extern active_door ActiveDoors[MAX_DOORS];      //      Master doors array
184 extern int Num_open_doors;                              // Number of open doors
185
186 extern cloaking_wall CloakingWalls[];
187 extern int Num_cloaking_walls;
188
189 extern wclip WallAnims[MAX_WALL_ANIMS];
190 extern int Num_wall_anims;
191
192 extern int walls_bm_num[MAX_WALL_ANIMS];
193
194 // Initializes all walls (i.e. no special walls.)
195 extern void wall_init();
196                                                                                                                                                                                          
197 // Automatically checks if a there is a doorway (i.e. can fly through)
198 extern int wall_is_doorway ( segment *seg, int side );
199
200 // Deteriorate appearance of wall. (Changes bitmap (paste-ons)) 
201 extern void wall_damage(segment *seg, int side, fix damage);
202
203 // Destroys a blastable wall. (So it is an opening afterwards)
204 extern void wall_destroy(segment *seg, int side);
205
206 void wall_illusion_on(segment *seg, int side);
207
208 void wall_illusion_off(segment *seg, int side);
209
210 // Opens a door, including animation and other processing.
211 void do_door_open(int door_num);
212
213 // Closes a door, including animation and other processing.
214 void do_door_close(int door_num);
215
216 // Opens a door  
217 extern void wall_open_door(segment *seg, int side);
218
219 // Closes a door  
220 extern void wall_close_door(segment *seg, int side);
221
222 //return codes for wall_hit_process()
223 #define WHP_NOT_SPECIAL         0               //wasn't a quote-wall-unquote
224 #define WHP_NO_KEY                      1               //hit door, but didn't have key
225 #define WHP_BLASTABLE           2               //hit blastable wall
226 #define WHP_DOOR                                3               //a door (which will now be opening)
227
228 // Determines what happens when a wall is shot
229 //obj is the object that hit...either a weapon or the player himself
230 extern int wall_hit_process(segment *seg, int side, fix damage, int playernum, object *obj );
231
232 // Opens/destroys specified door.
233 extern void wall_toggle(segment *seg, int side);
234
235 // Tidy up Walls array for load/save purposes.
236 extern void reset_walls();
237
238 // Called once per frame..
239 void wall_frame_process();
240
241 extern stuckobj Stuck_objects[MAX_STUCK_OBJECTS];
242
243 //      An object got stuck in a door (like a flare).
244 //      Add global entry.
245 extern void add_stuck_object(object *objp, int segnum, int sidenum);
246 extern void remove_obsolete_stuck_objects(void);
247
248 //set the tmap_num or tmap_num2 field for a wall/door
249 extern void wall_set_tmap_num(segment *seg,int side,segment *csegp,int cside,int anim_num,int frame_num);
250
251 // Remove any flares from a wall
252 void kill_stuck_objects(int wallnum);
253
254 //start wall open <-> closed transitions
255 void start_wall_cloak(segment *seg, int side);
256 void start_wall_decloak(segment *seg, int side);
257
258 /*
259  * reads a wclip structure from a CFILE
260  */
261 extern void wclip_read(wclip *wc, CFILE *fp);
262
263 /*
264  * reads a v16_wall structure from a CFILE
265  */
266 extern void v16_wall_read(v16_wall *w, CFILE *fp);
267
268 /*
269  * reads a v19_wall structure from a CFILE
270  */
271 extern void v19_wall_read(v19_wall *w, CFILE *fp);
272
273 /*
274  * reads a wall structure from a CFILE
275  */
276 extern void wall_read(wall *w, CFILE *fp);
277
278 /*
279  * reads a v19_door structure from a CFILE
280  */
281 extern void v19_door_read(v19_door *d, CFILE *fp);
282
283 /*
284  * reads an active_door structure from a CFILE
285  */
286 extern void active_door_read(active_door *ad, CFILE *fp);
287
288 #endif