Nuclide
Software Development Kit for id Technology (BETA)
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
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 ncTrigger(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
140 nonvirtual vector GetTouchPosition(void);
142 nonvirtual vector GetTouchNormal(void);
143
144private:
145 /* not needed to be saved right now */
146 float m_flTouchTime;
147 bool m_beingTouched;
148 entity m_eTouchLast;
149 vector m_touchPosition;
150 vector m_touchNormal;
151
152 nonvirtual void _TouchHandler(void);
153 nonvirtual void _BlockedHandler(void);
154
155#ifdef SERVER
156 string m_strGlobalName;
157 string m_strGlobalState;
158 string m_strKillTarget;
159 string m_strMessage;
160 string m_strMaster;
161 int m_iUseType;
162 int m_iValue;
163
164 bool m_bEnabled;
165 bool m_bStartDisabled;
166 bool m_bIsModern;
167
168 float team_no;
169
170 /* legacy trigger architecture */
171 float m_flDelay;
172#endif
173
174#ifdef CLIENT
175 float team;
176#endif
177};
This class is responsible for handling core entity functionality.
Definition: IO.h:78
ncTrigger handles all the non-input as well as Legacy (Quake, GoldSource) style trigger behaviour.
Definition: Trigger.h:71
virtual int GetValue(entity)
Returns what we will pass onto other's ncTrigger::GetMaster() calls if we're their master.
Definition: Trigger.qc:149
virtual void Blocked(entity)
Called whenever out movement is being blocked by an entity.
Definition: Trigger.qc:390
void ncTrigger(void)
Definition: Trigger.qc:18
nonvirtual void UseTargets(entity, int, float)
When called will trigger its legacy targets with a given delay.
Definition: Trigger.qc:88
virtual void Respawn(void)
Server: Called when the entity first spawns or when game-logic requests the entity to return to its o...
Definition: Trigger.qc:39
nonvirtual entity GetTargetEntity(void)
Returns the first entity named after the target field.
Definition: Trigger.qc:205
nonvirtual float GetTeam(void)
Retrives the team value of a given entity.
Definition: Trigger.qc:346
virtual void Input(entity, string, string)
Called when we are being prompted by another object/function with an input message.
Definition: Trigger.qc:307
nonvirtual void SetTriggerTarget(string)
Sets the legacy target for this entity.
Definition: Trigger.qc:143
nonvirtual globalstate_t GetGlobalValue(string)
Returns the value of a given env_global property.
Definition: Trigger.qc:155
nonvirtual vector GetTouchNormal(void)
Returns the normal of the last valid surface the entity has touched.
Definition: Trigger.qc:426
virtual void StartTouch(entity)
Called when we started touching another entity.
Definition: Trigger.qc:408
virtual bool CanBeTriggeredBy(entity)
Definition: Trigger.qc:45
nonvirtual bool HasTargetname(void)
Returns TRUE if the entity has a name that can be used for messaging.
Definition: Trigger.qc:220
virtual void EndTouch(entity)
Called when we stopped touching the last touched entity.
Definition: Trigger.qc:414
nonvirtual bool HasTriggerTarget(void)
Returns TRUE if the entity has a legacy trigger target.
Definition: Trigger.qc:214
virtual void Trigger(entity, triggermode_t)
Called whenever we're legacy triggered by another object or function.
Definition: Trigger.qc:82
virtual void SpawnKey(string, string)
This method handles entity key/value pairs on map load.
Definition: Trigger.qc:353
nonvirtual vector GetTouchPosition(void)
Returns the last valid point the entity has touched.
Definition: Trigger.qc:420
nonvirtual string GetTriggerTarget(void)
Returns the name of the entity group it can trigger (legacy style).
Definition: Trigger.qc:199
virtual void Restore(string, string)
Similar to ncIO::SpawnKey() but for save-game fields.
Definition: Trigger.qc:250
virtual void Touch(entity)
Called whenever we're touching another entity.
Definition: Trigger.qc:402
nonvirtual void SetTeam(float)
Assigns the entity to a given team value.
Definition: Trigger.qc:334
virtual void Save(float)
Handles saving a copy of this entity to a given filehandle.
Definition: Trigger.qc:229
nonvirtual int GetMaster(entity)
Returns whether our master allows us to be triggered.
Definition: Trigger.qc:166
typedef enumflags
Defines the valid alignment flags for text fields.
Definition: font.h:37