]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/turrets/turret/walker.qc
Merge branch 'master' into Mario/killsound
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / turret / walker.qc
index fec4060d44f30841b7fe32ca5b6403efce804600..0a82a4a7bcef08cd1db7c03cdbcc925ca6c0474f 100644 (file)
@@ -1,24 +1,4 @@
-#ifndef TURRET_WALKER_H
-#define TURRET_WALKER_H
-
-//#define WALKER_FANCYPATHING
-
-#include "walker_weapon.qh"
-
-CLASS(WalkerTurret, Turret)
-/* spawnflags */ ATTRIB(WalkerTurret, spawnflags, int, TUR_FLAG_PLAYER | TUR_FLAG_MOVE);
-/* mins       */ ATTRIB(WalkerTurret, mins, vector, '-70 -70 0');
-/* maxs       */ ATTRIB(WalkerTurret, maxs, vector, '70 70 95');
-/* modelname  */ ATTRIB(WalkerTurret, mdl, string, "walker_body.md3");
-/* model      */ ATTRIB_STRZONE(WalkerTurret, model, string, strcat("models/turrets/", this.mdl));
-/* head_model */ ATTRIB_STRZONE(WalkerTurret, head_model, string, strcat("models/turrets/", "walker_head_minigun.md3"));
-/* netname    */ ATTRIB(WalkerTurret, netname, string, "walker");
-/* fullname   */ ATTRIB(WalkerTurret, turret_name, string, _("Walker Turret"));
-    ATTRIB(WalkerTurret, m_weapon, Weapon, WEP_WALKER);
-ENDCLASS(WalkerTurret)
-REGISTER_TURRET(WALKER, NEW(WalkerTurret));
-
-#endif
+#include "walker.qh"
 
 #ifdef IMPLEMENTATION
 
@@ -65,12 +45,12 @@ const int ANIM_ROAM       = 11;
 
 #define WALKER_PATH(this, s, e) pathlib_astar(this, s, e)
 
-float walker_firecheck()
-{SELFPARAM();
-    if (self.animflag == ANIM_MELEE)
-        return 0;
+bool walker_firecheck(entity this)
+{
+    if (this.animflag == ANIM_MELEE)
+        return false;
 
-    return turret_firecheck();
+    return turret_firecheck(this);
 }
 
 void walker_melee_do_dmg(entity this)
@@ -78,15 +58,15 @@ void walker_melee_do_dmg(entity this)
     vector where;
     entity e;
 
-    makevectors(self.angles);
-    where = self.origin + v_forward * 128;
+    makevectors(this.angles);
+    where = this.origin + v_forward * 128;
 
     e = findradius(where,32);
     while (e)
     {
-        if (turret_validate_target(self, e, self.target_validate_flags))
-            if (e != self && e.owner != self)
-                Damage(e, self, self, (autocvar_g_turrets_unit_walker_melee_damage), DEATH_TURRET_WALK_MELEE.m_id, '0 0 0', v_forward * (autocvar_g_turrets_unit_walker_melee_force));
+        if (turret_validate_target(this, e, this.target_validate_flags))
+            if (e != this && e.owner != this)
+                Damage(e, this, this, (autocvar_g_turrets_unit_walker_melee_damage), DEATH_TURRET_WALK_MELEE.m_id, '0 0 0', v_forward * (autocvar_g_turrets_unit_walker_melee_force));
 
         e = e.chain;
     }
@@ -94,13 +74,18 @@ void walker_melee_do_dmg(entity this)
 
 void walker_setnoanim(entity this)
 {
-    turrets_setframe(ANIM_NO, false);
-    self.animflag = self.frame;
+    turrets_setframe(this, ANIM_NO, false);
+    this.animflag = this.frame;
 }
 void walker_rocket_explode(entity this)
 {
-    RadiusDamage (self, self.owner, (autocvar_g_turrets_unit_walker_rocket_damage), 0, (autocvar_g_turrets_unit_walker_rocket_radius), self, world, (autocvar_g_turrets_unit_walker_rocket_force), DEATH_TURRET_WALK_ROCKET.m_id, world);
-    remove (self);
+    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);
+}
+
+void walker_rocket_touch(entity this, entity toucher)
+{
+    walker_rocket_explode(this);
 }
 
 void walker_rocket_damage(entity this, entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector vforce)
