From 481f6b7a743aa4db7e8cfdc5d41eecc2b7af06fb Mon Sep 17 00:00:00 2001 From: TimePath Date: Sun, 22 May 2016 14:44:26 +1000 Subject: [PATCH] Kill more setself --- qcsrc/common/turrets/sv_turrets.qc | 42 ++++++++++++--------------- qcsrc/common/turrets/targettrigger.qc | 27 +++++------------ 2 files changed, 25 insertions(+), 44 deletions(-) diff --git a/qcsrc/common/turrets/sv_turrets.qc b/qcsrc/common/turrets/sv_turrets.qc index 2578c1e6d..f8101535e 100644 --- a/qcsrc/common/turrets/sv_turrets.qc +++ b/qcsrc/common/turrets/sv_turrets.qc @@ -499,39 +499,33 @@ entity turret_projectile(Sound _snd, float _size, float _health, float _death, f ** and updated aim<->predict impact distance. **/ void turret_do_updates(entity t_turret) -{SELFPARAM(); - vector enemy_pos; - - setself(t_turret); - - enemy_pos = real_origin(self.enemy); +{ + vector enemy_pos = real_origin(t_turret.enemy); - turret_tag_fire_update(); + WITHSELF(t_turret, turret_tag_fire_update()); - self.tur_shotdir_updated = v_forward; - self.tur_dist_enemy = vlen(self.tur_shotorg - enemy_pos); - self.tur_dist_aimpos = vlen(self.tur_shotorg - self.tur_aimpos); + t_turret.tur_shotdir_updated = v_forward; + t_turret.tur_dist_enemy = vlen(t_turret.tur_shotorg - enemy_pos); + t_turret.tur_dist_aimpos = vlen(t_turret.tur_shotorg - t_turret.tur_aimpos); - /*if((self.firecheck_flags & TFL_FIRECHECK_VERIFIED) && (self.enemy)) + /*if((t_turret.firecheck_flags & TFL_FIRECHECK_VERIFIED) && (t_turret.enemy)) { - oldpos = self.enemy.origin; - setorigin(self.enemy, self.tur_aimpos); - tracebox(self.tur_shotorg, '-1 -1 -1', '1 1 1', self.tur_shotorg + (self.tur_shotdir_updated * self.tur_dist_aimpos), MOVE_NORMAL,self); - setorigin(self.enemy, oldpos); + oldpos = t_turret.enemy.origin; + setorigin(t_turret.enemy, t_turret.tur_aimpos); + tracebox(t_turret.tur_shotorg, '-1 -1 -1', '1 1 1', t_turret.tur_shotorg + (t_turret.tur_shotdir_updated * t_turret.tur_dist_aimpos), MOVE_NORMAL,t_turret); + setorigin(t_turret.enemy, oldpos); - if(trace_ent == self.enemy) - self.tur_dist_impact_to_aimpos = 0; + if(trace_ent == t_turret.enemy) + t_turret.tur_dist_impact_to_aimpos = 0; else - self.tur_dist_impact_to_aimpos = vlen(trace_endpos - self.tur_aimpos); + t_turret.tur_dist_impact_to_aimpos = vlen(trace_endpos - t_turret.tur_aimpos); } else*/ - tracebox(self.tur_shotorg, '-1 -1 -1','1 1 1', self.tur_shotorg + (self.tur_shotdir_updated * self.tur_dist_aimpos), MOVE_NORMAL,self); - - self.tur_dist_impact_to_aimpos = vlen(trace_endpos - self.tur_aimpos) - (vlen(self.enemy.maxs - self.enemy.mins) * 0.5); - self.tur_impactent = trace_ent; - self.tur_impacttime = vlen(self.tur_shotorg - trace_endpos) / self.shot_speed; + tracebox(t_turret.tur_shotorg, '-1 -1 -1','1 1 1', t_turret.tur_shotorg + (t_turret.tur_shotdir_updated * t_turret.tur_dist_aimpos), MOVE_NORMAL,t_turret); - setself(this); + t_turret.tur_dist_impact_to_aimpos = vlen(trace_endpos - t_turret.tur_aimpos) - (vlen(t_turret.enemy.maxs - t_turret.enemy.mins) * 0.5); + t_turret.tur_impactent = trace_ent; + t_turret.tur_impacttime = vlen(t_turret.tur_shotorg - trace_endpos) / t_turret.shot_speed; } /** diff --git a/qcsrc/common/turrets/targettrigger.qc b/qcsrc/common/turrets/targettrigger.qc index d3deda070..aa1322c44 100644 --- a/qcsrc/common/turrets/targettrigger.qc +++ b/qcsrc/common/turrets/targettrigger.qc @@ -3,26 +3,13 @@ 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) ? -- 2.39.2