]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Turrets: make usable as weapons
authorTimePath <andrew.hardaker1995@gmail.com>
Wed, 30 Sep 2015 09:54:24 +0000 (19:54 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Wed, 30 Sep 2015 09:54:24 +0000 (19:54 +1000)
13 files changed:
qcsrc/common/turrets/turret/ewheel.qc
qcsrc/common/turrets/turret/flac.qc
qcsrc/common/turrets/turret/hellion.qc
qcsrc/common/turrets/turret/hk.qc
qcsrc/common/turrets/turret/machinegun.qc
qcsrc/common/turrets/turret/mlrs.qc
qcsrc/common/turrets/turret/phaser.qc
qcsrc/common/turrets/turret/plasma.qc
qcsrc/common/turrets/turret/plasma_dual.qc
qcsrc/common/turrets/turret/tesla.qc
qcsrc/common/turrets/turret/walker.qc
qcsrc/common/weapons/all.qh
qcsrc/server/mutators/gamemode_nexball_weapon.qc

index be562a828b7940ff175be627dfef299db8269dc6..81336a4951ba84d1f5dc7084f2837d0ef84efec0 100644 (file)
@@ -14,10 +14,50 @@ ENDCLASS(EWheel)
 
 REGISTER_TURRET(EWHEEL, NEW(EWheel));
 
+CLASS(EWheelAttack, PortoLaunch)
+/* flags     */ ATTRIB(EWheelAttack, spawnflags, int, WEP_TYPE_OTHER);
+/* impulse   */ ATTRIB(EWheelAttack, impulse, int, 5);
+/* refname   */ ATTRIB(EWheelAttack, netname, string, "turret_ewheel");
+/* wepname   */ ATTRIB(EWheelAttack, message, string, _("eWheel"));
+ENDCLASS(EWheelAttack)
+REGISTER_WEAPON(EWHEEL, NEW(EWheelAttack));
+
 #endif
 
 #ifdef IMPLEMENTATION
 #ifdef SVQC
+void turret_initparams(entity);
+METHOD(EWheelAttack, 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);
+        }
+
+        turret_do_updates(self);
+
+        entity missile = turret_projectile(SND(LASERGUN_FIRE), 1, 0, DEATH_TURRET_EWHEEL, PROJECTILE_BLASTER, true, true);
+        missile.missile_flags = MIF_SPLASH;
+
+        Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
+
+        if (!isPlayer) {
+            self.tur_head.frame += 2;
+
+            if (self.tur_head.frame > 3)
+                self.tur_head.frame = 0;
+        }
+       }
+       return true;
+}
+
 float autocvar_g_turrets_unit_ewheel_speed_fast;
 float autocvar_g_turrets_unit_ewheel_speed_slow;
 float autocvar_g_turrets_unit_ewheel_speed_slower;
