From 9c11e1549b0955bc04e46efdb3258d6201a93196 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Thu, 14 Sep 2023 14:21:56 -0400 Subject: [PATCH] v2.2.0: added some early level painting for crystal quest variant --- .../actors/mobs/npcs/Blacksmith.java | 33 ++++++++++--------- .../levels/painters/MiningLevelPainter.java | 16 --------- .../levels/rooms/quest/MineEntrance.java | 10 +++++- .../levels/rooms/quest/MineGiantRoom.java | 13 ++++++-- .../levels/rooms/quest/MineLargeRoom.java | 12 +++++-- .../levels/rooms/quest/MineSecretRoom.java | 8 ++++- .../levels/rooms/quest/MineSmallRoom.java | 13 +++++++- 7 files changed, 65 insertions(+), 40 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Blacksmith.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Blacksmith.java index 3592f4654..d864f5123 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Blacksmith.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Blacksmith.java @@ -81,7 +81,7 @@ public class Blacksmith extends NPC { String msg1 = ""; String msg2 = ""; - if (Quest.type == 0){ + if (Quest.type == Quest.OLD){ //pre-v2.2.0 saves msg1 = Quest.alternative ? Messages.get(Blacksmith.this, "blood_1") : Messages.get(Blacksmith.this, "gold_1"); } else { @@ -98,9 +98,9 @@ public class Blacksmith extends NPC { msg1 += "\n\n" + Messages.get(Blacksmith.this, "intro_quest_start"); switch (Quest.type){ - case 1: msg2 += Messages.get(Blacksmith.this, "intro_quest_crystal"); break; - case 2: msg2 += Messages.get(Blacksmith.this, "intro_quest_fungi"); break; - case 3: msg2 += Messages.get(Blacksmith.this, "intro_quest_gnoll"); break; + case Quest.CRYSTAL: msg2 += Messages.get(Blacksmith.this, "intro_quest_crystal"); break; + case Quest.FUNGI: msg2 += Messages.get(Blacksmith.this, "intro_quest_fungi"); break; + case Quest.GNOLL: msg2 += Messages.get(Blacksmith.this, "intro_quest_gnoll"); break; } } @@ -137,7 +137,7 @@ public class Blacksmith extends NPC { } else if (!Quest.completed) { - if (Quest.type == 0) { + if (Quest.type == Quest.OLD) { if (Quest.alternative) { Pickaxe pick = Dungeon.hero.belongings.getItem(Pickaxe.class); @@ -190,7 +190,7 @@ public class Blacksmith extends NPC { tell(Messages.get(this, "reminder")); } - } else if (Quest.type == 0 && Quest.reforges == 0) { + } else if (Quest.type == Quest.OLD && Quest.reforges == 0) { Game.runOnRenderThread(new Callback() { @Override @@ -248,11 +248,11 @@ public class Blacksmith extends NPC { public static class Quest { - // 0 = old blacksmith quest (pre-2.2.0) - // 1 = Crystal - // 2 = Fungi - // 3 = Gnoll - private static int type; + private static int type = 0; + public static final int OLD = 0; + public static final int CRYSTAL = 1; + public static final int FUNGI = 2; + public static final int GNOLL = 3; //pre-v2.2.0 private static boolean alternative; //false for mining gold, true for bat blood @@ -375,10 +375,11 @@ public class Blacksmith extends NPC { //currently the new quest is disabled in production as it is incomplete if (DeviceCompat.isDebug()){ - type = 1+Random.Int(3); + //type = 1+Random.Int(3); + type = CRYSTAL; alternative = false; } else { - type = 0; + type = OLD; alternative = Random.Int(2) == 0; } @@ -438,15 +439,15 @@ public class Blacksmith extends NPC { //if the blacksmith is generated pre-v2.2.0, and the player never spawned a mining test floor public static boolean oldQuestMineBlocked(){ - return type == 0 && !Dungeon.levelHasBeenGenerated(Dungeon.depth, 1); + return type == OLD && !Dungeon.levelHasBeenGenerated(Dungeon.depth, 1); } public static boolean oldBloodQuest(){ - return type == 0 && alternative; + return type == OLD && alternative; } public static boolean oldMiningQuest(){ - return type == 0 && !alternative; + return type == OLD && !alternative; } } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/painters/MiningLevelPainter.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/painters/MiningLevelPainter.java index ddcfa94a9..2d95b279e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/painters/MiningLevelPainter.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/painters/MiningLevelPainter.java @@ -39,8 +39,6 @@ public class MiningLevelPainter extends CavesPainter { // and an excellent job of ensuring that the total gold amount is consistent // but it doesn't ensure anything about gold distribution. Gold can often be overly clumped in certain areas - //TODO gold on left/right/below walls is also super hard to see atm - private int goldToAdd = 0; public RegularPainter setGold(int amount){ @@ -119,20 +117,6 @@ public class MiningLevelPainter extends CavesPainter { } - /* - //spreads gold over an entire cluster, currently unused - private void spreadGold(int i, boolean[] gold){ - for (int k : PathFinder.NEIGHBOURS4){ - if (!insideMap(i+k)) continue; - if (goldToAdd > 0 && gold[i+k] && map[i+k] == Terrain.WALL){ - map[i+k] = Terrain.BARRICADE; - goldToAdd--; - spreadGold(i+k, gold); - } - } - } - */ - @Override protected void paintDoors(Level l, ArrayList rooms) { HashMap roomMerges = new HashMap<>(); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/quest/MineEntrance.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/quest/MineEntrance.java index da7c05cb0..989eb892f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/quest/MineEntrance.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/quest/MineEntrance.java @@ -23,6 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.quest; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; +import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Blacksmith; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition; @@ -76,7 +77,14 @@ public class MineEntrance extends EntranceRoom { 0, LevelTransition.Type.BRANCH_EXIT)); - //TODO add per-quest decorations here + if (Blacksmith.Quest.Type() == Blacksmith.Quest.CRYSTAL){ + for (int i = 0; i < width()*height()/3; i ++){ + Point r = random(1); + if (level.distance(level.pointToCell(r), entrance) > 1) { + Painter.set(level, r, Terrain.MINE_CRYSTAL); + } + } + } } public static class QuestExit extends CustomTilemap { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/quest/MineGiantRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/quest/MineGiantRoom.java index 82308aaa9..e34931194 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/quest/MineGiantRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/quest/MineGiantRoom.java @@ -21,6 +21,7 @@ package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.quest; +import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Blacksmith; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; @@ -42,9 +43,15 @@ public class MineGiantRoom extends CaveRoom { public void paint(Level level) { super.paint(level); - //TODO per-quest details here - - Painter.fillEllipse(level, this, 3, Terrain.EMPTY); + if (Blacksmith.Quest.Type() == Blacksmith.Quest.CRYSTAL){ + Painter.fillEllipse(level, this, 2, Terrain.MINE_CRYSTAL); + Painter.fillEllipse(level, this, 4, Terrain.EMPTY); + for (int i = 0; i < (width()-8)*(height()-8)/3; i ++){ + Painter.set(level, random(4), Terrain.MINE_CRYSTAL); + } + } else { + Painter.fillEllipse(level, this, 3, Terrain.EMPTY); + } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/quest/MineLargeRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/quest/MineLargeRoom.java index 6839d79e3..f249d1b00 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/quest/MineLargeRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/quest/MineLargeRoom.java @@ -21,6 +21,7 @@ package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.quest; +import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Blacksmith; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; @@ -43,9 +44,16 @@ public class MineLargeRoom extends CaveRoom { public void paint(Level level) { super.paint(level); - //TODO per-quest details here + if (Blacksmith.Quest.Type() == Blacksmith.Quest.CRYSTAL){ + Painter.fillEllipse(level, this, 2, Terrain.MINE_CRYSTAL); + Painter.fillEllipse(level, this, 4, Terrain.EMPTY); - Painter.fillEllipse(level, this, 3, Terrain.EMPTY); + for (int i = 0; i < (width()-8)*(height()-8)/5; i ++){ + Painter.set(level, random(4), Terrain.MINE_CRYSTAL); + } + } else { + Painter.fillEllipse(level, this, 3, Terrain.EMPTY); + } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/quest/MineSecretRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/quest/MineSecretRoom.java index 6685a438b..889da0e73 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/quest/MineSecretRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/quest/MineSecretRoom.java @@ -21,6 +21,7 @@ package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.quest; +import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Blacksmith; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; @@ -38,7 +39,12 @@ public class MineSecretRoom extends SecretRoom { @Override public void paint(Level level) { Painter.fill( level, this, Terrain.WALL ); - Painter.fill( level, this, 1, Terrain.EMPTY ); + + if (Blacksmith.Quest.Type() == Blacksmith.Quest.CRYSTAL) { + Painter.fill(level, this, 1, Terrain.MINE_CRYSTAL); + } else { + Painter.fill(level, this, 1, Terrain.EMPTY); + } entrance().set( Door.Type.HIDDEN ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/quest/MineSmallRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/quest/MineSmallRoom.java index 68fabcd1d..c8ba3e77f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/quest/MineSmallRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/quest/MineSmallRoom.java @@ -21,8 +21,12 @@ package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.quest; +import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Blacksmith; 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.CaveRoom; +import com.watabou.utils.Point; public class MineSmallRoom extends CaveRoom { @@ -46,7 +50,14 @@ public class MineSmallRoom extends CaveRoom { public void paint(Level level) { super.paint(level); - //TODO per-quest details here + if (Blacksmith.Quest.Type() == Blacksmith.Quest.CRYSTAL){ + for (int i = 0; i < width()*height()/5; i ++){ + Point r = random(1); + if (level.map[level.pointToCell(r)] != Terrain.WALL) { + Painter.set(level, r, Terrain.MINE_CRYSTAL); + } + } + } } }