From bfba7197b7fe55a97b98ee32a231094dd1da9fdf Mon Sep 17 00:00:00 2001 From: Dennis Postma Date: Sun, 16 Feb 2025 21:22:49 +0100 Subject: [PATCH] #359: Throttle attack --- src/events/map/characterAttack.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/events/map/characterAttack.ts b/src/events/map/characterAttack.ts index 4ded236..8afbe7c 100644 --- a/src/events/map/characterAttack.ts +++ b/src/events/map/characterAttack.ts @@ -19,6 +19,11 @@ export default class CharacterMove extends BaseEvent { // Don't attack if the character is already moving if (this.getMapCharacter()?.isMoving) return + const throttleKey = `attack_${this.socket.characterId}` + if (this.isThrottled(throttleKey, 1000)) { + return + } + // Start attack await this.characterAttackService.attack(this.socket.characterId!) } catch (error) {