1 /* $Id: switch.h,v 1.4 2003-10-04 03:14:48 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.
17 * Triggers and Switches.
20 * Revision 1.1 1995/05/16 16:03:48 allender
23 * Revision 2.0 1995/02/27 11:26:52 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.19 1995/01/12 17:00:36 rob
28 * Fixed a problem with switches and secret levels.
30 * Revision 1.18 1994/10/06 21:24:40 matt
31 * Added switch for exit to secret level
33 * Revision 1.17 1994/09/29 17:05:52 matt
34 * Removed unused constant
36 * Revision 1.16 1994/09/24 17:10:07 yuan
37 * Added Matcen triggers.
39 * Revision 1.15 1994/08/15 18:06:39 yuan
40 * Added external trigger.
42 * Revision 1.14 1994/06/16 16:20:52 john
43 * Made player start out in physics mode; Neatend up game loop a bit.
45 * Revision 1.13 1994/05/30 20:22:08 yuan
48 * Revision 1.12 1994/05/27 10:32:44 yuan
49 * New dialog boxes (Walls and Triggers) added.
52 * Revision 1.11 1994/05/25 18:06:32 yuan
53 * Making new dialog box controls for walls and triggers.
55 * Revision 1.10 1994/04/28 18:04:40 yuan
57 * Trigger problem fixed (seg pointer is replaced by index now.)
59 * Revision 1.9 1994/04/26 11:19:01 yuan
60 * Make it so a trigger can only be triggered every 5 seconds.
70 #define MAX_TRIGGERS 100
71 #define MAX_WALLS_PER_LINK 10
75 #define TT_OPEN_DOOR 0 // Open a door
76 #define TT_CLOSE_DOOR 1 // Close a door
77 #define TT_MATCEN 2 // Activate a matcen
78 #define TT_EXIT 3 // End the level
79 #define TT_SECRET_EXIT 4 // Go to secret level
80 #define TT_ILLUSION_OFF 5 // Turn an illusion off
81 #define TT_ILLUSION_ON 6 // Turn an illusion on
82 #define TT_UNLOCK_DOOR 7 // Unlock a door
83 #define TT_LOCK_DOOR 8 // Lock a door
84 #define TT_OPEN_WALL 9 // Makes a wall open
85 #define TT_CLOSE_WALL 10 // Makes a wall closed
86 #define TT_ILLUSORY_WALL 11 // Makes a wall illusory
87 #define TT_LIGHT_OFF 12 // Turn a light off
88 #define TT_LIGHT_ON 13 // Turn s light on
89 #define NUM_TRIGGER_TYPES 14
93 //could also use flags for one-shots
95 #define TF_NO_MESSAGE 1 // Don't show a message when triggered
96 #define TF_ONE_SHOT 2 // Only trigger once
97 #define TF_DISABLED 4 // Set after one-shot fires
101 typedef struct v29_trigger {
108 short seg[MAX_WALLS_PER_LINK];
109 short side[MAX_WALLS_PER_LINK];
110 } __pack__ v29_trigger;
112 typedef struct v30_trigger {
115 sbyte pad; //keep alignment
118 short seg[MAX_WALLS_PER_LINK];
119 short side[MAX_WALLS_PER_LINK];
120 } __pack__ v30_trigger;
122 //flags for V30 & below triggers
123 #define TRIGGER_CONTROL_DOORS 1 // Control Trigger
124 #define TRIGGER_SHIELD_DAMAGE 2 // Shield Damage Trigger
125 #define TRIGGER_ENERGY_DRAIN 4 // Energy Drain Trigger
126 #define TRIGGER_EXIT 8 // End of level Trigger
127 #define TRIGGER_ON 16 // Whether Trigger is active
128 #define TRIGGER_ONE_SHOT 32 // If Trigger can only be triggered once
129 #define TRIGGER_MATCEN 64 // Trigger for materialization centers
130 #define TRIGGER_ILLUSION_OFF 128 // Switch Illusion OFF trigger
131 #define TRIGGER_SECRET_EXIT 256 // Exit to secret level
132 #define TRIGGER_ILLUSION_ON 512 // Switch Illusion ON trigger
133 #define TRIGGER_UNLOCK_DOORS 1024 // Unlocks a door
134 #define TRIGGER_OPEN_WALL 2048 // Makes a wall open
135 #define TRIGGER_CLOSE_WALL 4096 // Makes a wall closed
136 #define TRIGGER_ILLUSORY_WALL 8192 // Makes a wall illusory
138 //the trigger really should have both a type & a flags, since most of the
139 //flags bits are exclusive of the others.
140 typedef struct trigger {
141 ubyte type; //what this trigger does
142 ubyte flags; //currently unused
143 sbyte num_links; //how many doors, etc. linked to this
144 sbyte pad; //keep alignment
147 short seg[MAX_WALLS_PER_LINK];
148 short side[MAX_WALLS_PER_LINK];
151 extern trigger Triggers[MAX_TRIGGERS];
153 extern int Num_triggers;
155 extern void trigger_init();
156 extern void check_trigger(segment *seg, short side, short objnum,int shot);
157 extern int check_trigger_sub(int trigger_num, int player_num,int shot);
158 extern void triggers_frame_process();
161 #define v29_trigger_read(t, fp) cfread(t, sizeof(v29_trigger), 1, fp)
162 #define v30_trigger_read(t, fp) cfread(t, sizeof(v30_trigger), 1, fp)
163 #define trigger_read(t, fp) cfread(t, sizeof(trigger), 1, fp)
166 * reads a v29_trigger structure from a CFILE
168 extern void v29_trigger_read(v29_trigger *t, CFILE *fp);
171 * reads a v30_trigger structure from a CFILE
173 extern void v30_trigger_read(v30_trigger *t, CFILE *fp);
176 * reads a trigger structure from a CFILE
178 extern void trigger_read(trigger *t, CFILE *fp);