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, 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, void(entity thiswep, entity actor, int fire)) {
23 bool isPlayer = IS_PLAYER(actor);
25 if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(electro, refire))) {
27 turret_initparams(actor);
28 W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
29 actor.tur_shotdir_updated = w_shotdir;
30 actor.tur_shotorg = w_shotorg;
31 actor.tur_head = actor;
32 actor.shot_radius = 500;
33 weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
36 if (actor.tur_head.frame != 0)
37 actor.tur_shotorg = gettaginfo(actor.tur_head, gettagindex(actor.tur_head, "tag_fire"));
39 actor.tur_shotorg = gettaginfo(actor.tur_head, gettagindex(actor.tur_head, "tag_fire2"));
42 entity missile = turret_projectile(SND(ROCKET_FIRE), 6, 10, DEATH_TURRET_HELLION.m_id, PROJECTILE_ROCKET, FALSE, FALSE);
43 te_explosion (missile.origin);
44 missile.think = turret_hellion_missile_think;
45 missile.nextthink = time;
46 missile.flags = FL_PROJECTILE;
47 missile.max_health = time + 9;
48 missile.tur_aimpos = randomvec() * 128;
49 missile.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_GUIDED_HEAT;
50 if (!isPlayer) actor.tur_head.frame += 1;
54 void turret_hellion_missile_think()
60 self.nextthink = time + 0.05;
62 olddir = normalize(self.velocity);
64 if(self.max_health < time)
65 turret_projectile_explode();
67 // Enemy dead? just keep on the current heading then.
68 if ((self.enemy == world) || (self.enemy.deadflag != DEAD_NO))
71 // Make sure we dont return to tracking a respawned player
75 self.angles = vectoangles(self.velocity);
77 if ( (vlen(self.origin - self.owner.origin)) > (self.owner.shot_radius * 5) )
78 turret_projectile_explode();
81 self.velocity = olddir * min(vlen(self.velocity) * (autocvar_g_turrets_unit_hellion_shot_speed_gain), (autocvar_g_turrets_unit_hellion_shot_speed_max));
83 UpdateCSQCProjectile(self);
89 if (vlen(self.origin - self.enemy.origin) < self.owner.shot_radius * 0.2)
90 turret_projectile_explode();
92 // Predict enemy position
93 itime = vlen(self.enemy.origin - self.origin) / vlen(self.velocity);
94 pre_pos = self.enemy.origin + self.enemy.velocity * itime;
96 pre_pos = (pre_pos + self.enemy.origin) * 0.5;
98 // Find out the direction to that place
99 newdir = normalize(pre_pos - self.origin);
102 newdir = normalize(olddir + newdir * 0.35);
105 self.angles = vectoangles(self.velocity);
108 self.velocity = newdir * min(vlen(self.velocity) * (autocvar_g_turrets_unit_hellion_shot_speed_gain), (autocvar_g_turrets_unit_hellion_shot_speed_max));
111 self.think = turret_projectile_explode;
113 UpdateCSQCProjectile(self);