if(self.aim_flags & TFL_AIM_SIMPLE)
return real_origin(self.enemy);
- mintime = max(self.attack_finished_single - time,0) + sys_frametime;
+ mintime = max(self.attack_finished_single[0] - time,0) + sys_frametime;
// Baseline
pre_pos = real_origin(self.enemy);
prep = pre_pos + (self.enemy.velocity * (impact_time + mintime));
if(self.aim_flags & TFL_AIM_ZPREDICT)
- if(!(self.enemy.flags & FL_ONGROUND))
+ if(!IS_ONGROUND(self.enemy))
if(self.enemy.movetype == MOVETYPE_WALK || self.enemy.movetype == MOVETYPE_TOSS || self.enemy.movetype == MOVETYPE_BOUNCE)
{
float vz;
bool turret_send(entity this, entity to, float sf)
{
- WriteByte(MSG_ENTITY, ENT_CLIENT_TURRET);
+ WriteHeader(MSG_ENTITY, ENT_CLIENT_TURRET);
WriteByte(MSG_ENTITY, sf);
if(sf & TNSF_SETUP)
{
return true;
}
-void load_unit_settings(entity ent, float is_reload)
+void load_unit_settings(entity ent, bool is_reload)
{SELFPARAM();
string unitname = ent.netname;
string sbase;
// Ready?
if (self.firecheck_flags & TFL_FIRECHECK_REFIRE)
- if (self.attack_finished_single > time) return 0;
+ if (self.attack_finished_single[0] > time) return 0;
// Special case: volly fire turret that has to fire a full volly if a shot was fired.
if (self.shoot_flags & TFL_SHOOT_VOLLYALWAYS)
Turret info = get_turretinfo(self.m_id);
info.tr_attack(info);
- self.attack_finished_single = time + self.shot_refire;
+ self.attack_finished_single[0] = time + self.shot_refire;
self.ammo -= self.shot_dmg;
self.volly_counter = self.volly_counter - 1;
self.enemy = world;
if (self.shot_volly > 1)
- self.attack_finished_single = time + self.shot_volly_refire;
+ self.attack_finished_single[0] = time + self.shot_volly_refire;
}
#ifdef TURRET_DEBUG
}
void turrets_manager_think()
-{SELFPARAM();
- self.nextthink = time + 1;
+{
+ SELFPARAM();
+ this.nextthink = time + 1;
- entity e;
if (autocvar_g_turrets_reloadcvars == 1)
{
- e = nextent(world);
- while (e)
- {
- if (IS_TURRET(e))
- {
- load_unit_settings(e,1);
- Turret tur = get_turretinfo(self.m_id);
- tur.tr_think(tur);
- }
-
- e = nextent(e);
- }
- cvar_set("g_turrets_reloadcvars","0");
+ FOREACH_ENTITY(IS_TURRET(it), LAMBDA(
+ load_unit_settings(it, true);
+ Turret tur = get_turretinfo(it.m_id);
+ tur.tr_think(tur);
+ ));
+ cvar_set("g_turrets_reloadcvars", "0");
}
}
entity e = find(world, classname, "turret_manager");
if(!e)
{
- e = spawn();
- e.classname = "turret_manager";
+ e = new(turret_manager);
e.think = turrets_manager_think;
e.nextthink = time + 2;
}
self.nextthink = time + 1;
self.nextthink += turret_count * sys_frametime;
- self.tur_head = spawn();
+ self.tur_head = new(turret_head);
_setmodel(self.tur_head, tur.head_model);
setsize(self.tur_head, '0 0 0', '0 0 0');
setorigin(self.tur_head, '0 0 0');
setattachment(self.tur_head, self, "tag_head");
- self.tur_head.netname = self.tur_head.classname = "turret_head";
+ self.tur_head.netname = self.tur_head.classname;
self.tur_head.team = self.team;
self.tur_head.owner = self;
self.tur_head.takedamage = DAMAGE_NO;