1 /* $Id: wall.h,v 1.7 2003-10-10 09:36:35 btb Exp $ */
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.
20 * Revision 1.1 1995/05/16 16:05:14 allender
23 * Revision 2.0 1995/02/27 11:31:36 john
24 * New version 2.0, which has no anonymous unions, builds with
25 * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
27 * Revision 1.47 1994/11/19 15:20:35 mike
28 * rip out unused code and data
30 * Revision 1.46 1994/10/25 15:40:12 yuan
33 * Revision 1.45 1994/10/23 19:17:07 matt
34 * Fixed bug with "no key" messages
36 * Revision 1.44 1994/10/18 15:38:03 mike
37 * Define hidden walls.
39 * Revision 1.43 1994/10/04 13:32:26 adam
40 * commented out MAX_DOOR_ANIMS
42 * Revision 1.42 1994/10/04 13:31:21 adam
43 * upped MAX_WALL_ANIMS to 30
45 * Revision 1.41 1994/09/29 00:42:30 matt
46 * Made hitting a locked door play a sound
48 * Revision 1.40 1994/09/27 15:42:41 mike
49 * Prototype Wall_names.
51 * Revision 1.39 1994/09/23 22:15:32 matt
52 * Made doors not close on objects, made doors open again if shot while
53 * closing, and cleaned up walls/doors a bit.
55 * Revision 1.38 1994/09/22 15:31:33 matt
56 * Mucked with, and hopefully improved, exploding walls
58 * Revision 1.37 1994/09/21 17:17:05 mike
59 * Make objects stuck in doors go away when door opens.
61 * Revision 1.36 1994/09/13 21:10:46 matt
62 * Added wclips that use tmap1 instead of tmap2, saving lots of merging
64 * Revision 1.35 1994/09/13 20:11:08 yuan
65 * *** empty log message ***
67 * Revision 1.34 1994/09/10 13:31:53 matt
68 * Made exploding walls a type of blastable walls.
69 * Cleaned up blastable walls, making them tmap2 bitmaps.
71 * Revision 1.33 1994/08/17 12:55:34 matt
72 * Added external walls to wall_is_doorway
74 * Revision 1.32 1994/08/15 17:54:35 john
75 * *** empty log message ***
77 * Revision 1.31 1994/08/15 17:46:56 yuan
78 * Added external walls, fixed blastable walls.
80 * Revision 1.30 1994/08/05 21:17:21 matt
81 * Allow two doors to be linked together
83 * Revision 1.29 1994/08/01 10:39:10 matt
84 * Parenthesized parms to WID() macro
86 * Revision 1.28 1994/07/20 17:35:03 yuan
87 * Some minor bug fixes and new key gauges...
89 * Revision 1.27 1994/07/19 14:32:03 yuan
90 * Fixed keys bug... renumbered some constants.
92 * Revision 1.26 1994/07/14 22:38:29 matt
93 * Added exploding doors
95 * Revision 1.25 1994/07/11 15:08:43 yuan
96 * Wall anim file names stored in structure.
110 #define MAX_WALLS 254 // Maximum number of walls
111 #define MAX_WALL_ANIMS 60 // Maximum different types of doors
112 #define MAX_DOORS 90 // Maximum number of open doors
114 // Various wall types.
115 #define WALL_NORMAL 0 // Normal wall
116 #define WALL_BLASTABLE 1 // Removable (by shooting) wall
117 #define WALL_DOOR 2 // Door
118 #define WALL_ILLUSION 3 // Wall that appears to be there, but you can fly thru
119 #define WALL_OPEN 4 // Just an open side. (Trigger)
120 #define WALL_CLOSED 5 // Wall. Used for transparent walls.
121 #define WALL_OVERLAY 6 // Goes over an actual solid side. For triggers
122 #define WALL_CLOAKED 7 // Can see it, and see through it
124 // Various wall flags.
125 #define WALL_BLASTED 1 // Blasted out wall.
126 #define WALL_DOOR_OPENED 2 // Open door.
127 #define WALL_DOOR_LOCKED 8 // Door is locked.
128 #define WALL_DOOR_AUTO 16 // Door automatically closes after time.
129 #define WALL_ILLUSION_OFF 32 // Illusionary wall is shut off.
130 #define WALL_WALL_SWITCH 64 // This wall is openable by a wall switch.
131 #define WALL_BUDDY_PROOF 128 // Buddy assumes he cannot get through this wall.
134 #define WALL_DOOR_CLOSED 0 // Door is closed
135 #define WALL_DOOR_OPENING 1 // Door is opening.
136 #define WALL_DOOR_WAITING 2 // Waiting to close
137 #define WALL_DOOR_CLOSING 3 // Door is closing
138 #define WALL_DOOR_OPEN 4 // Door is open, and staying open
139 #define WALL_DOOR_CLOAKING 5 // Wall is going from closed -> open
140 #define WALL_DOOR_DECLOAKING 6 // Wall is going from open -> closed
142 //note: a door is considered opened (i.e., it has WALL_OPENED set) when it
143 //is more than half way open. Thus, it can have any of OPENING, CLOSING,
144 //or WAITING bits set when OPENED is set.
151 #define WALL_HPS 100*F1_0 // Normal wall's hp
152 #define WALL_DOOR_INTERVAL 5*F1_0 // How many seconds a door is open
154 #define DOOR_OPEN_TIME i2f(2) // How long takes to open
155 #define DOOR_WAIT_TIME i2f(5) // How long before auto door closes
157 #define MAX_CLIP_FRAMES 50
159 // WALL_IS_DOORWAY flags.
160 #define WID_FLY_FLAG 1
161 #define WID_RENDER_FLAG 2
162 #define WID_RENDPAST_FLAG 4
163 #define WID_EXTERNAL_FLAG 8
164 #define WID_CLOAKED_FLAG 16
166 //@@// WALL_IS_DOORWAY return values F/R/RP
167 //@@#define WID_WALL 2 // 0/1/0 wall
168 //@@#define WID_TRANSPARENT_WALL 6 // 0/1/1 transparent wall
169 //@@#define WID_ILLUSORY_WALL 3 // 1/1/0 illusory wall
170 //@@#define WID_TRANSILLUSORY_WALL 7 // 1/1/1 transparent illusory wall
171 //@@#define WID_NO_WALL 5 // 1/0/1 no wall, can fly through
172 //@@#define WID_EXTERNAL 8 // 0/0/0/1 don't see it, dont fly through it
174 #define MAX_STUCK_OBJECTS 32
176 typedef struct stuckobj {
177 short objnum, wallnum;
181 //Start old wall structures
183 typedef struct v16_wall {
184 sbyte type; // What kind of special wall.
185 sbyte flags; // Flags for the wall.
186 fix hps; // "Hit points" of the wall.
187 sbyte trigger; // Which trigger is associated with the wall.
188 sbyte clip_num; // Which animation associated with the wall.
192 typedef struct v19_wall {
193 int segnum,sidenum; // Seg & side for this wall
194 sbyte type; // What kind of special wall.
195 sbyte flags; // Flags for the wall.
196 fix hps; // "Hit points" of the wall.
197 sbyte trigger; // Which trigger is associated with the wall.
198 sbyte clip_num; // Which animation associated with the wall.
200 int linked_wall; // number of linked wall
203 typedef struct v19_door {
204 int n_parts; // for linked walls
205 short seg[2]; // Segment pointer of door.
206 short side[2]; // Side number of door.
207 short type[2]; // What kind of door animation.
208 fix open; // How long it has been open.
211 //End old wall structures
213 typedef struct wall {
214 int segnum,sidenum; // Seg & side for this wall
215 fix hps; // "Hit points" of the wall.
216 int linked_wall; // number of linked wall
217 ubyte type; // What kind of special wall.
218 ubyte flags; // Flags for the wall.
219 ubyte state; // Opening, closing, etc.
220 sbyte trigger; // Which trigger is associated with the wall.
221 sbyte clip_num; // Which animation associated with the wall.
222 ubyte keys; // which keys are required
223 sbyte controlling_trigger;// which trigger causes something to happen here. Not like "trigger" above, which is the trigger on this wall.
224 // Note: This gets stuffed at load time in gamemine.c. Don't try to use it in the editor. You will be sorry!
225 sbyte cloak_value; // if this wall is cloaked, the fade value
228 typedef struct active_door {
229 int n_parts; // for linked walls
230 short front_wallnum[2]; // front wall numbers for this door
231 short back_wallnum[2]; // back wall numbers for this door
232 fix time; // how long been opening, closing, waiting
233 } __pack__ active_door;
235 typedef struct cloaking_wall {
236 short front_wallnum; // front wall numbers for this door
237 short back_wallnum; // back wall numbers for this door
238 fix front_ls[4]; // front wall saved light values
239 fix back_ls[4]; // back wall saved light values
240 fix time; // how long been cloaking or decloaking
241 } __pack__ cloaking_wall;
244 #define WCF_EXPLODES 1 //door explodes when opening
245 #define WCF_BLASTABLE 2 //this is a blastable wall
246 #define WCF_TMAP1 4 //this uses primary tmap, not tmap2
247 #define WCF_HIDDEN 8 //this uses primary tmap, not tmap2
252 short frames[MAX_CLIP_FRAMES];
260 extern char Wall_names[7][10];
262 //#define WALL_IS_DOORWAY(seg,side) wall_is_doorway(seg, side)
264 #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)))
266 extern wall Walls[MAX_WALLS]; // Master walls array
267 extern int Num_walls; // Number of walls
269 extern active_door ActiveDoors[MAX_DOORS]; // Master doors array
270 extern int Num_open_doors; // Number of open doors
272 extern cloaking_wall CloakingWalls[];
273 extern int Num_cloaking_walls;
275 extern wclip WallAnims[MAX_WALL_ANIMS];
276 extern int Num_wall_anims;
278 extern int walls_bm_num[MAX_WALL_ANIMS];
280 // Initializes all walls (i.e. no special walls.)
281 extern void wall_init();
283 // Automatically checks if a there is a doorway (i.e. can fly through)
284 extern int wall_is_doorway ( segment *seg, int side );
286 // Deteriorate appearance of wall. (Changes bitmap (paste-ons))
287 extern void wall_damage(segment *seg, int side, fix damage);
289 // Destroys a blastable wall. (So it is an opening afterwards)
290 extern void wall_destroy(segment *seg, int side);
292 void wall_illusion_on(segment *seg, int side);
294 void wall_illusion_off(segment *seg, int side);
296 // Opens a door, including animation and other processing.
297 void do_door_open(int door_num);
299 // Closes a door, including animation and other processing.
300 void do_door_close(int door_num);
303 extern void wall_open_door(segment *seg, int side);
306 extern void wall_close_door(segment *seg, int side);
308 //return codes for wall_hit_process()
309 #define WHP_NOT_SPECIAL 0 //wasn't a quote-wall-unquote
310 #define WHP_NO_KEY 1 //hit door, but didn't have key
311 #define WHP_BLASTABLE 2 //hit blastable wall
312 #define WHP_DOOR 3 //a door (which will now be opening)
314 // Determines what happens when a wall is shot
315 //obj is the object that hit...either a weapon or the player himself
316 extern int wall_hit_process(segment *seg, int side, fix damage, int playernum, object *obj );
318 // Opens/destroys specified door.
319 extern void wall_toggle(segment *seg, int side);
321 // Tidy up Walls array for load/save purposes.
322 extern void reset_walls();
324 // Called once per frame..
325 void wall_frame_process();
327 extern stuckobj Stuck_objects[MAX_STUCK_OBJECTS];
329 // An object got stuck in a door (like a flare).
331 extern void add_stuck_object(object *objp, int segnum, int sidenum);
332 extern void remove_obsolete_stuck_objects(void);
334 //set the tmap_num or tmap_num2 field for a wall/door
335 extern void wall_set_tmap_num(segment *seg,int side,segment *csegp,int cside,int anim_num,int frame_num);
337 // Remove any flares from a wall
338 void kill_stuck_objects(int wallnum);
340 //start wall open <-> closed transitions
341 void start_wall_cloak(segment *seg, int side);
342 void start_wall_decloak(segment *seg, int side);
344 extern int wclip_read_n_d1(wclip *wc, int n, CFILE *fp);
346 #define wclip_read_n(wc, n, fp) cfread(wc, sizeof(wclip), n, fp)
347 #define v16_wall_read(w, fp) cfread(w, sizeof(v16_wall), 1, fp)
348 #define v19_wall_read(w, fp) cfread(w, sizeof(v19_wall), 1, fp)
349 #define wall_read(w, fp) cfread(w, sizeof(wall), 1, fp)
350 #define v19_door_read(d, fp) cfread(d, sizeof(v19_door), 1, fp)
351 #define active_door_read(d, fp) cfread(d, sizeof(active_door), 1, fp)
354 * reads n wclip structs from a CFILE
356 extern int wclip_read_n(wclip *wc, int n, CFILE *fp);
359 * reads a v16_wall structure from a CFILE
361 extern void v16_wall_read(v16_wall *w, CFILE *fp);
364 * reads a v19_wall structure from a CFILE
366 extern void v19_wall_read(v19_wall *w, CFILE *fp);
369 * reads a wall structure from a CFILE
371 extern void wall_read(wall *w, CFILE *fp);
374 * reads a v19_door structure from a CFILE
376 extern void v19_door_read(v19_door *d, CFILE *fp);
379 * reads an active_door structure from a CFILE
381 extern void active_door_read(active_door *ad, CFILE *fp);