Skip to content
This repository has been archived by the owner on Nov 3, 2024. It is now read-only.

Commit

Permalink
fix: force melee switch to make sure lol
Browse files Browse the repository at this point in the history
  • Loading branch information
leia-uwu committed Sep 26, 2024
1 parent b412ec1 commit f8e94f6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
7 changes: 6 additions & 1 deletion server/src/game/objects/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
12 changes: 8 additions & 4 deletions server/src/game/weaponManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,26 @@ 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;

if (!this.weapons[idx].type) {
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();

Expand Down

0 comments on commit f8e94f6

Please sign in to comment.