From 7efac018901c7433d98bb9a1e82acf1bc35027dd Mon Sep 17 00:00:00 2001 From: Melledy <52122272+Melledy@users.noreply.github.com> Date: Mon, 25 Apr 2022 04:04:01 -0700 Subject: [PATCH] Make monsters scale off world level --- .../emu/grasscutter/data/GenshinData.java | 7 +++++- .../grasscutter/data/def/WorldLevelData.java | 24 +++++++++++++++++++ .../emu/grasscutter/game/GenshinScene.java | 11 ++++++++- 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 src/main/java/emu/grasscutter/data/def/WorldLevelData.java diff --git a/src/main/java/emu/grasscutter/data/GenshinData.java b/src/main/java/emu/grasscutter/data/GenshinData.java index 3b3d351da..29410b1c7 100644 --- a/src/main/java/emu/grasscutter/data/GenshinData.java +++ b/src/main/java/emu/grasscutter/data/GenshinData.java @@ -60,7 +60,8 @@ public class GenshinData { private static final Int2ObjectMap fetterDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap fetterCharacterCardDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap rewardDataMap = new Int2ObjectOpenHashMap<>(); - + private static final Int2ObjectMap worldLevelDataMap = new Int2ObjectOpenHashMap<>(); + // Cache private static Map> fetters = new HashMap<>(); @@ -260,4 +261,8 @@ public class GenshinData { return fetters; } + + public static Int2ObjectMap getWorldLevelDataMap() { + return worldLevelDataMap; + } } diff --git a/src/main/java/emu/grasscutter/data/def/WorldLevelData.java b/src/main/java/emu/grasscutter/data/def/WorldLevelData.java new file mode 100644 index 000000000..c2072d8f2 --- /dev/null +++ b/src/main/java/emu/grasscutter/data/def/WorldLevelData.java @@ -0,0 +1,24 @@ +package emu.grasscutter.data.def; + +import emu.grasscutter.data.GenshinResource; +import emu.grasscutter.data.ResourceType; + +@ResourceType(name = "WorldLevelExcelConfigData.json") +public class WorldLevelData extends GenshinResource { + private int Level; + private int MonsterLevel; + + @Override + public int getId() { + return this.Level; + } + + public int getMonsterLevel() { + return MonsterLevel; + } + + @Override + public void onLoad() { + + } +} diff --git a/src/main/java/emu/grasscutter/game/GenshinScene.java b/src/main/java/emu/grasscutter/game/GenshinScene.java index 60d72c9a7..955d42d1c 100644 --- a/src/main/java/emu/grasscutter/game/GenshinScene.java +++ b/src/main/java/emu/grasscutter/game/GenshinScene.java @@ -17,6 +17,7 @@ import emu.grasscutter.data.GenshinDepot; import emu.grasscutter.data.GenshinResource; import emu.grasscutter.data.def.MonsterData; import emu.grasscutter.data.def.SceneData; +import emu.grasscutter.data.def.WorldLevelData; import emu.grasscutter.game.entity.EntityAvatar; import emu.grasscutter.game.entity.EntityClientGadget; import emu.grasscutter.game.entity.EntityGadget; @@ -337,6 +338,14 @@ public class GenshinScene { } } + // World level + WorldLevelData worldLevelData = GenshinData.getWorldLevelDataMap().get(player.getWorldLevel()); + int worldLevelOverride = 0; + + if (worldLevelData != null) { + worldLevelOverride = worldLevelData.getMonsterLevel(); + } + // Todo List toAdd = new LinkedList<>(); List toRemove = new LinkedList<>(); @@ -350,7 +359,7 @@ public class GenshinScene { continue; } - EntityMonster entity = new EntityMonster(this, data, entry.getPos(), entry.getLevel()); + EntityMonster entity = new EntityMonster(this, data, entry.getPos(), worldLevelOverride > 0 ? worldLevelOverride : entry.getLevel()); entity.getRotation().set(entry.getRot()); entity.setGroupId(entry.getGroup().getGroupId()); entity.setPoseId(entry.getPoseId());