From 72d9cd530dacaa1741c40a0cef74b16e7be109a3 Mon Sep 17 00:00:00 2001 From: Melledy <121644117+Melledy@users.noreply.github.com> Date: Mon, 15 Dec 2025 07:40:03 -0800 Subject: [PATCH] Implement proper melody drops in Monolith --- src/main/java/emu/nebula/GameConstants.java | 3 -- .../nebula/data/resources/StarTowerDef.java | 2 + .../resources/SubNoteSkillDropGroupDef.java | 45 +++++++++++++++++++ .../emu/nebula/game/tower/StarTowerGame.java | 22 ++------- .../game/tower/cases/StarTowerHawkerCase.java | 2 +- 5 files changed, 51 insertions(+), 23 deletions(-) create mode 100644 src/main/java/emu/nebula/data/resources/SubNoteSkillDropGroupDef.java diff --git a/src/main/java/emu/nebula/GameConstants.java b/src/main/java/emu/nebula/GameConstants.java index d45da55..10a0369 100644 --- a/src/main/java/emu/nebula/GameConstants.java +++ b/src/main/java/emu/nebula/GameConstants.java @@ -56,9 +56,6 @@ public class GameConstants { public static final int MAX_PENDING_FRIENDSHIPS = 30; public static final int TOWER_COIN_ITEM_ID = 11; - public static final int[] TOWER_COMMON_SUB_NOTE_SKILLS = new int[] { - 90011, 90012, 90013, 90014, 90015, 90016, 90017 - }; public static final int[] TOWER_EVENTS_IDS = new int[] { 101, 102, 104, 105, 106, 107, 108, 114, 115, 116, 126, 127, 128 }; diff --git a/src/main/java/emu/nebula/data/resources/StarTowerDef.java b/src/main/java/emu/nebula/data/resources/StarTowerDef.java index eb25dd2..79b494a 100644 --- a/src/main/java/emu/nebula/data/resources/StarTowerDef.java +++ b/src/main/java/emu/nebula/data/resources/StarTowerDef.java @@ -4,6 +4,7 @@ import java.util.Arrays; import emu.nebula.data.BaseDef; import emu.nebula.data.ResourceType; + import lombok.Getter; @Getter @@ -12,6 +13,7 @@ public class StarTowerDef extends BaseDef { private int Id; private int GroupId; private int Difficulty; + private int SubNoteSkillDropGroupId; private int[] FloorNum; private transient int maxFloors; diff --git a/src/main/java/emu/nebula/data/resources/SubNoteSkillDropGroupDef.java b/src/main/java/emu/nebula/data/resources/SubNoteSkillDropGroupDef.java new file mode 100644 index 0000000..c4e5967 --- /dev/null +++ b/src/main/java/emu/nebula/data/resources/SubNoteSkillDropGroupDef.java @@ -0,0 +1,45 @@ +package emu.nebula.data.resources; + +import emu.nebula.data.BaseDef; +import emu.nebula.data.ResourceType; +import emu.nebula.util.Utils; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; +import it.unimi.dsi.fastutil.ints.IntArrayList; +import it.unimi.dsi.fastutil.ints.IntList; +import lombok.Getter; + +@Getter +@ResourceType(name = "SubNoteSkillDropGroup.json") +public class SubNoteSkillDropGroupDef extends BaseDef { + private int Id; + private int GroupId; + private int SubNoteSkillId; + + private static Int2ObjectMap GROUPS = new Int2ObjectOpenHashMap<>(); + + @Override + public int getId() { + return Id; + } + + @Override + public void onLoad() { + var packageList = GROUPS.computeIfAbsent(this.GroupId, i -> new IntArrayList()); + packageList.add(this.SubNoteSkillId); + } + + public static int getRandomDrop(int groupId) { + var dropList = GROUPS.get(groupId); + + if (dropList == null) { + return 0; + } + + return Utils.randomElement(dropList); + } + + public static IntList getGroup(int groupId) { + return GROUPS.get(groupId); + } +} diff --git a/src/main/java/emu/nebula/game/tower/StarTowerGame.java b/src/main/java/emu/nebula/game/tower/StarTowerGame.java index 3a40616..8b5ad96 100644 --- a/src/main/java/emu/nebula/game/tower/StarTowerGame.java +++ b/src/main/java/emu/nebula/game/tower/StarTowerGame.java @@ -5,11 +5,11 @@ import java.util.List; import dev.morphia.annotations.Entity; -import emu.nebula.GameConstants; import emu.nebula.data.GameData; import emu.nebula.data.resources.SecondarySkillDef; import emu.nebula.data.resources.StarTowerDef; import emu.nebula.data.resources.StarTowerStageDef; +import emu.nebula.data.resources.SubNoteSkillDropGroupDef; import emu.nebula.game.achievement.AchievementCondition; import emu.nebula.game.achievement.AchievementManager; import emu.nebula.game.character.ElementType; @@ -84,9 +84,6 @@ public class StarTowerGame { private ItemParamMap potentials; private IntSet secondarySkills; - // Sub note skill drop list - private IntList subNoteDropList; - // Modifiers private StarTowerModifiers modifiers; @@ -123,9 +120,6 @@ public class StarTowerGame { this.newInfos = new ItemParamMap(); - // Init melody drop list - this.subNoteDropList = new IntArrayList(); - // Init modifiers this.modifiers = new StarTowerModifiers(this); @@ -141,12 +135,6 @@ public class StarTowerGame { continue; } - // Add sub note skill id to drop list - int subNoteSkill = character.getData().getElementType().getSubNoteSkillItemId(); - if (subNoteSkill > 0 && !this.subNoteDropList.contains(subNoteSkill)) { - this.subNoteDropList.add(subNoteSkill); - } - // Add to character list charList.add(id); } @@ -178,11 +166,6 @@ public class StarTowerGame { // Temp data to cache for rare potential count this.rarePotentialCount = new ItemParamMap(); - // Finish setting up droppable sub note skills - for (int id : GameConstants.TOWER_COMMON_SUB_NOTE_SKILLS) { - this.subNoteDropList.add(id); - } - // Enter first room this.enterNextRoom(); this.getRoom().setMapInfo(req); @@ -784,7 +767,8 @@ public class StarTowerGame { } public int getRandomSubNoteId() { - return Utils.randomElement(this.getSubNoteDropList()); + int groupId = this.getData().getSubNoteSkillDropGroupId(); + return SubNoteSkillDropGroupDef.getRandomDrop(groupId); } private PlayerChangeInfo addRandomSubNoteSkills(PlayerChangeInfo change) { diff --git a/src/main/java/emu/nebula/game/tower/cases/StarTowerHawkerCase.java b/src/main/java/emu/nebula/game/tower/cases/StarTowerHawkerCase.java index 9e31684..a2999de 100644 --- a/src/main/java/emu/nebula/game/tower/cases/StarTowerHawkerCase.java +++ b/src/main/java/emu/nebula/game/tower/cases/StarTowerHawkerCase.java @@ -64,7 +64,7 @@ public class StarTowerHawkerCase extends StarTowerBaseCase { } for (int i = 0; i < subNotes; i++) { // Randomize sub note - int id = Utils.randomElement(this.getGame().getSubNoteDropList()); + int id = this.getGame().getRandomSubNoteId(); // Create sub note shop item StarTowerShopGoods goods = null;