]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/turrets/targettrigger.qc
Merge branch 'TimePath/modules'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / targettrigger.qc
index 65510645b130a9d5968cd7bee6fa273fd5e1d152..f2a97d4a12529e6fd576819d7509b5bd55597937 100644 (file)
@@ -1,38 +1,25 @@
-void spawnfunc_turret_targettrigger();
-void turret_targettrigger_touch();
+#include "targettrigger.qh"
+spawnfunc(turret_targettrigger);
+void turret_targettrigger_touch(entity this, entity toucher);
 
-void turret_targettrigger_touch()
+void turret_targettrigger_touch(entity this, entity toucher)
 {
-    entity e;
-    if (self.cnt > time) return;
-    entity oldself;
-    oldself = self;
-
-    e = find(world, targetname, self.target);
-    while (e)
-    {
-        if (e.turret_flags & TUR_FLAG_RECIEVETARGETS)
-        {
-            self = e;
-            if(e.turret_addtarget)
-                e.turret_addtarget(other,oldself);
-        }
-
-        e = find(e, targetname, oldself.target);
-    }
-
-    oldself.cnt = time + 0.5;
-
-    self = oldself;
+    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;
+        it.turret_addtarget(it, toucher, this);
+    });
+    this.cnt = time + 0.5;
 }
 
 /*QUAKED turret_targettrigger (.5 .5 .5) ?
 */
-void spawnfunc_turret_targettrigger()
+spawnfunc(turret_targettrigger)
 {
-    if(!autocvar_g_turrets) { remove(self); return; }
+    if(!autocvar_g_turrets) { delete(this); return; }
 
-    InitTrigger ();
+    InitTrigger(this);
 
-    self.touch = turret_targettrigger_touch;
+    settouch(this, turret_targettrigger_touch);
 }