Nuclide
Software Development Kit for id Tech
NSTrigger.h
Go to the documentation of this file.
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/* NSTrigger class is responsible for the legacy trigger architecture.
18 In the future, NSEntity can be configured so that legacy
19 triggers can be disabled. That's why this class is separate from NSIO.
20
21 This is a very low-level class. You're never meant to use this.
22 Use NSEntity as a basis for your classes.
23*/
24
25#define CENVGLOBAL_CVAR "env_global_data"
26
28typedef enum
29{
37
39typedef enum
40{
48
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
71{
72public:
73 void NSTrigger(void);
74
75 /* touch/blocked */
78 virtual void Blocked(entity);
80 virtual void StartTouch(entity);
81
83 virtual void Touch(entity);
84
86 virtual void EndTouch(entity);
87
88 /* overrides */
89 virtual void SpawnKey(string,string);
90
91#ifdef SERVER
92 /* overrides */
93 virtual void Save(float);
94 virtual void Restore(string,string);
95 virtual void Respawn(void);
96 virtual void Input(entity,string,string);
97
98 /* Called to check if the target entity can touch trigger itself. */
99 virtual bool CanBeTriggeredBy(entity);
100
102 virtual void Trigger(entity, triggermode_t);
103
104 /* master feature */
106 /* multisource overrides this, so keep virtual */
107 virtual int GetValue(entity);
108
110 nonvirtual void UseTargets(entity,int,float);
111
113 nonvirtual void SetTriggerTarget(string);
114
116 nonvirtual int GetMaster(entity);
117
119 nonvirtual globalstate_t GetGlobalValue(string);
120
122 nonvirtual string GetTriggerTarget(void);
123
125 nonvirtual entity GetTargetEntity(void);
126
128 nonvirtual bool HasTriggerTarget(void);
129
131 nonvirtual bool HasTargetname(void);
132
134 nonvirtual void SetTeam(float);
135
137 nonvirtual float GetTeam(void);
138#endif
139
140private:
141 /* not needed to be saved right now */
142 float m_flTouchTime;
143 bool m_beingTouched;
144 entity m_eTouchLast;
145
146 nonvirtual void _TouchHandler(void);
147 nonvirtual void _BlockedHandler(void);
148
149#ifdef SERVER
150 string m_oldstrTarget; /* needed due to trigger_changetarget */
151
152 string m_strGlobalName;
153 string m_strGlobalState;
154 string m_strKillTarget;
155 string m_strMessage;
156 string m_strMaster;
157 int m_iUseType;
158 int m_iValue;
159
160 bool m_bEnabled;
161 bool m_bStartDisabled;
162 bool m_bIsModern;
163
164 float team_no;
165
166 /* legacy trigger architecture */
167 float m_flDelay;
168#endif
169
170#ifdef CLIENT
171 float team;
172#endif
173};
globalstate_t
States for env_global data.
Definition: NSTrigger.h:29
@ GLOBAL_ON
env_global data in question is set to 'on'.
Definition: NSTrigger.h:33
@ GLOBAL_OFF
env_global data in question is set to 'off'.
Definition: NSTrigger.h:31
@ GLOBAL_DEAD
env_global data in question is dead.
Definition: NSTrigger.h:35
enumflags
Definition: NSTrigger.h:50
triggermode_t
The type of trigger activation.
Definition: NSTrigger.h:40
@ TRIG_OFF
Trigger the target 'off', for doors that may tell them to close.
Definition: NSTrigger.h:42
@ TRIG_TOGGLE
Trigger the target the opposite to whatever they're currently in.
Definition: NSTrigger.h:46
@ TRIG_ON
Trigger the target 'on', for doors that may tell them to open.
Definition: NSTrigger.h:44
This class is responsible for handling core entity functionality.
Definition: NSIO.h:27
NSTrigger handles all the non-input as well as Legacy (Quake, GoldSource) style trigger behaviour.
Definition: NSTrigger.h:71
virtual void SpawnKey(string, string)
This method handles entity key/value pairs on map load.
Definition: NSTrigger.qc:359
virtual void Trigger(entity, triggermode_t)
Called whenever we're legacy triggered by another object or function.
Definition: NSTrigger.qc:85
virtual void Input(entity, string, string)
Called when we are being prompted by another object/function with an input message.
Definition: NSTrigger.qc:319
virtual bool CanBeTriggeredBy(entity)
Definition: NSTrigger.qc:48
nonvirtual globalstate_t GetGlobalValue(string)
Returns the value of a given env_global property.
Definition: NSTrigger.qc:158
nonvirtual bool HasTriggerTarget(void)
Returns TRUE if the entity has a legacy trigger target.
Definition: NSTrigger.qc:217
nonvirtual void UseTargets(entity, int, float)
When called will trigger its legacy targets with a given delay.
Definition: NSTrigger.qc:91
nonvirtual int GetMaster(entity)
Returns whether our master allows us to be triggered.
Definition: NSTrigger.qc:169
nonvirtual void SetTeam(float)
Assigns the entity to a given team value.
Definition: NSTrigger.qc:340
virtual void EndTouch(entity)
Called when we stopped touching the last touched entity.
Definition: NSTrigger.qc:420
nonvirtual string GetTriggerTarget(void)
Returns the name of the entity group it can trigger (legacy style).
Definition: NSTrigger.qc:202
virtual int GetValue(entity)
Returns what we will pass onto other's ::GetMaster() calls if we're their master.
Definition: NSTrigger.qc:152
void NSTrigger(void)
Definition: NSTrigger.qc:18
virtual void StartTouch(entity)
Called when we started touching another entity.
Definition: NSTrigger.qc:414
virtual void Save(float)
Handles saving a copy of this entity to a given filehandle.
Definition: NSTrigger.qc:237
nonvirtual bool HasTargetname(void)
Returns TRUE if the entity has a name that can be used for messaging.
Definition: NSTrigger.qc:228
virtual void Respawn(void)
Server: Called when the entity first spawns or when game-logic requests the entity to return to its o...
Definition: NSTrigger.qc:41
nonvirtual entity GetTargetEntity(void)
Returns the first entity named after the target field.
Definition: NSTrigger.qc:208
nonvirtual void SetTriggerTarget(string)
Sets the legacy target for this entity.
Definition: NSTrigger.qc:146
virtual void Touch(entity)
Called whenever we're touching another entity.
Definition: NSTrigger.qc:408
virtual void Blocked(entity)
Called whenever out movement is being blocked by an entity.
Definition: NSTrigger.qc:396
virtual void Restore(string, string)
Similar to ::SpawnKey but for save-game fields.
Definition: NSTrigger.qc:259
nonvirtual float GetTeam(void)
Retrives the team value of a given entity.
Definition: NSTrigger.qc:352
entity() spawn