exclude dead entities from auto-attack target selection
This commit is contained in:
+1
-1
@@ -85,7 +85,7 @@ export default class Ability {
|
||||
const entities = projectile.game?.entities ?? []
|
||||
const pos = projectile.position
|
||||
projectile.despawn()
|
||||
const nearbyDeadTeammates = entities.filter((it) => it.dead && it.team == team)
|
||||
const nearbyDeadTeammates = entities.filter((it) => it.dead && it.team == team && it.distanceTo(pos) <= ability.radius)
|
||||
const closestDeadTeammate = nearbyDeadTeammates.reduce((e1, e2) => (e1?.distanceTo(pos) ?? Infinity) < e2.distanceTo(pos) ? e1 : e2, null)
|
||||
if (closestDeadTeammate != null) {
|
||||
closestDeadTeammate.revive(closestDeadTeammate.maxHealth / 4)
|
||||
|
||||
+2
-2
@@ -300,8 +300,8 @@ export default class Entity {
|
||||
const entities = this.game?.entities
|
||||
if (entities == null) { return }
|
||||
const targetsInRange = targetAllies
|
||||
? entities.filter((it) => this.team == it.team && it.distanceTo(cursor) <= range + this.radius + it.radius)
|
||||
: entities.filter((it) => this.team != it.team && it.distanceTo(cursor) <= range + this.radius + it.radius)
|
||||
? entities.filter((it) => !it.dead && this.team == it.team && it.distanceTo(cursor) <= range + this.radius + it.radius)
|
||||
: entities.filter((it) => !it.dead && this.team != it.team && it.distanceTo(cursor) <= range + this.radius + it.radius)
|
||||
|
||||
if (targetsInRange.length < 1) { return }
|
||||
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ export default class Game {
|
||||
|
||||
if (options.action == 'attack') { entity.attackAction(new Vector2(options.x, options.y)) }
|
||||
if (options.action == 'cast') { entity.castAction(options.slot, new Vector2(options.x, options.y)) }
|
||||
if (options.action == 'halt') { entity.haltAction(), delay }
|
||||
if (options.action == 'halt') { entity.haltAction() }
|
||||
if (options.action == 'stop') { entity.stopAction() }
|
||||
if (options.action == 'move') { entity.moveAction(new Vector2(options.x, options.y)) }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user