v0.9.2a: standardized behaviour for if enemies are in mind vision

This commit is contained in:
Evan Debenham
2021-03-07 19:29:34 -05:00
parent cb3845a18d
commit 771a028419

View File

@@ -1051,7 +1051,9 @@ public abstract class Level implements Bundlable {
blobs.get(Web.class).clear(cell);
}
}
private static boolean[] heroMindFov;
public void updateFieldOfView( Char c, boolean[] fieldOfView ) {
int cx = c.pos % width();
@@ -1124,37 +1126,35 @@ public abstract class Level implements Bundlable {
//Currently only the hero can get mind vision or awareness
if (c.isAlive() && c == Dungeon.hero) {
if (heroMindFov == null || heroMindFov.length != length()){
heroMindFov = new boolean[length];
} else {
BArray.setFalse(heroMindFov);
}
Dungeon.hero.mindVisionEnemies.clear();
if (c.buff( MindVision.class ) != null) {
for (Mob mob : mobs) {
int p = mob.pos;
if (!fieldOfView[p]){
Dungeon.hero.mindVisionEnemies.add(mob);
for (int i : PathFinder.NEIGHBOURS9) {
heroMindFov[mob.pos + i] = true;
}
}
} else if (((Hero) c).hasTalent(Talent.HEIGHTENED_SENSES)) {
for (Mob mob : mobs) {
int p = mob.pos;
if (!fieldOfView[p]
&& distance(c.pos, p) <= 1+((Hero) c).pointsInTalent(Talent.HEIGHTENED_SENSES)) {
Dungeon.hero.mindVisionEnemies.add(mob);
if (!fieldOfView[p] && distance(c.pos, p) <= 1+((Hero) c).pointsInTalent(Talent.HEIGHTENED_SENSES)) {
for (int i : PathFinder.NEIGHBOURS9) {
heroMindFov[mob.pos + i] = true;
}
}
}
}
for (Mob m : Dungeon.hero.mindVisionEnemies) {
for (int i : PathFinder.NEIGHBOURS9) {
fieldOfView[m.pos + i] = true;
}
}
if (c.buff( Awareness.class ) != null) {
for (Heap heap : heaps.valueList()) {
int p = heap.pos;
for (int i : PathFinder.NEIGHBOURS9)
fieldOfView[p+i] = true;
for (int i : PathFinder.NEIGHBOURS9) heroMindFov[p+i] = true;
}
}
@@ -1166,14 +1166,12 @@ public abstract class Level implements Bundlable {
continue;
}
int p = ch.pos;
for (int i : PathFinder.NEIGHBOURS9)
fieldOfView[p+i] = true;
for (int i : PathFinder.NEIGHBOURS9) heroMindFov[p+i] = true;
}
for (TalismanOfForesight.HeapAwareness h : c.buffs(TalismanOfForesight.HeapAwareness.class)){
if (Dungeon.depth != h.depth) continue;
for (int i : PathFinder.NEIGHBOURS9)
fieldOfView[h.pos+i] = true;
for (int i : PathFinder.NEIGHBOURS9) heroMindFov[h.pos+i] = true;
}
for (Mob m : mobs){
@@ -1182,22 +1180,24 @@ public abstract class Level implements Bundlable {
m.fieldOfView = new boolean[length()];
Dungeon.level.updateFieldOfView( m, m.fieldOfView );
}
for (Mob m1 : mobs){
if (m.fieldOfView[m1.pos] && !fieldOfView[m1.pos] &&
!Dungeon.hero.mindVisionEnemies.contains(m1)){
Dungeon.hero.mindVisionEnemies.add(m1);
}
}
BArray.or(fieldOfView, m.fieldOfView, fieldOfView);
BArray.or(heroMindFov, m.fieldOfView, heroMindFov);
}
}
for (RevealedArea a : c.buffs(RevealedArea.class)){
if (Dungeon.depth != a.depth) continue;
for (int i : PathFinder.NEIGHBOURS9)
fieldOfView[a.pos+i] = true;
for (int i : PathFinder.NEIGHBOURS9) heroMindFov[a.pos+i] = true;
}
//set mind vision chars
for (Mob mob : mobs) {
if (heroMindFov[mob.pos] && !fieldOfView[mob.pos]){
Dungeon.hero.mindVisionEnemies.add(mob);
}
}
BArray.or(heroMindFov, fieldOfView, fieldOfView);
}
if (c == Dungeon.hero) {