// Generic aiming
vector turret_aim_generic()
-{
+{SELFPARAM();
vector pre_pos, prep;
float distance, impact_time = 0, i, mintime;
// Generic damage handling
void turret_hide()
-{
+{SELFPARAM();
self.effects |= EF_NODRAW;
self.nextthink = time + self.respawntime - 0.2;
self.think = turret_respawn;
}
void turret_die()
-{
+{SELFPARAM();
self.deadflag = DEAD_DEAD;
self.tur_head.deadflag = self.deadflag;
}
void turret_damage (entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector vforce)
-{
+{SELFPARAM();
// Enough already!
if(self.deadflag == DEAD_DEAD)
return;
void() turret_think;
void turret_respawn()
-{
+{SELFPARAM();
// Make sure all parts belong to the same team since
// this function doubles as "teamchange" function.
self.tur_head.team = self.team;
#define cvar_base "g_turrets_unit_"
.float clientframe;
void turrets_setframe(float _frame, float client_only)
-{
+{SELFPARAM();
if((client_only ? self.clientframe : self.frame ) != _frame)
{
self.SendFlags |= TNSF_ANIM;
}
float turret_send(entity to, float sf)
-{
+{SELFPARAM();
WriteByte(MSG_ENTITY, ENT_CLIENT_TURRET);
WriteByte(MSG_ENTITY, sf);
}
void load_unit_settings(entity ent, string unitname, float is_reload)
-{
+{SELFPARAM();
string sbase;
if (ent == world)
}
void turret_projectile_explode()
-{
+{SELFPARAM();
self.takedamage = DAMAGE_NO;
self.event_damage = func_null;
}
void turret_projectile_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector vforce)
-{
+{SELFPARAM();
self.velocity += vforce;
self.health -= damage;
//self.realowner = attacker; // Dont change realowner, it does not make much sense for turrets
}
entity turret_projectile(string _snd, float _size, float _health, float _death, float _proj_type, float _cull, float _cli_anim)
-{
+{SELFPARAM();
entity proj;
sound (self, CH_WEAPON_A, _snd, VOL_BASE, ATTEN_NORM);
** and updated aim<->predict impact distance.
**/
void turret_do_updates(entity t_turret)
-{
+{SELFPARAM();
vector enemy_pos;
- entity oldself;
- oldself = self;
- self = t_turret;
+ setself(t_turret);
enemy_pos = real_origin(self.enemy);
self.tur_impactent = trace_ent;
self.tur_impacttime = vlen(self.tur_shotorg - trace_endpos) / self.shot_speed;
- self = oldself;
+ setself(this);
}
/**
**/
.float turret_framecounter;
void turret_track()
-{
+{SELFPARAM();
vector target_angle; // This is where we want to aim
vector move_angle; // This is where we can aim
float f_tmp;
*/
#ifdef TURRET_DEBUG_TARGETSELECT
- dprint("Target:",e_target.netname," is a valid target for ",e_turret.netname,"\n");
+ LOG_TRACE("Target:",e_target.netname," is a valid target for ",e_turret.netname,"\n");
#endif
return 1;
}
entity turret_select_target()
-{
+{SELFPARAM();
entity e; // target looper entity
float score; // target looper entity score
entity e_enemy; // currently best scoreing target
** Preforms pre-fire checks based on the uints firecheck_flags
**/
float turret_firecheck()
-{
+{SELFPARAM();
// This one just dont care =)
if (self.firecheck_flags & TFL_FIRECHECK_NO)
return 1;
return 1;
}
+bool turret_checkfire()
+{SELFPARAM();
+ bool ret = false; // dummy
+ if(MUTATOR_CALLHOOK(Turret_CheckFire, ret))
+ return ret_bool;
+
+ return self.turret_firecheckfunc();
+}
+
void turret_fire()
-{
+{SELFPARAM();
if (autocvar_g_turrets_nofire != 0)
return;
+ if(MUTATOR_CALLHOOK(TurretFire, self))
+ return;
+
TUR_ACTION(self.turretid, TR_ATTACK);
self.attack_finished_single = time + self.shot_refire;
}
void turret_think()
-{
+{SELFPARAM();
entity e;
self.nextthink = time + self.ticrate;
turret_do_updates(self);
- if (self.turret_firecheckfunc())
+ if (turret_checkfire())
turret_fire();
}
}
turret_do_updates(self);
// Fire?
- if (self.turret_firecheckfunc())
+ if (turret_checkfire())
turret_fire();
}
else
turret_do_updates(self);
// Fire!
- if (self.turret_firecheckfunc() != 0)
+ if (turret_checkfire())
turret_fire();
TUR_ACTION(self.turretid, TR_THINK);
turret_do_updates(self);
// Fire?
- if (self.turret_firecheckfunc())
+ if (turret_checkfire())
turret_fire();
}
If activator is world, the turret go inactive.
*/
void turret_use()
-{
- dprint("Turret ",self.netname, " used by ", activator.classname, "\n");
+{SELFPARAM();
+ LOG_TRACE("Turret ",self.netname, " used by ", activator.classname, "\n");
self.team = activator.team;
}
void turret_link()
-{
+{SELFPARAM();
Net_LinkEntity(self, true, 0, turret_send);
self.think = turret_think;
self.nextthink = time;
}
void turrets_manager_think()
-{
+{SELFPARAM();
self.nextthink = time + 1;
entity e;
}
float turret_initialize(float tur_id)
-{
+{SELFPARAM();
if(!autocvar_g_turrets)
return false;
if (self.tur_defend == world)
{
self.target = "";
- dprint("Turret has invalid defendpoint!\n");
+ LOG_TRACE("Turret has invalid defendpoint!\n");
}
}