From f8e94f6cf7255a880872c717379e5d6c7b6ba77b Mon Sep 17 00:00:00 2001 From: leia uwu Date: Thu, 26 Sep 2024 17:42:56 -0300 Subject: [PATCH] fix: force melee switch to make sure lol --- server/src/game/objects/player.ts | 7 ++++++- server/src/game/weaponManager.ts | 12 ++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/server/src/game/objects/player.ts b/server/src/game/objects/player.ts index 393a7394..acee0af2 100644 --- a/server/src/game/objects/player.ts +++ b/server/src/game/objects/player.ts @@ -889,7 +889,12 @@ export class Player extends BaseGameObject { this.weapons, ); this.weapons[GameConfig.WeaponSlot.Melee].type ||= "fists"; - this.weaponManager.setCurWeapIndex(GameConfig.WeaponSlot.Melee); + this.weaponManager.setCurWeapIndex( + GameConfig.WeaponSlot.Melee, + undefined, + undefined, + true, + ); } super.serializeFull(); } diff --git a/server/src/game/weaponManager.ts b/server/src/game/weaponManager.ts index 0ad6bd0b..1a6a890f 100644 --- a/server/src/game/weaponManager.ts +++ b/server/src/game/weaponManager.ts @@ -52,9 +52,13 @@ export class WeaponManager { * @param shouldReload will attempt automatic reload at 0 ammo if true * @returns */ - setCurWeapIndex(idx: number, cancelAction = true, cancelSlowdown = true): void { + setCurWeapIndex( + idx: number, + cancelAction = true, + cancelSlowdown = true, + forceSwitch = false, + ): void { // if current slot is invalid and next too, switch to melee - let forceMeleeSwitch = false; if (!this.activeWeapon && !this.weapons[idx].type) { idx = WeaponSlot.Melee; @@ -62,12 +66,12 @@ export class WeaponManager { this.weapons[idx].type = "fists"; this.weapons[idx].cooldown = 0; } - forceMeleeSwitch = true; + forceSwitch = true; } if (idx === this._curWeapIdx) return; if (this.weapons[idx].type === "") return; - if (this.bursts.length && !forceMeleeSwitch) return; + if (this.bursts.length && !forceSwitch) return; this.player.cancelAnim();