]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/turrets/targettrigger.qc
Kill more setself
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / targettrigger.qc
index 98c23c4584df4e98a4707c33f3121aee48ad55a5..aa1322c4411b7d5d37339afa57e3b95afce5f884 100644 (file)
@@ -1,37 +1,24 @@
-void spawnfunc_turret_targettrigger();
+spawnfunc(turret_targettrigger);
 void turret_targettrigger_touch();
 
 void turret_targettrigger_touch()
 {SELFPARAM();
-    entity e;
-    if (self.cnt > time) return;
-    entity oldself = this;
-
-    e = find(world, targetname, self.target);
-    while (e)
-    {
-        if (e.turret_flags & TUR_FLAG_RECIEVETARGETS)
-        {
-            setself(e);
-            if(e.turret_addtarget)
-                e.turret_addtarget(other,oldself);
-        }
-
-        e = find(e, targetname, oldself.target);
-    }
-
-    oldself.cnt = time + 0.5;
-
-    setself(this);
+    if (this.cnt > time) return;
+    FOREACH_ENTITY_STRING_ORDERED(targetname, this.target, {
+        if (!(it.turret_flags & TUR_FLAG_RECIEVETARGETS)) continue;
+        if (!it.turret_addtarget) continue;
+        WITHSELF(it, it.turret_addtarget(other, this));
+    });
+    this.cnt = time + 0.5;
 }
 
 /*QUAKED turret_targettrigger (.5 .5 .5) ?
 */
-void spawnfunc_turret_targettrigger()
-{SELFPARAM();
-    if(!autocvar_g_turrets) { remove(self); return; }
+spawnfunc(turret_targettrigger)
+{
+    if(!autocvar_g_turrets) { remove(this); return; }
 
-    InitTrigger ();
+    WITHSELF(this, InitTrigger());
 
-    self.touch = turret_targettrigger_touch;
+    this.touch = turret_targettrigger_touch;
 }