From 8aa0fde1cd67ac84e3614216ac0ab52b0a7f584a Mon Sep 17 00:00:00 2001 From: ImmuState Date: Fri, 20 May 2022 15:57:59 -0700 Subject: [PATCH] Make energy usage configurable, and preserve current behavior as the default. --- src/main/java/emu/grasscutter/game/avatar/Avatar.java | 11 +++++++++-- .../java/emu/grasscutter/game/player/TeamManager.java | 4 ++++ .../java/emu/grasscutter/utils/ConfigContainer.java | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/emu/grasscutter/game/avatar/Avatar.java b/src/main/java/emu/grasscutter/game/avatar/Avatar.java index 7898b7502..ed6dd006f 100644 --- a/src/main/java/emu/grasscutter/game/avatar/Avatar.java +++ b/src/main/java/emu/grasscutter/game/avatar/Avatar.java @@ -62,6 +62,8 @@ import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; +import static emu.grasscutter.Configuration.GAME_OPTIONS; + @Entity(value = "avatars", useDiscriminator = false) public class Avatar { @Id private ObjectId id; @@ -517,8 +519,13 @@ public class Avatar { if (data.getSkillDepot() != null && data.getSkillDepot().getEnergySkillData() != null) { ElementType element = data.getSkillDepot().getElementType(); this.setFightProperty(element.getMaxEnergyProp(), data.getSkillDepot().getEnergySkillData().getCostElemVal()); - this.setFightProperty(element.getCurEnergyProp(), currentEnergy); - //this.setFightProperty((element.getMaxEnergyProp().getId() % 70) + 1000, data.getSkillDepot().getEnergySkillData().getCostElemVal()); + + if (GAME_OPTIONS.energyUsage) { + this.setFightProperty(element.getCurEnergyProp(), currentEnergy); + } + else { + this.setFightProperty(element.getCurEnergyProp(), data.getSkillDepot().getEnergySkillData().getCostElemVal()); + } } // Artifacts diff --git a/src/main/java/emu/grasscutter/game/player/TeamManager.java b/src/main/java/emu/grasscutter/game/player/TeamManager.java index 55b7a5380..3d9806080 100644 --- a/src/main/java/emu/grasscutter/game/player/TeamManager.java +++ b/src/main/java/emu/grasscutter/game/player/TeamManager.java @@ -621,6 +621,10 @@ public class TeamManager { } public void handleEvtDoSkillSuccNotify(GameSession session, int skillId, int casterId) { + if (!GAME_OPTIONS.energyUsage) { + return; + } + // Determine the entity that has cast the skill. Optional caster = this.getActiveTeam().stream() .filter(character -> character.getId() == casterId) diff --git a/src/main/java/emu/grasscutter/utils/ConfigContainer.java b/src/main/java/emu/grasscutter/utils/ConfigContainer.java index 654d77dd4..aea9411c0 100644 --- a/src/main/java/emu/grasscutter/utils/ConfigContainer.java +++ b/src/main/java/emu/grasscutter/utils/ConfigContainer.java @@ -176,6 +176,7 @@ public class ConfigContainer { public boolean watchGachaConfig = false; public boolean enableShopItems = true; public boolean staminaUsage = true; + public boolean energyUsage = false; public Rates rates = new Rates(); public static class InventoryLimits {