diff --git a/www/assets/js/Enums.js b/www/assets/js/Enums.js index f7aaccf..ad1602f 100644 --- a/www/assets/js/Enums.js +++ b/www/assets/js/Enums.js @@ -221,6 +221,7 @@ const Action = { MOVE_BACK: 'back', MOVE_RIGHT: 'right', JUMP: 'jump', + JUMP_THROW: 'jump_throw', CROUCH: 'crouch', WALK: 'walk', RELOAD: 'reload', diff --git a/www/assets/js/PlayerAction.js b/www/assets/js/PlayerAction.js index d20d95a..6cfc49d 100644 --- a/www/assets/js/PlayerAction.js +++ b/www/assets/js/PlayerAction.js @@ -1,4 +1,4 @@ -import {Action, InventorySlot} from "./Enums.js"; +import {Action, GrenadeSlots, InventorySlot} from "./Enums.js"; export class PlayerAction { #game @@ -70,6 +70,12 @@ export class PlayerAction { this.#actionCallback[Action.MOVE_RIGHT] = (enabled) => this.#states.moveRight = enabled this.#actionCallback[Action.USE] = (enabled) => this.#states.use = enabled this.#actionCallback[Action.JUMP] = (enabled) => enabled && (this.#states.jumping = true) + this.#actionCallback[Action.JUMP_THROW] = (enabled) => { + if (enabled && GrenadeSlots.includes(game.playerMe.getEquippedSlotId())) { + this.#states.jumping = true + this.attack(game.getPlayerMeRotation()) + } + } this.#actionCallback[Action.CROUCH] = (enabled) => enabled ? this.#states.crouching = true : this.#states.standing = true this.#actionCallback[Action.WALK] = (enabled) => enabled ? this.#states.shifting = true : this.#states.running = true this.#actionCallback[Action.DROP] = (enabled) => enabled && (this.#states.drop = true) diff --git a/www/assets/js/Setting.js b/www/assets/js/Setting.js index 74ede7d..a6c1e54 100644 --- a/www/assets/js/Setting.js +++ b/www/assets/js/Setting.js @@ -45,6 +45,7 @@ export class Setting { 'KeyV': Action.EQUIP_KNIFE, 'KeyT': Action.DROP_BOMB, 'KeyH': Action.SWITCH_HANDS, + 'KeyJ': Action.JUMP_THROW, 'Digit1': Action.EQUIP_PRIMARY, 'Digit2': Action.EQUIP_SECONDARY, 'Digit3': Action.EQUIP_KNIFE,