/// Function to use for target evaluation. usualy turret_targetscore_generic
.float(entity _turret, entity _target) turret_score_target;
-.float(entity e_target,entity e_sender) turret_addtarget;
+.bool(entity this, entity e_target,entity e_sender) turret_addtarget;
.entity pathcurrent;
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));
+ it.turret_addtarget(it, other, this);
});
this.cnt = time + 0.5;
}
it.tur_head.frame = 0;
}
-float turret_hk_addtarget(entity e_target,entity e_sender);
+bool turret_hk_addtarget(entity this, entity e_target,entity e_sender);
METHOD(HunterKiller, tr_setup, void(HunterKiller this, entity it))
{
it.ammo_flags = TFL_AMMO_ROCKETS | TFL_AMMO_RECHARGE;
it.turret_addtarget = turret_hk_addtarget;
}
-float turret_hk_addtarget(entity e_target,entity e_sender)
-{SELFPARAM();
+bool turret_hk_addtarget(entity this, entity e_target,entity e_sender)
+{
if (e_target)
{
- if (turret_validate_target(self,e_target,self.target_validate_flags) > 0)
+ if (turret_validate_target(this,e_target,this.target_validate_flags) > 0)
{
- self.enemy = e_target;
- return 1;
+ this.enemy = e_target;
+ return true;
}
}
- return 0;
+ return false;
}
#endif // SVQC
}
}
-bool hk_is_valid_target(entity e_target);
+bool hk_is_valid_target(entity this, entity e_target);
void turret_hk_missile_think(entity this)
{
vector vu, vd, vf, vl, vr, ve; // Vector (direction)
e = findradius(self.origin, 5000);
while (e)
{
- if (hk_is_valid_target(e))
+ if (hk_is_valid_target(this, e))
{
if (!self.enemy)
self.enemy = e;
UpdateCSQCProjectile(self);
}
-bool hk_is_valid_target(entity e_target)
-{SELFPARAM();
+bool hk_is_valid_target(entity this, entity e_target)
+{
if (e_target == world)
- return 0;
+ return false;
// If only this was used more..
if (e_target.flags & FL_NOTARGET)
- return 0;
+ return false;
// Cant touch this
if ((e_target.takedamage == DAMAGE_NO) || (e_target.health < 0))
- return 0;
+ return false;
// player
if (IS_CLIENT(e_target))
{
- if (self.owner.target_select_playerbias < 0)
- return 0;
+ if (this.owner.target_select_playerbias < 0)
+ return false;
if (IS_DEAD(e_target))
- return 0;
+ return false;
}
// Missile
- if ((e_target.flags & FL_PROJECTILE) && (self.owner.target_select_missilebias < 0))
- return 0;
+ if ((e_target.flags & FL_PROJECTILE) && (this.owner.target_select_missilebias < 0))
+ return false;
// Team check
- if ((e_target.team == self.owner.team) || (self.owner.team == e_target.owner.team))
- return 0;
+ if ((e_target.team == this.owner.team) || (this.owner.team == e_target.owner.team))
+ return false;
- return 1;
+ return true;
}
#endif
#ifdef SVQC
-entity toast(entity from, float range, float damage);
+entity toast(entity actor, entity from, float range, float damage);
SOUND(TeslaCoilTurretAttack_FIRE, W_Sound("electro_fire"));
METHOD(TeslaCoilTurretAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) {
bool isPlayer = IS_PLAYER(actor);
actor.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_MISSILES | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK;
- entity t = toast(e,r,d);
+ entity t = toast(actor, e,r,d);
remove(e);
if (t == NULL) return;
for (int i = 0; i < 10; ++i) {
d *= 0.75;
r *= 0.85;
- t = toast(t, r, d);
+ t = toast(actor, t, r, d);
if (t == world) break;
}
}
}
-entity toast(entity from, float range, float damage)
-{SELFPARAM();
+entity toast(entity actor, entity from, float range, float damage)
+{
entity e;
entity etarget = world;
float d,dd;
{
if ((e.railgunhit != 1) && (e != from))
{
- r = turret_validate_target(self,e,self.target_validate_flags);
+ r = turret_validate_target(actor,e,actor.target_validate_flags);
if (r > 0)
{
traceline(from.origin,0.5 * (e.absmin + e.absmax),MOVE_WORLDONLY,from);
if (etarget)
{
te_csqc_lightningarc(from.origin,etarget.origin);
- Damage(etarget, self, self, damage, DEATH_TURRET_TESLA.m_id, etarget.origin, '0 0 0');
+ Damage(etarget, actor, actor, damage, DEATH_TURRET_TESLA.m_id, etarget.origin, '0 0 0');
etarget.railgunhit = 1;
}
}
#ifdef TURRET_DEBUG
-void marker_think()
-{SELFPARAM();
- if(self.cnt)
- if(self.cnt < time)
+void marker_think(entity this, )
+{
+ if(this.cnt)
+ if(this.cnt < time)
{
- setthink(self, SUB_Remove);
- self.nextthink = time;
+ setthink(this, SUB_Remove);
+ this.nextthink = time;
return;
}
- self.frame += 1;
- if(self.frame > 29)
- self.frame = 0;
+ this.frame += 1;
+ if(this.frame > 29)
+ this.frame = 0;
- self.nextthink = time;
+ this.nextthink = time;
}
void mark_error(vector where,float lifetime)