1
0
forked from noxious/server

Don't attack if isMoving

This commit is contained in:
2025-02-12 03:01:07 +01:00
parent d75ed7a44f
commit 8cca44a3b4
3 changed files with 23 additions and 8 deletions

View File

@ -11,8 +11,16 @@ export default class CharacterMove extends BaseEvent {
private async handleEvent(data: any, callback: (response: any) => void): Promise<void> {
try {
console.log('attack', this.socket.characterId)
await this.characterAttackService.attack(this.socket.characterId)
if (!this.socket.characterId) {
this.logger.error('map:character:attack error: Character not found or not initialized')
return
}
// Don't attack if the character is already moving
if (this.getMapCharacter()?.isMoving) return
// Start attack
await this.characterAttackService.attack(this.socket.characterId!)
} catch (error) {
this.logger.error('map:character:attack error', error)
return callback(false)