** 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;
}
/**
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) ?