Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
triggers.qc File Reference
#include "triggers.qh"
Include dependency graph for triggers.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void DelayThink (entity this)
void generic_netlinked_legacy_use (entity this, entity actor, entity trigger)
void generic_netlinked_reset (entity this)
void generic_netlinked_setactive (entity this, int act)
void generic_setactive (entity this, int act)
bool isPushable (entity e)
void SUB_DontUseTargets (entity this, entity actor, entity trigger)
void SUB_UseTargets (entity this, entity actor, entity trigger)
void SUB_UseTargets_Ex (entity this, entity actor, entity trigger, bool preventReuse, int skiptargets)
void SUB_UseTargets_PreventReuse (entity this, entity actor, entity trigger)
void SUB_UseTargets_SkipTargets (entity this, entity actor, entity trigger, int skiptargets)
void trigger_common_write (entity this, bool withtarget)
void trigger_link (entity this, bool(entity this, entity to, int sendflags) sendfunc)

Function Documentation

◆ DelayThink()

void DelayThink ( entity this)

Definition at line 39 of file triggers.qc.

40{
41 SUB_UseTargets (this, this.enemy, NULL);
42 delete(this);
43}
#define NULL
Definition post.qh:14
entity enemy
Definition sv_ctf.qh:152
void SUB_UseTargets(entity this, entity actor, entity trigger)
Definition triggers.qc:344

References enemy, entity(), NULL, and SUB_UseTargets().

Referenced by SUB_UseTargets_Ex().

◆ generic_netlinked_legacy_use()

void generic_netlinked_legacy_use ( entity this,
entity actor,
entity trigger )

Definition at line 98 of file triggers.qc.

99{
100 //LOG_WARNF("Entity %s was (de)activated by a trigger, please update map to use relays", this.targetname);
101 this.setactive(this, ACTIVE_TOGGLE);
102}
const int ACTIVE_TOGGLE
Definition defs.qh:40

References ACTIVE_TOGGLE, and entity().

Referenced by conveyor_init(), spawnfunc(), and spawnfunc().

◆ generic_netlinked_reset()

void generic_netlinked_reset ( entity this)

Definition at line 76 of file triggers.qc.

77{
78 if(this.targetname && this.targetname != "")
79 {
80 if(this.spawnflags & START_ENABLED)
81 {
82 this.active = ACTIVE_ACTIVE;
83 }
84 else
85 {
86 this.active = ACTIVE_NOT;
87 }
88 }
89 else
90 {
91 this.active = ACTIVE_ACTIVE;
92 }
93
95}
int spawnflags
Definition ammo.qh:15
const int ACTIVE_NOT
Definition defs.qh:36
int active
Definition defs.qh:34
const int ACTIVE_ACTIVE
Definition defs.qh:37
const int START_ENABLED
Definition defs.qh:6
const int SF_TRIGGER_UPDATE
Definition defs.qh:23
int SendFlags
Definition net.qh:159
string targetname
Definition triggers.qh:56

References active, ACTIVE_ACTIVE, ACTIVE_NOT, entity(), SendFlags, SF_TRIGGER_UPDATE, spawnflags, START_ENABLED, and targetname.

Referenced by conveyor_init(), spawnfunc(), and spawnfunc().

◆ generic_netlinked_setactive()

void generic_netlinked_setactive ( entity this,
int act )

Definition at line 65 of file triggers.qc.

66{
67 int old_status = this.active;
68 generic_setactive(this, act);
69
70 if (this.active != old_status)
71 {
73 }
74}
void generic_setactive(entity this, int act)
Definition triggers.qc:46

References active, entity(), generic_setactive(), SendFlags, and SF_TRIGGER_UPDATE.

Referenced by conveyor_init(), spawnfunc(), spawnfunc(), and spawnfunc().

◆ generic_setactive()

void generic_setactive ( entity this,
int act )

Definition at line 46 of file triggers.qc.

47{
48 if(act == ACTIVE_TOGGLE)
49 {
50 if(this.active == ACTIVE_ACTIVE)
51 {
52 this.active = ACTIVE_NOT;
53 }
54 else
55 {
56 this.active = ACTIVE_ACTIVE;
57 }
58 }
59 else
60 {
61 this.active = act;
62 }
63}

References active, ACTIVE_ACTIVE, ACTIVE_NOT, ACTIVE_TOGGLE, and entity().

Referenced by generic_netlinked_setactive(), relay_activators_use(), and spawnfunc().

◆ isPushable()

bool isPushable ( entity e)

Definition at line 3 of file triggers.qc.

