fix melee attacks
This commit is contained in:
+6
-4
@@ -107,7 +107,7 @@ export default class Entity {
|
||||
return false
|
||||
}
|
||||
|
||||
this.casting = { ability, cursor, timestamp }
|
||||
this.casting = { ability, cursor, timestamp } // TODO: use ID only for ability
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -118,7 +118,9 @@ export default class Entity {
|
||||
|
||||
moveAction(cursor, attack = false) {
|
||||
if (this.casting != null && this.casting.ability.moveCancelable) {
|
||||
this.casting = null
|
||||
if (!attack && !(this.casting != null && this.casting.ability.id == this.abilities[0])) {
|
||||
this.casting = null
|
||||
}
|
||||
}
|
||||
|
||||
this.#attacking = attack
|
||||
@@ -266,8 +268,8 @@ export default class Entity {
|
||||
const cursor = this.#dest ?? this.position
|
||||
const basicAttack = this.ability(0)
|
||||
if (basicAttack != null) {
|
||||
const target = this.closestTargetTo(cursor, basicAttack.range)
|
||||
if (target != null && this.distanceTo(target.position) < basicAttack.range) {
|
||||
const target = this.closestTargetTo(cursor, 500)
|
||||
if (target != null && this.distanceTo(target.position) < basicAttack.range + this.radius + target.radius) {
|
||||
const cooldown = this.game?.secToTick(basicAttack.cooldown) ?? 0
|
||||
const lastCast = this.cooldowns[basicAttack.id]
|
||||
const timestamp = this.game?.currentTick ?? 0
|
||||
|
||||
Reference in New Issue
Block a user