v3.0.0: fixed new target swapping causing removed enemies to be attacked

This commit is contained in:
Evan Debenham
2024-12-31 13:05:52 -05:00
parent 4446177e84
commit 7cdc881c24

View File

@@ -1205,7 +1205,7 @@ public abstract class Mob extends Char {
if (!recentlyAttackedBy.isEmpty()){
boolean swapped = false;
for (Char ch : recentlyAttackedBy){
if (ch != null && alignment != ch.alignment && fieldOfView[ch.pos] && ch.invisible == 0 && !isCharmedBy(ch)) {
if (ch != null && ch.isActive() && Actor.chars().contains(ch) && alignment != ch.alignment && fieldOfView[ch.pos] && ch.invisible == 0 && !isCharmedBy(ch)) {
if (canAttack(ch) || enemy == null || Dungeon.level.distance(pos, ch.pos) < Dungeon.level.distance(pos, enemy.pos)) {
enemy = ch;
target = ch.pos;