@@ -112,7 +97,7 @@ void walker_rocket_damage(entity this, entity inflictor, entity attacker, float
         W_PrepareExplosionByDamage(this, this.owner, walker_rocket_explode);
 }
 
-#define WALKER_ROCKET_MOVE movelib_move_simple(self, newdir, (autocvar_g_turrets_unit_walker_rocket_speed), (autocvar_g_turrets_unit_walker_rocket_turnrate)); UpdateCSQCProjectile(self)
+#define WALKER_ROCKET_MOVE(s) movelib_move_simple((s), newdir, (autocvar_g_turrets_unit_walker_rocket_speed), (autocvar_g_turrets_unit_walker_rocket_turnrate)); UpdateCSQCProjectile(s)
 void walker_rocket_loop(entity this);
 void walker_rocket_think(entity this)
 {
@@ -121,123 +106,118 @@ void walker_rocket_think(entity this)
     float itime;
     float m_speed;
 
-    self.nextthink = time;
+    this.nextthink = time;
 
-    edist = vlen(self.enemy.origin - self.origin);
+    edist = vlen(this.enemy.origin - this.origin);
 
     // Simulate crude guidance
-    if (self.cnt < time)
+    if (this.cnt < time)
     {
         if (edist < 1000)
-            self.tur_shotorg = randomvec() * min(edist, 64);
+            this.tur_shotorg = randomvec() * min(edist, 64);
         else
-            self.tur_shotorg = randomvec() * min(edist, 256);
+            this.tur_shotorg = randomvec() * min(edist, 256);
 
-        self.cnt = time + 0.5;
+        this.cnt = time + 0.5;
     }
 
     if (edist < 128)
-        self.tur_shotorg = '0 0 0';
+        this.tur_shotorg = '0 0 0';
 
-    if (self.max_health < time)
+    if (this.max_health < time)
     {
-        setthink(self, walker_rocket_explode);
-        self.nextthink  = time;
+        setthink(this, walker_rocket_explode);
+        this.nextthink  = time;
         return;
     }
 
-    if (self.shot_dmg != 1337 && random() < 0.01)
+    if (this.shot_dmg != 1337 && random() < 0.01)
     {
-        walker_rocket_loop(self);
+        walker_rocket_loop(this);
         return;
     }
 
-    m_speed = vlen(self.velocity);
+    m_speed = vlen(this.velocity);
 
     // Enemy dead? just keep on the current heading then.
-    if (self.enemy == world || IS_DEAD(self.enemy))
-        self.enemy = world;
+    if (this.enemy == NULL || IS_DEAD(this.enemy))
+        this.enemy = NULL;
 
-    if (self.enemy)
+    if (this.enemy)
     {
         itime = max(edist / m_speed, 1);
-        newdir = steerlib_pull(self, self.enemy.origin + self.tur_shotorg);
+        newdir = steerlib_pull(this, this.enemy.origin + this.tur_shotorg);
     }
     else
-        newdir  = normalize(self.velocity);
+        newdir  = normalize(this.velocity);
 
-    WALKER_ROCKET_MOVE;
+    WALKER_ROCKET_MOVE(this);
 }
 
 void walker_rocket_loop3(entity this)
 {
-    vector newdir;
-    self.nextthink = time;
+    this.nextthink = time;
 
-    if (self.max_health < time)
+    if (this.max_health < time)
     {
-        setthink(self, walker_rocket_explode);
+        setthink(this, walker_rocket_explode);
         return;
     }
 
-    if(vdist(self.origin - self.tur_shotorg, <, 100))
+    if(vdist(this.origin - this.tur_shotorg, <, 100))
     {
-        setthink(self, walker_rocket_think);
+        setthink(this, walker_rocket_think);
         return;
     }
 
-    newdir = steerlib_pull(self, self.tur_shotorg);
-    WALKER_ROCKET_MOVE;
+    vector newdir = steerlib_pull(this, this.tur_shotorg);
+    WALKER_ROCKET_MOVE(this);
 
-    self.angles = vectoangles(self.velocity);
+    this.angles = vectoangles(this.velocity);
 }
 
 void walker_rocket_loop2(entity this)
 {
-    vector newdir;
-
-    self.nextthink = time;
+    this.nextthink = time;
 
-    if (self.max_health < time)
+    if (this.max_health < time)
     {
-        setthink(self, walker_rocket_explode);
+        setthink(this, walker_rocket_explode);
         return;
     }
 
-    if(vdist(self.origin - self.tur_shotorg, <, 100))
+    if(vdist(this.origin - this.tur_shotorg, <, 100))
     {
-        self.tur_shotorg = self.origin - '0 0 200';
-        setthink(self, walker_rocket_loop3);
+        this.tur_shotorg = this.origin - '0 0 200';
+        setthink(this, walker_rocket_loop3);
         return;
     }
 
-    newdir = steerlib_pull(self, self.tur_shotorg);
-    WALKER_ROCKET_MOVE;
+    vector newdir = steerlib_pull(this, this.tur_shotorg);
+    WALKER_ROCKET_MOVE(this);
 }
 
 void walker_rocket_loop(entity this)
 {
-    self.nextthink = time;
-    self.tur_shotorg = self.origin + '0 0 300';
-    setthink(self, walker_rocket_loop2);
-    self.shot_dmg = 1337;
+    this.nextthink = time;
+    this.tur_shotorg = this.origin + '0 0 300';
+    setthink(this, walker_rocket_loop2);
+    this.shot_dmg = 1337;
 }
 
