1 #ifndef TURRET_HELLION_WEAPON_H
2 #define TURRET_HELLION_WEAPON_H
4 CLASS(HellionAttack, PortoLaunch)
5 /* flags */ ATTRIB(HellionAttack, spawnflags, int, WEP_TYPE_OTHER);
6 /* impulse */ ATTRIB(HellionAttack, impulse, int, 9);
7 /* refname */ ATTRIB(HellionAttack, netname, string, "turret_hellion");
8 /* wepname */ ATTRIB(HellionAttack, message, string, _("Hellion"));
9 ENDCLASS(HellionAttack)
10 REGISTER_WEAPON(HELLION, NEW(HellionAttack));
18 float autocvar_g_turrets_unit_hellion_shot_speed_gain;
19 float autocvar_g_turrets_unit_hellion_shot_speed_max;
21 void turret_hellion_missile_think();
22 METHOD(HellionAttack, wr_think, bool(entity thiswep, bool fire1, bool fire2)) {
24 bool isPlayer = IS_PLAYER(self);
26 if (!isPlayer || weapon_prepareattack(false, WEP_CVAR_PRI(electro, refire))) {
28 turret_initparams(self);
29 W_SetupShot_Dir(self, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
30 self.tur_shotdir_updated = w_shotdir;
31 self.tur_shotorg = w_shotorg;
33 self.shot_radius = 500;
34 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
37 if (self.tur_head.frame != 0)
38 self.tur_shotorg = gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_fire"));
40 self.tur_shotorg = gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_fire2"));
43 entity missile = turret_projectile(SND(ROCKET_FIRE), 6, 10, DEATH_TURRET_HELLION, PROJECTILE_ROCKET, FALSE, FALSE);
44 te_explosion (missile.origin);
45 missile.think = turret_hellion_missile_think;
46 missile.nextthink = time;
47 missile.flags = FL_PROJECTILE;
48 missile.max_health = time + 9;
49 missile.tur_aimpos = randomvec() * 128;
50 missile.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_GUIDED_HEAT;
51 if (!isPlayer) self.tur_head.frame += 1;
56 void turret_hellion_missile_think()
62 self.nextthink = time + 0.05;
64 olddir = normalize(self.velocity);
66 if(self.max_health < time)
67 turret_projectile_explode();
69 // Enemy dead? just keep on the current heading then.
70 if ((self.enemy == world) || (self.enemy.deadflag != DEAD_NO))
73 // Make sure we dont return to tracking a respawned player
77 self.angles = vectoangles(self.velocity);
79 if ( (vlen(self.origin - self.owner.origin)) > (self.owner.shot_radius * 5) )
80 turret_projectile_explode();
83 self.velocity = olddir * min(vlen(self.velocity) * (autocvar_g_turrets_unit_hellion_shot_speed_gain), (autocvar_g_turrets_unit_hellion_shot_speed_max));
85 UpdateCSQCProjectile(self);
91 if (vlen(self.origin - self.enemy.origin) < self.owner.shot_radius * 0.2)
92 turret_projectile_explode();
94 // Predict enemy position
95 itime = vlen(self.enemy.origin - self.origin) / vlen(self.velocity);
96 pre_pos = self.enemy.origin + self.enemy.velocity * itime;
98 pre_pos = (pre_pos + self.enemy.origin) * 0.5;
100 // Find out the direction to that place
101 newdir = normalize(pre_pos - self.origin);
104 newdir = normalize(olddir + newdir * 0.35);
107 self.angles = vectoangles(self.velocity);
110 self.velocity = newdir * min(vlen(self.velocity) * (autocvar_g_turrets_unit_hellion_shot_speed_gain), (autocvar_g_turrets_unit_hellion_shot_speed_max));
113 self.think = turret_projectile_explode;
115 UpdateCSQCProjectile(self);