fix auto attack range after cast

This commit is contained in:
2025-01-18 10:01:46 +09:00
parent 8ebae0d866
commit ed6394354e
2 changed files with 5 additions and 6 deletions
+4 -5
View File
@@ -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)
+1 -1
View File
@@ -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
}
}