// checks if the current item may be spawned (self.items and self.weapons may be read and written to, as well as the ammo_ fields)
// return error to request removal
+MUTATOR_HOOKABLE(TurretSpawn);
+ // return error to request removal
+ // INPUT: self - turret
+
MUTATOR_HOOKABLE(OnEntityPreSpawn);
// return error to prevent entity spawn, or modify the entity
vector turret_stdproc_aim_generic()
{
- vector pre_pos,prep;
- float distance,impact_time,i,mintime;
+ vector pre_pos, prep;
+ float distance, impact_time, i, mintime;
turret_tag_fire_update();
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 - time,0) + sys_frametime;
// Baseline
pre_pos = real_origin(self.enemy);
// thorw head slightly off aim when hit?
if (self.damage_flags & TFL_DMG_HEADSHAKE)
{
- //baseent.tur_aimoff_x += (random() * damage);
- //baseent.tur_aimoff_y += ((random()*0.75) * damage);
self.tur_head.angles_x = self.tur_head.angles_x + (-0.5 + random()) * damage;
self.tur_head.angles_y = self.tur_head.angles_y + (-0.5 + random()) * damage;
}
if (self.turrcaps_flags & TFL_TURRCAPS_MOVE)
self.velocity = self.velocity + vforce;
- // FIXME: Better damage feedback
- // Start burning when we have 10% or less health left
- //if (self.health < (self.tur_health * 0.1))
- // self.effects = EF_FLAME;
-
+ // FIXME: Better damage feedback?
+
if (self.health <= 0)
{
self.event_damage = SUB_Null;
if (self.ammo < self.ammo_max)
self.ammo = min(self.ammo + self.ammo_recharge, self.ammo_max);
+ if (self.health < (self.tur_health * 0.5))
+ if(random() < 0.25)
+ te_spark(self.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);
+
// Inactive turrets needs to run the think loop,
// So they can handle animation and wake up if need be.
if not (self.tur_active)
{
e = spawn();
+ /*
setorigin(e,'0 0 0');
setmodel(e,"models/turrets/plasma.md3");
vector v;
//crash();
}
setmodel(e,"");
+ */
e.classname = "turret_manager";
e.think = turrets_manager_think;
// Offsets & origins
if (!self.tur_shotorg) self.tur_shotorg = '50 0 50';
+// Gane hooks
+ if(MUTATOR_CALLHOOK(TurretSpawn))
+ return 0;
+
// End of default & sanety checks, start building the turret.
// Spawn extra bits
activator = ee;
self.use();
}
-
+
turret_stdproc_respawn();
return 1;
}
void turret_fusionreactor_dinit();
void turret_fusionreactor_fire();
-float turret_fusionreactor_firecheck()
-{
- if (self.enemy == world) return 0;
- if not (self.enemy.ammo_flags & TFL_AMMO_RECIVE) return 0;
- if not (self.enemy.ammo_flags & TFL_AMMO_ENERGY) return 0;
- if (self.ammo < self.shot_dmg) return 0;
- if (self.enemy.ammo >= self.enemy.ammo_max) return 0;
- if (self.tur_dist_aimpos > self.target_range) return 0;
- if (self.tur_dist_aimpos < self.target_range_min) return 0;
-
- return 1;
-}
-
void turret_fusionreactor_fire()
{
vector fl_org;
self.enemy.ammo = min(self.enemy.ammo + self.shot_dmg,self.enemy.ammo_max);
fl_org = 0.5 * (self.enemy.absmin + self.enemy.absmax);
te_smallflash(fl_org);
- //te_lightning1(world,self.origin,self.enemy.origin);
}
void turret_fusionreactor_postthink()
{
- float f;
- f = self.ammo / self.ammo_max;
- self.tur_head.avelocity = '0 250 0' * f;
+ self.tur_head.avelocity = '0 250 0' * (self.ammo / self.ammo_max);
}
+/*
void turret_fusionreactor_respawnhook()
{
self.tur_head.avelocity = '0 50 0';
}
+*/
+
+/**
+** Preforms pre-fire checks for fusionreactor
+**/
+float turret_fusionreactor_firecheck()
+{
+ if (self.attack_finished_single > time)
+ return 0;
+
+ if (self.enemy.deadflag != DEAD_NO)
+ return 0;
+
+ if (self.enemy == world)
+ return 0;
+
+ if (self.ammo < self.shot_dmg)
+ return 0;
+
+ if (self.enemy.ammo >= self.enemy.ammo_max)
+ return 0;
+
+ if (vlen(self.enemy.origin - self.origin) > self.target_range)
+ return 0;
+
+ if(self.team != self.enemy.team)
+ return 0;
+
+ if not (self.enemy.ammo_flags & TFL_AMMO_ENERGY)
+ return 0;
+
+ return 1;
+}
void turret_fusionreactor_dinit()
{
self.shoot_flags = TFL_SHOOT_HITALLVALID;
self.aim_flags = TFL_AIM_NO;
self.track_flags = TFL_TRACK_NO;
- self.turret_respawnhook = turret_fusionreactor_respawnhook;
+ // self.turret_respawnhook = turret_fusionreactor_respawnhook;
if (turret_stdproc_init("fusreac_std",0,"models/turrets/base.md3","models/turrets/reactor.md3") == 0)
{