4{
5 if(e.pushable)
6 return true;
7#ifdef SVQC
8 if(IS_VEHICLE(e))
9 return false;
10 if(e.iscreature)
11 return true;
12 if (ITEM_IS_LOOT(e))
13 {
14 return true;
15 }
16 switch(e.classname)
17 {
18 case "body":
19 return true;
20 case "bullet": // antilagged bullets can't hit this either
21 return false;
22 }
23 if (e.projectiledeathtype)
24 return true;
25#endif
26#ifdef CSQC
27 if(e.flags & FL_PROJECTILE)
28 return true;
29 if(e.isplayermodel)
30 return true;
31#endif
32 return false;
33}
const int FL_PROJECTILE
Definition constants.qh:85
#define ITEM_IS_LOOT(item)
Returns whether the item is loot.
Definition spawning.qh:39
#define IS_VEHICLE(v)
Definition utils.qh:24

References entity(), FL_PROJECTILE, IS_VEHICLE, and ITEM_IS_LOOT.

Referenced by conveyor_think(), jumppad_push(), nade_entrap_touch(), trigger_impulse_touch_accel(), trigger_impulse_touch_directional(), and trigger_impulse_touch_radial().

◆ SUB_DontUseTargets()

void SUB_DontUseTargets ( entity this,
entity actor,
entity trigger )

Definition at line 35 of file triggers.qc.

35{ }

References entity().

◆ SUB_UseTargets()

◆ SUB_UseTargets_Ex()

void SUB_UseTargets_Ex ( entity this,
entity actor,
entity trigger,
bool preventReuse,
int skiptargets )

Definition at line 248 of file triggers.qc.

249{
250//
251// check for a delay
252//
253 if (this.delay)
254 {
255 // create a temp object to fire at a later time
256 entity t = new_pure(DelayedUse);
257 t.nextthink = time + this.delay;
259 t.enemy = actor;
260 t.message = this.message;
261 t.killtarget = this.killtarget;
262 if(!(skiptargets & BIT(1))) t.target = this.target;
263 if(!(skiptargets & BIT(2))) t.target2 = this.target2;
264 if(!(skiptargets & BIT(3))) t.target3 = this.target3;
265 if(!(skiptargets & BIT(4))) t.target4 = this.target4;
266 t.antiwall_flag = this.antiwall_flag;
267 return;
268 }
269
270 string s;
271
272//
273// print the message
274//
275#ifdef SVQC
276 if(this)
277 if(IS_PLAYER(actor) && this.message != "")
278 if(IS_REAL_CLIENT(actor))
279 {
280 centerprint(actor, this.message);
281 if (this.noise == "")
282 play2(actor, SND(TALK));
283 }
284
285//
286// kill the killtagets
287//
288 s = this.killtarget;
289 if (s != "")
290 {
291 for(entity t = NULL; (t = find(t, targetname, s)); )
292 delete(t);
293 }
294#endif
295
296//
297// fire targets
298//
299
300 if(this.target_random)
302
303 for(int i = 0; i < 4; ++i)
304 {
305 if(skiptargets & BIT(i + 1))
306 continue;
307 switch(i)
308 {
309 default:
310 case 0: s = this.target; break;
311 case 1: s = this.target2; break;
312 case 2: s = this.target3; break;
313 case 3: s = this.target4; break;
314 }
315 if (s != "")
316 {
317 for(entity t = NULL; (t = find(t, targetname, s)); )
318 {
319 if(t != this && t.use && (t.sub_target_used != time || !preventReuse))
320 {
321 if(this.target_random)
322 {
323 RandomSelection_AddEnt(t, 1, 0);
324 }
325 else
326 {
327 t.use(t, actor, this);
328 if(preventReuse)
329 t.sub_target_used = time;
330 }
331 }
332 }
333 }
334 }
335
337 {
339 if(preventReuse)
340 RandomSelection_chosen_ent.sub_target_used = time;
341 }
342}
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition bits.qh:8
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
string message
Definition powerups.qc:19
float delay
Definition items.qc:17
#define IS_PLAYER(s)
Definition player.qh:242
float time
entity find(entity start,.string field, string match)
void centerprint(string text,...)
#define new_pure(class)
purely logical entities (not linked to the area grid)
Definition oo.qh:66
ERASEABLE void RandomSelection_Init()
Definition random.qc:4
#define RandomSelection_AddEnt(e, weight, priority)
Definition random.qh:14
entity RandomSelection_chosen_ent
Definition random.qh:5
#define setthink(e, f)
void play2(entity e, string filename)
Definition all.qc:116
#define SND(id)
Definition all.qh:35
string noise
Definition subs.qh:83
string killtarget
Definition subs.qh:48
string target4
Definition subs.qh:55
string target3
Definition subs.qh:54
float target_random
Definition subs.qh:57
string target2
void DelayThink(entity this)
Definition triggers.qc:39
float antiwall_flag
Definition triggers.qh:6
string target
Definition triggers.qh:55
#define IS_REAL_CLIENT(v)
Definition utils.qh:17

