}
// Generic damage handling
-void turret_hide()
-{SELFPARAM();
+void turret_hide(entity this)
+{
self.effects |= EF_NODRAW;
self.nextthink = time + self.respawntime - 0.2;
- self.think = turret_respawn;
+ setthink(self, turret_respawn);
}
-void turret_die()
-{SELFPARAM();
+void turret_die(entity this)
+{
self.deadflag = DEAD_DEAD;
self.tur_head.deadflag = self.deadflag;
// Setup respawn
self.SendFlags |= TNSF_STATUS;
self.nextthink = time + 0.2;
- self.think = turret_hide;
+ setthink(self, turret_hide);
tur.tr_death(tur, self);
}
this.tur_head.event_damage = func_null;
this.takedamage = DAMAGE_NO;
this.nextthink = time;
- this.think = turret_die;
+ setthink(this, turret_die);
}
this.SendFlags |= TNSF_STATUS;
}
-void() turret_think;
-void turret_respawn()
-{SELFPARAM();
+void turret_think(entity this);
+void turret_respawn(entity this)
+{
// Make sure all parts belong to the same team since
// this function doubles as "teamchange" function.
self.tur_head.team = self.team;
self.ammo = self.ammo_max;
self.nextthink = time + self.ticrate;
- self.think = turret_think;
+ setthink(self, turret_think);
self.SendFlags = TNSF_FULL_UPDATE;
}
}
-void turret_projectile_explode()
-{SELFPARAM();
+void turret_projectile_explode(entity this)
+{
self.takedamage = DAMAGE_NO;
self.event_damage = func_null;
remove(self);
}
-void turret_projectile_touch()
+void turret_projectile_touch(entity this)
{
PROJECTILE_TOUCH;
- turret_projectile_explode();
+ turret_projectile_explode(this);
}
void turret_projectile_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector vforce)
this.health -= damage;
//this.realowner = attacker; // Dont change realowner, it does not make much sense for turrets
if(this.health <= 0)
- WITHSELF(this, W_PrepareExplosionByDamage(this.owner, turret_projectile_explode));
+ W_PrepareExplosionByDamage(this, this.owner, turret_projectile_explode);
}
entity turret_projectile(Sound _snd, float _size, float _health, float _death, float _proj_type, float _cull, float _cli_anim)
proj.realowner = self;
proj.bot_dodge = true;
proj.bot_dodgerating = self.shot_dmg;
- proj.think = turret_projectile_explode;
- proj.touch = turret_projectile_touch;
+ setthink(proj, turret_projectile_explode);
+ settouch(proj, turret_projectile_touch);
proj.nextthink = time + 9;
proj.movetype = MOVETYPE_FLYMISSILE;
proj.velocity = normalize(self.tur_shotdir_updated + randomvec() * self.shot_spread) * self.shot_speed;
** and updated aim<->predict impact distance.
**/
void turret_do_updates(entity t_turret)
-{SELFPARAM();
- vector enemy_pos;
-
- setself(t_turret);
+{
+ vector enemy_pos = real_origin(t_turret.enemy);
- enemy_pos = real_origin(self.enemy);
+ WITHSELF(t_turret, turret_tag_fire_update());
- turret_tag_fire_update();
+ 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);
- 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);
-
- /*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;
}
/**
#endif
}
-void turret_think()
-{SELFPARAM();
+void turret_think(entity this)
+{
self.nextthink = time + self.ticrate;
MUTATOR_CALLHOOK(TurretThink, self);
When .used a turret switch team to activator.team.
If activator is world, the turret go inactive.
*/
-void turret_use()
-{SELFPARAM();
- LOG_TRACE("Turret ",self.netname, " used by ", activator.classname, "\n");
+void turret_use(entity this, entity actor, entity trigger)
+{
+ LOG_TRACE("Turret ",this.netname, " used by ", actor.classname, "\n");
- self.team = activator.team;
+ this.team = actor.team;
- if(self.team == 0)
- self.active = ACTIVE_NOT;
+ if(this.team == 0)
+ this.active = ACTIVE_NOT;
else
- self.active = ACTIVE_ACTIVE;
+ this.active = ACTIVE_ACTIVE;
}
void turret_link()
{SELFPARAM();
Net_LinkEntity(self, true, 0, turret_send);
- self.think = turret_think;
+ setthink(self, turret_think);
self.nextthink = time;
self.tur_head.effects = EF_NODRAW;
}
-void turrets_manager_think()
+void turrets_manager_think(entity this)
{
- SELFPARAM();
this.nextthink = time + 1;
if (autocvar_g_turrets_reloadcvars == 1)
if(!e)
{
e = new(turret_manager);
- e.think = turrets_manager_think;
+ setthink(e, turrets_manager_think);
e.nextthink = time + 2;
}
#endif
turret_link();
- turret_respawn();
+ turret_respawn(self);
turret_tag_fire_update();
tur.tr_setup(tur, self);