]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/turrets/turret/walker.qc
turrets: remove _all
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / turret / walker.qc
index 0a82a4a7bcef08cd1db7c03cdbcc925ca6c0474f..415d5dfeef16fd315cd5c08d7dc269be2c199bd9 100644 (file)
@@ -1,7 +1,5 @@
 #include "walker.qh"
 
-#ifdef IMPLEMENTATION
-
 #ifdef SVQC
 
 float autocvar_g_turrets_unit_walker_melee_damage;
@@ -43,8 +41,6 @@ const int ANIM_ROAM       = 11;
 .float animflag;
 .float idletime;
 
-#define WALKER_PATH(this, s, e) pathlib_astar(this, s, e)
-
 bool walker_firecheck(entity this)
 {
     if (this.animflag == ANIM_MELEE)
@@ -80,7 +76,7 @@ void walker_setnoanim(entity this)
 void walker_rocket_explode(entity this)
 {
     RadiusDamage (this, this.owner, (autocvar_g_turrets_unit_walker_rocket_damage), 0, (autocvar_g_turrets_unit_walker_rocket_radius), this, NULL, (autocvar_g_turrets_unit_walker_rocket_force), DEATH_TURRET_WALK_ROCKET.m_id, NULL);
-    delete (this);
+    delete(this);
 }
 
 void walker_rocket_touch(entity this, entity toucher)
@@ -299,7 +295,7 @@ void walker_move_path(entity this)
 
                 if (this.pathgoal.enemy)
                 {
-                    this.pathcurrent = WALKER_PATH(this, this.pathgoal.origin, this.pathgoal.enemy.origin);
+                    this.pathcurrent = pathlib_astar(this, this.pathgoal.origin, this.pathgoal.enemy.origin);
                     this.pathgoal = this.pathgoal.enemy;
                 }
             }
@@ -326,6 +322,30 @@ void walker_move_path(entity this)
 #endif
 }
 
+void walker_findtarget(entity this)
+{
+    entity e = find(NULL, targetname, this.target);
+    if (!e)
+    {
+        LOG_TRACE("Initital waypoint for walker does NOT exist, fix your map!");
+        this.target = "";
+    }
+
+    if (e.classname != "turret_checkpoint")
+        LOG_TRACE("Warning: not a turrret path");
+    else
+    {
+#ifdef WALKER_FANCYPATHING
+        this.pathcurrent = pathlib_astar(this, this.origin, e.origin);
+        this.pathgoal = e;
+#else
+        this.pathcurrent = e;
+#endif
+    }
+
+    // TODO: this doesn't reset target, so tur_defend will be the checkpoint too!
+}
+
 spawnfunc(turret_walker) { if(!turret_initialize(this, TUR_WALKER)) delete(this); }
 
 METHOD(WalkerTurret, tr_think, void(WalkerTurret thistur, entity it))
@@ -550,8 +570,6 @@ METHOD(WalkerTurret, tr_setup, void(WalkerTurret this, entity it))
 {
     it.ticrate = 0.05;
 
-    entity e;
-
     // Respawn is called & first spawn to, to set team. need to make sure we do not move the initial spawn.
     if(it.move_movetype == MOVETYPE_WALK)
     {
@@ -587,26 +605,7 @@ METHOD(WalkerTurret, tr_setup, void(WalkerTurret this, entity it))
     it.turret_firecheckfunc = walker_firecheck;
 
     if (it.target != "")
-    {
-        e = find(NULL, targetname, it.target);
-        if (!e)
-        {
-            LOG_TRACE("Initital waypoint for walker does NOT exsist, fix your map!");
-            it.target = "";
-        }
-
-        if (e.classname != "turret_checkpoint")
-            LOG_TRACE("Warning: not a turrret path");
-        else
-        {
-#ifdef WALKER_FANCYPATHING
-            it.pathcurrent = WALKER_PATH(it, it.origin, e.origin);
-            it.pathgoal = e;
-#else
-            it.pathcurrent = e;
-#endif
-        }
-    }
+        InitializeEntity(it, walker_findtarget, INITPRIO_FINDTARGET);
 }
 
 #endif // SVQC
@@ -642,4 +641,3 @@ void walker_draw(entity this)
         }
 
 #endif // CSQC
-#endif