From 5b9d386e17a72c26280efdb6d6efa412a3ec047b Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Sat, 28 Sep 2024 19:51:22 -0400 Subject: [PATCH] fix(AbilityModifier.java): Always parse `param[1-3]` as `DynamicFloat`s --- .../java/emu/grasscutter/data/binout/AbilityModifier.java | 7 ++++--- .../java/emu/grasscutter/data/common/DynamicFloat.java | 4 ++++ .../game/ability/actions/ActionExecuteGadgetLua.java | 6 +++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/emu/grasscutter/data/binout/AbilityModifier.java b/src/main/java/emu/grasscutter/data/binout/AbilityModifier.java index 562616bb4..a1de94e92 100644 --- a/src/main/java/emu/grasscutter/data/binout/AbilityModifier.java +++ b/src/main/java/emu/grasscutter/data/binout/AbilityModifier.java @@ -345,9 +345,10 @@ public class AbilityModifier implements Serializable { public DynamicFloat valueRangeMax; public String overrideMapKey; - public int param1; - public int param2; - public int param3; + public DynamicFloat + param1 = DynamicFloat.ZERO, + param2 = DynamicFloat.ZERO, + param3 = DynamicFloat.ZERO; public String funcName; public LuaCallType luaCallType; diff --git a/src/main/java/emu/grasscutter/data/common/DynamicFloat.java b/src/main/java/emu/grasscutter/data/common/DynamicFloat.java index 99dc12433..06df52879 100644 --- a/src/main/java/emu/grasscutter/data/common/DynamicFloat.java +++ b/src/main/java/emu/grasscutter/data/common/DynamicFloat.java @@ -57,6 +57,10 @@ public class DynamicFloat { return this.get(ability.getAbilitySpecials(), 0f); } + public int getInt(Ability ability) { + return (int) this.get(ability.getAbilitySpecials(), 0f); + } + public float get(Object2FloatMap props, float defaultValue) { if (!this.dynamic) return constant; diff --git a/src/main/java/emu/grasscutter/game/ability/actions/ActionExecuteGadgetLua.java b/src/main/java/emu/grasscutter/game/ability/actions/ActionExecuteGadgetLua.java index cca594ee1..cb9855222 100644 --- a/src/main/java/emu/grasscutter/game/ability/actions/ActionExecuteGadgetLua.java +++ b/src/main/java/emu/grasscutter/game/ability/actions/ActionExecuteGadgetLua.java @@ -15,9 +15,13 @@ public class ActionExecuteGadgetLua extends AbilityActionHandler { // Investigate if we need to use target if (owner.getEntityController() != null) { + var param1 = action.param1.getInt(ability); + var param2 = action.param2.getInt(ability); + var param3 = action.param3.getInt(ability); + owner .getEntityController() - .onClientExecuteRequest(owner, action.param1, action.param2, action.param3); + .onClientExecuteRequest(owner, param1, param2, param3); return true; }