@@ -133,23 +173,8 @@ void spawnfunc_turret_ewheel() { SELFPARAM(); if(!turret_initialize(TUR_EWHEEL.m
         METHOD(EWheel, tr_attack, void(EWheel thistur))
         {
             SELFPARAM();
-            float i;
-            entity _mis;
-
-            for (i = 0; i < 1; ++i)
-            {
-                turret_do_updates(self);
-
-                _mis = turret_projectile(SND(LASERGUN_FIRE), 1, 0, DEATH_TURRET_EWHEEL, PROJECTILE_BLASTER, TRUE, TRUE);
-                _mis.missile_flags = MIF_SPLASH;
-
-                Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
-
-                self.tur_head.frame += 2;
-
-                if (self.tur_head.frame > 3)
-                    self.tur_head.frame = 0;
-            }
+            Weapon wep = WEP_EWHEEL;
+            wep.wr_think(wep, true, false);
         }
         METHOD(EWheel, tr_think, bool(EWheel thistur))
         {
index d917e27f2f0158518516c166d3549bd7452630eb..f2554ad541ddfd92ded06c096591f84ea38186f9 100644 (file)
@@ -14,10 +14,52 @@ ENDCLASS(Flac)
 
 REGISTER_TURRET(FLAC, NEW(Flac));
 
+CLASS(FlacAttack, PortoLaunch)
+/* flags     */ ATTRIB(FlacAttack, spawnflags, int, WEP_TYPE_OTHER);
+/* impulse   */ ATTRIB(FlacAttack, impulse, int, 5);
+/* refname   */ ATTRIB(FlacAttack, netname, string, "turret_flac");
+/* wepname   */ ATTRIB(FlacAttack, message, string, _("FLAC"));
+ENDCLASS(FlacAttack)
+REGISTER_WEAPON(FLAC, NEW(FlacAttack));
+
 #endif
 
 #ifdef IMPLEMENTATION
 #ifdef SVQC
+void turret_initparams(entity);
+void turret_flac_projectile_think_explode();
+METHOD(FlacAttack, 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;
+            self.tur_impacttime = 10;
+            weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
+        }
+
+        turret_tag_fire_update();
+
+        entity proj = turret_projectile(SND(HAGAR_FIRE), 5, 0, DEATH_TURRET_FLAC, PROJECTILE_HAGAR, true, true);
+        proj.missile_flags = MIF_SPLASH | MIF_PROXY;
+        proj.think       = turret_flac_projectile_think_explode;
+        proj.nextthink  = time + self.tur_impacttime + (random() * 0.01 - random() * 0.01);
+        Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
+
+        if (!isPlayer) {
+            self.tur_head.frame = self.tur_head.frame + 1;
+            if (self.tur_head.frame >= 4)
+                self.tur_head.frame = 0;
+        }
+       }
+       return true;
+}
+
 void turret_flac_projectile_think_explode()
 {SELFPARAM();
     if(self.enemy != world)
@@ -39,19 +81,8 @@ void spawnfunc_turret_flac() { SELFPARAM(); if(!turret_initialize(TUR_FLAC.m_id)
 
         METHOD(Flac, tr_attack, void(Flac thistur))
         {
-            entity proj;
-
-            turret_tag_fire_update();
-
-            proj = turret_projectile(SND(HAGAR_FIRE), 5, 0, DEATH_TURRET_FLAC, PROJECTILE_HAGAR, TRUE, TRUE);
-            Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
-            proj.think   = turret_flac_projectile_think_explode;
-            proj.nextthink  = time + self.tur_impacttime + (random() * 0.01 - random() * 0.01);
-            proj.missile_flags = MIF_SPLASH | MIF_PROXY;
-
-            self.tur_head.frame = self.tur_head.frame + 1;
-            if (self.tur_head.frame >= 4)
-                self.tur_head.frame = 0;
+            Weapon wep = WEP_FLAC;
+            wep.wr_think(wep, true, false);
         }
         METHOD(Flac, tr_think, bool(Flac thistur))
         {
index 60cf6e0c69095b95a888762dfbbfc389ddee1560..d0622bf859a96efde823a43fa31a09f53aecf42a 100644 (file)
@@ -14,10 +14,54 @@ ENDCLASS(Hellion)
 
 REGISTER_TURRET(HELLION, NEW(Hellion));
 
+CLASS(HellionAttack, PortoLaunch)
+/* flags     */ ATTRIB(HellionAttack, spawnflags, int, WEP_TYPE_OTHER);
+/* impulse   */ ATTRIB(HellionAttack, impulse, int, 9);
+/* refname   */ ATTRIB(HellionAttack, netname, string, "turret_hellion");
+/* wepname   */ ATTRIB(HellionAttack, message, string, _("Hellion"));
+ENDCLASS(HellionAttack)
+REGISTER_WEAPON(HELLION, NEW(HellionAttack));
+
 #endif
 
 #ifdef IMPLEMENTATION
 #ifdef SVQC
+void turret_initparams(entity);
+void turret_hellion_missile_think();
+METHOD(HellionAttack, 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;
+            self.shot_radius = 500;
+            weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
+        }
+        if (!isPlayer) {
+            if (self.tur_head.frame != 0)
+                self.tur_shotorg = gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_fire"));
+            else
+                self.tur_shotorg = gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_fire2"));
+        }
+
+        entity missile = turret_projectile(SND(ROCKET_FIRE), 6, 10, DEATH_TURRET_HELLION, PROJECTILE_ROCKET, FALSE, FALSE);
+        te_explosion (missile.origin);
+        missile.think          = turret_hellion_missile_think;
+        missile.nextthink      = time;
+        missile.flags          = FL_PROJECTILE;
+        missile.max_health   = time + 9;
+        missile.tur_aimpos   = randomvec() * 128;
+        missile.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_GUIDED_HEAT;
+        if (!isPlayer) self.tur_head.frame += 1;
+       }
+       return true;
+}
+
 float autocvar_g_turrets_unit_hellion_shot_speed_gain;
 float autocvar_g_turrets_unit_hellion_shot_speed_max;
 
@@ -87,22 +131,8 @@ void spawnfunc_turret_hellion() { SELFPARAM(); if(!turret_initialize(TUR_HELLION
 
         METHOD(Hellion, tr_attack, void(Hellion thistur))
         {
-            entity missile;
-
-            if(self.tur_head.frame != 0)
-                self.tur_shotorg = gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_fire"));
-            else
-                self.tur_shotorg = gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_fire2"));
-
-            missile = turret_projectile(SND(ROCKET_FIRE), 6, 10, DEATH_TURRET_HELLION, PROJECTILE_ROCKET, FALSE, FALSE);
-            te_explosion (missile.origin);
-            missile.think              = turret_hellion_missile_think;
-            missile.nextthink  = time;
-            missile.flags              = FL_PROJECTILE;
-            missile.max_health   = time + 9;
-            missile.tur_aimpos   = randomvec() * 128;
-            missile.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_GUIDED_HEAT;
-            self.tur_head.frame += 1;
+            Weapon wep = WEP_HELLION;
+            wep.wr_think(wep, true, false);
         }
         METHOD(Hellion, tr_think, bool(Hellion thistur))
         {
index 240143e573501c312af81a67236d943c03d89cc2..8fedee421c1904362eb17c85a16cf47887bd475e 100644 (file)
@@ -14,10 +14,52 @@ ENDCLASS(HunterKiller)
 
 REGISTER_TURRET(HK, NEW(HunterKiller));
 
+CLASS(HunterKillerAttack, PortoLaunch)
+/* flags     */ ATTRIB(HunterKillerAttack, spawnflags, int, WEP_TYPE_OTHER);
+/* impulse   */ ATTRIB(HunterKillerAttack, impulse, int, 9);
+/* refname   */ ATTRIB(HunterKillerAttack, netname, string, "turret_hk");
+/* wepname   */ ATTRIB(HunterKillerAttack, message, string, _("Hunter-Killer"));
+ENDCLASS(HunterKillerAttack)
+REGISTER_WEAPON(HK, NEW(HunterKillerAttack));
+
 #endif
 
 #ifdef IMPLEMENTATION
 #ifdef SVQC
+void turret_initparams(entity);
+void turret_hk_missile_think();
+METHOD(HunterKillerAttack, 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(ROCKET_FIRE), 6, 10, DEATH_TURRET_HK, PROJECTILE_ROCKET, FALSE, FALSE);
+        te_explosion (missile.origin);
+
+        missile.think = turret_hk_missile_think;
+        missile.nextthink = time + 0.25;
+        missile.movetype = MOVETYPE_BOUNCEMISSILE;
+        missile.velocity = self.tur_shotdir_updated * (self.shot_speed * 0.75);
+        missile.angles = vectoangles(missile.velocity);
+        missile.cnt = time + 30;
+        missile.ticrate = max(autocvar_sys_ticrate, 0.05);
+        missile.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_GUIDED_AI;
+
+        if (!isPlayer)
+        if (self.tur_head.frame == 0)
+            self.tur_head.frame = self.tur_head.frame + 1;
+       }
+       return true;
+}
+
 float autocvar_g_turrets_unit_hk_shot_speed;
 float autocvar_g_turrets_unit_hk_shot_speed_accel;
 float autocvar_g_turrets_unit_hk_shot_speed_accel2;
@@ -284,22 +326,8 @@ void spawnfunc_turret_hk() { SELFPARAM(); if(!turret_initialize(TUR_HK.m_id)) re
 
         METHOD(HunterKiller, tr_attack, void(HunterKiller thistur))
         {
-            entity missile;
-
-            missile = turret_projectile(SND(ROCKET_FIRE), 6, 10, DEATH_TURRET_HK, PROJECTILE_ROCKET, FALSE, FALSE);
-            te_explosion (missile.origin);
-
-            missile.think                      = turret_hk_missile_think;
-            missile.nextthink          = time + 0.25;
-            missile.movetype            = MOVETYPE_BOUNCEMISSILE;
-            missile.velocity            = self.tur_shotdir_updated * (self.shot_speed * 0.75);
-            missile.angles                = vectoangles(missile.velocity);
-            missile.cnt                          = time + 30;
-            missile.ticrate              = max(autocvar_sys_ticrate, 0.05);
-            missile.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_GUIDED_AI;
-
-            if (self.tur_head.frame == 0)
-                self.tur_head.frame = self.tur_head.frame + 1;
+            Weapon wep = WEP_HK;
+            wep.wr_think(wep, true, false);
         }
         METHOD(HunterKiller, tr_think, bool(HunterKiller thistur))
         {
index 8ca679a053cd7960accd836bc5f13ccf2039c047..43dc1750d71f81f1a7826ad64ccd0343cb4f616a 100644 (file)
@@ -14,20 +14,47 @@ ENDCLASS(MachineGunTurret)
 
 REGISTER_TURRET(MACHINEGUN, NEW(MachineGunTurret));
 
+CLASS(MachineGunTurretAttack, PortoLaunch)
+/* flags     */ ATTRIB(MachineGunTurretAttack, spawnflags, int, WEP_TYPE_OTHER);
+/* impulse   */ ATTRIB(MachineGunTurretAttack, impulse, int, 9);
+/* refname   */ ATTRIB(MachineGunTurretAttack, netname, string, "turret_machinegun");
+/* wepname   */ ATTRIB(MachineGunTurretAttack, message, string, _("Machinegun"));
+ENDCLASS(MachineGunTurretAttack)
+REGISTER_WEAPON(TUR_MACHINEGUN, NEW(MachineGunTurretAttack));
+
 #endif
 
 #ifdef IMPLEMENTATION
 #ifdef SVQC
-void spawnfunc_turret_machinegun() { SELFPARAM(); if(!turret_initialize(TUR_MACHINEGUN.m_id)) remove(self); }
+void turret_initparams(entity);
+void W_MachineGun_MuzzleFlash();
+
+METHOD(MachineGunTurretAttack, wr_think, bool(entity thiswep, bool fire1, bool fire2)) {
+       SELFPARAM();
+       bool isPlayer = IS_PLAYER(self);
+       if (fire1)
+       if (!isPlayer || weapon_prepareattack(false, WEP_CVAR(machinegun, sustained_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, 0, w_ready);
+        }
+        fireBullet (self.tur_shotorg, self.tur_shotdir_updated, self.shot_spread, 0, self.shot_dmg, self.shot_force, DEATH_TURRET_MACHINEGUN, 0);
+        W_MachineGun_MuzzleFlash();
+        setattachment(self.muzzle_flash, self.tur_head, "tag_fire");
+       }
+       return true;
+}
 
-void W_MachineGun_MuzzleFlash(void);
+void spawnfunc_turret_machinegun() { SELFPARAM(); if(!turret_initialize(TUR_MACHINEGUN.m_id)) remove(self); }
 
         METHOD(MachineGunTurret, tr_attack, void(MachineGunTurret thistur))
         {
-            fireBullet (self.tur_shotorg, self.tur_shotdir_updated, self.shot_spread, 0, self.shot_dmg, self.shot_force, DEATH_TURRET_MACHINEGUN, 0);
-
-            W_MachineGun_MuzzleFlash();
-            setattachment(self.muzzle_flash, self.tur_head, "tag_fire");
+            Weapon wep = WEP_TUR_MACHINEGUN;
+            wep.wr_think(wep, true, false);
         }
         METHOD(MachineGunTurret, tr_think, bool(MachineGunTurret thistur))
         {
index 35fe1e3c722b1573672d86212ba6d0483e99e1d9..08a1edcfae49349a47b1415b894806a99d4f51fe 100644 (file)
@@ -14,21 +14,48 @@ ENDCLASS(MLRSTurret)
 
 REGISTER_TURRET(MLRS, NEW(MLRSTurret));
 
+CLASS(MLRSTurretAttack, PortoLaunch)
+/* flags     */ ATTRIB(MLRSTurretAttack, spawnflags, int, WEP_TYPE_OTHER);
+/* impulse   */ ATTRIB(MLRSTurretAttack, impulse, int, 9);
+/* refname   */ ATTRIB(MLRSTurretAttack, netname, string, "turret_mlrs");
+/* wepname   */ ATTRIB(MLRSTurretAttack, message, string, _("MLRS"));
+ENDCLASS(MLRSTurretAttack)
+REGISTER_WEAPON(TUR_MLRS, NEW(MLRSTurretAttack));
+
 #endif
 
 #ifdef IMPLEMENTATION
 #ifdef SVQC
+void turret_initparams(entity);
+METHOD(MLRSTurretAttack, wr_think, bool(entity thiswep, bool fire1, bool fire2)) {
+       SELFPARAM();
+       bool isPlayer = IS_PLAYER(self);
+       if (fire1)
+       if (!isPlayer || weapon_prepareattack(false, WEP_CVAR(machinegun, sustained_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;
+            self.shot_radius = 500;
+            weapon_thinkf(WFRAME_FIRE1, 0, w_ready);
+        }
+        turret_tag_fire_update();
+        entity missile = turret_projectile(SND(ROCKET_FIRE), 6, 10, DEATH_TURRET_MLRS, PROJECTILE_ROCKET, TRUE, TRUE);
+        missile.nextthink = time + max(self.tur_impacttime,(self.shot_radius * 2) / self.shot_speed);
+        missile.missile_flags = MIF_SPLASH;
+        te_explosion (missile.origin);
+       }
+       return true;
+}
+
 void spawnfunc_turret_mlrs() { SELFPARAM(); if(!turret_initialize(TUR_MLRS.m_id)) remove(self); }
 
         METHOD(MLRSTurret, tr_attack, void(MLRSTurret thistur))
         {
-            entity missile;
-
-            turret_tag_fire_update();
-            missile = turret_projectile(SND(ROCKET_FIRE), 6, 10, DEATH_TURRET_MLRS, PROJECTILE_ROCKET, TRUE, TRUE);
-            missile.nextthink = time + max(self.tur_impacttime,(self.shot_radius * 2) / self.shot_speed);
-            missile.missile_flags = MIF_SPLASH;
-            te_explosion (missile.origin);
+            Weapon wep = WEP_TUR_MLRS;
+            wep.wr_think(wep, true, false);
         }
         METHOD(MLRSTurret, tr_think, bool(MLRSTurret thistur))
         {
index 8689ebd26290f365d1395ac0f20c4c8e5d03e4f3..7cef889095444b03c0c4263fda01e9ab84f2f47f 100644 (file)
@@ -14,11 +14,65 @@ ENDCLASS(PhaserTurret)
 
 REGISTER_TURRET(PHASER, NEW(PhaserTurret));
 
+CLASS(PhaserTurretAttack, PortoLaunch)
+/* flags     */ ATTRIB(PhaserTurretAttack, spawnflags, int, WEP_TYPE_OTHER);
+/* impulse   */ ATTRIB(PhaserTurretAttack, impulse, int, 9);
+/* refname   */ ATTRIB(PhaserTurretAttack, netname, string, "turret_phaser");
+/* wepname   */ ATTRIB(PhaserTurretAttack, message, string, _("Phaser"));
+ENDCLASS(PhaserTurretAttack)
+REGISTER_WEAPON(PHASER, NEW(PhaserTurretAttack));
+
 #endif
 
 #ifdef IMPLEMENTATION
 #ifdef SVQC
-.float fireflag;
+void beam_think();
+.int fireflag;
+METHOD(PhaserTurretAttack, 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;
+            self.shot_speed = 1;
+            weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
+        }
+        entity beam = spawn();
+        beam.ticrate = 0.1; //autocvar_sys_ticrate;
+        setmodel(beam, MDL_TUR_PHASER_BEAM);
+        beam.effects = EF_LOWPRECISION;
+        beam.solid = SOLID_NOT;
+        beam.think = beam_think;
+        beam.cnt = time + self.shot_speed;
+        beam.shot_spread = time + 2;
+        beam.nextthink = time;
+        beam.owner = self;
+        beam.shot_dmg = self.shot_dmg / (self.shot_speed / beam.ticrate);
+        beam.scale = self.target_range / 256;
+        beam.movetype = MOVETYPE_NONE;
+        beam.enemy = self.enemy;
+        beam.bot_dodge = true;
+        beam.bot_dodgerating = beam.shot_dmg;
+        sound (beam, CH_SHOTS_SINGLE, SND_TUR_PHASER, VOL_BASE, ATTEN_NORM);
+        self.fireflag = 1;
+
+        beam.attack_finished_single = self.attack_finished_single;
+        self.attack_finished_single = time; // + autocvar_sys_ticrate;
+
+        setattachment(beam,self.tur_head, "tag_fire");
+
+        soundat (self, trace_endpos, CH_SHOTS, SND(NEXIMPACT), VOL_BASE, ATTEN_NORM);
+        if (!isPlayer)
+        if (self.tur_head.frame == 0)
+            self.tur_head.frame = 1;
+    }
+    return true;
+}
 
 float turret_phaser_firecheck()
 {SELFPARAM();
@@ -68,36 +122,8 @@ void spawnfunc_turret_phaser() { SELFPARAM(); if(!turret_initialize(TUR_PHASER.m
 
         METHOD(PhaserTurret, tr_attack, void(PhaserTurret thistur))
         {
-            entity beam;
-
-            beam = spawn();
-            beam.ticrate = 0.1; //autocvar_sys_ticrate;
-            setmodel(beam, MDL_TUR_PHASER_BEAM);
-            beam.effects = EF_LOWPRECISION;
-            beam.solid = SOLID_NOT;
-            beam.think = beam_think;
-            beam.cnt = time + self.shot_speed;
-            beam.shot_spread = time + 2;
-            beam.nextthink = time;
-            beam.owner = self;
-            beam.shot_dmg = self.shot_dmg / (self.shot_speed / beam.ticrate);
-            beam.scale = self.target_range / 256;
-            beam.movetype = MOVETYPE_NONE;
-            beam.enemy = self.enemy;
-            beam.bot_dodge = true;
-            beam.bot_dodgerating = beam.shot_dmg;
-            sound (beam, CH_SHOTS_SINGLE, SND_TUR_PHASER, VOL_BASE, ATTEN_NORM);
-            self.fireflag = 1;
-
-            beam.attack_finished_single = self.attack_finished_single;
-            self.attack_finished_single = time; // + autocvar_sys_ticrate;
-
-            setattachment(beam,self.tur_head,"tag_fire");
-
-            soundat (self, trace_endpos, CH_SHOTS, SND(NEXIMPACT), VOL_BASE, ATTEN_NORM);
-
-            if (self.tur_head.frame == 0)
-                self.tur_head.frame = 1;
+            Weapon wep = WEP_PHASER;
+            wep.wr_think(wep, true, false);
         }
         METHOD(PhaserTurret, tr_think, bool(PhaserTurret thistur))
         {
index d5c8ea42a1d7f272eda7fa9953c9b84a366b9214..319740006366e70000f54bec96ddad8af355a390 100644 (file)
@@ -14,18 +14,18 @@ ENDCLASS(PlasmaTurret)
 
 REGISTER_TURRET(PLASMA, NEW(PlasmaTurret));
 
-#endif
-
-#ifdef IMPLEMENTATION
-
 CLASS(PlasmaAttack, PortoLaunch)
 /* flags     */ ATTRIB(PlasmaAttack, spawnflags, int, WEP_TYPE_OTHER);
 /* impulse   */ ATTRIB(PlasmaAttack, impulse, int, 5);
-/* refname   */ ATTRIB(PlasmaAttack, netname, string, "plasma");
+/* refname   */ ATTRIB(PlasmaAttack, netname, string, "turret_plasma");
 /* wepname   */ ATTRIB(PlasmaAttack, message, string, _("Plasma"));
 ENDCLASS(PlasmaAttack)
 REGISTER_WEAPON(PLASMA, NEW(PlasmaAttack));
 
+#endif
+
+#ifdef IMPLEMENTATION
+
 #ifdef SVQC
 
 void turret_initparams(entity tur);
index a7e064b35d6806aa59ec172f931211a7e73e371a..a8885c0404dad0d6834394410f643ba676afdb38 100644 (file)
@@ -14,20 +14,20 @@ ENDCLASS(DualPlasmaTurret)
 
 REGISTER_TURRET(PLASMA_DUAL, NEW(DualPlasmaTurret));
 
-#endif
-
-#ifdef IMPLEMENTATION
-
 #include "../../weapons/all.qh"
 
 CLASS(PlasmaDualAttack, PortoLaunch)
 /* flags     */ ATTRIB(PlasmaDualAttack, spawnflags, int, WEP_TYPE_OTHER);
 /* impulse   */ ATTRIB(PlasmaDualAttack, impulse, int, 5);
-/* refname   */ ATTRIB(PlasmaDualAttack, netname, string, "plasmadual");
+/* refname   */ ATTRIB(PlasmaDualAttack, netname, string, "turret_plasmadual");
 /* wepname   */ ATTRIB(PlasmaDualAttack, message, string, _("Dual plasma"));
 ENDCLASS(PlasmaDualAttack)
 REGISTER_WEAPON(PLASMA_DUAL, NEW(PlasmaDualAttack));
 
+#endif
+
+#ifdef IMPLEMENTATION
+
 #ifdef SVQC
 
 void turret_initparams(entity tur);
index 80b2d1e7f3011e5409c79b7a347e6603516aa3dd..84d959803809193f1abe17cd01f6679ef6f4a89a 100644 (file)
@@ -14,10 +14,66 @@ ENDCLASS(TeslaCoil)
 
 REGISTER_TURRET(TESLA, NEW(TeslaCoil));
 
+CLASS(TeslaCoilTurretAttack, PortoLaunch)
+/* flags     */ ATTRIB(TeslaCoilTurretAttack, spawnflags, int, WEP_TYPE_OTHER);
+/* impulse   */ ATTRIB(TeslaCoilTurretAttack, impulse, int, 9);
+/* refname   */ ATTRIB(TeslaCoilTurretAttack, netname, string, "turret_tesla");
+/* wepname   */ ATTRIB(TeslaCoilTurretAttack, message, string, _("Tesla Coil"));
+ENDCLASS(TeslaCoilTurretAttack)
+REGISTER_WEAPON(TESLA, NEW(TeslaCoilTurretAttack));
+
 #endif
 
 #ifdef IMPLEMENTATION
 #ifdef SVQC
+entity toast(entity from, float range, float damage);
+METHOD(TeslaCoilTurretAttack, 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);
+        }
+
+        float d = self.shot_dmg;
+        float r = self.target_range;
+        entity e = spawn();
+        setorigin(e,self.tur_shotorg);
+
+        self.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_MISSILES | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK;
+
+        entity t = toast(e,r,d);
+        remove(e);
+
+        if (t == NULL) return true;
+
+        self.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_MISSILES | TFL_TARGETSELECT_TEAMCHECK;
+
+        self.attack_finished_single = time + self.shot_refire;
+        for (int i = 0; i < 10; ++i) {
+            d *= 0.75;
+            r *= 0.85;
+            t = toast(t, r, d);
+            if (t == world) break;
+
+        }
+
+        e = findchainfloat(railgunhit, 1);
+        while (e) {
+            e.railgunhit = 0;
+            e = e.chain;
+        }
+
+    }
+    return true;
+}
+
 entity toast(entity from, float range, float damage)
 {SELFPARAM();
     entity e;
@@ -100,39 +156,8 @@ void spawnfunc_turret_tesla() { SELFPARAM(); if(!turret_initialize(TUR_TESLA.m_i
 
         METHOD(TeslaCoil, tr_attack, void(TeslaCoil thistur))
         {
-            entity e, t;
-            float d, r, i;
-
-            d = self.shot_dmg;
-            r = self.target_range;
-            e = spawn();
-            setorigin(e,self.tur_shotorg);
-
-            self.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_MISSILES | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK;
-
-            t = toast(e,r,d);
-            remove(e);
-
-            if (t == world) return;
-
-            self.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_MISSILES | TFL_TARGETSELECT_TEAMCHECK;
-
-            self.attack_finished_single = time + self.shot_refire;
-            for (i = 0; i < 10; ++i)
-            {
-                d *= 0.75;
-                r *= 0.85;
-                t = toast(t, r, d);
-                if (t == world) break;
-
-            }
-
-            e = findchainfloat(railgunhit, 1);
-            while (e)
-            {
-                e.railgunhit = 0;
-                e = e.chain;
-            }
+            Weapon wep = WEP_TESLA;
+            wep.wr_think(wep, true, false);
         }
         METHOD(TeslaCoil, tr_think, bool(TeslaCoil thistur))
         {
index 36582d4281a7efb84df535e89baea0533b2d76c5..d223bf4877c141ce7fcae1a7f5d0b82fa16f888d 100644 (file)
@@ -14,10 +14,38 @@ ENDCLASS(WalkerTurret)
 
 REGISTER_TURRET(WALKER, NEW(WalkerTurret));
 
+CLASS(WalkerTurretAttack, PortoLaunch)
+/* flags     */ ATTRIB(WalkerTurretAttack, spawnflags, int, WEP_TYPE_OTHER);
+/* impulse   */ ATTRIB(WalkerTurretAttack, impulse, int, 5);
+/* refname   */ ATTRIB(WalkerTurretAttack, netname, string, "turret_walker");
+/* wepname   */ ATTRIB(WalkerTurretAttack, message, string, _("Walker"));
+ENDCLASS(WalkerTurretAttack)
+REGISTER_WEAPON(WALKER, NEW(WalkerTurretAttack));
+
 #endif
 
 #ifdef IMPLEMENTATION
 #ifdef SVQC
+METHOD(WalkerTurretAttack, 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);
+        }
+        sound (self, CH_WEAPON_A, SND_UZI_FIRE, VOL_BASE, ATTEN_NORM);
+        fireBullet (self.tur_shotorg, self.tur_shotdir_updated, self.shot_spread, 0, self.shot_dmg, self.shot_force, DEATH_TURRET_WALK_GUN, 0);
+        Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
+    }
+    return true;
+}
+
 float autocvar_g_turrets_unit_walker_melee_damage;
 float autocvar_g_turrets_unit_walker_melee_force;
 float autocvar_g_turrets_unit_walker_melee_range;
@@ -345,9 +373,8 @@ void spawnfunc_turret_walker() { SELFPARAM(); if(!turret_initialize(TUR_WALKER.m
 
         METHOD(WalkerTurret, tr_attack, void(WalkerTurret thistur))
         {
-            sound (self, CH_WEAPON_A, SND_UZI_FIRE, VOL_BASE, ATTEN_NORM);
-            fireBullet (self.tur_shotorg, self.tur_shotdir_updated, self.shot_spread, 0, self.shot_dmg, self.shot_force, DEATH_TURRET_WALK_GUN, 0);
-            Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
+            Weapon wep = WEP_WALKER;
+            wep.wr_think(wep, true, false);
         }
         METHOD(WalkerTurret, tr_think, bool(WalkerTurret thistur))
         {
index 7f7e34dda605a04a8f6a68595d2076b9308a64d3..cf15dd6bc473c8f12e4ffc3cc00c6be64beaf217 100644 (file)
@@ -107,7 +107,7 @@ WepSet ReadWepSet();
 
 // weapon name macros
 const int WEP_FIRST = 1;
-#define WEP_MAXCOUNT 32 // Increase as needed. Can be up to 72.
+#define WEP_MAXCOUNT 72 // Increase as needed. Can be up to 72.
 int WEP_COUNT;
 #define WEP_LAST (WEP_FIRST + WEP_COUNT - 1)
 WepSet WEPSET_ALL;
index a8822f897b3496fc2dbebb828d716262f7bd2924..d0b8bee092586f348810668e245ee911999a9266 100644 (file)
@@ -1,4 +1,5 @@
-#ifndef IMPLEMENTATION
+#ifndef GAMEMODE_NEXBALL_WEAPON_H
+#define GAMEMODE_NEXBALL_WEAPON_H
 
 CLASS(BallStealer, PortoLaunch)
 /* flags     */ ATTRIB(BallStealer, spawnflags, int, WEP_TYPE_OTHER);