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