From ed6394354efc15db281846cc0373e04f57478dc6 Mon Sep 17 00:00:00 2001 From: Thayol Date: Sat, 18 Jan 2025 10:01:46 +0900 Subject: [PATCH] fix auto attack range after cast --- src/ability.js | 9 ++++----- src/entity.js | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/ability.js b/src/ability.js index 366c0d4..ea61f8d 100644 --- a/src/ability.js +++ b/src/ability.js @@ -70,9 +70,9 @@ export default class Ability { radius: 5, range: 500, speed: 2000, - effect: function rangedAttackEffect(caster, cursor) { + effect: function rangedAttackEffect(caster, targetId) { const ability = this - const target = caster.closestTargetTo(cursor, ability.range) + const target = caster.game?.entities.find((it) => it.id == targetId) if (target == null) { return } const rangedAttackAfter = function rangedAttackAfter() { @@ -102,10 +102,9 @@ export default class Ability { damage: 60, radius: 5, range: 100, - effect: function meleeAttackEffect(caster, cursor) { + effect: function meleeAttackEffect(caster, targetId) { const ability = this - const target = caster.closestTargetTo(cursor, ability.range) - + const target = caster.game?.entities.find((it) => it.id == targetId) if (target == null) { return } target.damage(ability.damage) diff --git a/src/entity.js b/src/entity.js index 086412d..344092a 100644 --- a/src/entity.js +++ b/src/entity.js @@ -275,7 +275,7 @@ export default class Entity { const timestamp = this.game?.currentTick ?? 0 if (lastCast != null && lastCast + cooldown > timestamp) { return false } - this.castAction('a', cursor, false) + this.castAction('a', target.id, false) return true } }