Debian Codegraph @

Descent3/trigger.h

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/main/trigger.h $
21 * $Revision: 17 $
22 * $Date: 5/20/99 9:03p $
23 * $Author: Matt $
24 *
25 * Trigger header
26 *
27 * $Log: /DescentIII/main/trigger.h $
28 *
29 * 17 5/20/99 9:03p Matt
30 * Changed trigger system so that collisions with rendered portals don't
31 * set off triggers on the portals.
32 *
33 * 16 4/14/99 3:57a Jeff
34 * fixed case mismatch in #includes
35 *
36 * 15 3/23/99 5:52p Matt
37 * Added clutter activators for triggers
38 *
39 * 14 2/21/99 4:35p Chris
40 * Improving the level goal system... Not done.
41 *
42 * 13 2/11/99 1:10p Matt
43 * Added functions to get & set a triggers enabled/disabled state
44 *
45 * 12 1/21/99 11:34a Matt
46 * Got rid of portal triggers. Since we don't have multi-face portals, a
47 * face trigger works fine for a portal. Also fixed a few editor/trigger
48 * bugs.
49 *
50 * 11 1/14/99 11:06a Matt
51 * Added names to triggers
52 *
53 * 10 1/08/99 2:56p Samir
54 * Ripped out OSIRIS1.
55 *
56 * 9 12/16/98 10:18p Jeff
57 * added new osiris struct members
58 *
59 * 8 4/24/98 1:53a Samir
60 * added trigger init and free.
61 *
62 * 7 2/03/98 11:12a Samir
63 * If pointer passed to TRIGNUM is NULL return -1.
64 *
65 * 6 1/20/98 4:12p Samir
66 * New script housekeeping system.
67 *
68 * 5 9/24/97 6:18p Samir
69 * Use script names instead of script id values to identify scripts.
70 *
71 * 4 9/12/97 3:58p Matt
72 * Added support for activators and one-shot triggers
73 *
74 * 3 9/11/97 1:57p Matt
75 * Added trigger struct & a bunch of functions. System is not done yet,
76 * though.
77 *
78 * 2 9/08/97 10:01a Matt
79 * Ripped out old trigger code
80 *
81 * $NoKeywords: $
82 */
83
84 #ifndef TRIGGER_H
85 #define TRIGGER_H
86
87 #include "pstypes.h"
88 #include "ObjScript.h"
89 #include "object_external_struct.h"
90 #include "vecmat.h"
91
92 // Trigger flags
93 #define TF_UNUSED 1 //
94 #define TF_DISABLED 2 // This trigger is currently not active
95 #define TF_DEAD 4 // This trigger has been tripped and is now dead
96 #define TF_ONESHOT 8 // This trigger only works once
97 #define TF_INFORM_ACTIVATE_TO_LG 16 // This trigger is involved in the level goal system
98
99 // Activator flags
100 #define AF_PLAYER 1 // The player can activate this trigger
101 #define AF_PLAYER_WEAPON 2 // The player's weapons can activate this trigger
102 #define AF_ROBOT 4 // A robot can activate this trigger
103 #define AF_ROBOT_WEAPON 8 // A robot's weapon can activate this trigger
104 #define AF_CLUTTER 16 // A piece of clutter
105
106 // Declare this here so we don't have to include the header file
107 //@$-struct tD3XThread;
108
109 struct tOSIRISTriggerScript {
110 int script_id;
111 void *script_instance;
112 };
113
114 #define TRIG_NAME_LEN 19
115
116 // The trigger structure
117 struct trigger {
118 char name[TRIG_NAME_LEN + 1]; // the name of this trigger
119 int roomnum; // the room this trigger is in
120 int facenum; // the face to which this trigger is attched
121 int16_t flags; // flags for this trigger
122 int16_t activator; // flags for what can activate this trigger
123 // This is allocated when the level is started
124 tOSIRISTriggerScript osiris_script;
125 };
126
127 // The number of triggers currently in the mine
128 extern int Num_triggers;
129
130 // The list of triggers for the mine
131 extern trigger Triggers[];
132
133 // Macro to get trigger number
134 #define TRIGNUM(tp) (tp) ? ((tp)-Triggers) : -1
135
136 // initializes trigger system
137 void InitTriggers();
138
139 // Free triggers.
140 void FreeTriggers();
141
142 // types for CheckTrigger()
143 #define TT_PASS_THROUGH 0
144 #define TT_COLLIDE 1
145
146 // Called to see if a trigger was tripped
147 void CheckTrigger(int roomnum, int facenum, object *objp, int type);
148
149 // Enable or disable a trigger
150 void TriggerSetState(int trigger_num, bool enabled);
151
152 // Determines if a trigger is enabled or disabled
153 // Returns TRUE if enabled, else false
154 bool TriggerGetState(int trigger_num);
155
156 // Create a new trigger
157 // Parameters: roomnum,facenum - where the trigger is
158 // activator - activator mask
159 // script - handle for the script for this trigger
160 // Returns: trigger number of new trigger, or -1 if error
161 int AddTrigger(char *name, int roomnum, int facenum, int activator, const char *script);
162
163 // Remove a trigger
164 // Paramters: trig_num - the trigger to delete
165 void DeleteTrigger(int trig_num);
166
167 // Remove a trigger
168 // Paramters: roomnum,facenum - where the trigger is
169 void DeleteTrigger(int roomnum, int facenum);
170
171 #endif