From b1ae257c3b74dedd9bd5cd2440d40717286f901a Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Fri, 18 Mar 2022 16:34:54 -0400 Subject: [PATCH] v1.2.0: fixed various errors with sentry rooms --- .../assets/messages/levels/levels.properties | 2 +- .../shatteredpixeldungeon/actors/hero/Hero.java | 3 ++- .../levels/rooms/special/SentryRoom.java | 17 +++++++++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/core/src/main/assets/messages/levels/levels.properties b/core/src/main/assets/messages/levels/levels.properties index 6e34557b3..fbfe8239b 100644 --- a/core/src/main/assets/messages/levels/levels.properties +++ b/core/src/main/assets/messages/levels/levels.properties @@ -15,7 +15,7 @@ levels.rooms.special.massgraveroom$bones.name=Mass grave levels.rooms.special.massgraveroom$bones.desc=Bones litter the floor, what happened here? levels.rooms.special.sentryroom$sentry.name=red sentry -levels.rooms.special.sentryroom$sentry.desc=This blood-red sentry seems to be positioned here to guard the treasure at the other end of this room. It will fire beams of disintegration magic at you if you step in the area it defends. It's immune to all harmful effects, but seems to take a while to charge up before it starts firing.\n\nSomehow the sentry only wants to fire on you, as if it knows that the denizens of the dungeon are no threat to the treasure. +levels.rooms.special.sentryroom$sentry.desc=This blood-red sentry seems to be positioned here to guard the treasure at the other end of this room. It will fire beams of disintegration magic at you if you step in the area it defends.\n\nIt's immune to all harmful effects and can see through invisibility, but seems to take a while to charge up before it starts firing.\n\nSomehow the sentry only wants to fire on you, as if it knows that the denizens of the dungeon are no threat to the treasure. levels.rooms.special.toxicgasroom$toxicvent.name=toxic vent levels.rooms.special.toxicgasroom$toxicvent.desc=A careless adventurer must have triggered this trap ages ago. Despite its inactive state, it's still spewing toxic gas into the room and shows no signs of stopping. You'll need some way to prevent damage from the gas if you want to explore this room. diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java index 38e949bfc..fbd63dd6a 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java @@ -59,6 +59,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.abilities.warrior.En import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Monk; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Snake; +import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.NPC; import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter; import com.shatteredpixel.shatteredpixeldungeon.effects.CheckedCell; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; @@ -1278,7 +1279,7 @@ public class Hero extends Char { Mob target = null; for (Mob m : Dungeon.level.mobs.toArray(new Mob[0])) { - if (fieldOfView[ m.pos ] && m.alignment == Alignment.ENEMY) { + if (fieldOfView[ m.pos ] && m.alignment == Alignment.ENEMY && !(m instanceof NPC)) { visible.add(m); if (!visibleEnemies.contains( m )) { newMob = true; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/SentryRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/SentryRoom.java index 07b45beb1..a12f8f280 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/SentryRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/SentryRoom.java @@ -39,8 +39,10 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.EmptyRoom; +import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.sprites.MobSprite; import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTilemap; +import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.watabou.noosa.Game; import com.watabou.noosa.audio.Sample; import com.watabou.noosa.particles.Emitter; @@ -215,6 +217,7 @@ public class SentryRoom extends SpecialRoom { spriteClass = SentrySprite.class; properties.add(Property.IMMOVABLE); + alignment = Alignment.ENEMY; } private float initialChargeDelay; @@ -224,9 +227,18 @@ public class SentryRoom extends SpecialRoom { @Override protected boolean act() { - if (Dungeon.hero != null){ + if (fieldOfView == null || fieldOfView.length != Dungeon.level.length()){ + fieldOfView = new boolean[Dungeon.level.length()]; + } + Dungeon.level.updateFieldOfView( this, fieldOfView ); - if (Dungeon.level.map[Dungeon.hero.pos] == Terrain.EMPTY_SP + if (properties().contains(Property.IMMOVABLE)){ + throwItems(); + } + + if (Dungeon.hero != null){ + if (fieldOfView[Dungeon.hero.pos] + && Dungeon.level.map[Dungeon.hero.pos] == Terrain.EMPTY_SP && room.inside(Dungeon.level.cellToPoint(Dungeon.hero.pos))){ if (curChargeDelay > 0.001f){ //helps prevent rounding errors @@ -264,6 +276,7 @@ public class SentryRoom extends SpecialRoom { public void onZapComplete(){ Dungeon.hero.damage(Random.NormalIntRange(2+Dungeon.depth/2, 4+Dungeon.depth), new Eye.DeathGaze()); if (!Dungeon.hero.isAlive()){ + GLog.n( Messages.capitalize(Messages.get(Char.class, "kill", name())) ); Dungeon.fail( getClass() ); } }