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_strGlobalName;
151 string m_strGlobalState;
152 string m_strKillTarget;
153 string m_strMessage;
154 string m_strMaster;
155 int m_iUseType;
156 int m_iValue;
157
158 bool m_bEnabled;
159 bool m_bStartDisabled;
160 bool m_bIsModern;
161
162 float team_no;
163
164 /* legacy trigger architecture */
165 float m_flDelay;
166#endif
167
168#ifdef CLIENT
169 float team;
170#endif
171};
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:353
virtual void Trigger(entity, triggermode_t)
Called whenever we're legacy triggered by another object or function.
Definition: NSTrigger.qc:83
virtual void Input(entity, string, string)
Called when we are being prompted by another object/function with an input message.
Definition: NSTrigger.qc:313
virtual bool CanBeTriggeredBy(entity)
Definition: NSTrigger.qc:46
nonvirtual globalstate_t GetGlobalValue(string)
Returns the value of a given env_global property.
Definition: NSTrigger.qc:156
nonvirtual bool HasTriggerTarget(void)
Returns TRUE if the entity has a legacy trigger target.
Definition: NSTrigger.qc:215
nonvirtual void UseTargets(entity, int, float)
When called will trigger its legacy targets with a given delay.
Definition: NSTrigger.qc:89
nonvirtual int GetMaster(entity)
Returns whether our master allows us to be triggered.
Definition: NSTrigger.qc:167
nonvirtual void SetTeam(float)
Assigns the entity to a given team value.
Definition: NSTrigger.qc:334
virtual void EndTouch(entity)
Called when we stopped touching the last touched entity.
Definition: NSTrigger.qc:414
nonvirtual string GetTriggerTarget(void)
Returns the name of the entity group it can trigger (legacy style).
Definition: NSTrigger.qc:200
virtual int GetValue(entity)
Returns what we will pass onto other's NSTrigger::GetMaster() calls if we're their master.
Definition: NSTrigger.qc:150
void NSTrigger(void)
Definition: NSTrigger.qc:18
virtual void StartTouch(entity)
Called when we started touching another entity.
Definition: NSTrigger.qc:408
virtual void Save(float)
Handles saving a copy of this entity to a given filehandle.
Definition: NSTrigger.qc:235
nonvirtual bool HasTargetname(void)
Returns TRUE if the entity has a name that can be used for messaging.
Definition: NSTrigger.qc:226
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:40
nonvirtual entity GetTargetEntity(void)
Returns the first entity named after the target field.
Definition: NSTrigger.qc:206
nonvirtual void SetTriggerTarget(string)
Sets the legacy target for this entity.
Definition: NSTrigger.qc:144
virtual void Touch(entity)
Called whenever we're touching another entity.
Definition: NSTrigger.qc:402
virtual void Blocked(entity)
Called whenever out movement is being blocked by an entity.
Definition: NSTrigger.qc:390
virtual void Restore(string, string)
Similar to NSIO::SpawnKey but for save-game fields.
Definition: NSTrigger.qc:256
nonvirtual float GetTeam(void)
Retrives the team value of a given entity.
Definition: NSTrigger.qc:346