diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Heap.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Heap.java index b45bf1267..d24ea2df1 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Heap.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Heap.java @@ -62,8 +62,6 @@ import java.util.Collections; import java.util.LinkedList; public class Heap implements Bundlable { - - private static final int SEEDS_TO_POTION = 3; public enum Type { HEAP, @@ -82,6 +80,7 @@ public class Heap implements Bundlable { public ItemSprite sprite; public boolean seen = false; + public boolean haunted = false; public LinkedList items = new LinkedList(); @@ -140,6 +139,14 @@ public class Heap implements Bundlable { break; default: } + + if (haunted){ + if (Wraith.spawnAt( pos ) == null) { + hero.sprite.emitter().burst( ShadowParticle.CURSE, 6 ); + hero.damage( hero.HP / 2, this ); + } + Sample.INSTANCE.play( Assets.SND_CURSED ); + } if (type != Type.MIMIC) { type = Type.HEAP; @@ -153,6 +160,17 @@ public class Heap implements Bundlable { } } + public Heap setHauntedIfCursed( float chance ){ + for (Item item : items) { + if (item.cursed && Random.Float() < chance) { + haunted = true; + item.cursedKnown = true; + break; + } + } + return this; + } + public int size() { return items.size(); } @@ -429,6 +447,7 @@ public class Heap implements Bundlable { private static final String SEEN = "seen"; private static final String TYPE = "type"; private static final String ITEMS = "items"; + private static final String HAUNTED = "haunted"; @SuppressWarnings("unchecked") @Override @@ -449,6 +468,8 @@ public class Heap implements Bundlable { } } + haunted = bundle.getBoolean( HAUNTED ); + } @Override @@ -457,6 +478,7 @@ public class Heap implements Bundlable { bundle.put( SEEN, seen ); bundle.put( TYPE, type.toString() ); bundle.put( ITEMS, items ); + bundle.put( HAUNTED, haunted ); } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/CavesBossLevel.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/CavesBossLevel.java index c932e1f06..23094b3fb 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/CavesBossLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/CavesBossLevel.java @@ -202,7 +202,7 @@ public class CavesBossLevel extends Level { do { pos = Random.IntRange( ROOM_LEFT, ROOM_RIGHT ) + Random.IntRange( ROOM_TOP + 1, ROOM_BOTTOM ) * width(); } while (pos == entrance); - drop( item, pos ).type = Heap.Type.REMAINS; + drop( item, pos ).setHauntedIfCursed(1f).type = Heap.Type.REMAINS; } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/CityBossLevel.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/CityBossLevel.java index 290c25a7f..312afee31 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/CityBossLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/CityBossLevel.java @@ -173,7 +173,7 @@ public class CityBossLevel extends Level { Random.IntRange( LEFT + 1, LEFT + HALL_WIDTH - 2 ) + Random.IntRange( TOP + HALL_HEIGHT + 2, TOP + HALL_HEIGHT + CHAMBER_HEIGHT ) * width(); } while (pos == entrance); - drop( item, pos ).type = Heap.Type.REMAINS; + drop( item, pos ).setHauntedIfCursed(1f).type = Heap.Type.REMAINS; } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/HallsBossLevel.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/HallsBossLevel.java index 74c9ab5a1..a2f4b1f02 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/HallsBossLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/HallsBossLevel.java @@ -163,7 +163,7 @@ public class HallsBossLevel extends Level { do { pos = Random.IntRange( ROOM_LEFT, ROOM_RIGHT ) + Random.IntRange( ROOM_TOP + 1, ROOM_BOTTOM ) * width(); } while (pos == entrance); - drop( item, pos ).type = Heap.Type.REMAINS; + drop( item, pos ).setHauntedIfCursed(1f).type = Heap.Type.REMAINS; } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/LastShopLevel.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/LastShopLevel.java index 4f6036832..c2cc2fbeb 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/LastShopLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/LastShopLevel.java @@ -121,7 +121,7 @@ public class LastShopLevel extends RegularLevel { do { pos = pointToCell(roomEntrance.random()); } while (pos == entrance); - drop( item, pos ).type = Heap.Type.REMAINS; + drop( item, pos ).setHauntedIfCursed(1f).type = Heap.Type.REMAINS; } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/PrisonBossLevel.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/PrisonBossLevel.java index 67e5f1dd2..0971c12ee 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/PrisonBossLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/PrisonBossLevel.java @@ -159,7 +159,7 @@ public class PrisonBossLevel extends Level { protected void createItems() { Item item = Bones.get(); if (item != null) { - drop( item, randomRespawnCell() ).type = Heap.Type.REMAINS; + drop( item, randomRespawnCell() ).setHauntedIfCursed(1f).type = Heap.Type.REMAINS; } drop(new IronKey(10), randomPrisonCell()); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java index 1ef1eec12..5c78c60ac 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java @@ -341,7 +341,11 @@ public abstract class RegularLevel extends Level { addItemToSpawn(new GoldenKey(Dungeon.depth)); } } else { - drop( toDrop, cell ).type = type; + Heap dropped = drop( toDrop, cell ); + dropped.type = type; + if (type == Heap.Type.SKELETON){ + dropped.setHauntedIfCursed(0.75f); + } } } @@ -362,7 +366,7 @@ public abstract class RegularLevel extends Level { map[cell] = Terrain.GRASS; losBlocking[cell] = false; } - drop( item, cell ).type = Heap.Type.REMAINS; + drop( item, cell ).setHauntedIfCursed(1f).type = Heap.Type.REMAINS; } //guide pages diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/SewerBossLevel.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/SewerBossLevel.java index 5f733b523..71ac1fbdb 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/SewerBossLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/SewerBossLevel.java @@ -121,7 +121,7 @@ public class SewerBossLevel extends SewerLevel { do { pos = pointToCell(roomEntrance.random()); } while (pos == entrance || solid[pos]); - drop( item, pos ).type = Heap.Type.REMAINS; + drop( item, pos ).setHauntedIfCursed(1f).type = Heap.Type.REMAINS; } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/secret/SecretSummoningRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/secret/SecretSummoningRoom.java index b8d4dd506..b9ad3636d 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/secret/SecretSummoningRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/secret/SecretSummoningRoom.java @@ -51,7 +51,7 @@ public class SecretSummoningRoom extends SecretRoom { Painter.fill(level, this, 1, Terrain.SECRET_TRAP); Point center = center(); - level.drop(Generator.random(), level.pointToCell(center)).type = Heap.Type.SKELETON; + level.drop(Generator.random(), level.pointToCell(center)).setHauntedIfCursed(0.75f).type = Heap.Type.SKELETON; for (Point p : getPoints()){ int cell = level.pointToCell(p); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/MassGraveRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/MassGraveRoom.java index 8e068398f..97cf03f23 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/MassGraveRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/MassGraveRoom.java @@ -89,6 +89,7 @@ public class MassGraveRoom extends SpecialRoom { pos = level.pointToCell(random()); } while (level.map[pos] != Terrain.EMPTY_SP || level.heaps.get(pos) != null); Heap h = level.drop(item, pos); + h.haunted = true; h.type = Heap.Type.SKELETON; } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/PitRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/PitRoom.java index f9db3a077..88d576a54 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/PitRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/PitRoom.java @@ -81,7 +81,7 @@ public class PitRoom extends SpecialRoom { int n = Random.IntRange( 1, 2 ); for (int i=0; i < n; i++) { - level.drop( prize( level ), remains ); + level.drop( prize( level ), remains ).setHauntedIfCursed(0.75f); } }