]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/turrets/turret/plasma.qc
Merge branch 'terencehill/lms_itemtimes_fix' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / turret / plasma.qc
index 1adb45623053010a01c80efa9331710c50e4d714..37bdd93299978f50f11671369fccdd897a8618ba 100644 (file)
@@ -1,21 +1,15 @@
-#ifndef TUR_PLASMA_H
-#define TUR_PLASMA_H
+#ifndef TURRET_PLASMA_H
+#define TURRET_PLASMA_H
 
-CLASS(PlasmaAttack, PortoLaunch)
-/* flags     */ ATTRIB(PlasmaAttack, spawnflags, int, WEP_TYPE_OTHER);
-/* impulse   */ ATTRIB(PlasmaAttack, impulse, int, 5);
-/* refname   */ ATTRIB(PlasmaAttack, netname, string, "turret_plasma");
-/* wepname   */ ATTRIB(PlasmaAttack, message, string, _("Plasma"));
-ENDCLASS(PlasmaAttack)
-REGISTER_WEAPON(PLASMA, NEW(PlasmaAttack));
+#include "plasma_weapon.qc"
 
 CLASS(PlasmaTurret, Turret)
 /* spawnflags */ ATTRIB(PlasmaTurret, spawnflags, int, TUR_FLAG_SPLASH | TUR_FLAG_MEDPROJ | TUR_FLAG_PLAYER);
 /* mins       */ ATTRIB(PlasmaTurret, mins, vector, '-32 -32 0');
 /* maxs       */ ATTRIB(PlasmaTurret, maxs, vector, '32 32 64');
 /* modelname  */ ATTRIB(PlasmaTurret, mdl, string, "base.md3");
-/* model      */ ATTRIB(PlasmaTurret, model, string, strzone(strcat("models/turrets/", this.mdl)));
-/* head_model */ ATTRIB(PlasmaTurret, head_model, string, strzone(strcat("models/turrets/", "plasma.md3")));
+/* model      */ ATTRIB_STRZONE(PlasmaTurret, model, string, strcat("models/turrets/", this.mdl));
+/* head_model */ ATTRIB_STRZONE(PlasmaTurret, head_model, string, strcat("models/turrets/", "plasma.md3"));
 /* netname    */ ATTRIB(PlasmaTurret, netname, string, "plasma");
 /* fullname   */ ATTRIB(PlasmaTurret, turret_name, string, _("Plasma Cannon"));
     ATTRIB(PlasmaTurret, m_weapon, Weapon, WEP_PLASMA);
@@ -25,67 +19,50 @@ REGISTER_TURRET(PLASMA, NEW(PlasmaTurret));
 #endif
 
 #ifdef IMPLEMENTATION
-#ifdef SVQC
 
-METHOD(PlasmaAttack, wr_think, bool(entity thiswep, bool fire1, bool fire2)) {
-       SELFPARAM();
-       bool isPlayer = IS_PLAYER(self);
-       if (fire1)
-       if (!isPlayer || weapon_prepareattack(false, WEP_CVAR_PRI(electro, refire))) {
-               if (isPlayer) {
-            turret_initparams(self);
-            W_SetupShot_Dir(self, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
-            self.tur_shotdir_updated = w_shotdir;
-            self.tur_shotorg = w_shotorg;
-            self.tur_head = self;
-            weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
-        }
-        entity missile = turret_projectile(SND(HAGAR_FIRE), 1, 0, DEATH_TURRET_PLASMA, PROJECTILE_ELECTRO_BEAM, true, true);
-        missile.missile_flags = MIF_SPLASH;
-        Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
-       }
-       return true;
-}
+#include "plasma_weapon.qc"
+
+#ifdef SVQC
 
-void spawnfunc_turret_plasma() { SELFPARAM(); if(!turret_initialize(TUR_PLASMA)) remove(self); }
+spawnfunc(turret_plasma) { if (!turret_initialize(TUR_PLASMA)) remove(self); }
 
-        METHOD(PlasmaTurret, tr_attack, void(PlasmaTurret this))
-        {
-            if(g_instagib)
-            {
-                FireRailgunBullet (self.tur_shotorg, self.tur_shotorg + self.tur_shotdir_updated * MAX_SHOT_DISTANCE, 10000000000,
-                                   800, 0, 0, 0, 0, DEATH_TURRET_PLASMA);
+METHOD(PlasmaTurret, tr_attack, void(PlasmaTurret this, entity it))
+{
+    if(g_instagib)
+    {
+        FireRailgunBullet (self.tur_shotorg, self.tur_shotorg + self.tur_shotdir_updated * MAX_SHOT_DISTANCE, 10000000000,
+                           800, 0, 0, 0, 0, DEATH_TURRET_PLASMA.m_id);
 
-                Send_Effect(EFFECT_VORTEX_MUZZLEFLASH, self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
+        Send_Effect(EFFECT_VORTEX_MUZZLEFLASH, self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
 
-                // teamcolor / hit beam effect
-                vector v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
-                WarpZone_TrailParticles(world, particleeffectnum(EFFECT_VAPORIZER(self.team)), self.tur_shotorg, v);
-            }
-            else
-            {
-                super.tr_attack(this);
-            }
-            if (self.tur_head.frame == 0)
-                self.tur_head.frame = 1;
-        }
-        METHOD(PlasmaTurret, tr_think, void(PlasmaTurret thistur))
-        {
-            if (self.tur_head.frame != 0)
-                self.tur_head.frame = self.tur_head.frame + 1;
+        // teamcolor / hit beam effect
+        vector v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
+        WarpZone_TrailParticles(world, particleeffectnum(EFFECT_VAPORIZER(self.team)), self.tur_shotorg, v);
+    }
+    else
+    {
+        SUPER(PlasmaTurret).tr_attack(this, it);
+    }
+    if (self.tur_head.frame == 0)
+        self.tur_head.frame = 1;
+}
+METHOD(PlasmaTurret, tr_think, void(PlasmaTurret thistur, entity it))
+{
+    if (self.tur_head.frame != 0)
+        self.tur_head.frame = self.tur_head.frame + 1;
 
-            if (self.tur_head.frame > 5)
-                self.tur_head.frame = 0;
-        }
-        METHOD(PlasmaTurret, tr_setup, void(PlasmaTurret this, entity it))
-        {
-            it.ammo_flags = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE | TFL_AMMO_RECIEVE;
-            it.damage_flags |= TFL_DMG_HEADSHAKE;
-            it.firecheck_flags |= TFL_FIRECHECK_AFF;
-            it.aim_flags = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE | TFL_AIM_SPLASH;
+    if (self.tur_head.frame > 5)
+        self.tur_head.frame = 0;
+}
+METHOD(PlasmaTurret, tr_setup, void(PlasmaTurret this, entity it))
+{
+    it.ammo_flags = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE | TFL_AMMO_RECIEVE;
+    it.damage_flags |= TFL_DMG_HEADSHAKE;
+    it.firecheck_flags |= TFL_FIRECHECK_AFF;
+    it.aim_flags = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE | TFL_AIM_SPLASH;
 
-            turret_do_updates(it);
-        }
+    turret_do_updates(it);
+}
 
-#endif // SVQC
+#endif
 #endif