References antiwall_flag, BIT, centerprint(), delay, DelayThink(), entity(), find(), IS_PLAYER, IS_REAL_CLIENT, killtarget, message, new_pure, noise, NULL, play2(), RandomSelection_AddEnt, RandomSelection_chosen_ent, RandomSelection_Init(), setthink, SND, target, target2, target3, target4, target_random, targetname, and time.

Referenced by SUB_UseTargets(), SUB_UseTargets_PreventReuse(), and SUB_UseTargets_SkipTargets().

◆ SUB_UseTargets_PreventReuse()

void SUB_UseTargets_PreventReuse ( entity this,
entity actor,
entity trigger )

Definition at line 345 of file triggers.qc.

345{ SUB_UseTargets_Ex(this, actor, trigger, true, 0); }

References entity(), and SUB_UseTargets_Ex().

◆ SUB_UseTargets_SkipTargets()

void SUB_UseTargets_SkipTargets ( entity this,
entity actor,
entity trigger,
int skiptargets )

Definition at line 346 of file triggers.qc.

346{ SUB_UseTargets_Ex(this, actor, trigger, false, skiptargets); }

References entity(), and SUB_UseTargets_Ex().

Referenced by WarpZone_Touch().

◆ trigger_common_write()

void trigger_common_write ( entity this,
bool withtarget )

Definition at line 110 of file triggers.qc.

111{
112 int f = 0;
113 if(this.warpzone_isboxy)
114 BITSET_ASSIGN(f, 1);
115 if(this.origin != '0 0 0')
116 BITSET_ASSIGN(f, 4);
117 if(this.movedir != '0 0 0')
118 BITSET_ASSIGN(f, 8);
119 if(this.angles != '0 0 0')
120 BITSET_ASSIGN(f, 16);
122
123 if(withtarget)
124 {
125 // probably some way to clean this up...
126 int targbits = 0;
127 if(this.target && this.target != "") targbits |= BIT(0);
128 if(this.target2 && this.target2 != "") targbits |= BIT(1);
129 if(this.target3 && this.target3 != "") targbits |= BIT(2);
130 if(this.target4 && this.target4 != "") targbits |= BIT(3);
131 if(this.targetname && this.targetname != "") targbits |= BIT(4);
132 if(this.killtarget && this.killtarget != "") targbits |= BIT(5);
133
134 WriteByte(MSG_ENTITY, targbits);
135
136 if(targbits & BIT(0))
138 if(targbits & BIT(1))
140 if(targbits & BIT(2))
142 if(targbits & BIT(3))
144 if(targbits & BIT(4))
146 if(targbits & BIT(5))
148 }
149
150 if(f & 4)
151 WriteVector(MSG_ENTITY, this.origin);
152
153 if(f & 8)
154 WriteVector(MSG_ENTITY, this.movedir);
155
156 if(f & 16)
157 WriteVector(MSG_ENTITY, this.angles);
158
160 WriteVector(MSG_ENTITY, this.mins);
161 WriteVector(MSG_ENTITY, this.maxs);
162 WriteByte(MSG_ENTITY, bound(1, this.scale * 16, 255));
163}
float modelindex
vector mins
vector maxs
vector origin
WriteString(chan, ent.netname)
ent angles
Definition ent_cs.qc:146
WriteByte(chan, ent.angles.y/DEC_FACTOR)
const int MSG_ENTITY
Definition net.qh:156
#define BITSET_ASSIGN(a, b)
Definition common.qh:107
float warpzone_isboxy
Definition common.qh:15
vector movedir
Definition viewloc.qh:18
float bound(float min, float value, float max)
void WriteShort(float data, float dest, float desto)
float scale
Definition projectile.qc:14

References angles, BIT, BITSET_ASSIGN, bound(), entity(), killtarget, maxs, mins, modelindex, movedir, MSG_ENTITY, origin, scale, target, target2, target3, target4, targetname, warpzone_isboxy, WriteByte(), WriteShort(), and WriteString().

Referenced by door_send(), func_ladder_send(), plat_send(), train_send(), trigger_impulse_send(), trigger_keylock_send(), trigger_push_send(), trigger_push_velocity_send(), and trigger_teleport_send().

◆ trigger_link()

void trigger_link ( entity this,
bool(entity this, entity to, int sendflags) sendfunc )

Definition at line 104 of file triggers.qc.

105{
106 setSendEntity(this, sendfunc);
107 this.SendFlags = 0xFFFFFF;
108}
#define setSendEntity(e, f)

References entity(), SendFlags, and setSendEntity.

Referenced by func_ladder_link(), trigger_impulse_link(), trigger_push_link(), and trigger_push_velocity_link().