From ed6d26e0a7972247416d7257b77738c0b912f97a Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 8 Jul 2024 15:32:36 -0400 Subject: [PATCH] v2.5.0: mimics are now sneaky if hero had mimic tooth when they spawned --- .../shatteredpixeldungeon/Dungeon.java | 4 +--- .../actors/mobs/EbonyMimic.java | 5 +++++ .../shatteredpixeldungeon/actors/mobs/Mimic.java | 16 +++++++++++++++- .../shatteredpixeldungeon/levels/Level.java | 6 ++---- .../shatteredpixeldungeon/scenes/GameScene.java | 4 +--- .../sprites/MimicSprite.java | 12 ++++++------ 6 files changed, 30 insertions(+), 17 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java index 03d7984fc..35dd1a7e5 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java @@ -49,7 +49,6 @@ import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TalismanOfForesi import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll; -import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.MimicTooth; import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfRegrowth; import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfWarding; import com.shatteredpixel.shatteredpixeldungeon.journal.Notes; @@ -950,10 +949,9 @@ public class Dungeon { GameScene.updateFog(l, t, width, height); - boolean stealthyMimics = MimicTooth.stealthyMimics(); if (hero.buff(MindVision.class) != null){ for (Mob m : level.mobs.toArray(new Mob[0])){ - if (stealthyMimics && m instanceof Mimic && m.alignment == Char.Alignment.NEUTRAL){ + if (m instanceof Mimic && m.alignment == Char.Alignment.NEUTRAL && ((Mimic) m).stealthy()){ continue; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/EbonyMimic.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/EbonyMimic.java index 5cae1c05b..a53473cb4 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/EbonyMimic.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/EbonyMimic.java @@ -66,6 +66,11 @@ public class EbonyMimic extends Mimic { } } + @Override + public boolean stealthy() { + return true; + } + public void stopHiding(){ state = HUNTING; if (sprite != null) sprite.idle(); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mimic.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mimic.java index c070f4964..6c6e86132 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mimic.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mimic.java @@ -65,15 +65,19 @@ public class Mimic extends Mob { } public ArrayList items; + + private boolean stealthy = false; private static final String LEVEL = "level"; private static final String ITEMS = "items"; + private static final String STEALTHY= "stealthy"; @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle( bundle ); if (items != null) bundle.put( ITEMS, items ); bundle.put( LEVEL, level ); + bundle.put( STEALTHY, stealthy ); } @SuppressWarnings("unchecked") @@ -84,6 +88,7 @@ public class Mimic extends Mob { } level = bundle.getInt( LEVEL ); adjustStats(level); + stealthy = bundle.getBoolean(STEALTHY); super.restoreFromBundle(bundle); if (state != PASSIVE && alignment == Alignment.NEUTRAL){ alignment = Alignment.ENEMY; @@ -142,7 +147,7 @@ public class Mimic extends Mob { @Override public CharSprite sprite() { MimicSprite sprite = (MimicSprite) super.sprite(); - if (alignment == Alignment.NEUTRAL) sprite.hideMimic(); + if (alignment == Alignment.NEUTRAL) sprite.hideMimic(this); return sprite; } @@ -215,6 +220,11 @@ public class Mimic extends Mob { } } + //stealthy mimics have changes to visual behaviour that make them much harder to detect + public boolean stealthy(){ + return stealthy; + } + @Override public int damageRoll() { if (alignment == Alignment.NEUTRAL){ @@ -309,6 +319,10 @@ public class Mimic extends Mob { //generate an extra reward for killing the mimic m.generatePrize(useDecks); + if (MimicTooth.stealthyMimics()){ + m.stealthy = true; + } + return m; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java index 189fe911e..c51c42078 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java @@ -71,7 +71,6 @@ import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfEnchantment; import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfIntuition; import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.DimensionalSundial; import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.EyeOfNewt; -import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.MimicTooth; import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.MossyClump; import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.TrapMechanism; import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.TrinketCatalyst; @@ -1342,10 +1341,9 @@ public abstract class Level implements Bundlable { } Dungeon.hero.mindVisionEnemies.clear(); - boolean stealthyMimics = MimicTooth.stealthyMimics(); if (c.buff( MindVision.class ) != null) { for (Mob mob : mobs) { - if (stealthyMimics && mob instanceof Mimic && mob.alignment == Char.Alignment.NEUTRAL){ + if (mob instanceof Mimic && mob.alignment == Char.Alignment.NEUTRAL&& ((Mimic) mob).stealthy()){ continue; } for (int i : PathFinder.NEIGHBOURS9) { @@ -1362,7 +1360,7 @@ public abstract class Level implements Bundlable { if (mindVisRange >= 1) { for (Mob mob : mobs) { - if (stealthyMimics && mob instanceof Mimic && mob.alignment == Char.Alignment.NEUTRAL) { + if (mob instanceof Mimic && mob.alignment == Char.Alignment.NEUTRAL&& ((Mimic) mob).stealthy()){ continue; } int p = mob.pos; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java index f432b1575..3118fe54a 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java @@ -60,7 +60,6 @@ import com.shatteredpixel.shatteredpixeldungeon.items.journal.Guidebook; import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation; import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.DimensionalSundial; -import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.MimicTooth; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon; import com.shatteredpixel.shatteredpixeldungeon.journal.Document; import com.shatteredpixel.shatteredpixeldungeon.journal.Journal; @@ -1323,10 +1322,9 @@ public class GameScene extends PixelScene { public static void afterObserve() { if (scene != null) { - boolean stealthyMimics = MimicTooth.stealthyMimics(); for (Mob mob : Dungeon.level.mobs.toArray(new Mob[0])) { if (mob.sprite != null) { - if (stealthyMimics && mob instanceof Mimic && mob.state == mob.PASSIVE && mob.sprite.visible){ + if (mob instanceof Mimic && mob.state == mob.PASSIVE && ((Mimic) mob).stealthy() && mob.sprite.visible){ //mimics stay visible in fog of war after being first seen mob.sprite.visible = true; } else { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/MimicSprite.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/MimicSprite.java index 18bceb41f..27002b35d 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/MimicSprite.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/MimicSprite.java @@ -23,7 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.sprites; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; -import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.MimicTooth; +import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic; import com.watabou.noosa.TextureFilm; public class MimicSprite extends MobSprite { @@ -77,12 +77,12 @@ public class MimicSprite extends MobSprite { public void linkVisuals(Char ch) { super.linkVisuals(ch); if (ch.alignment == Char.Alignment.NEUTRAL) { - hideMimic(); + hideMimic(ch); } } - public void hideMimic(){ - if (MimicTooth.stealthyMimics()){ + public void hideMimic(Char ch){ + if (ch instanceof Mimic && ((Mimic) ch).stealthy()){ play(advancedHiding); } else { play(hiding); @@ -119,8 +119,8 @@ public class MimicSprite extends MobSprite { } @Override - public void hideMimic() { - super.hideMimic(); + public void hideMimic(Char ch) { + super.hideMimic(ch); alpha(0.2f); }