+#include "triggers.qh"
void SUB_DontUseTargets(entity this, entity actor, entity trigger) { }
void SUB_UseTargets(entity this, entity actor, entity trigger);
void DelayThink(entity this)
{
SUB_UseTargets (this, this.enemy, NULL);
- remove(this);
+ delete(this);
}
void FixSize(entity e)
#ifdef SVQC
+bool autocvar_g_triggers_debug = true;
+
void trigger_init(entity this)
{
string m = this.model;
EXACTTRIGGER_INIT;
- if(m != "")
- {
- precache_model(m);
- _setmodel(this, m); // no precision needed
+ 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);
- BITSET_ASSIGN(this.effects, EF_NODEPTHTEST);
+ if(autocvar_g_triggers_debug)
+ BITSET_ASSIGN(this.effects, EF_NODEPTHTEST);
}
void trigger_link(entity this, bool(entity this, entity to, int sendflags) sendfunc)
}
#endif
+
/*
==============================
SUB_UseTargets
==============================
*/
-void SUB_UseTargets(entity this, entity actor, entity trigger)
+
+void SUB_UseTargets_Ex(entity this, entity actor, entity trigger, bool preventReuse)
{
//
// check for a delay
t.target2 = this.target2;
t.target3 = this.target3;
t.target4 = this.target4;
+ t.antiwall_flag = this.antiwall_flag;
return;
}
if (s != "")
{
for(entity t = NULL; (t = find(t, targetname, s)); )
- remove(t);
+ delete(t);
}
#endif
int aw_flag = this.antiwall_flag;
for(entity t = NULL; (t = find(t, targetname, s)); )
{
- if(t.use)
+ if(t.use && (t.sub_target_used != time || !preventReuse))
{
if(this.target_random)
{
- RandomSelection_Add(t, 0, string_null, 1, 0);
+ RandomSelection_AddEnt(t, 1, 0);
}
else
{
t.antiwall_flag = aw_flag;
t.use(t, actor, this);
+ if(preventReuse)
+ t.sub_target_used = time;
}
}
}
}
if(this.target_random && RandomSelection_chosen_ent)
+ {
RandomSelection_chosen_ent.use(RandomSelection_chosen_ent, actor, this);
+ if(preventReuse)
+ RandomSelection_chosen_ent.sub_target_used = time;
+ }
}
+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); }
+
void SUB_UseTargets_self(entity this)
{
SUB_UseTargets(this, NULL, NULL);