]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
OK weapons: Better secondary attack code.
authorLyberta <lyberta@lyberta.net>
Sat, 17 Feb 2018 06:55:02 +0000 (09:55 +0300)
committerLyberta <lyberta@lyberta.net>
Sat, 17 Feb 2018 06:55:02 +0000 (09:55 +0300)
qcsrc/common/mutators/mutator/overkill/hmg.qc
qcsrc/common/mutators/mutator/overkill/okmachinegun.qc
qcsrc/common/mutators/mutator/overkill/oknex.qc
qcsrc/common/mutators/mutator/overkill/okshotgun.qc
qcsrc/common/mutators/mutator/overkill/rpc.qc

index 28bc8c8b55930c347987b7a25bb0b3bb5ef338ff..347e76d4be1a8036e6a4ea76e6407026ba2be306 100644 (file)
@@ -70,25 +70,7 @@ METHOD(HeavyMachineGun, wr_think, void(entity thiswep, entity actor, .entity wea
        {
                // Secondary uses it's own refire timer if refire_type is 1.
                actor.jump_interval = time + WEP_CVAR_SEC(hmg, refire) * W_WeaponRateFactor(actor);
-               // Ugly hack to reuse the fire mode of the blaster.
-               makevectors(actor.v_angle);
-               Weapon oldwep = actor.(weaponentity).m_weapon; // we can't avoid this hack
-               actor.(weaponentity).m_weapon = WEP_BLASTER;
-               W_Blaster_Attack(
-                       actor,
-                       weaponentity,
-                       WEP_BLASTER.m_id | HITTYPE_SECONDARY,
-                       WEP_CVAR_SEC(hmg, shotangle),
-                       WEP_CVAR_SEC(hmg, damage),
-                       WEP_CVAR_SEC(hmg, edgedamage),
-                       WEP_CVAR_SEC(hmg, radius),
-                       WEP_CVAR_SEC(hmg, force),
-                       WEP_CVAR_SEC(hmg, speed),
-                       WEP_CVAR_SEC(hmg, spread),
-                       WEP_CVAR_SEC(hmg, delay),
-                       WEP_CVAR_SEC(hmg, lifetime)
-               );
-               actor.(weaponentity).m_weapon = oldwep;
+               BLASTER_SECONDARY_ATTACK(hmg, actor, weaponentity);
                if ((actor.(weaponentity).wframe == WFRAME_IDLE) ||
                        (actor.(weaponentity).wframe == WFRAME_FIRE2))
                {
@@ -128,22 +110,7 @@ METHOD(HeavyMachineGun, wr_think, void(entity thiswep, entity actor, .entity wea
                {
                        return;
                }
-               // ugly instagib hack to reuse the fire mode of the laser
-               makevectors(actor.v_angle);
-               W_Blaster_Attack(
-                       actor,
-                       weaponentity,
-                       WEP_BLASTER.m_id | HITTYPE_SECONDARY,
-                       WEP_CVAR_SEC(hmg, shotangle),
-                       WEP_CVAR_SEC(hmg, damage),
-                       WEP_CVAR_SEC(hmg, edgedamage),
-                       WEP_CVAR_SEC(hmg, radius),
-                       WEP_CVAR_SEC(hmg, force),
-                       WEP_CVAR_SEC(hmg, speed),
-                       WEP_CVAR_SEC(hmg, spread),
-                       WEP_CVAR_SEC(hmg, delay),
-                       WEP_CVAR_SEC(hmg, lifetime)
-               );
+               BLASTER_SECONDARY_ATTACK(hmg, actor, weaponentity);
                weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(hmg, animtime), w_ready);
        }
 }
index 48c6634ddff28b695c9425927b6a9e3fffbbe342..63c1e245b4ad1121cfbf593ac4e563da67c6b2b0 100644 (file)
@@ -64,22 +64,7 @@ METHOD(OverkillMachineGun, wr_think, void(entity thiswep, entity actor, .entity
        {
                // Secondary uses it's own refire timer if refire_type is 1.
                actor.jump_interval = time + WEP_CVAR_SEC(okmachinegun, refire) * W_WeaponRateFactor(actor);
-               // Ugly hack to reuse the fire mode of the blaster.
-               makevectors(actor.v_angle);
-               W_Blaster_Attack(
-                       actor,
-                       weaponentity,
-                       WEP_BLASTER.m_id | HITTYPE_SECONDARY,
-                       WEP_CVAR_SEC(okmachinegun, shotangle),
-                       WEP_CVAR_SEC(okmachinegun, damage),
-                       WEP_CVAR_SEC(okmachinegun, edgedamage),
-                       WEP_CVAR_SEC(okmachinegun, radius),
-                       WEP_CVAR_SEC(okmachinegun, force),
-                       WEP_CVAR_SEC(okmachinegun, speed),
-                       WEP_CVAR_SEC(okmachinegun, spread),
-                       WEP_CVAR_SEC(okmachinegun, delay),
-                       WEP_CVAR_SEC(okmachinegun, lifetime)
-               );
+               BLASTER_SECONDARY_ATTACK(okmachinegun, actor, weaponentity);
                if ((actor.(weaponentity).wframe == WFRAME_IDLE) ||
                        (actor.(weaponentity).wframe == WFRAME_FIRE2))
                {
@@ -119,22 +104,7 @@ METHOD(OverkillMachineGun, wr_think, void(entity thiswep, entity actor, .entity
                {
                        return;
                }
-               // Ugly hack to reuse the fire mode of the blaster.
-               makevectors(actor.v_angle);
-               W_Blaster_Attack(
-                       actor,
-                       weaponentity,
-                       WEP_BLASTER.m_id | HITTYPE_SECONDARY,
-                       WEP_CVAR_SEC(okmachinegun, shotangle),
-                       WEP_CVAR_SEC(okmachinegun, damage),
-                       WEP_CVAR_SEC(okmachinegun, edgedamage),
-                       WEP_CVAR_SEC(okmachinegun, radius),
-                       WEP_CVAR_SEC(okmachinegun, force),
-                       WEP_CVAR_SEC(okmachinegun, speed),
-                       WEP_CVAR_SEC(okmachinegun, spread),
-                       WEP_CVAR_SEC(okmachinegun, delay),
-                       WEP_CVAR_SEC(okmachinegun, lifetime)
-               );
+               BLASTER_SECONDARY_ATTACK(okmachinegun, actor, weaponentity);
                weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(okmachinegun, animtime), w_ready);
        }
 }
index cbfa1216d8206a70849a0360d927a650dc0f6347..0f67ddba2b0e8bca1318e35c7f75461cff7ae9da 100644 (file)
@@ -140,22 +140,7 @@ METHOD(OverkillNex, wr_think, void(entity thiswep, entity actor, .entity weapone
        {
                // Secondary uses it's own refire timer if refire_type is 1.
                actor.jump_interval = time + WEP_CVAR_SEC(oknex, refire) * W_WeaponRateFactor(actor);
-               // Ugly hack to reuse the fire mode of the blaster.
-               makevectors(actor.v_angle);
-               W_Blaster_Attack(
-                       actor,
-                       weaponentity,
-                       WEP_BLASTER.m_id | HITTYPE_SECONDARY,
-                       WEP_CVAR_SEC(oknex, shotangle),
-                       WEP_CVAR_SEC(oknex, damage),
-                       WEP_CVAR_SEC(oknex, edgedamage),
-                       WEP_CVAR_SEC(oknex, radius),
-                       WEP_CVAR_SEC(oknex, force),
-                       WEP_CVAR_SEC(oknex, speed),
-                       WEP_CVAR_SEC(oknex, spread),
-                       WEP_CVAR_SEC(oknex, delay),
-                       WEP_CVAR_SEC(oknex, lifetime)
-               );
+               BLASTER_SECONDARY_ATTACK(oknex, actor, weaponentity);
                if ((actor.(weaponentity).wframe == WFRAME_IDLE) ||
                        (actor.(weaponentity).wframe == WFRAME_FIRE2))
                {
@@ -197,22 +182,7 @@ METHOD(OverkillNex, wr_think, void(entity thiswep, entity actor, .entity weapone
                {
                        return;
                }
-               // ugly instagib hack to reuse the fire mode of the laser
-               makevectors(actor.v_angle);
-               W_Blaster_Attack(
-                       actor,
-                       weaponentity,
-                       WEP_BLASTER.m_id | HITTYPE_SECONDARY,
-                       WEP_CVAR_SEC(oknex, shotangle),
-                       WEP_CVAR_SEC(oknex, damage),
-                       WEP_CVAR_SEC(oknex, edgedamage),
-                       WEP_CVAR_SEC(oknex, radius),
-                       WEP_CVAR_SEC(oknex, force),
-                       WEP_CVAR_SEC(oknex, speed),
-                       WEP_CVAR_SEC(oknex, spread),
-                       WEP_CVAR_SEC(oknex, delay),
-                       WEP_CVAR_SEC(oknex, lifetime)
-               );
+               BLASTER_SECONDARY_ATTACK(oknex, actor, weaponentity);
                weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(oknex, animtime), w_ready);
                return;
        }
index a0c80f25ec7457787b926a700a79af76ce9d6f09..2f1651776fdab25a67b98a42b0f9e386b44805ea 100644 (file)
@@ -19,22 +19,7 @@ METHOD(OverkillShotgun, wr_think, void(entity thiswep, entity actor, .entity wea
        {
                // Secondary uses it's own refire timer if refire_type is 1.
                actor.jump_interval = time + WEP_CVAR_SEC(okshotgun, refire) * W_WeaponRateFactor(actor);
-               // Ugly hack to reuse the fire mode of the blaster.
-               makevectors(actor.v_angle);
-               W_Blaster_Attack(
-                       actor,
-                       weaponentity,
-                       WEP_BLASTER.m_id | HITTYPE_SECONDARY,
-                       WEP_CVAR_SEC(okshotgun, shotangle),
-                       WEP_CVAR_SEC(okshotgun, damage),
-                       WEP_CVAR_SEC(okshotgun, edgedamage),
-                       WEP_CVAR_SEC(okshotgun, radius),
-                       WEP_CVAR_SEC(okshotgun, force),
-                       WEP_CVAR_SEC(okshotgun, speed),
-                       WEP_CVAR_SEC(okshotgun, spread),
-                       WEP_CVAR_SEC(okshotgun, delay),
-                       WEP_CVAR_SEC(okshotgun, lifetime)
-               );
+               BLASTER_SECONDARY_ATTACK(okshotgun, actor, weaponentity);
                if ((actor.(weaponentity).wframe == WFRAME_IDLE) ||
                        (actor.(weaponentity).wframe == WFRAME_FIRE2))
                {
@@ -80,22 +65,7 @@ METHOD(OverkillShotgun, wr_think, void(entity thiswep, entity actor, .entity wea
                {
                        return;
                }
-               // Ugly hack to reuse the fire mode of the blaster.
-               makevectors(actor.v_angle);
-               W_Blaster_Attack(
-                       actor,
-                       weaponentity,
-                       WEP_BLASTER.m_id | HITTYPE_SECONDARY,
-                       WEP_CVAR_SEC(okshotgun, shotangle),
-                       WEP_CVAR_SEC(okshotgun, damage),
-                       WEP_CVAR_SEC(okshotgun, edgedamage),
-                       WEP_CVAR_SEC(okshotgun, radius),
-                       WEP_CVAR_SEC(okshotgun, force),
-                       WEP_CVAR_SEC(okshotgun, speed),
-                       WEP_CVAR_SEC(okshotgun, spread),
-                       WEP_CVAR_SEC(okshotgun, delay),
-                       WEP_CVAR_SEC(okshotgun, lifetime)
-               );
+               BLASTER_SECONDARY_ATTACK(okshotgun, actor, weaponentity);
                weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(okshotgun, animtime), w_ready);
        }
 }
index f42a55f65e012aa8f54f55a5377f8fe8fd60dccc..ceb4563b84bfd1b76992a32c9e486704a93ba04f 100644 (file)
@@ -121,25 +121,7 @@ METHOD(RocketPropelledChainsaw, wr_think, void(entity thiswep, entity actor, .en
        {
                // Secondary uses it's own refire timer if refire_type is 1.
                actor.jump_interval = time + WEP_CVAR_SEC(rpc, refire) * W_WeaponRateFactor(actor);
-               // Ugly hack to reuse the fire mode of the blaster.
-               makevectors(actor.v_angle);
-               Weapon oldwep = actor.(weaponentity).m_weapon; // we can't avoid this hack
-               actor.(weaponentity).m_weapon = WEP_BLASTER;
-               W_Blaster_Attack(
-                       actor,
-                       weaponentity,
-                       WEP_BLASTER.m_id | HITTYPE_SECONDARY,
-                       WEP_CVAR_SEC(rpc, shotangle),
-                       WEP_CVAR_SEC(rpc, damage),
-                       WEP_CVAR_SEC(rpc, edgedamage),
-                       WEP_CVAR_SEC(rpc, radius),
-                       WEP_CVAR_SEC(rpc, force),
-                       WEP_CVAR_SEC(rpc, speed),
-                       WEP_CVAR_SEC(rpc, spread),
-                       WEP_CVAR_SEC(rpc, delay),
-                       WEP_CVAR_SEC(rpc, lifetime)
-               );
-               actor.(weaponentity).m_weapon = oldwep;
+               BLASTER_SECONDARY_ATTACK(rpc, actor, weaponentity);
                if ((actor.(weaponentity).wframe == WFRAME_IDLE) ||
                        (actor.(weaponentity).wframe == WFRAME_FIRE2))
                {
@@ -179,22 +161,7 @@ METHOD(RocketPropelledChainsaw, wr_think, void(entity thiswep, entity actor, .en
                {
                        return;
                }
-               // ugly instagib hack to reuse the fire mode of the laser
-               makevectors(actor.v_angle);
-               W_Blaster_Attack(
-                       actor,
-                       weaponentity,
-                       WEP_BLASTER.m_id | HITTYPE_SECONDARY,
-                       WEP_CVAR_SEC(rpc, shotangle),
-                       WEP_CVAR_SEC(rpc, damage),
-                       WEP_CVAR_SEC(rpc, edgedamage),
-                       WEP_CVAR_SEC(rpc, radius),
-                       WEP_CVAR_SEC(rpc, force),
-                       WEP_CVAR_SEC(rpc, speed),
-                       WEP_CVAR_SEC(rpc, spread),
-                       WEP_CVAR_SEC(rpc, delay),
-                       WEP_CVAR_SEC(rpc, lifetime)
-               );
+               BLASTER_SECONDARY_ATTACK(rpc, actor, weaponentity);
                weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(rpc, animtime), w_ready);
        }
 }