ent.turret_respawnhook();
}
+void turret_projectile_explode()
+{
+ self.takedamage = DAMAGE_NO;
+ self.event_damage = SUB_Null;
+
+#ifdef TURRET_DEBUG
+ float d;
+ d = RadiusDamage (self, self.owner, self.owner.shot_dmg, 0, self.owner.shot_radius, self, self.owner.shot_force, self.totalfrags, world);
+ self.owner.tur_dbg_dmg_t_h = self.owner.tur_dbg_dmg_t_h + d;
+ self.owner.tur_dbg_dmg_t_f = self.owner.tur_dbg_dmg_t_f + self.owner.shot_dmg;
+#else
+ RadiusDamage (self, self.realowner, self.owner.shot_dmg, 0, self.owner.shot_radius, self, self.owner.shot_force, self.totalfrags, world);
+#endif
+ remove(self);
+}
+
+void turret_projectile_touch()
+{
+ PROJECTILE_TOUCH;
+ turret_projectile_explode();
+}
+
+void turret_projectile_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector vforce)
+{
+ self.velocity += vforce;
+ self.health -= damage;
+ //self.realowner = attacker; // Dont change realowner, it does not make much sense for turrets
+ if(self.health <= 0)
+ turret_projectile_explode();
+}
+
+entity turret_projectile(string _snd, float _size, float _health, float _death, float _proj_type, float _cull, float _cli_anim)
+{
+ entity proj;
+
+ sound (self, CH_WEAPON_A, _snd, VOL_BASE, ATTN_NORM);
+ proj = spawn ();
+ setorigin(proj, self.tur_shotorg);
+ setsize(proj, '-0.5 -0.5 -0.5' * _size, '0.5 0.5 0.5' * _size);
+ proj.owner = self;
+ proj.realowner = self;
+ proj.bot_dodge = TRUE;
+ proj.bot_dodgerating = self.shot_dmg;
+ proj.think = turret_projectile_explode;
+ proj.touch = 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;
+ proj.flags = FL_PROJECTILE;
+ proj.enemy = self.enemy;
+ proj.totalfrags = _death;
+ PROJECTILE_MAKETRIGGER(proj);
+ if(_health)
+ {
+ proj.health = _health;
+ proj.takedamage = DAMAGE_YES;
+ proj.event_damage = turret_projectile_damage;
+ }
+ else
+ proj.flags |= FL_NOTARGET;
+
+ CSQCProjectile(proj, _cli_anim, _proj_type, _cull);
+
+ return proj;
+}
+
/**
** updates enemy distances, predicted impact point/time
** and updated aim<->predict impact distance.
* if it hits a glitch in my logic :P so try to set as mutch
* as possible beforehand.
*/
- if (self.turrcaps_flags & TFL_TURRCAPS_SUPPORT)
- self.ticrate = 0.2; // Support units generaly dont need to have a high speed ai-loop
- else
- self.ticrate = 0.1; // 10 fps for normal turrets
-
+ if not(self.ticrate)
+ {
+ if (self.turrcaps_flags & TFL_TURRCAPS_SUPPORT)
+ self.ticrate = 0.2; // Support units generaly dont need to have a high speed ai-loop
+ else
+ self.ticrate = 0.1; // 10 fps for normal turrets
+ }
+
self.ticrate = bound(sys_frametime, self.ticrate, 60); // keep it sane
// General stuff
#define ewheel_amin_bck_slow 3
#define ewheel_amin_bck_fast 4
-void turret_ewheel_projectile_explode()
-{
-#ifdef TURRET_DEBUG
- float d;
-
- d = RadiusDamage (self, self.owner, self.owner.shot_dmg, 0, self.owner.shot_radius, world, self.owner.shot_force, DEATH_TURRET_EWHEEL, world);
- self.owner.tur_dbg_dmg_t_h = self.owner.tur_dbg_dmg_t_h + d;
- self.owner.tur_dbg_dmg_t_f = self.owner.tur_dbg_dmg_t_f + self.owner.shot_dmg;
-#else
- RadiusDamage (self, self.owner, self.owner.shot_dmg, 0, self.owner.shot_radius, world, self.owner.shot_force, DEATH_TURRET_EWHEEL, world);
-#endif
-
- remove (self);
-}
void ewheel_attack()
{
- entity proj;
float i;
for (i = 0; i < 1; ++i)
{
turret_do_updates(self);
- sound (self, CH_WEAPON_A, "weapons/lasergun_fire.wav", VOL_BASE, ATTN_NORM);
+ turret_projectile("weapons/lasergun_fire.wav", 1, 0, DEATH_TURRET_EWHEEL, PROJECTILE_LASER, TRUE, TRUE);
pointparticles(particleeffectnum("laser_muzzleflash"), self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
- proj = spawn ();
- setorigin(proj, self.tur_shotorg);
- proj.classname = "ewheel bolt";
- proj.owner = self;
- proj.bot_dodge = FALSE;
- proj.bot_dodgerating = self.shot_dmg;
- proj.think = turret_ewheel_projectile_explode;
- proj.nextthink = time + 9;
- //proj.solid = SOLID_TRIGGER;
- proj.movetype = MOVETYPE_FLYMISSILE;
- proj.velocity = normalize(self.tur_shotdir_updated + randomvec() * self.shot_spread) * self.shot_speed;
- proj.touch = turret_ewheel_projectile_explode;
- proj.enemy = self.enemy;
- proj.flags = FL_PROJECTILE | FL_NOTARGET;
- PROJECTILE_MAKETRIGGER(proj);
-
- CSQCProjectile(proj, TRUE, PROJECTILE_LASER, TRUE);
-
self.tur_head.frame += 2;
if (self.tur_head.frame > 3)
void spawnfunc_turret_flac();
void turret_flac_dinit();
void turret_flac_attack();
-void turret_flac_projectile_explode();
-void turret_flac_attack()
-{
- entity proj;
-
- turret_tag_fire_update();
-
- sound (self, CH_WEAPON_A, "weapons/hagar_fire.wav", VOL_BASE, ATTN_NORM);
- proj = spawn ();
- setorigin(proj, self.tur_shotorg);
- setsize(proj, '0 0 0', '0 0 0');
- proj.classname = "flac_projectile";
- proj.owner = self;
- proj.bot_dodge = TRUE;
- proj.bot_dodgerating = self.shot_dmg;
- proj.solid = SOLID_BBOX;
- proj.movetype = MOVETYPE_FLYMISSILE;
- proj.flags = FL_PROJECTILE;
- proj.takedamage = DAMAGE_NO;
- proj.velocity = normalize(self.tur_shotdir_updated + randomvec() * self.shot_spread) * self.shot_speed;
- proj.angles = vectoangles(proj.velocity);
- proj.touch = turret_flac_projectile_explode;
- proj.think = turret_flac_projectile_explode;
- proj.nextthink = time + max(self.tur_impacttime,(self.shot_radius * 3) / self.shot_speed);
- proj.enemy = self.enemy;
- proj.cnt = time + 5;
-
- CSQCProjectile(proj, TRUE, PROJECTILE_HAGAR, TRUE);
-
- self.tur_head.frame = self.tur_head.frame + 1;
- if (self.tur_head.frame >= 4) self.tur_head.frame = 0;
-
-}
-
-void turret_flac_projectile_explode()
+void turret_flac_projectile_think_explode()
{
- if( (self.enemy != world) &&
- (vlen(self.origin - self.enemy.origin) < self.owner.shot_radius * 3) )
- {
- // OMG HAXX!
+ if(self.enemy != world)
+ if(vlen(self.origin - self.enemy.origin) < self.owner.shot_radius * 3)
setorigin(self,self.enemy.origin + randomvec() * self.owner.shot_radius);
- }
+
+ self.takedamage = DAMAGE_NO;
self.event_damage = SUB_Null;
-
+
#ifdef TURRET_DEBUG
- float ftmp;
- ftmp = RadiusDamage (self, self.owner, self.owner.shot_dmg, 0, self.owner.shot_radius, world, self.owner.shot_force, DEATH_TURRET_FLAC, world);
- self.owner.tur_dbg_dmg_t_h = self.owner.tur_dbg_dmg_t_h + ftmp; //self.owner.shot_dmg;
+ float d;
+ d = RadiusDamage (self, self.owner, self.owner.shot_dmg, self.owner.shot_dmg, self.owner.shot_radius, self, self.owner.shot_force, self.totalfrags, world);
+ self.owner.tur_dbg_dmg_t_h = self.owner.tur_dbg_dmg_t_h + d;
self.owner.tur_dbg_dmg_t_f = self.owner.tur_dbg_dmg_t_f + self.owner.shot_dmg;
#else
- RadiusDamage (self, self.owner, self.owner.shot_dmg, self.owner.shot_dmg * 0.5, self.owner.shot_radius, world, self.owner.shot_force, DEATH_TURRET_FLAC, world);
+ RadiusDamage (self, self.realowner, self.owner.shot_dmg, self.owner.shot_dmg, self.owner.shot_radius, self, self.owner.shot_force, self.totalfrags, world);
#endif
-
- remove (self);
+ remove(self);
}
+void turret_flac_attack()
+{
+ entity proj;
+
+ turret_tag_fire_update();
+
+ proj = turret_projectile("weapons/hagar_fire.wav", 5, 0, DEATH_TURRET_FLAC, PROJECTILE_HAGAR, TRUE, TRUE);
+ pointparticles(particleeffectnum("laser_muzzleflash"), self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
+ proj.think = turret_flac_projectile_think_explode;
+ proj.nextthink = time + self.tur_impacttime + (random() * 0.01 - random() * 0.01);
+
+ self.tur_head.frame = self.tur_head.frame + 1;
+ if (self.tur_head.frame >= 4)
+ self.tur_head.frame = 0;
+
+}
void turret_flac_dinit()
{
- if (self.netname == "") self.netname = "FLAC Cannon";
+ if (self.netname == "")
+ self.netname = "FLAC Cannon";
self.turrcaps_flags = TFL_TURRCAPS_RADIUSDMG | TFL_TURRCAPS_FASTPROJ | TFL_TURRCAPS_MISSILEKILL;
self.ammo_flags = TFL_AMMO_ROCKETS | TFL_AMMO_RECHARGE;
self.aim_flags = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE;
-
+
if (turret_stdproc_init("flac_std", "models/turrets/base.md3", "models/turrets/flac.md3", TID_FLAC) == 0)
{
remove(self);
self.damage_flags |= TFL_DMG_HEADSHAKE;
self.target_select_flags |= TFL_TARGETSELECT_NOTURRETS | TFL_TARGETSELECT_MISSILESONLY;
-
-
+
// Our fire routine
self.turret_firefunc = turret_flac_attack;
-.float shot_speed_max;
-.float shot_speed_gain;
-
void spawnfunc_turret_hellion();
void turret_hellion_dinit();
void turret_hellion_attack();
-void turret_hellion_missile_explode();
-void turret_hellion_missile_think();
-void turret_hellion_missile_damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector vforce)
-
-void turret_hellion_postthink()
-{
- if (autocvar_g_turrets_reloadcvars)
- {
- if (!self.shot_speed_max) self.shot_speed_max = autocvar_g_turrets_unit_hellion_std_shot_speed_max;
- if (!self.shot_speed_gain) self.shot_speed_gain = autocvar_g_turrets_unit_hellion_std_shot_speed_gain;
- }
-
- if (self.tur_head.frame != 0)
- self.tur_head.frame += 1;
-
- if (self.tur_head.frame >= 7)
- self.tur_head.frame = 0;
-}
-
-void turret_hellion_attack()
-{
- entity missile;
-
- if(self.tur_head.frame != 0)
- self.tur_shotorg = gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_fire"));
- else
- self.tur_shotorg = gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_fire2"));
-
- sound (self, CH_WEAPON_A, "weapons/hagar_fire.wav", VOL_BASE, ATTN_NORM);
-
- missile = spawn ();
- setorigin(missile, self.tur_shotorg);
- setsize (missile, '-3 -3 -3', '3 3 3'); // give it some size so it can be shot
-
- missile.classname = "hellion_missile";
- missile.owner = self;
- missile.bot_dodge = TRUE;
- missile.bot_dodgerating = self.shot_dmg;
- missile.takedamage = DAMAGE_YES;
- missile.event_damage = turret_hellion_missile_damage;
- missile.damageforcescale = 2;
- missile.health = 10;
- missile.enemy = self.enemy;
- missile.think = turret_hellion_missile_think;
- missile.nextthink = time;// + 0.2;
- missile.solid = SOLID_BBOX;
- missile.movetype = MOVETYPE_FLY;
- missile.velocity = normalize(self.tur_shotdir_updated + randomvec() * self.shot_spread) * self.shot_speed;
- missile.angles = vectoangles(missile.velocity);
- missile.touch = turret_hellion_missile_explode;
- missile.flags = FL_PROJECTILE;
- missile.solid = SOLID_BBOX;
- missile.tur_health = time + 9;
- missile.tur_aimpos = randomvec() * 128;
- te_explosion (missile.origin);
- CSQCProjectile(missile, FALSE, PROJECTILE_ROCKET, FALSE); // no culling, has fly sound
-
- self.tur_head.frame += 1;
-}
-
-void turret_hellion_missile_damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector vforce)
-{
- self.health = self.health - damage;
- self.velocity = self.velocity + vforce;
- if (self.health <= 0) turret_hellion_missile_explode();
-}
void turret_hellion_missile_think()
{
olddir = normalize(self.velocity);
if(self.tur_health < time)
- turret_hellion_missile_explode();
+ turret_projectile_explode();
// Enemy dead? just keep on the current heading then.
if ((self.enemy == world) || (self.enemy.deadflag != DEAD_NO))
self.angles = vectoangles(self.velocity);
if ( (vlen(self.origin - self.owner.origin)) > (self.owner.shot_radius * 5) )
- turret_hellion_missile_explode();
+ turret_projectile_explode();
// Accelerate
- self.velocity = olddir * min(vlen(self.velocity) * self.owner.shot_speed_gain,self.owner.shot_speed_max);
+ self.velocity = olddir * min(vlen(self.velocity) * autocvar_g_turrets_unit_hellion_std_shot_speed_gain, autocvar_g_turrets_unit_hellion_std_shot_speed_max);
UpdateCSQCProjectile(self);
// Enemy in range?
if (vlen(self.origin - self.enemy.origin) < self.owner.shot_radius * 0.2)
- turret_hellion_missile_explode();
+ turret_projectile_explode();
// Predict enemy position
itime = vlen(self.enemy.origin - self.origin) / vlen(self.velocity);
self.angles = vectoangles(self.velocity);
// Accelerate
- self.velocity = newdir * min(vlen(self.velocity) * self.owner.shot_speed_gain,self.owner.shot_speed_max);
+ self.velocity = newdir * min(vlen(self.velocity) * autocvar_g_turrets_unit_hellion_std_shot_speed_gain, autocvar_g_turrets_unit_hellion_std_shot_speed_max);
if (itime < 0.05)
- self.think = turret_hellion_missile_explode;
+ self.think = turret_projectile_explode;
UpdateCSQCProjectile(self);
}
-
-void turret_hellion_missile_explode()
+void turret_hellion_attack()
{
- float d;
-
- if(self.event_damage != SUB_Null)
- {
- self.event_damage = SUB_Null;
- self.think = turret_hellion_missile_explode;
- self.nextthink = time;
- return;
- }
-
- self.event_damage = SUB_Null;
- d = RadiusDamage (self, self.owner, self.owner.shot_dmg, 0, self.owner.shot_radius, world, self.owner.shot_force, DEATH_TURRET_HELLION, world);
-
-#ifdef TURRET_DEBUG
- self.owner.tur_dbg_dmg_t_h = self.owner.tur_dbg_dmg_t_h + d; //self.owner.shot_dmg;
- self.owner.tur_dbg_dmg_t_f = self.owner.tur_dbg_dmg_t_f + self.owner.shot_dmg;
-#endif
+ entity missile;
+
+ if(self.tur_head.frame != 0)
+ self.tur_shotorg = gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_fire"));
+ else
+ self.tur_shotorg = gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_fire2"));
+
+ missile = turret_projectile("weapons/rocket_fire.wav", 6, 10, DEATH_TURRET_HELLION, PROJECTILE_ROCKET, FALSE, FALSE);
+ te_explosion (missile.origin);
+ missile.think = turret_hellion_missile_think;
+ missile.nextthink = time;
+ missile.flags = FL_PROJECTILE;
+ missile.tur_health = time + 9;
+ missile.tur_aimpos = randomvec() * 128;
+ self.tur_head.frame += 1;
+}
- // Target dead, get another is still targeting the same.
- if ((self.enemy.deadflag != DEAD_NO) && (self.enemy == self.owner.enemy))
- self.owner.enemy = world;
+void turret_hellion_postthink()
+{
+ if (self.tur_head.frame != 0)
+ self.tur_head.frame += 1;
- remove (self);
+ if (self.tur_head.frame >= 7)
+ self.tur_head.frame = 0;
}
void turret_hellion_dinit()
{
if (self.netname == "") self.netname = "Hellion Missile Turret";
- if not (self.shot_speed_max)
- self.shot_speed_max = autocvar_g_turrets_unit_hellion_std_shot_speed_max;
-
- if not (self.shot_speed_gain)
- self.shot_speed_gain = autocvar_g_turrets_unit_hellion_std_shot_speed_gain;
-
self.turrcaps_flags = TFL_TURRCAPS_RADIUSDMG | TFL_TURRCAPS_FASTPROJ | TFL_TURRCAPS_PLAYERKILL | TFL_TURRCAPS_MISSILEKILL;
self.aim_flags = TFL_AIM_SIMPLE;
self.target_select_flags = TFL_TARGETSELECT_LOS | TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMTS | TFL_TARGETSELECT_TEAMCHECK ;
void spawnfunc_turret_hk();
void turret_hk_dinit();
void turret_hk_attack();
-void turret_hk_missile_explode();
-void turret_hk_missile_think();
-void turret_hk_missile_damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force);
-float turret_hk_addtarget(entity e_target,entity e_sender);
-//void turret_hk_missile_touch();
-
-float hk_maxspeed;
-float hk_minspeed;
-float hk_accel;
-float hk_accel2;
-float hk_decel;
-float turret_hk_addtarget(entity e_target,entity e_sender)
-{
- if (e_target)
- {
- if (turret_validate_target(self,e_target,self.target_validate_flags) > 0)
- {
- self.enemy = e_target;
- return 1;
- }
- }
-
- return 0;
-}
float hk_is_valid_target(entity e_target)
{
return 1;
}
-
-void turret_hk_missile_damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
-{
- if (attacker.team == self.team)
- damage *= 0.5;
-
- self.velocity += force;
-
- self.health -= damage;
-
- if (self.health <= 0)
- turret_hk_missile_explode();
-}
-
-void turret_hk_attack()
-{
- entity missile;
- //entity flash2;
-
- sound (self, CH_WEAPON_A, "weapons/rocket_fire.wav", VOL_BASE, ATTN_NORM);
-
- missile = spawn ();
- missile.solid = SOLID_BBOX;
- setsize (missile, '-3 -3 -3', '3 3 3'); // give it some size so it can be shot
- setorigin(missile, self.tur_shotorg);
-
- missile.scale = 1;
- missile.classname = "hk_missile";
- missile.owner = self;
- missile.bot_dodge = TRUE;
- missile.bot_dodgerating = self.shot_dmg;
- missile.takedamage = DAMAGE_YES;
- missile.damageforcescale = 4;
- missile.health = 10;
- missile.think = turret_hk_missile_think;
- missile.event_damage = turret_hk_missile_damage;
- missile.nextthink = time + 0.25;
- missile.movetype = MOVETYPE_BOUNCEMISSILE;
- missile.velocity = self.tur_shotdir_updated * (self.shot_speed * 0.75);
- missile.angles = vectoangles(missile.velocity);
- missile.touch = turret_hk_missile_explode; //turret_hk_missile_touch;
- missile.flags = FL_PROJECTILE;
- missile.enemy = self.enemy;
- missile.team = self.team;
- missile.cnt = time + 30;
- missile.ticrate = max(autocvar_sys_ticrate,0.05);
-
- CSQCProjectile(missile, FALSE, PROJECTILE_ROCKET, FALSE); // no culling, fly sound
-
- te_explosion (missile.origin);
-
- if (self.tur_head.frame == 0)
- self.tur_head.frame = self.tur_head.frame + 1;
-
-}
-
void turret_hk_missile_think()
{
vector vu, vd, vf, vl, vr, ve; // Vector (direction)
// Close enougth to do decent damage?
if ( edist <= (self.owner.shot_radius * 0.25) )
{
- turret_hk_missile_explode();
+ turret_projectile_explode();
return;
}
ad = vlen(vectoangles(normalize(self.enemy.origin - self.origin)) - self.angles);
// To close to something, Slow down!
- if ( ((ff < 0.7) || (ad > 4)) && (myspeed > hk_minspeed) )
- myspeed = max(myspeed * hk_decel,hk_minspeed);
+ if ( ((ff < 0.7) || (ad > 4)) && (myspeed > autocvar_g_turrets_unit_hk_std_shot_speed) )
+ myspeed = max(myspeed * autocvar_g_turrets_unit_hk_std_shot_speed_decel, autocvar_g_turrets_unit_hk_std_shot_speed);
// Failry clear, accelerate.
- if ( (ff > 0.7) && (myspeed < hk_maxspeed) )
- myspeed = min(myspeed * hk_accel,hk_maxspeed);
+ if ( (ff > 0.7) && (myspeed < autocvar_g_turrets_unit_hk_std_shot_speed_max) )
+ myspeed = min(myspeed * autocvar_g_turrets_unit_hk_std_shot_speed_accel, autocvar_g_turrets_unit_hk_std_shot_speed_max);
// Setup trace pitch
pt_seek = 1 - ff;
{
// Got a clear path to target, speed up fast (if not at full speed) and go straight for it.
myspeed = vlen(self.velocity);
- if (myspeed < hk_maxspeed)
- myspeed = min(myspeed * hk_accel2,hk_maxspeed);
+ if (myspeed < autocvar_g_turrets_unit_hk_std_shot_speed_max)
+ myspeed = min(myspeed * autocvar_g_turrets_unit_hk_std_shot_speed_accel2,autocvar_g_turrets_unit_hk_std_shot_speed_max);
wishdir = ve;
}
- if ((myspeed > hk_minspeed) && (self.cnt > time))
- myspeed = min(myspeed * hk_accel2,hk_maxspeed);
+ if ((myspeed > autocvar_g_turrets_unit_hk_std_shot_speed) && (self.cnt > time))
+ myspeed = min(myspeed * autocvar_g_turrets_unit_hk_std_shot_speed_accel2,autocvar_g_turrets_unit_hk_std_shot_speed_max);
// Ranoutagazfish?
if (self.cnt < time)
UpdateCSQCProjectile(self);
}
-void turret_hk_missile_explode()
+void turret_hk_attack()
{
- float d;
-
- if(self.event_damage != SUB_Null)
- {
- self.event_damage = SUB_Null;
- self.think = turret_hk_missile_explode;
- self.nextthink = time;
- return;
- }
-
- if ((other == self.owner)||(other == self.owner.tur_head))
- return;
+ entity missile;
- self.event_damage = SUB_Null;
- d = RadiusDamage (self, self.owner, self.owner.shot_dmg, 0, self.owner.shot_radius, world, self.owner.shot_force, DEATH_TURRET_HK, world);
+ missile = turret_projectile("weapons/rocket_fire.wav", 6, 10, DEATH_TURRET_HK, PROJECTILE_ROCKET, FALSE, FALSE);
+ te_explosion (missile.origin);
-#ifdef TURRET_DEBUG
- self.owner.tur_dbg_dmg_t_h = self.owner.tur_dbg_dmg_t_h + d; //self.owner.shot_dmg;
- self.owner.tur_dbg_dmg_t_f = self.owner.tur_dbg_dmg_t_f + self.owner.shot_dmg;
-#endif
+ missile.think = turret_hk_missile_think;
+ missile.nextthink = time + 0.25;
+ missile.movetype = MOVETYPE_BOUNCEMISSILE;
+ missile.velocity = self.tur_shotdir_updated * (self.shot_speed * 0.75);
+ missile.angles = vectoangles(missile.velocity);
+ missile.cnt = time + 30;
+ missile.ticrate = max(autocvar_sys_ticrate, 0.05);
- // Target dead, get another is still targeting the same.
- if ((self.enemy.deadflag != DEAD_NO) && (self.enemy == self.owner.enemy))
- self.owner.enemy = world;
+ if (self.tur_head.frame == 0)
+ self.tur_head.frame = self.tur_head.frame + 1;
- remove (self);
}
void turret_hk_postthink()
{
- if (autocvar_g_turrets_reloadcvars)
- {
- hk_maxspeed = autocvar_g_turrets_unit_hk_std_shot_speed_max;
- hk_minspeed = autocvar_g_turrets_unit_hk_std_shot_speed;
- hk_accel = autocvar_g_turrets_unit_hk_std_shot_speed_accel;
- hk_accel2 = autocvar_g_turrets_unit_hk_std_shot_speed_accel2;
- hk_decel = autocvar_g_turrets_unit_hk_std_shot_speed_decel;
- }
-
if (self.tur_head.frame != 0)
self.tur_head.frame = self.tur_head.frame + 1;
if (self.tur_head.frame > 5)
self.tur_head.frame = 0;
+}
+float turret_hk_addtarget(entity e_target,entity e_sender)
+{
+ if (e_target)
+ {
+ if (turret_validate_target(self,e_target,self.target_validate_flags) > 0)
+ {
+ self.enemy = e_target;
+ return 1;
+ }
+ }
+
+ return 0;
}
void turret_hk_dinit()
{
- if (self.netname == "") self.netname = "Hunter-killer turret";
-
- hk_maxspeed = autocvar_g_turrets_unit_hk_std_shot_speed_max;
- hk_minspeed = autocvar_g_turrets_unit_hk_std_shot_speed;
- hk_accel = autocvar_g_turrets_unit_hk_std_shot_speed_accel;
- hk_accel2 = autocvar_g_turrets_unit_hk_std_shot_speed_accel2;
- hk_decel = autocvar_g_turrets_unit_hk_std_shot_speed_decel;
+ if (self.netname == "")
+ self.netname = "Hunter-killer turret";
self.turrcaps_flags = TFL_TURRCAPS_RADIUSDMG | TFL_TURRCAPS_MEDPROJ | TFL_TURRCAPS_PLAYERKILL | TFL_TURRCAPS_RECIVETARGETS;
-
self.ammo_flags = TFL_AMMO_ROCKETS | TFL_AMMO_RECHARGE;
-
self.aim_flags = TFL_AIM_SIMPLE;
-
self.target_select_flags = TFL_TARGETSELECT_LOS | TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_TRIGGERTARGET | TFL_TARGETSELECT_RANGELIMTS | TFL_TARGETSELECT_TEAMCHECK;
-
self.firecheck_flags = TFL_FIRECHECK_WORLD | TFL_FIRECHECK_DEAD | TFL_FIRECHECK_TEAMCECK | TFL_FIRECHECK_REFIRE | TFL_FIRECHECK_AFF;
-
- self.target_select_flags = TFL_TARGETSELECT_LOS | TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_TRIGGERTARGET | TFL_TARGETSELECT_RANGELIMTS | TFL_TARGETSELECT_TEAMCHECK;
-
self.shoot_flags = TFL_SHOOT_CLEARTARGET;
if (turret_stdproc_init("hk_std", "models/turrets/base.md3", "models/turrets/hk.md3", TID_HK) == 0)
void spawnfunc_turret_mlrs();
void turret_mlrs_dinit();
void turret_mlrs_attack();
-void turret_mlrs_rocket_explode();
-void turret_mlrs_rocket_touch();
void turret_mlrs_postthink()
{
void turret_mlrs_attack()
{
entity missile;
-
- turret_tag_fire_update();
-
- sound (self, CH_WEAPON_A, "weapons/rocket_fire.wav", VOL_BASE, ATTN_NORM);
-
- missile = spawn ();
- setsize (missile, '-3 -3 -3', '3 3 3'); // give it some size so it can be shot
- setorigin(missile, self.tur_shotorg);
- missile.classname = "mlrs_missile";
- missile.owner = self;
- missile.bot_dodge = TRUE;
- missile.bot_dodgerating = self.shot_dmg;
- missile.takedamage = DAMAGE_NO;
- missile.damageforcescale = 4;
- missile.think = turret_mlrs_rocket_explode;
- missile.nextthink = time + max(self.tur_impacttime,(self.shot_radius * 2) / self.shot_speed);
- missile.solid = SOLID_BBOX;
- missile.movetype = MOVETYPE_FLYMISSILE;
- missile.velocity = normalize(self.tur_shotdir_updated + randomvec() * self.shot_spread) * self.shot_speed;
- missile.angles = vectoangles(missile.velocity);
- missile.touch = turret_mlrs_rocket_touch;
- missile.flags = FL_PROJECTILE;
- missile.solid = SOLID_BBOX;
- missile.enemy = self.enemy;
-
- CSQCProjectile(missile, TRUE, PROJECTILE_ROCKET, FALSE); // no cull, fly sound
-
+
+ turret_tag_fire_update();
+ missile = turret_projectile("weapons/rocket_fire.wav", 6, 10, DEATH_TURRET_MLRS, PROJECTILE_ROCKET, TRUE, TRUE);
te_explosion (missile.origin);
-}
-
-void turret_mlrs_rocket_touch()
-{
- if( (other == self.owner) || (other == self.owner.tur_head) )
- return;
-
- PROJECTILE_TOUCH;
-
- turret_mlrs_rocket_explode();
-}
-
-void turret_mlrs_rocket_explode()
-{
-
- if(self.event_damage != SUB_Null)
- {
- self.event_damage = SUB_Null;
- self.think = turret_mlrs_rocket_explode;
- self.nextthink = time;
- return;
- }
-
-#ifdef TURRET_DEBUG
- float d;
-
- d = RadiusDamage (self, self.owner, self.owner.shot_dmg, 0, self.owner.shot_radius, world, self.owner.shot_force, DEATH_TURRET_MLRS, world);
- self.owner.tur_dbg_dmg_t_h = self.owner.tur_dbg_dmg_t_h + d; //self.owner.shot_dmg;
- self.owner.tur_dbg_dmg_t_f = self.owner.tur_dbg_dmg_t_f + self.owner.shot_dmg;
-#else
- RadiusDamage (self, self.owner, self.owner.shot_dmg, self.owner.shot_dmg * 0.5, self.owner.shot_radius, world, self.owner.shot_force, DEATH_TURRET_MLRS, world);
-#endif
-
- // Target dead, Tell turret.
- if ((self.enemy.deadflag != DEAD_NO) && (self.enemy == self.owner.enemy))
- self.owner.enemy = world;
-
- remove (self);
+ missile.nextthink = time + max(self.tur_impacttime,(self.shot_radius * 2) / self.shot_speed);
}
void turret_mlrs_dinit()
void turret_plasma_dual_init();
void turret_plasma_attack();
-void turret_plasma_projectile_explode();
+
void turret_plasma_postthink()
{
}
void turret_plasma_attack()
-{
- entity proj;
-
- sound (self, CH_WEAPON_A, "weapons/hagar_fire.wav", VOL_BASE, ATTN_NORM);
+{
+ turret_projectile("weapons/hagar_fire.wav", 1, 0, DEATH_TURRET_PLASMA, PROJECTILE_ELECTRO_BEAM, TRUE, TRUE);
pointparticles(particleeffectnum("laser_muzzleflash"), self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
-
- proj = spawn ();
- setorigin(proj, self.tur_shotorg);
- setsize(proj, '-1 -1 -1', '1 1 1');
- proj.classname = "plasmabomb";
- proj.owner = self;
- proj.bot_dodge = TRUE;
- proj.bot_dodgerating = self.shot_dmg;
- proj.think = turret_plasma_projectile_explode;
- proj.nextthink = time + 9;
- proj.solid = SOLID_BBOX;
- proj.movetype = MOVETYPE_FLYMISSILE;
- proj.velocity = normalize(self.tur_shotdir_updated + randomvec() * self.shot_spread) * self.shot_speed;
- proj.touch = turret_plasma_projectile_explode;
- proj.flags = FL_PROJECTILE;
- proj.enemy = self.enemy;
- proj.flags = FL_PROJECTILE | FL_NOTARGET;
-
- CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO_BEAM, TRUE);
-
if (self.tur_head.frame == 0)
self.tur_head.frame = 1;
}
void turret_plasma_dual_attack()
{
- entity proj;
-
- sound (self, CH_WEAPON_A, "weapons/hagar_fire.wav", VOL_BASE, ATTN_NORM);
- proj = spawn ();
- setorigin(proj, self.tur_shotorg);
- setsize(proj, '0 0 0', '0 0 0');
- proj.classname = "plasmabomb";
- proj.owner = self;
- proj.bot_dodge = TRUE;
- proj.bot_dodgerating = self.shot_dmg;
- proj.think = turret_plasma_projectile_explode;
- proj.nextthink = time + 9;
- proj.solid = SOLID_BBOX;
- proj.movetype = MOVETYPE_FLYMISSILE;
- proj.velocity = normalize(self.tur_shotdir_updated + randomvec() * self.shot_spread) * self.shot_speed;
- proj.touch = turret_plasma_projectile_explode;
- proj.flags = FL_PROJECTILE;
- proj.enemy = self.enemy;
- proj.flags = FL_PROJECTILE | FL_NOTARGET;
-
+ turret_projectile("weapons/hagar_fire.wav", 1, 0, DEATH_TURRET_PLASMA, PROJECTILE_ELECTRO_BEAM, TRUE, TRUE);
+ pointparticles(particleeffectnum("laser_muzzleflash"), self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
self.tur_head.frame += 1;
-
- CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO_BEAM, TRUE);
-}
-
-void turret_plasma_projectile_explode()
-{
- self.event_damage = SUB_Null;
- //w_deathtypestring = "ate to much plasma";
-#ifdef TURRET_DEBUG
- float d;
-
- d = RadiusDamage (self, self.owner, self.owner.shot_dmg, 0, self.owner.shot_radius, world, self.owner.shot_force, DEATH_TURRET_PLASMA, world);
- self.owner.tur_dbg_dmg_t_h = self.owner.tur_dbg_dmg_t_h + d; //self.owner.shot_dmg;
- self.owner.tur_dbg_dmg_t_f = self.owner.tur_dbg_dmg_t_f + self.owner.shot_dmg;
-#else
- RadiusDamage (self, self.owner, self.owner.shot_dmg, 0, self.owner.shot_radius, world, self.owner.shot_force, DEATH_TURRET_PLASMA, world);
-#endif
-
- remove (self);
}
void turret_plasma_std_init()
// How to aim
self.aim_flags = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE | TFL_AIM_GROUND2;
- self.turrcaps_flags = TFL_TURRCAPS_RADIUSDMG | TFL_TURRCAPS_MEDPROJ | TFL_TURRCAPS_PLAYERKILL | TFL_TURRCAPS_MISSILEKILL;
+ self.turrcaps_flags = TFL_TURRCAPS_RADIUSDMG | TFL_TURRCAPS_MEDPROJ | TFL_TURRCAPS_PLAYERKILL;
if (turret_stdproc_init("plasma_std", "models/turrets/base.md3", "models/turrets/plasma.md3", TID_PLASMA) == 0)
{