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 | WEP_FLAG_HIDDEN | WEP_FLAG_MUTATORBLOCKED);
6 /* impulse */ ATTRIB(HellionAttack, impulse, int, 9);
7 /* refname */ ATTRIB(HellionAttack, netname, string, "turret_hellion");
8 /* wepname */ ATTRIB(HellionAttack, m_name, 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 SOUND(HellionAttack_FIRE, W_Sound("electro_fire"));
23 METHOD(HellionAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) {
24 bool isPlayer = IS_PLAYER(actor);
26 if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire))) {
28 turret_initparams(actor);
29 W_SetupShot_Dir(actor, v_forward, false, 0, SND(HellionAttack_FIRE), CH_WEAPON_B, 0);
30 actor.tur_shotdir_updated = w_shotdir;
31 actor.tur_shotorg = w_shotorg;
32 actor.tur_head = actor;
33 actor.shot_radius = 500;
34 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
37 if (actor.tur_head.frame != 0)
38 actor.tur_shotorg = gettaginfo(actor.tur_head, gettagindex(actor.tur_head, "tag_fire"));
40 actor.tur_shotorg = gettaginfo(actor.tur_head, gettagindex(actor.tur_head, "tag_fire2"));
43 entity missile = turret_projectile(SND(ROCKET_FIRE), 6, 10, DEATH_TURRET_HELLION.m_id, 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) actor.tur_head.frame += 1;
55 void turret_hellion_missile_think()
61 self.nextthink = time + 0.05;
63 olddir = normalize(self.velocity);
65 if(self.max_health < time)
66 turret_projectile_explode();
68 // Enemy dead? just keep on the current heading then.
69 if ((self.enemy == world) || (self.enemy.deadflag != DEAD_NO))
72 // Make sure we dont return to tracking a respawned player
76 self.angles = vectoangles(self.velocity);
78 if ( (vlen(self.origin - self.owner.origin)) > (self.owner.shot_radius * 5) )
79 turret_projectile_explode();
82 self.velocity = olddir * min(vlen(self.velocity) * (autocvar_g_turrets_unit_hellion_shot_speed_gain), (autocvar_g_turrets_unit_hellion_shot_speed_max));
84 UpdateCSQCProjectile(self);
90 if (vlen(self.origin - self.enemy.origin) < self.owner.shot_radius * 0.2)
91 turret_projectile_explode();
93 // Predict enemy position
94 itime = vlen(self.enemy.origin - self.origin) / vlen(self.velocity);
95 pre_pos = self.enemy.origin + self.enemy.velocity * itime;
97 pre_pos = (pre_pos + self.enemy.origin) * 0.5;
99 // Find out the direction to that place
100 newdir = normalize(pre_pos - self.origin);
103 newdir = normalize(olddir + newdir * 0.35);
106 self.angles = vectoangles(self.velocity);
109 self.velocity = newdir * min(vlen(self.velocity) * (autocvar_g_turrets_unit_hellion_shot_speed_gain), (autocvar_g_turrets_unit_hellion_shot_speed_max));
112 self.think = turret_projectile_explode;
114 UpdateCSQCProjectile(self);