Nuclide
Software Development Kit for id Technology (BETA)
Loading...
Searching...
No Matches
Trigger.h
1/*
2 * Copyright (c) 2016-2024 Vera Visions LLC.
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
13 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
14 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15*/
16
17/* ncTrigger class is responsible for the legacy trigger architecture.
18 In the future, ncEntity can be configured so that legacy
19 triggers can be disabled. That's why this class is separate from ncIO.
20
21 This is a very low-level class. You're never meant to use this.
22 Use ncEntity as a basis for your classes.
23*/
24
25#define CENVGLOBAL_CVAR "env_global_data"
26
28typedef enum
29{
31 GLOBAL_OFF,
33 GLOBAL_ON,
35 GLOBAL_DEAD
36} globalstate_t;
37
39typedef enum
40{
42 TRIG_OFF,
44 TRIG_ON,
46 TRIG_TOGGLE
47} triggermode_t;
48
49enumflags
50{
51 TOUCHFILTER_CLIENTS,
52 TOUCHFILTER_NPCS,
53 TOUCHFILTER_PUSHABLE,
54 TOUCHFILTER_PHYSICS,
55 TOUCHFILTER_FRIENDLIES,
56 TOUCHFILTER_CLIENTSINVEHICLES,
57 TOUCHFILTER_EVERYTHING,
58 TOUCHFILTER_PADDING1,
59 TOUCHFILTER_PADDING2,
60 TOUCHFILTER_CLIENTSNOTINVEHICLES,
61 TOUCHFILTER_DEBRIS,
62 TOUCHFILTER_NPCSINVEHICLES,
63 TOUCHFILTER_NOBOTS
64};
65
66
77{
78public:
79 void ncTrigger(void);
80
81 /* touch/blocked */
84 virtual void Blocked(entity);
86 virtual void StartTouch(entity);
87
89 virtual void Touch(entity);
90
92 virtual void EndTouch(entity);
93
94 /* overrides */
95 virtual void SpawnKey(string,string);
96
97 virtual void OnRemoveEntity(void);
98
99#ifdef SERVER
100 /* overrides */
101 virtual void Save(float);
102 virtual void Restore(string,string);
103 virtual void Spawned(void);
104 virtual void Input(entity,string,string);
105
107 nonvirtual void SetValue(int newValue);
108
109 /* Called to check if the target entity can touch trigger itself. */
110 virtual bool CanBeTriggeredBy(entity);
111
113 virtual void Trigger(entity, triggermode_t);
114
115 /* master feature */
117 /* multisource overrides this, so keep virtual */
118 virtual int GetValue(entity);
119
121 nonvirtual void UseTargets(entity,int,float);
122
124 nonvirtual void SetTriggerTarget(string);
125
127 nonvirtual int GetMaster(entity);
128
130 nonvirtual bool TriggerEnabled(void);
131
132 nonvirtual void EnableTrigger(void);
133 nonvirtual void DisableTrigger(void);
134 nonvirtual void ToggleTrigger(void);
135
137 nonvirtual globalstate_t GetGlobalValue(string);
138
140 nonvirtual string GetTriggerMessage(void);
141
143 nonvirtual string GetTriggerKillTarget(void);
144
146 nonvirtual string GetTriggerTarget(void);
147
149 nonvirtual float GetTriggerDelay(void);
150
152 nonvirtual entity GetTargetEntity(void);
153
155 nonvirtual bool HasTriggerTarget(void);
156
158 nonvirtual bool HasTargetname(void);
159
161 nonvirtual void SetTeam(float);
162
164 nonvirtual float GetTeam(void);
165#endif
167 nonvirtual vector GetTouchPosition(void);
169 nonvirtual vector GetTouchNormal(void);
170
171private:
172 /* not needed to be saved right now */
173 float m_timeSinceLastTouch;
174 bool m_beingTouched;
175 entity m_touchingEntity;
176 vector m_touchPosition;
177 vector m_touchNormal;
178
179 nonvirtual void _TouchHandler(void);
180 nonvirtual void _BlockedHandler(void);
181
182#ifdef SERVER
183 nonvirtual void _TouchEnded(void);
184
185 string m_globalName;
186 string m_globalState;
187 string m_triggerKillTarget;
188 string m_triggerMessage;
189 string m_masterName;
190 int m_triggerValue;
191
192 bool m_triggerEnabled;
193 bool m_triggerStartsDisabled;
194 bool m_triggerSpawnflagFilter;
195
196 float m_touchingOnlyTeam;
197
198 string m_outputOnStartTouch;
199 string m_outputOnEndTouch;
200
201 /* legacy trigger architecture */
202 float m_triggerDelay;
203#endif
204
205#ifdef CLIENT
206 float team;
207#endif
208};
void ncIO(void)
Definition IO.qc:18
nonvirtual bool TriggerEnabled(void)
Returns whether the trigger functionality of this entity is enabled.
Definition Trigger.qc:304
virtual int GetValue(entity)
Returns what we will pass onto other's ncTrigger::GetMaster() calls if we're their master.
Definition Trigger.qc:178
virtual void Blocked(entity)
Called whenever out movement is being blocked by an entity.
Definition Trigger.qc:476
void ncTrigger(void)
Definition Trigger.qc:22
nonvirtual void UseTargets(entity, int, float)
When called will trigger its legacy targets with a given delay.
Definition Trigger.qc:110
nonvirtual entity GetTargetEntity(void)
Returns the first entity named after the target field.
Definition Trigger.qc:262
nonvirtual float GetTeam(void)
Retrives the team value of a given entity.
Definition Trigger.qc:425
virtual void Input(entity, string, string)
Called when we are being prompted by another object/function with an input message.
Definition Trigger.qc:380
nonvirtual void SetTriggerTarget(string)
Sets the legacy target for this entity.
Definition Trigger.qc:166
nonvirtual void EnableTrigger(void)
Definition Trigger.qc:286
nonvirtual float GetTriggerDelay(void)
Returns the time until this triggers is scheduled to fire its targets, relative time in seconds.
Definition Trigger.qc:244
nonvirtual globalstate_t GetGlobalValue(string)
Returns the value of a given env_global property.
Definition Trigger.qc:184
nonvirtual vector GetTouchNormal(void)
Returns the normal of the last valid surface the entity has touched.
Definition Trigger.qc:512
virtual void StartTouch(entity)
Called when we started touching another entity.
Definition Trigger.qc:494
nonvirtual void DisableTrigger(void)
Definition Trigger.qc:292
nonvirtual void SetValue(int newValue)
Sets the internal value of the entity as queried by GetValue().
Definition Trigger.qc:172
virtual bool CanBeTriggeredBy(entity)
Definition Trigger.qc:55
nonvirtual bool HasTargetname(void)
Returns TRUE if the entity has a name that can be used for messaging.
Definition Trigger.qc:277
virtual void EndTouch(entity)
Called when we stopped touching the last touched entity.
Definition Trigger.qc:500
nonvirtual bool HasTriggerTarget(void)
Returns TRUE if the entity has a legacy trigger target.
Definition Trigger.qc:271
virtual void Trigger(entity, triggermode_t)
Called whenever we're legacy triggered by another object or function.
Definition Trigger.qc:104
virtual void SpawnKey(string, string)
This method handles entity key/value pairs on map load.
Definition Trigger.qc:432
nonvirtual vector GetTouchPosition(void)
Returns the last valid point the entity has touched.
Definition Trigger.qc:506
nonvirtual string GetTriggerKillTarget(void)
Returns the name of the entity group it will remove from the game upon trigger.
Definition Trigger.qc:256
virtual void Spawned(void)
Called when the entity is fulled initialized.
Definition Trigger.qc:42
nonvirtual string GetTriggerTarget(void)
Returns the name of the entity group it can trigger (legacy style).
Definition Trigger.qc:238
nonvirtual string GetTriggerMessage(void)
Returns the message which will be displayed upon trigger.
Definition Trigger.qc:250
virtual void Restore(string, string)
Similar to ncIO::SpawnKey() but for save-game fields.
Definition Trigger.qc:329
virtual void OnRemoveEntity(void)
Handles what happens before the entity gets removed from the client game.
Definition Trigger.qc:577
virtual void Touch(entity)
Called whenever we're touching another entity.
Definition Trigger.qc:488
nonvirtual void SetTeam(float)
Assigns the entity to a given team value.
Definition Trigger.qc:407
nonvirtual void ToggleTrigger(void)
Definition Trigger.qc:298
virtual void Save(float)
Handles saving a copy of this entity to a given filehandle.
Definition Trigger.qc:310
nonvirtual int GetMaster(entity)
Returns whether our master allows us to be triggered.
Definition Trigger.qc:205