X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Ftriggers%2Ftriggers.qc;h=54e1e09919f06666bb6ff1b22c379b5f7577bc0c;hb=63cf60651482d650ae40d005bd4847d5111123a9;hp=d9c6a08126a90672e85be1966b31144faeba8ef2;hpb=3d4a324cc2e15c1eb99209674942506eb998e2ec;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/triggers/triggers.qc b/qcsrc/common/triggers/triggers.qc index d9c6a0812..54e1e0991 100644 --- a/qcsrc/common/triggers/triggers.qc +++ b/qcsrc/common/triggers/triggers.qc @@ -1,3 +1,4 @@ +#include "triggers.qh" void SUB_DontUseTargets(entity this, entity actor, entity trigger) { } void SUB_UseTargets(entity this, entity actor, entity trigger); @@ -5,7 +6,7 @@ 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) @@ -41,8 +42,7 @@ void trigger_init(entity this) void trigger_link(entity this, bool(entity this, entity to, int sendflags) sendfunc) { - this.SendEntity = SendEntity_self; - this.SendEntity3 = sendfunc; + setSendEntity(this, sendfunc); this.SendFlags = 0xFFFFFF; } @@ -164,26 +164,28 @@ void trigger_remove_generic(entity this) } #endif + /* ============================== SUB_UseTargets the global "activator" should be set to the entity that initiated the firing. -If self.delay is set, a DelayedUse entity will be created that will actually +If this.delay is set, a DelayedUse entity will be created that will actually do the SUB_UseTargets after that many seconds have passed. -Centerprints any self.message to the activator. +Centerprints any this.message to the activator. -Removes all entities with a targetname that match self.killtarget, +Removes all entities with a targetname that match this.killtarget, and removes them, so some events can remove other triggers. Search for (string)targetname in all entities that -match (string)self.target and call their .use function +match (string)this.target and call their .use function ============================== */ -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 @@ -225,8 +227,8 @@ void SUB_UseTargets(entity this, entity actor, entity trigger) s = this.killtarget; if (s != "") { - for(entity t = world; (t = find(t, targetname, s)); ) - remove(t); + for(entity t = NULL; (t = find(t, targetname, s)); ) + delete(t); } #endif @@ -252,9 +254,9 @@ void SUB_UseTargets(entity this, entity actor, entity trigger) // Flag to set func_clientwall state // 1 == deactivate, 2 == activate, 0 == do nothing int aw_flag = this.antiwall_flag; - for(entity t = world; (t = find(t, targetname, s)); ) + 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) { @@ -266,6 +268,8 @@ void SUB_UseTargets(entity this, entity actor, entity trigger) t.antiwall_flag = aw_flag; t.use(t, actor, this); + if(preventReuse) + t.sub_target_used = time; } } } @@ -273,9 +277,16 @@ void SUB_UseTargets(entity this, entity actor, entity trigger) } 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);