From 834e0d46f010c553556a05ac0a872d009d96b029 Mon Sep 17 00:00:00 2001 From: Jbleezy Date: Mon, 3 Jan 2022 04:00:44 -0800 Subject: [PATCH] Add ability to switch to melee weapon --- README.md | 1 + scripts/zm/_zm_reimagined.gsc | 70 ++++++++++++++++++++++++++++++++++- 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 25d19657..54a07a63 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ * Removed hint when player is first attacked on solo ## Weapons +* Switch to melee weapon by pressing the new melee weapon button (same button as the Maxis Drone on Origins) ### AN-94 * Increased weapon cost from 1200 to 1500 diff --git a/scripts/zm/_zm_reimagined.gsc b/scripts/zm/_zm_reimagined.gsc index 7dd560b7..c60ce163 100644 --- a/scripts/zm/_zm_reimagined.gsc +++ b/scripts/zm/_zm_reimagined.gsc @@ -85,7 +85,7 @@ onplayerspawned() self thread fall_velocity_check(); - //self thread remove_fast_melee(); // Removed until melee weapon can be added + self thread melee_weapon_switch_watcher(); self thread solo_lives_fix(); @@ -1731,6 +1731,74 @@ fall_velocity_check() } } +melee_weapon_switch_watcher() +{ + self endon("disconnect"); + + self thread melee_weapon_disable_weapon_trading(); + + prev_wep = undefined; + while(1) + { + melee_wep = self get_player_melee_weapon(); + curr_wep = self getCurrentWeapon(); + + if(self actionSlotTwoButtonPressed() && !self hasWeapon("equip_dieseldrone_zm")) + { + if(curr_wep != melee_wep) + { + prev_wep = curr_wep; + self switchToWeapon(melee_wep); + } + else + { + if(isDefined(prev_wep) && self hasWeapon(prev_wep)) + { + self switchToWeapon(prev_wep); + } + else + { + self switchToWeapon(self getWeaponsListPrimaries()[0]); + } + + prev_wep = undefined; + } + + self waittill("weapon_change"); + } + + wait 0.05; + } +} + +melee_weapon_disable_weapon_trading() +{ + self endon("disconnect"); + + while(1) + { + melee_wep = self get_player_melee_weapon(); + curr_wep = self getCurrentWeapon(); + + if(curr_wep == melee_wep && self getWeaponsListPrimaries().size >= 1) + { + self.is_drinking = 1; + + while(curr_wep == melee_wep && self getWeaponsListPrimaries().size >= 1) + { + melee_wep = self get_player_melee_weapon(); + curr_wep = self getCurrentWeapon(); + + wait 0.05; + } + + self.is_drinking = 0; + } + + wait 0.05; + } +} + remove_fast_melee() { self endon("disconnect");