1 #include "hellion_weapon.qh"
5 float autocvar_g_turrets_unit_hellion_shot_speed_gain;
6 float autocvar_g_turrets_unit_hellion_shot_speed_max;
8 void turret_hellion_missile_think(entity this);
9 SOUND(HellionAttack_FIRE, W_Sound("electro_fire"));
10 METHOD(HellionAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) {
11 bool isPlayer = IS_PLAYER(actor);
13 if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire))) {
15 turret_initparams(actor);
16 W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_HellionAttack_FIRE, CH_WEAPON_B, 0, DEATH_TURRET_HELLION.m_id);
17 actor.tur_shotdir_updated = w_shotdir;
18 actor.tur_shotorg = w_shotorg;
19 actor.tur_head = actor;
20 actor.shot_radius = 500;
21 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
24 if (actor.tur_head.frame != 0)
25 actor.tur_shotorg = gettaginfo(actor.tur_head, gettagindex(actor.tur_head, "tag_fire"));
27 actor.tur_shotorg = gettaginfo(actor.tur_head, gettagindex(actor.tur_head, "tag_fire2"));
30 entity missile = turret_projectile(actor, SND_ROCKET_FIRE, 6, 10, DEATH_TURRET_HELLION.m_id, PROJECTILE_ROCKET, false, false);
31 te_explosion (missile.origin);
32 setthink(missile, turret_hellion_missile_think);
33 missile.nextthink = time;
34 missile.max_health = time + 9;
35 missile.tur_aimpos = randomvec() * 128;
36 missile.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_GUIDED_HEAT;
37 if (!isPlayer) actor.tur_head.frame += 1;
41 void turret_hellion_missile_think(entity this)
47 this.nextthink = time + 0.05;
49 olddir = normalize(this.velocity);
51 if(this.max_health < time)
52 turret_projectile_explode(this);
54 // Enemy dead? just keep on the current heading then.
55 if ((this.enemy == NULL) || (IS_DEAD(this.enemy)))
58 // Make sure we dont return to tracking a respawned player
62 this.angles = vectoangles(this.velocity);
64 if(vdist(this.origin - this.owner.origin, >, (this.owner.shot_radius * 5)))
65 turret_projectile_explode(this);
68 this.velocity = olddir * min(vlen(this.velocity) * (autocvar_g_turrets_unit_hellion_shot_speed_gain), (autocvar_g_turrets_unit_hellion_shot_speed_max));
70 UpdateCSQCProjectile(this);
76 if(vdist(this.origin - this.enemy.origin, <, this.owner.shot_radius * 0.2))
77 turret_projectile_explode(this);
79 // Predict enemy position
80 itime = vlen(this.enemy.origin - this.origin) / vlen(this.velocity);
81 pre_pos = this.enemy.origin + this.enemy.velocity * itime;
83 pre_pos = (pre_pos + this.enemy.origin) * 0.5;
85 // Find out the direction to that place
86 newdir = normalize(pre_pos - this.origin);
89 newdir = normalize(olddir + newdir * 0.35);
92 this.angles = vectoangles(this.velocity);
95 this.velocity = newdir * min(vlen(this.velocity) * (autocvar_g_turrets_unit_hellion_shot_speed_gain), (autocvar_g_turrets_unit_hellion_shot_speed_max));
98 setthink(this, turret_projectile_explode);
100 UpdateCSQCProjectile(this);