- WITH(entity, self, this, WarpZoneLib_ExactTrigger_Init());
- if(m != "")
- {
- precache_model(m);
- _setmodel(this, m); // no precision needed
+ EXACTTRIGGER_INIT;
+ if(autocvar_g_triggers_debug)
+ {
+ if(m != "")
+ {
+ precache_model(m);
+ _setmodel(this, m); // no precision needed
+ }
+ setorigin(this, this.origin);
+ if(this.scale)
+ setsize(this, this.mins * this.scale, this.maxs * this.scale);
+ else
+ setsize(this, this.mins, this.maxs);
- setorigin(this, this.origin);
- if(this.scale)
- setsize(this, this.mins * this.scale, this.maxs * this.scale);
- else
- setsize(this, this.mins, this.maxs);
}
void trigger_link(entity this, bool(entity this, entity to, int sendflags) sendfunc)
{
}
void trigger_link(entity this, bool(entity this, entity to, int sendflags) sendfunc)
{
- if(self.target) { strunzone(self.target); }
- self.target = strzone(ReadString());
- if(self.target2) { strunzone(self.target2); }
- self.target2 = strzone(ReadString());
- if(self.target3) { strunzone(self.target3); }
- self.target3 = strzone(ReadString());
- if(self.target4) { strunzone(self.target4); }
- self.target4 = strzone(ReadString());
- if(self.targetname) { strunzone(self.targetname); }
- self.targetname = strzone(ReadString());
- if(self.killtarget) { strunzone(self.killtarget); }
- self.killtarget = strzone(ReadString());
+ if(this.target) { strunzone(this.target); }
+ this.target = strzone(ReadString());
+ if(this.target2) { strunzone(this.target2); }
+ this.target2 = strzone(ReadString());
+ if(this.target3) { strunzone(this.target3); }
+ this.target3 = strzone(ReadString());
+ if(this.target4) { strunzone(this.target4); }
+ this.target4 = strzone(ReadString());
+ if(this.targetname) { strunzone(this.targetname); }
+ this.targetname = strzone(ReadString());
+ if(this.killtarget) { strunzone(this.killtarget); }
+ this.killtarget = strzone(ReadString());
- self.origin_x = ReadCoord();
- self.origin_y = ReadCoord();
- self.origin_z = ReadCoord();
+ this.origin_x = ReadCoord();
+ this.origin_y = ReadCoord();
+ this.origin_z = ReadCoord();
- self.origin = '0 0 0';
- setorigin(self, self.origin);
-
- self.modelindex = ReadShort();
- self.mins_x = ReadCoord();
- self.mins_y = ReadCoord();
- self.mins_z = ReadCoord();
- self.maxs_x = ReadCoord();
- self.maxs_y = ReadCoord();
- self.maxs_z = ReadCoord();
- self.scale = ReadByte() / 16;
- setsize(self, self.mins, self.maxs);
-
- self.movedir_x = ReadCoord();
- self.movedir_y = ReadCoord();
- self.movedir_z = ReadCoord();
-
- self.angles_x = ReadCoord();
- self.angles_y = ReadCoord();
- self.angles_z = ReadCoord();
+ this.origin = '0 0 0';
+ setorigin(this, this.origin);
+
+ this.modelindex = ReadShort();
+ this.mins_x = ReadCoord();
+ this.mins_y = ReadCoord();
+ this.mins_z = ReadCoord();
+ this.maxs_x = ReadCoord();
+ this.maxs_y = ReadCoord();
+ this.maxs_z = ReadCoord();
+ this.scale = ReadByte() / 16;
+ setsize(this, this.mins, this.maxs);
+
+ this.movedir_x = ReadCoord();
+ this.movedir_y = ReadCoord();
+ this.movedir_z = ReadCoord();
+
+ this.angles_x = ReadCoord();
+ this.angles_y = ReadCoord();
+ this.angles_z = ReadCoord();
/*
==============================
SUB_UseTargets
the global "activator" should be set to the entity that initiated the firing.
/*
==============================
SUB_UseTargets
the global "activator" should be set to the entity that initiated the firing.
and removes them, so some events can remove other triggers.
Search for (string)targetname in all entities that
and removes them, so some events can remove other triggers.
Search for (string)targetname in all entities that
- t = new(DelayedUse);
- t.nextthink = time + self.delay;
- t.think = DelayThink;
- t.enemy = activator;
- t.message = self.message;
- t.killtarget = self.killtarget;
- t.target = self.target;
- t.target2 = self.target2;
- t.target3 = self.target3;
- t.target4 = self.target4;
+ entity t = new(DelayedUse);
+ t.nextthink = time + this.delay;
+ setthink(t, DelayThink);
+ t.enemy = actor;
+ t.message = this.message;
+ t.killtarget = this.killtarget;
+ t.target = this.target;
+ t.target2 = this.target2;
+ t.target3 = this.target3;
+ t.target4 = this.target4;
+ t.antiwall_flag = this.antiwall_flag;
- centerprint(activator, self.message);
- if (self.noise == "")
- play2(activator, SND(TALK));
+ centerprint(actor, this.message);
+ if (this.noise == "")
+ play2(actor, SND(TALK));
{
// Flag to set func_clientwall state
// 1 == deactivate, 2 == activate, 0 == do nothing
{
// Flag to set func_clientwall state
// 1 == deactivate, 2 == activate, 0 == do nothing
- float aw_flag = self.antiwall_flag;
- for(t = world; (t = find(t, targetname, s)); )
- if(t.use)
+ int aw_flag = this.antiwall_flag;
+ for(entity t = NULL; (t = find(t, targetname, s)); )
- RandomSelection_Add(t, 0, string_null, 1, 0);
- }
- else
- {
- if (t.classname == "func_clientwall" || t.classname == "func_clientillusionary")
- t.antiwall_flag = aw_flag;
- setself(t);
- other = this;
- activator = act;
- self.use();
+ if(this.target_random)
+ {
+ RandomSelection_AddEnt(t, 1, 0);
+ }
+ else
+ {
+ if (t.classname == "func_clientwall" || t.classname == "func_clientillusionary")
+ t.antiwall_flag = aw_flag;
+
+ t.use(t, actor, this);
+ if(preventReuse)
+ t.sub_target_used = time;
+ }
-#ifdef CSQC
-void trigger_touch_generic(entity this, void() touchfunc)
-{
- entity e;
- for(e = findradius((this.absmin + this.absmax) * 0.5, vlen(this.absmax - this.absmin) * 0.5 + 1); e; e = e.chain)
- if(e.isplayermodel || e.classname == "csqcprojectile")
- {
- vector emin = e.absmin, emax = e.absmax;
- if(this.solid == SOLID_BSP)
- {
- emin -= '1 1 1';
- emax += '1 1 1';
- }
- if(boxesoverlap(emin, emax, this.absmin, this.absmax)) // quick
- if(WarpZoneLib_BoxTouchesBrush(emin, emax, this, e)) // accurate
- {
- other = e;
- WITH(entity, self, this, touchfunc());
- }
- }
-}
-void trigger_draw_generic(entity this)
-{
- float dt = time - this.move_time;
- this.move_time = time;
- if(dt <= 0) { return; }
+void SUB_UseTargets(entity this, entity actor, entity trigger) { SUB_UseTargets_Ex(this, actor, trigger, false); }
+void SUB_UseTargets_PreventReuse(entity this, entity actor, entity trigger) { SUB_UseTargets_Ex(this, actor, trigger, true); }
- if(this.trigger_touch) { trigger_touch_generic(this, this.trigger_touch); }
+void SUB_UseTargets_self(entity this)
+{
+ SUB_UseTargets(this, NULL, NULL);