home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #6 / amigaacscoverdisc1998-061998.iso / games / descent / source / main / wall.h < prev    next >
C/C++ Source or Header  |  1998-06-08  |  10KB  |  282 lines

  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-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
  12. */
  13. /*
  14.  * $Source: f:/miner/source/main/rcs/wall.h $
  15.  * $Revision: 2.0 $
  16.  * $Author: john $
  17.  * $Date: 1995/02/27 11:31:36 $
  18.  * 
  19.  * $Log: wall.h $
  20.  * Revision 2.0  1995/02/27  11:31:36  john
  21.  * New version 2.0, which has no anonymous unions, builds with
  22.  * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
  23.  * 
  24.  * Revision 1.47  1994/11/19  15:20:35  mike
  25.  * rip out unused code and data
  26.  * 
  27.  * Revision 1.46  1994/10/25  15:40:12  yuan
  28.  * MAX_WALLS pumped up
  29.  * 
  30.  * Revision 1.45  1994/10/23  19:17:07  matt
  31.  * Fixed bug with "no key" messages
  32.  * 
  33.  * Revision 1.44  1994/10/18  15:38:03  mike
  34.  * Define hidden walls.
  35.  * 
  36.  * Revision 1.43  1994/10/04  13:32:26  adam
  37.  * commented out MAX_DOOR_ANIMS
  38.  * 
  39.  * Revision 1.42  1994/10/04  13:31:21  adam
  40.  * upped MAX_WALL_ANIMS to 30
  41.  * 
  42.  * Revision 1.41  1994/09/29  00:42:30  matt
  43.  * Made hitting a locked door play a sound
  44.  * 
  45.  * Revision 1.40  1994/09/27  15:42:41  mike
  46.  * Prototype Wall_names.
  47.  * 
  48.  * Revision 1.39  1994/09/23  22:15:32  matt
  49.  * Made doors not close on objects, made doors open again if shot while
  50.  * closing, and cleaned up walls/doors a bit.
  51.  * 
  52.  * Revision 1.38  1994/09/22  15:31:33  matt
  53.  * Mucked with, and hopefully improved, exploding walls
  54.  * 
  55.  * Revision 1.37  1994/09/21  17:17:05  mike
  56.  * Make objects stuck in doors go away when door opens.
  57.  * 
  58.  * Revision 1.36  1994/09/13  21:10:46  matt
  59.  * Added wclips that use tmap1 instead of tmap2, saving lots of merging
  60.  * 
  61.  * Revision 1.35  1994/09/13  20:11:08  yuan
  62.  * *** empty log message ***
  63.  * 
  64.  * Revision 1.34  1994/09/10  13:31:53  matt
  65.  * Made exploding walls a type of blastable walls.
  66.  * Cleaned up blastable walls, making them tmap2 bitmaps.
  67.  * 
  68.  * Revision 1.33  1994/08/17  12:55:34  matt
  69.  * Added external walls to wall_is_doorway
  70.  * 
  71.  * Revision 1.32  1994/08/15  17:54:35  john
  72.  * *** empty log message ***
  73.  * 
  74.  * Revision 1.31  1994/08/15  17:46:56  yuan
  75.  * Added external walls, fixed blastable walls.
  76.  * 
  77.  * Revision 1.30  1994/08/05  21:17:21  matt
  78.  * Allow two doors to be linked together
  79.  * 
  80.  * Revision 1.29  1994/08/01  10:39:10  matt
  81.  * Parenthesized parms to WID() macro
  82.  * 
  83.  * Revision 1.28  1994/07/20  17:35:03  yuan
  84.  * Some minor bug fixes and new key gauges...
  85.  * 
  86.  * Revision 1.27  1994/07/19  14:32:03  yuan
  87.  * Fixed keys bug... renumbered some constants.
  88.  * 
  89.  * Revision 1.26  1994/07/14  22:38:29  matt
  90.  * Added exploding doors
  91.  * 
  92.  * Revision 1.25  1994/07/11  15:08:43  yuan
  93.  * Wall anim file names stored in structure.
  94.  *  
  95.  */
  96.  
  97. #ifndef _WALL_H
  98. #define _WALL_H
  99.  
  100. #include "inferno.h"
  101. #include "segment.h"
  102. #include "object.h"
  103.  
  104. //#include "vclip.h"
  105.  
  106. #define MAX_WALLS                    175    // Maximum number of walls
  107. #define MAX_WALL_ANIMS            30        // Maximum different types of doors
  108. #define MAX_DOORS                    50        // Maximum number of open doors
  109. // not used -> #define MAX_DOOR_ANIMS            20        // Maximum different types of doors
  110.  
  111. // Various wall types.
  112. #define WALL_NORMAL                0      // Normal wall
  113. #define WALL_BLASTABLE            1      // Removable (by shooting) wall
  114. #define WALL_DOOR                    2      // Door 
  115. #define WALL_ILLUSION            3      // Wall that appears to be there, but you can fly thru
  116. #define WALL_OPEN                    4        // Just an open side. (Trigger)
  117. #define WALL_CLOSED                5        // Wall.  Used for transparent walls.
  118.  
  119. // Various wall flags.
  120. #define WALL_BLASTED                1      // Blasted out wall.
  121. #define WALL_DOOR_OPENED        2      // Open door. 
  122. #define WALL_DOOR_LOCKED        8        // Door is locked.
  123. #define WALL_DOOR_AUTO            16        // Door automatically closes after time.
  124. #define WALL_ILLUSION_OFF        32        // Illusionary wall is shut off.
  125.  
  126. // Wall states
  127. #define WALL_DOOR_CLOSED        0        // Door is closed
  128. #define WALL_DOOR_OPENING        1        // Door is opening.
  129. #define WALL_DOOR_WAITING        2        // Waiting to close
  130. #define WALL_DOOR_CLOSING        3        // Door is closing
  131.  
  132. //note: a door is considered opened (i.e., it has WALL_OPENED set) when it 
  133. //is more than half way open.  Thus, it can have any of OPENING, CLOSING, 
  134. //or WAITING bits set when OPENED is set.
  135.  
  136. #define KEY_NONE                    1
  137. #define KEY_BLUE                    2
  138. #define KEY_RED                   4
  139. #define KEY_GOLD                   8
  140.  
  141. #define WALL_HPS                    100*F1_0        // Normal wall's hp
  142. #define WALL_DOOR_INTERVAL         5*F1_0        // How many seconds a door is open
  143.  
  144. #define DOOR_OPEN_TIME            i2f(2)        // How long takes to open
  145. #define DOOR_WAIT_TIME            i2f(5)        // How long before auto door closes
  146.  
  147. #define MAX_CLIP_FRAMES            20
  148.  
  149. // WALL_IS_DOORWAY flags.
  150. #define WID_FLY_FLAG                    1
  151. #define WID_RENDER_FLAG                2
  152. #define WID_RENDPAST_FLAG            4
  153. #define WID_EXTERNAL_FLAG            8
  154.  
  155. //    WALL_IS_DOORWAY return values            F/R/RP
  156. #define WID_WALL                        2    // 0/1/0        wall    
  157. #define WID_TRANSPARENT_WALL        6    //    0/1/1        transparent wall
  158. #define WID_ILLUSORY_WALL            3    //    1/1/0        illusory wall
  159. #define WID_TRANSILLUSORY_WALL    7    //    1/1/1        transparent illusory wall
  160. #define WID_NO_WALL                    5    //    1/0/1        no wall, can fly through
  161. #define WID_EXTERNAL                    8    // 0/0/0/1    don't see it, dont fly through it
  162.  
  163. #define    MAX_STUCK_OBJECTS    32
  164.  
  165. typedef struct stuckobj {
  166.     short    objnum, wallnum;
  167.     int    signature;
  168. } stuckobj;
  169.  
  170. typedef struct wall {
  171.     int    segnum,sidenum;    // Seg & side for this wall
  172.     fix   hps;                      // "Hit points" of the wall. 
  173.     int    linked_wall;        // number of linked wall
  174.     ubyte    type;                   // What kind of special wall.
  175.     ubyte    flags;                // Flags for the wall.        
  176.     ubyte    state;                // Opening, closing, etc.
  177.     byte    trigger;                // Which trigger is associated with the wall.
  178.     byte    clip_num;            // Which    animation associated with the wall. 
  179.     ubyte    keys;                    // which keys are required
  180.     short    pad;                    // keep longword aligned
  181.     } wall;
  182.  
  183. typedef struct active_door {
  184.     int        n_parts;                    // for linked walls
  185.     short        front_wallnum[2];        // front wall numbers for this door
  186.     short        back_wallnum[2];         // back wall numbers for this door
  187.     fix        time;                        // how long been opening, closing, waiting
  188. } active_door;
  189.  
  190. //wall clip flags
  191. #define WCF_EXPLODES        1        //door explodes when opening
  192. #define WCF_BLASTABLE    2        //this is a blastable wall
  193. #define WCF_TMAP1            4        //this uses primary tmap, not tmap2
  194. #define WCF_HIDDEN        8        //this uses primary tmap, not tmap2
  195.  
  196. typedef struct {
  197.     fix                play_time;
  198.     short                num_frames;
  199.     short                frames[MAX_CLIP_FRAMES];
  200.     short                open_sound;
  201.     short                close_sound;
  202.     short                flags;
  203.     char                filename[13];
  204.     char                pad;
  205. } wclip;
  206.  
  207. extern char    Wall_names[7][10];
  208.  
  209. //#define WALL_IS_DOORWAY(seg,side) wall_is_doorway(seg, side)
  210.  
  211. #define WALL_IS_DOORWAY(seg,side) (((seg)->children[(side)] == -1) ? WID_WALL : ((seg)->children[(side)] == -2) ? WID_EXTERNAL_FLAG : ((seg)->sides[(side)].wall_num == -1) ? WID_NO_WALL : wall_is_doorway((seg), (side)))
  212.  
  213. extern wall Walls[MAX_WALLS];            // Master walls array
  214. extern int Num_walls;                    // Number of walls
  215.  
  216. extern active_door ActiveDoors[MAX_DOORS];    //    Master doors array
  217. extern int Num_open_doors;                // Number of open doors
  218.  
  219. extern wclip WallAnims[MAX_WALL_ANIMS];
  220. extern int Num_wall_anims;
  221.  
  222. extern int walls_bm_num[MAX_WALL_ANIMS];
  223.  
  224. // Initializes all walls (i.e. no special walls.)
  225. extern void wall_init();
  226.                                                                                              
  227. // Automatically checks if a there is a doorway (i.e. can fly through)
  228. extern int wall_is_doorway ( segment *seg, int side );
  229.  
  230. // Deteriorate appearance of wall. (Changes bitmap (paste-ons)) 
  231. extern void wall_damage(segment *seg, int side, fix damage);
  232.  
  233. // Destroys a blastable wall. (So it is an opening afterwards)
  234. extern void wall_destroy(segment *seg, int side);
  235.  
  236. void wall_illusion_on(segment *seg, int side);
  237.  
  238. void wall_illusion_off(segment *seg, int side);
  239.  
  240. // Opens a door, including animation and other processing.
  241. void do_door_open(int door_num);
  242.  
  243. // Closes a door, including animation and other processing.
  244. void do_door_close(int door_num);
  245.  
  246. // Opens a door  
  247. extern void wall_open_door(segment *seg, int side);
  248.  
  249. // Closes a door (called after given interval)
  250. extern void wall_close_door(int wall_num);
  251.  
  252. //return codes for wall_hit_process()
  253. #define WHP_NOT_SPECIAL        0        //wasn't a quote-wall-unquote
  254. #define WHP_NO_KEY            1        //hit door, but didn't have key
  255. #define WHP_BLASTABLE        2        //hit blastable wall
  256. #define WHP_DOOR                3        //a door (which will now be opening)
  257.  
  258. // Determines what happens when a wall is shot
  259. //obj is the object that hit...either a weapon or the player himself
  260. extern int wall_hit_process(segment *seg, int side, fix damage, int playernum, object *obj );
  261.  
  262. // Opens/destroys specified door.
  263. extern void wall_toggle(segment *seg, int side);
  264.  
  265. // Tidy up Walls array for load/save purposes.
  266. extern void reset_walls();
  267.  
  268. // Called once per frame..
  269. void wall_frame_process();
  270.  
  271. extern stuckobj    Stuck_objects[MAX_STUCK_OBJECTS];
  272.  
  273. //    An object got stuck in a door (like a flare).
  274. //    Add global entry.
  275. extern void add_stuck_object(object *objp, int segnum, int sidenum);
  276. extern void remove_obsolete_stuck_objects(void);
  277.  
  278. //set the tmap_num or tmap_num2 field for a wall/door
  279. extern void wall_set_tmap_num(segment *seg,int side,segment *csegp,int cside,int anim_num,int frame_num);
  280.  
  281. #endif
  282.