v2.4.0: improved 'adjacent enemy' logic for swiftness

This commit is contained in:
Evan Debenham
2024-04-19 15:05:14 -04:00
parent 51a82bc591
commit 5b959f315c

View File

@@ -346,11 +346,20 @@ public class Armor extends EquipableItem {
if (hasGlyph(Swiftness.class, owner)) {
boolean enemyNear = false;
PathFinder.buildDistanceMap(owner.pos, Dungeon.level.passable, 2);
//for each enemy, check if they are adjacent, or within 2 tiles and an adjacent cell is open
for (Char ch : Actor.chars()){
if ( PathFinder.distance[ch.pos] != Integer.MAX_VALUE && owner.alignment != ch.alignment){
enemyNear = true;
break;
if ( Dungeon.level.distance(ch.pos, owner.pos) <= 2 && owner.alignment != ch.alignment){
if (Dungeon.level.adjacent(ch.pos, owner.pos)){
enemyNear = true;
break;
} else {
for (int i : PathFinder.NEIGHBOURS8){
if (Dungeon.level.adjacent(owner.pos+i, ch.pos) && !Dungeon.level.solid[owner.pos+i]){
enemyNear = true;
break;
}
}
}
}
}
if (!enemyNear) speed *= (1.2f + 0.04f * buffedLvl()) * glyph.procChanceMultiplier(owner);