Added offhand blaster.
authorLyberta <lyberta@lyberta.net>
Fri, 16 Feb 2018 08:02:12 +0000 (11:02 +0300)
committerLyberta <lyberta@lyberta.net>
Fri, 16 Feb 2018 08:02:12 +0000 (11:02 +0300)
qcsrc/common/mutators/mutator/_mod.inc
qcsrc/common/mutators/mutator/_mod.qh
qcsrc/common/mutators/mutator/offhand_blaster/_mod.inc [new file with mode: 0644]
qcsrc/common/mutators/mutator/offhand_blaster/_mod.qh [new file with mode: 0644]
qcsrc/common/mutators/mutator/offhand_blaster/sv_offhand_blaster.qc [new file with mode: 0644]
qcsrc/common/mutators/mutator/overkill/sv_overkill.qc
qcsrc/common/weapons/weapon/blaster.qc
qcsrc/common/weapons/weapon/blaster.qh
qcsrc/common/weapons/weapon/vaporizer.qc

index 9d52fa2..40a763c 100644 (file)
@@ -22,6 +22,7 @@
 #include <common/mutators/mutator/nades/_mod.inc>
 #include <common/mutators/mutator/new_toys/_mod.inc>
 #include <common/mutators/mutator/nix/_mod.inc>
+#include <common/mutators/mutator/offhand_blaster/_mod.inc>
 #include <common/mutators/mutator/overkill/_mod.inc>
 #include <common/mutators/mutator/physical_items/_mod.inc>
 #include <common/mutators/mutator/pinata/_mod.inc>
index f9edf4c..6a9261d 100644 (file)
@@ -22,6 +22,7 @@
 #include <common/mutators/mutator/nades/_mod.qh>
 #include <common/mutators/mutator/new_toys/_mod.qh>
 #include <common/mutators/mutator/nix/_mod.qh>
+#include <common/mutators/mutator/offhand_blaster/_mod.qh>
 #include <common/mutators/mutator/overkill/_mod.qh>
 #include <common/mutators/mutator/physical_items/_mod.qh>
 #include <common/mutators/mutator/pinata/_mod.qh>
diff --git a/qcsrc/common/mutators/mutator/offhand_blaster/_mod.inc b/qcsrc/common/mutators/mutator/offhand_blaster/_mod.inc
new file mode 100644 (file)
index 0000000..41bb01e
--- /dev/null
@@ -0,0 +1,4 @@
+// generated file; do not modify
+#ifdef SVQC
+    #include <common/mutators/mutator/offhand_blaster/sv_offhand_blaster.qc>
+#endif
diff --git a/qcsrc/common/mutators/mutator/offhand_blaster/_mod.qh b/qcsrc/common/mutators/mutator/offhand_blaster/_mod.qh
new file mode 100644 (file)
index 0000000..98fb481
--- /dev/null
@@ -0,0 +1 @@
+// generated file; do not modify
diff --git a/qcsrc/common/mutators/mutator/offhand_blaster/sv_offhand_blaster.qc b/qcsrc/common/mutators/mutator/offhand_blaster/sv_offhand_blaster.qc
new file mode 100644 (file)
index 0000000..a4b9b18
--- /dev/null
@@ -0,0 +1,24 @@
+string autocvar_g_offhand_blaster;
+
+REGISTER_MUTATOR(offhand_blaster, expr_evaluate(autocvar_g_offhand_blaster));
+
+MUTATOR_HOOKFUNCTION(offhand_blaster, BuildMutatorsString)
+{
+       M_ARGV(0, string) = strcat(M_ARGV(0, string), ":offhand_blaster");
+}
+
+MUTATOR_HOOKFUNCTION(offhand_blaster, BuildMutatorsPrettyString)
+{
+       M_ARGV(0, string) = strcat(M_ARGV(0, string), ", Offhand blaster");
+}
+
+MUTATOR_HOOKFUNCTION(offhand_blaster, BuildGameplayTipsString)
+{
+    M_ARGV(0, string) = strcat(M_ARGV(0, string), "\n\n^3offhand blaster^8 is enabled, press 'e' to use it\n");
+}
+
+MUTATOR_HOOKFUNCTION(offhand_blaster, PlayerSpawn)
+{
+       entity player = M_ARGV(0, entity);
+       player.offhand = OFFHAND_BLASTER;
+}
index fab0b6f..cb790af 100644 (file)
@@ -144,23 +144,7 @@ MUTATOR_HOOKFUNCTION(ok, PlayerPreThink)
                        if(player.(weaponentity).m_weapon == WEP_Null && slot != 0)
                                continue;
 
