]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/turrets/turret/hellion_weapon.qc
Clean up some of the turret code's self uses
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / turret / hellion_weapon.qc
index 20eee23587f7f40f88371941739d4433f6ab291f..f053d782e3b7ea481faa4362d00853aada221c99 100644 (file)
@@ -1,15 +1,4 @@
-#ifndef TURRET_HELLION_WEAPON_H
-#define TURRET_HELLION_WEAPON_H
-
-CLASS(HellionAttack, PortoLaunch)
-/* flags     */ ATTRIB(HellionAttack, spawnflags, int, WEP_TYPE_OTHER | WEP_FLAG_HIDDEN | WEP_FLAG_MUTATORBLOCKED);
-/* impulse   */ ATTRIB(HellionAttack, impulse, int, 9);
-/* refname   */ ATTRIB(HellionAttack, netname, string, "turret_hellion");
-/* wepname   */ ATTRIB(HellionAttack, m_name, string, _("Hellion"));
-ENDCLASS(HellionAttack)
-REGISTER_WEAPON(HELLION, NEW(HellionAttack));
-
-#endif
+#include "hellion_weapon.qh"
 
 #ifdef IMPLEMENTATION
 
@@ -18,14 +7,15 @@ REGISTER_WEAPON(HELLION, NEW(HellionAttack));
 float autocvar_g_turrets_unit_hellion_shot_speed_gain;
 float autocvar_g_turrets_unit_hellion_shot_speed_max;
 
-void turret_hellion_missile_think();
+void turret_hellion_missile_think(entity this);
+SOUND(HellionAttack_FIRE, W_Sound("electro_fire"));
 METHOD(HellionAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) {
     bool isPlayer = IS_PLAYER(actor);
     if (fire & 1)
     if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire))) {
         if (isPlayer) {
             turret_initparams(actor);
-            W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
+            W_SetupShot_Dir(actor, v_forward, false, 0, SND_HellionAttack_FIRE, CH_WEAPON_B, 0);
             actor.tur_shotdir_updated = w_shotdir;
             actor.tur_shotorg = w_shotorg;
             actor.tur_head = actor;
@@ -39,9 +29,9 @@ METHOD(HellionAttack, wr_think, void(entity thiswep, entity actor, .entity weapo
                 actor.tur_shotorg = gettaginfo(actor.tur_head, gettagindex(actor.tur_head, "tag_fire2"));
         }
 
-        entity missile = turret_projectile(SND(ROCKET_FIRE), 6, 10, DEATH_TURRET_HELLION.m_id, PROJECTILE_ROCKET, FALSE, FALSE);
+        entity missile = turret_projectile(actor, SND_ROCKET_FIRE, 6, 10, DEATH_TURRET_HELLION.m_id, PROJECTILE_ROCKET, false, false);
         te_explosion (missile.origin);
-        missile.think          = turret_hellion_missile_think;
+        setthink(missile, turret_hellion_missile_think);
         missile.nextthink      = time;
         missile.flags          = FL_PROJECTILE;
         missile.max_health   = time + 9;
@@ -51,8 +41,8 @@ METHOD(HellionAttack, wr_think, void(entity thiswep, entity actor, .entity weapo
     }
 }
 
-void turret_hellion_missile_think()
-{SELFPARAM();
+void turret_hellion_missile_think(entity this)
+{
     vector olddir,newdir;
     vector pre_pos;
     float itime;
@@ -62,10 +52,10 @@ void turret_hellion_missile_think()
     olddir = normalize(self.velocity);
 
     if(self.max_health < time)
-        turret_projectile_explode();
+        turret_projectile_explode(self);
 
     // Enemy dead? just keep on the current heading then.
-    if ((self.enemy == world) || (self.enemy.deadflag != DEAD_NO))
+    if ((self.enemy == world) || (IS_DEAD(self.enemy)))
     {
 
         // Make sure we dont return to tracking a respawned player
@@ -74,8 +64,8 @@ void turret_hellion_missile_think()
         // Turn model
         self.angles = vectoangles(self.velocity);
 
-        if ( (vlen(self.origin - self.owner.origin)) > (self.owner.shot_radius * 5) )
-            turret_projectile_explode();
+        if(vdist(self.origin - self.owner.origin, >, (self.owner.shot_radius * 5)))
+            turret_projectile_explode(self);
 
         // Accelerate
         self.velocity = olddir * min(vlen(self.velocity) * (autocvar_g_turrets_unit_hellion_shot_speed_gain), (autocvar_g_turrets_unit_hellion_shot_speed_max));
@@ -86,8 +76,8 @@ void turret_hellion_missile_think()
     }
 
     // Enemy in range?
-    if (vlen(self.origin - self.enemy.origin) < self.owner.shot_radius * 0.2)
-        turret_projectile_explode();
+    if(vdist(self.origin - self.enemy.origin, <, self.owner.shot_radius * 0.2))
+        turret_projectile_explode(self);
 
     // Predict enemy position
     itime = vlen(self.enemy.origin - self.origin) / vlen(self.velocity);
@@ -108,7 +98,7 @@ void turret_hellion_missile_think()
     self.velocity = newdir * min(vlen(self.velocity) * (autocvar_g_turrets_unit_hellion_shot_speed_gain), (autocvar_g_turrets_unit_hellion_shot_speed_max));
 
     if (itime < 0.05)
-        self.think = turret_projectile_explode;
+        setthink(self, turret_projectile_explode);
 
     UpdateCSQCProjectile(self);
 }