-void walker_fire_rocket(vector org)
-{SELFPARAM();
-    entity rocket;
-
-    fixedmakevectors(self.angles);
+void walker_fire_rocket(entity this, vector org)
+{
+    fixedmakevectors(this.angles);
 
     te_explosion (org);
 
-    rocket = new(walker_rocket);
+    entity rocket = new(walker_rocket);
     setorigin(rocket, org);
 
-    sound (self, CH_WEAPON_A, SND_HAGAR_FIRE, VOL_BASE, ATTEN_NORM);
+    sound (this, CH_WEAPON_A, SND_HAGAR_FIRE, VOL_BASE, ATTEN_NORM);
     setsize (rocket, '-3 -3 -3', '3 3 3'); // give it some size so it can be shot
 
-    rocket.owner                         = self;
+    rocket.owner                         = this;
     rocket.bot_dodge             = true;
     rocket.bot_dodgerating     = 50;
     rocket.takedamage           = DAMAGE_YES;
@@ -245,7 +225,7 @@ void walker_fire_rocket(vector org)
     rocket.health                       = 25;
     rocket.tur_shotorg         = randomvec() * 512;
     rocket.cnt                         = time + 1;
-    rocket.enemy                         = self.enemy;
+    rocket.enemy                         = this.enemy;
 
     if (random() < 0.01)
         setthink(rocket, walker_rocket_loop);
@@ -255,11 +235,13 @@ void walker_fire_rocket(vector org)
     rocket.event_damage           = walker_rocket_damage;
 
     rocket.nextthink             = time;
-    rocket.movetype               = MOVETYPE_FLY;
+    set_movetype(rocket, MOVETYPE_FLY);
     rocket.velocity               = normalize((v_forward + v_up * 0.5) + (randomvec() * 0.2)) * (autocvar_g_turrets_unit_walker_rocket_speed);
     rocket.angles                       = vectoangles(rocket.velocity);
-    settouch(rocket, walker_rocket_explode);
-    rocket.flags                         = FL_PROJECTILE;
+    settouch(rocket, walker_rocket_touch);
+    rocket.flags = FL_PROJECTILE;
+    IL_PUSH(g_projectiles, rocket);
+    IL_PUSH(g_bot_dodge, rocket);
     rocket.solid                         = SOLID_BBOX;
     rocket.max_health           = time + 9;
     rocket.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_GUIDED_HEAT;
@@ -269,144 +251,143 @@ void walker_fire_rocket(vector org)
 
 .vector enemy_last_loc;
 .float enemy_last_time;
-void walker_move_to(vector _target, float _dist)
-{SELFPARAM();
-    switch (self.waterlevel)
+void walker_move_to(entity this, vector _target, float _dist)
+{
+    switch (this.waterlevel)
     {
         case WATERLEVEL_NONE:
             if (_dist > 500)
-                self.animflag = ANIM_RUN;
+                this.animflag = ANIM_RUN;
             else
-                self.animflag = ANIM_WALK;
+                this.animflag = ANIM_WALK;
         case WATERLEVEL_WETFEET:
         case WATERLEVEL_SWIMMING:
-            if (self.animflag != ANIM_SWIM)
-                self.animflag = ANIM_WALK;
+            if (this.animflag != ANIM_SWIM)
+                this.animflag = ANIM_WALK;
             else
-                self.animflag = ANIM_SWIM;
+                this.animflag = ANIM_SWIM;
             break;
         case WATERLEVEL_SUBMERGED:
-            self.animflag = ANIM_SWIM;
+            this.animflag = ANIM_SWIM;
     }
 
-    self.moveto = _target;
-    self.steerto = steerlib_attract2(self, self.moveto, 0.5, 500, 0.95);
+    this.moveto = _target;
+    this.steerto = steerlib_attract2(this, this.moveto, 0.5, 500, 0.95);
 
-    if(self.enemy)
+    if(this.enemy)
     {
-        self.enemy_last_loc = _target;
-        self.enemy_last_time = time;
+        this.enemy_last_loc = _target;
+        this.enemy_last_time = time;
     }
 }
 
-void walker_move_path()
-{SELFPARAM();
+void walker_move_path(entity this)
+{
 #ifdef WALKER_FANCYPATHING
     // Are we close enougth to a path node to switch to the next?
-    if(vdist(self.origin - self.pathcurrent.origin, <, 64))
-        if (self.pathcurrent.path_next == world)
+    if(vdist(this.origin - this.pathcurrent.origin, <, 64))
+        if (this.pathcurrent.path_next == NULL)
         {
             // Path endpoint reached
-            pathlib_deletepath(self.pathcurrent.owner);
-            self.pathcurrent = world;
+            pathlib_deletepath(this.pathcurrent.owner);
+            this.pathcurrent = NULL;
 
-            if (self.pathgoal)
+            if (this.pathgoal)
             {
-                if (self.pathgoal.use)
-                    self.pathgoal.use(self, NULL, NULL);
+                if (this.pathgoal.use)
+                    this.pathgoal.use(this, NULL, NULL);
 
-                if (self.pathgoal.enemy)
+                if (this.pathgoal.enemy)
                 {
-                    self.pathcurrent = WALKER_PATH(self, self.pathgoal.origin, self.pathgoal.enemy.origin);
-                    self.pathgoal = self.pathgoal.enemy;
+                    this.pathcurrent = WALKER_PATH(this, this.pathgoal.origin, this.pathgoal.enemy.origin);
+                    this.pathgoal = this.pathgoal.enemy;
                 }
             }
             else
-                self.pathgoal = world;
+                this.pathgoal = NULL;
         }
         else
-            self.pathcurrent = self.pathcurrent.path_next;
+            this.pathcurrent = this.pathcurrent.path_next;
 
-    self.moveto = self.pathcurrent.origin;
-    self.steerto = steerlib_attract2(self, self.moveto,0.5,500,0.95);
-    walker_move_to(self.moveto, 0);
+    this.moveto = this.pathcurrent.origin;
+    this.steerto = steerlib_attract2(this, this.moveto,0.5,500,0.95);
+    walker_move_to(this, this.moveto, 0);
 
 #else
-    if(vdist(self.origin - self.pathcurrent.origin, <, 64))
-        self.pathcurrent = self.pathcurrent.enemy;
+    if(vdist(this.origin - this.pathcurrent.origin, <, 64))
+        this.pathcurrent = this.pathcurrent.enemy;
 
-    if(!self.pathcurrent)
+    if(!this.pathcurrent)
         return;
 
-    self.moveto = self.pathcurrent.origin;
-    self.steerto = steerlib_attract2(self, self.moveto, 0.5, 500, 0.95);
-    walker_move_to(self.moveto, 0);
+    this.moveto = this.pathcurrent.origin;
+    this.steerto = steerlib_attract2(this, this.moveto, 0.5, 500, 0.95);
+    walker_move_to(this, this.moveto, 0);
 #endif
 }
 
-spawnfunc(turret_walker) { if(!turret_initialize(TUR_WALKER)) remove(this); }
+spawnfunc(turret_walker) { if(!turret_initialize(this, TUR_WALKER)) delete(this); }
 
 METHOD(WalkerTurret, tr_think, void(WalkerTurret thistur, entity it))
 {
-    SELFPARAM();
-    fixedmakevectors(self.angles);
+    fixedmakevectors(it.angles);
 
-    if (self.spawnflags & TSF_NO_PATHBREAK && self.pathcurrent)
-        walker_move_path();
-    else if (self.enemy == world)
+    if (it.spawnflags & TSF_NO_PATHBREAK && it.pathcurrent)
+        walker_move_path(it);
+    else if (it.enemy == NULL)
     {
-        if(self.pathcurrent)
-            walker_move_path();
+        if(it.pathcurrent)
+            walker_move_path(it);
         else
         {
-            if(self.enemy_last_time != 0)
+            if(it.enemy_last_time != 0)
             {
-                if(vdist(self.origin - self.enemy_last_loc, <, 128) || time - self.enemy_last_time > 10)
-                    self.enemy_last_time = 0;
+                if(vdist(it.origin - it.enemy_last_loc, <, 128) || time - it.enemy_last_time > 10)
+                    it.enemy_last_time = 0;
                 else
-                    walker_move_to(self.enemy_last_loc, 0);
+                    walker_move_to(it, it.enemy_last_loc, 0);
             }
             else
             {
-                if(self.animflag != ANIM_NO)
+                if(it.animflag != ANIM_NO)
                 {
-                    traceline(self.origin + '0 0 64', self.origin + '0 0 64' + v_forward * 128, MOVE_NORMAL, self);
+                    traceline(it.origin + '0 0 64', it.origin + '0 0 64' + v_forward * 128, MOVE_NORMAL, it);
 
                     if(trace_fraction != 1.0)
-                        self.tur_head.idletime = -1337;
+                        it.tur_head.idletime = -1337;
                     else
                     {
-                        traceline(trace_endpos, trace_endpos - '0 0 256', MOVE_NORMAL, self);
+                        traceline(trace_endpos, trace_endpos - '0 0 256', MOVE_NORMAL, it);
                         if(trace_fraction == 1.0)
-                            self.tur_head.idletime = -1337;
+                            it.tur_head.idletime = -1337;
                     }
 
-                    if(self.tur_head.idletime == -1337)
+                    if(it.tur_head.idletime == -1337)
                     {
-                        self.moveto = self.origin + randomvec() * 256;
-                        self.tur_head.idletime = 0;
+                        it.moveto = it.origin + randomvec() * 256;
+                        it.tur_head.idletime = 0;
                     }
 
-                    self.moveto = self.moveto * 0.9 + ((self.origin + v_forward * 500) + randomvec() * 400) * 0.1;
-                    self.moveto_z = self.origin_z + 64;
-                    walker_move_to(self.moveto, 0);
+                    it.moveto = it.moveto * 0.9 + ((it.origin + v_forward * 500) + randomvec() * 400) * 0.1;
+                    it.moveto_z = it.origin_z + 64;
+                    walker_move_to(it, it.moveto, 0);
                 }
 
-                if(self.idletime < time)
+                if(it.idletime < time)
                 {
-                    if(random() < 0.5 || !(self.spawnflags & TSL_ROAM))
+                    if(random() < 0.5 || !(it.spawnflags & TSL_ROAM))
                     {
-                        self.idletime = time + 1 + random() * 5;
-                        self.moveto = self.origin;
-                        self.animflag = ANIM_NO;
+                        it.idletime = time + 1 + random() * 5;
+                        it.moveto = it.origin;
+                        it.animflag = ANIM_NO;
                     }
                     else
                     {
-                        self.animflag = ANIM_WALK;
-                        self.idletime = time + 4 + random() * 2;
-                        self.moveto = self.origin + randomvec() * 256;
-                        self.tur_head.moveto = self.moveto;
-                        self.tur_head.idletime = 0;
+                        it.animflag = ANIM_WALK;
+                        it.idletime = time + 4 + random() * 2;
+                        it.moveto = it.origin + randomvec() * 256;
+                        it.tur_head.moveto = it.moveto;
+                        it.tur_head.idletime = 0;
                     }
                 }
             }
@@ -414,47 +395,47 @@ METHOD(WalkerTurret, tr_think, void(WalkerTurret thistur, entity it))
     }
     else
     {
-        if (self.tur_dist_enemy < (autocvar_g_turrets_unit_walker_melee_range) && self.animflag != ANIM_MELEE)
+        if (it.tur_dist_enemy < (autocvar_g_turrets_unit_walker_melee_range) && it.animflag != ANIM_MELEE)
         {
             vector wish_angle;
 
-            wish_angle = angleofs(self, self.enemy);
-            if (self.animflag != ANIM_SWIM)
+            wish_angle = angleofs(it, it.enemy);
+            if (it.animflag != ANIM_SWIM)
             if (fabs(wish_angle_y) < 15)
             {
-                self.moveto   = self.enemy.origin;
-                self.steerto  = steerlib_attract2(self, self.moveto, 0.5, 500, 0.95);
-                self.animflag = ANIM_MELEE;
+                it.moveto   = it.enemy.origin;
+                it.steerto  = steerlib_attract2(it, it.moveto, 0.5, 500, 0.95);
+                it.animflag = ANIM_MELEE;
             }
         }
-        else if (self.tur_head.attack_finished_single[0] < time)
+        else if (it.tur_head.attack_finished_single[0] < time)
         {
-            if(self.tur_head.shot_volly)
+            if(it.tur_head.shot_volly)
             {
-                self.animflag = ANIM_NO;
+                it.animflag = ANIM_NO;
 
-                self.tur_head.shot_volly = self.tur_head.shot_volly -1;
-                if(self.tur_head.shot_volly == 0)
-                    self.tur_head.attack_finished_single[0] = time + (autocvar_g_turrets_unit_walker_rocket_refire);
+                it.tur_head.shot_volly = it.tur_head.shot_volly -1;
+                if(it.tur_head.shot_volly == 0)
+                    it.tur_head.attack_finished_single[0] = time + (autocvar_g_turrets_unit_walker_rocket_refire);
                 else
-                    self.tur_head.attack_finished_single[0] = time + 0.2;
+                    it.tur_head.attack_finished_single[0] = time + 0.2;
 
-                if(self.tur_head.shot_volly > 1)
-                    walker_fire_rocket(gettaginfo(self, gettagindex(self, "tag_rocket01")));
+                if(it.tur_head.shot_volly > 1)
+                    walker_fire_rocket(it, gettaginfo(it, gettagindex(it, "tag_rocket01")));
                 else
-                    walker_fire_rocket(gettaginfo(self, gettagindex(self, "tag_rocket02")));
+                    walker_fire_rocket(it, gettaginfo(it, gettagindex(it, "tag_rocket02")));
             }
             else
             {
-                if (self.tur_dist_enemy > (autocvar_g_turrets_unit_walker_rocket_range_min))
-                if (self.tur_dist_enemy < (autocvar_g_turrets_unit_walker_rocket_range))
-                    self.tur_head.shot_volly = 4;
+                if (it.tur_dist_enemy > (autocvar_g_turrets_unit_walker_rocket_range_min))
+                if (it.tur_dist_enemy < (autocvar_g_turrets_unit_walker_rocket_range))
+                    it.tur_head.shot_volly = 4;
             }
         }
         else
         {
-            if (self.animflag != ANIM_MELEE)
-                walker_move_to(self.enemy.origin, self.tur_dist_enemy);
+            if (it.animflag != ANIM_MELEE)
+                walker_move_to(it, it.enemy.origin, it.tur_dist_enemy);
         }
     }
 
@@ -463,99 +444,99 @@ METHOD(WalkerTurret, tr_think, void(WalkerTurret thistur, entity it))
         float turny = 0, turnx = 0;
         float vz;
 
-        real_angle = vectoangles(self.steerto) - self.angles;
-        vz = self.velocity_z;
+        real_angle = vectoangles(it.steerto) - it.angles;
+        vz = it.velocity_z;
 
-        switch (self.animflag)
+        switch (it.animflag)
         {
             case ANIM_NO:
-                movelib_brake_simple(self, (autocvar_g_turrets_unit_walker_speed_stop));
+                movelib_brake_simple(it, (autocvar_g_turrets_unit_walker_speed_stop));
                 break;
 
             case ANIM_TURN:
                 turny = (autocvar_g_turrets_unit_walker_turn);
-                movelib_brake_simple(self, (autocvar_g_turrets_unit_walker_speed_stop));
+                movelib_brake_simple(it, (autocvar_g_turrets_unit_walker_speed_stop));
                 break;
 
             case ANIM_WALK:
                 turny = (autocvar_g_turrets_unit_walker_turn_walk);
-                movelib_move_simple(self, v_forward, (autocvar_g_turrets_unit_walker_speed_walk), 0.6);
+                movelib_move_simple(it, v_forward, (autocvar_g_turrets_unit_walker_speed_walk), 0.6);
                 break;
 
             case ANIM_RUN:
                 turny = (autocvar_g_turrets_unit_walker_turn_run);
-                movelib_move_simple(self, v_forward, (autocvar_g_turrets_unit_walker_speed_run), 0.6);
+                movelib_move_simple(it, v_forward, (autocvar_g_turrets_unit_walker_speed_run), 0.6);
                 break;
 
             case ANIM_STRAFE_L:
                 turny = (autocvar_g_turrets_unit_walker_turn_strafe);
-                movelib_move_simple(self, v_right * -1, (autocvar_g_turrets_unit_walker_speed_walk), 0.8);
+                movelib_move_simple(it, v_right * -1, (autocvar_g_turrets_unit_walker_speed_walk), 0.8);
                 break;
 
             case ANIM_STRAFE_R:
                 turny = (autocvar_g_turrets_unit_walker_turn_strafe);
-                movelib_move_simple(self, v_right, (autocvar_g_turrets_unit_walker_speed_walk), 0.8);
+                movelib_move_simple(it, v_right, (autocvar_g_turrets_unit_walker_speed_walk), 0.8);
                 break;
 
             case ANIM_JUMP:
-                self.velocity += '0 0 1' * (autocvar_g_turrets_unit_walker_speed_jump);
+                it.velocity += '0 0 1' * (autocvar_g_turrets_unit_walker_speed_jump);
                 break;
 
             case ANIM_LAND:
                 break;
 
             case ANIM_PAIN:
-                if(self.frame != ANIM_PAIN)
-                    defer(self, 0.25, walker_setnoanim);
+                if(it.frame != ANIM_PAIN)
+                    defer(it, 0.25, walker_setnoanim);
 
                 break;
 
             case ANIM_MELEE:
-                if(self.frame != ANIM_MELEE)
+                if(it.frame != ANIM_MELEE)
                 {
-                    defer(self, 0.41, walker_setnoanim);
-                    defer(self, 0.21, walker_melee_do_dmg);
+                    defer(it, 0.41, walker_setnoanim);
+                    defer(it, 0.21, walker_melee_do_dmg);
                 }
 
-                movelib_brake_simple(self, (autocvar_g_turrets_unit_walker_speed_stop));
+                movelib_brake_simple(it, (autocvar_g_turrets_unit_walker_speed_stop));
                 break;
 
             case ANIM_SWIM:
                 turny = (autocvar_g_turrets_unit_walker_turn_swim);
                 turnx = (autocvar_g_turrets_unit_walker_turn_swim);
 
-                self.angles_x += bound(-10, shortangle_f(real_angle_x, self.angles_x), 10);
-                movelib_move_simple(self, v_forward, (autocvar_g_turrets_unit_walker_speed_swim), 0.3);
-                vz = self.velocity_z + sin(time * 4) * 8;
+                it.angles_x += bound(-10, shortangle_f(real_angle_x, it.angles_x), 10);
+                movelib_move_simple(it, v_forward, (autocvar_g_turrets_unit_walker_speed_swim), 0.3);
+                vz = it.velocity_z + sin(time * 4) * 8;
                 break;
 
             case ANIM_ROAM:
                 turny = (autocvar_g_turrets_unit_walker_turn_walk);
-                movelib_move_simple(self, v_forward ,(autocvar_g_turrets_unit_walker_speed_roam), 0.5);
+                movelib_move_simple(it, v_forward ,(autocvar_g_turrets_unit_walker_speed_roam), 0.5);
                 break;
         }
 
         if(turny)
         {
-            turny = bound( turny * -1, shortangle_f(real_angle_y, self.angles_y), turny );
-            self.angles_y += turny;
+            turny = bound( turny * -1, shortangle_f(real_angle_y, it.angles_y), turny );
+            it.angles_y += turny;
         }
 
         if(turnx)
         {
-            turnx = bound( turnx * -1, shortangle_f(real_angle_x, self.angles_x), turnx );
-            self.angles_x += turnx;
+            turnx = bound( turnx * -1, shortangle_f(real_angle_x, it.angles_x), turnx );
+            it.angles_x += turnx;
         }
 
-        self.velocity_z = vz;
+        it.velocity_z = vz;
     }
 
 
-    if(self.origin != self.oldorigin)
-        self.SendFlags |= TNSF_MOVE;
+    if(it.origin != it.oldorigin)
+        it.SendFlags |= TNSF_MOVE;
 
-    self.oldorigin = self.origin;
-    turrets_setframe(self.animflag, false);
+    it.oldorigin = it.origin;
+    turrets_setframe(it, it.animflag, false);
 }
 METHOD(WalkerTurret, tr_death, void(WalkerTurret this, entity it))
 {
@@ -572,7 +553,7 @@ METHOD(WalkerTurret, tr_setup, void(WalkerTurret this, entity it))
     entity e;
 
     // Respawn is called & first spawn to, to set team. need to make sure we do not move the initial spawn.
-    if(it.movetype == MOVETYPE_WALK)
+    if(it.move_movetype == MOVETYPE_WALK)
     {
         if(it.pos1)
             setorigin(it, it.pos1);
@@ -588,10 +569,12 @@ METHOD(WalkerTurret, tr_setup, void(WalkerTurret this, entity it))
     it.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK | TFL_TARGETSELECT_LOS;
     it.iscreature = true;
     it.teleportable = TELEPORT_NORMAL;
+    if(!it.damagedbycontents)
+        IL_PUSH(g_damagedbycontents, it);
     it.damagedbycontents = true;
     it.solid = SOLID_SLIDEBOX;
     it.takedamage = DAMAGE_AIM;
-    if(it.movetype != MOVETYPE_WALK)
+    if(it.move_movetype != MOVETYPE_WALK)
     {
         setorigin(it, it.origin);
         tracebox(it.origin + '0 0 128', it.mins, it.maxs, it.origin - '0 0 10000', MOVE_NORMAL, it);
@@ -599,21 +582,21 @@ METHOD(WalkerTurret, tr_setup, void(WalkerTurret this, entity it))
         it.pos1 = it.origin;
         it.pos2 = it.angles;
     }
-    it.movetype = MOVETYPE_WALK;
+    set_movetype(it, MOVETYPE_WALK);
     it.idle_aim = '0 0 0';
     it.turret_firecheckfunc = walker_firecheck;
 
     if (it.target != "")
     {
-        e = find(world, targetname, it.target);
+        e = find(NULL, targetname, it.target);
         if (!e)
         {
-            LOG_TRACE("Initital waypoint for walker does NOT exsist, fix your map!\n");
+            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\n");
+            LOG_TRACE("Warning: not a turrret path");
         else
         {
 #ifdef WALKER_FANCYPATHING
@@ -643,8 +626,7 @@ void walker_draw(entity this)
     fixedmakevectors(this.angles);
     movelib_groundalign4point(this, 300, 100, 0.25, 45);
     setorigin(this, this.origin + this.velocity * dt);
-    this.tur_head.angles += dt * this.tur_head.move_avelocity;
-    this.angles_y = this.move_angles_y;
+    this.tur_head.angles += dt * this.tur_head.avelocity;
 
     if (this.health < 127)
     if(random() < 0.15)
@@ -654,9 +636,7 @@ void walker_draw(entity this)
         METHOD(WalkerTurret, tr_setup, void(WalkerTurret this, entity it))
         {
             it.gravity         = 1;
-            it.movetype                = MOVETYPE_BOUNCE;
-            it.move_movetype   = MOVETYPE_BOUNCE;
-            it.move_origin     = it.origin;
+            set_movetype(it, MOVETYPE_BOUNCE);
             it.move_time               = time;
             it.draw                    = walker_draw;
         }