-                       Weapon oldwep = player.(weaponentity).m_weapon;
-                       player.(weaponentity).m_weapon = WEP_BLASTER;
-                       W_Blaster_Attack(
-                               player,
-                               weaponentity,
-                               WEP_BLASTER.m_id | HITTYPE_SECONDARY,
-                               WEP_CVAR_SEC(vaporizer, shotangle),
-                               WEP_CVAR_SEC(vaporizer, damage),
-                               WEP_CVAR_SEC(vaporizer, edgedamage),
-                               WEP_CVAR_SEC(vaporizer, radius),
-                               WEP_CVAR_SEC(vaporizer, force),
-                               WEP_CVAR_SEC(vaporizer, speed),
-                               WEP_CVAR_SEC(vaporizer, spread),
-                               WEP_CVAR_SEC(vaporizer, delay),
-                               WEP_CVAR_SEC(vaporizer, lifetime)
-                       );
-                       player.(weaponentity).m_weapon = oldwep;
+                       BLASTER_SECONDARY_ATTACK_HACK(vaporizer, player, weaponentity);
                }
        }
 
index 2189c1d..9ca40be 100644 (file)
@@ -193,6 +193,17 @@ METHOD(Blaster, wr_killmessage, Notification(entity thiswep))
     return WEAPON_BLASTER_MURDER;
 }
 
+METHOD(OffhandBlaster, offhand_think, void(OffhandBlaster this, entity actor, bool key_pressed))
+{
+       if (!key_pressed || (time < actor.jump_interval))
+       {
+               return;
+       }
+       actor.jump_interval = time + WEP_CVAR_SEC(blaster, refire) * W_WeaponRateFactor(actor);
+       .entity weaponentity = weaponentities[1];
+       BLASTER_SECONDARY_ATTACK_HACK(blaster, actor, weaponentity);
+}
+
 #endif
 #ifdef CSQC
 
index 0a0e7c1..9d28e73 100644 (file)
@@ -48,6 +48,10 @@ REGISTER_WEAPON(BLASTER, blaster, NEW(Blaster));
 SPAWNFUNC_WEAPON(weapon_blaster, WEP_BLASTER)
 SPAWNFUNC_WEAPON(weapon_laser, WEP_BLASTER)
 
+CLASS(OffhandBlaster, OffhandWeapon)
+ENDCLASS(OffhandBlaster)
+OffhandBlaster OFFHAND_BLASTER; STATIC_INIT(OFFHAND_BLASTER) { OFFHAND_BLASTER = NEW(OffhandBlaster); }
+
 #ifdef SVQC
 .float blaster_damage;
 .float blaster_edgedamage;
@@ -55,4 +59,24 @@ SPAWNFUNC_WEAPON(weapon_laser, WEP_BLASTER)
 .float blaster_force;
 .float blaster_lifetime;
 
+#define BLASTER_SECONDARY_ATTACK_HACK(weapon_name, actor, weaponentity) \
+       makevectors(actor.v_angle); \
+       Weapon oldwep = actor.(weaponentity).m_weapon; \
+       actor.(weaponentity).m_weapon = WEP_BLASTER; \
+       W_Blaster_Attack( \
+               actor, \
+               weaponentity, \
+               WEP_BLASTER.m_id | HITTYPE_SECONDARY, \
+               WEP_CVAR_SEC(weapon_name, shotangle), \
+               WEP_CVAR_SEC(weapon_name, damage), \
+               WEP_CVAR_SEC(weapon_name, edgedamage), \
+               WEP_CVAR_SEC(weapon_name, radius), \
+               WEP_CVAR_SEC(weapon_name, force), \
+               WEP_CVAR_SEC(weapon_name, speed), \
+               WEP_CVAR_SEC(weapon_name, spread), \
+               WEP_CVAR_SEC(weapon_name, delay), \
+               WEP_CVAR_SEC(weapon_name, lifetime) \
+       ); \
+       actor.(weaponentity).m_weapon = oldwep;
+
 #endif
index 4a9475a..0cb3883 100644 (file)
@@ -342,25 +342,7 @@ METHOD(Vaporizer, wr_think, void(entity thiswep, entity actor, .entity weaponent
             if(WEP_CVAR_SEC(vaporizer, ammo))
                 W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(vaporizer, ammo), weaponentity);
 
-            // ugly instagib hack to reuse the fire mode of the laser
-            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(vaporizer, shotangle),
-                WEP_CVAR_SEC(vaporizer, damage),
-                WEP_CVAR_SEC(vaporizer, edgedamage),
-                WEP_CVAR_SEC(vaporizer, radius),
-                WEP_CVAR_SEC(vaporizer, force),
-                WEP_CVAR_SEC(vaporizer, speed),
-                WEP_CVAR_SEC(vaporizer, spread),
-                WEP_CVAR_SEC(vaporizer, delay),
-                WEP_CVAR_SEC(vaporizer, lifetime)
-            );
-            actor.(weaponentity).m_weapon = oldwep;
+            BLASTER_SECONDARY_ATTACK_HACK(vaporizer, actor, weaponentity);
 
             // now do normal refire
             weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(vaporizer, animtime), w_ready);