From 43467ebc852e8846ce4c2307f3f66ba27704dcc0 Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Sat, 16 Sep 2023 18:32:01 -0400 Subject: [PATCH] Factor fight properties into healing calculation --- .../game/ability/actions/ActionHealHP.java | 42 ++++++++----------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/src/main/java/emu/grasscutter/game/ability/actions/ActionHealHP.java b/src/main/java/emu/grasscutter/game/ability/actions/ActionHealHP.java index 48af2bbe6..17b220c14 100644 --- a/src/main/java/emu/grasscutter/game/ability/actions/ActionHealHP.java +++ b/src/main/java/emu/grasscutter/game/ability/actions/ActionHealHP.java @@ -6,6 +6,7 @@ import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction; import emu.grasscutter.game.ability.Ability; import emu.grasscutter.game.entity.*; import emu.grasscutter.game.props.FightProperty; +import it.unimi.dsi.fastutil.objects.Object2FloatOpenHashMap; @AbilityAction(AbilityModifierAction.Type.HealHP) public final class ActionHealHP extends AbilityActionHandler { @@ -31,24 +32,25 @@ public final class ActionHealHP extends AbilityActionHandler { if (owner == null) return false; - ability - .getAbilitySpecials() - .forEach((k, v) -> Grasscutter.getLogger().trace(">>> {}: {}", k, v)); + // Get all properties. + var properties = new Object2FloatOpenHashMap(); + // Add entity fight properties. + for (var property : FightProperty.values()) { + var name = property.name(); + var value = owner.getFightProperty(property); + properties.put(name, value); + } + // Add ability properties. + properties.putAll(ability.getAbilitySpecials()); - var amountByCasterMaxHPRatio = action.amountByCasterMaxHPRatio.get(ability); - var amountByCasterAttackRatio = action.amountByCasterAttackRatio.get(ability); - var amountByCasterCurrentHPRatio = action.amountByCasterCurrentHPRatio.get(ability); - var amountByTargetCurrentHPRatio = action.amountByTargetCurrentHPRatio.get(ability); - var amountByTargetMaxHPRatio = action.amountByTargetMaxHPRatio.get(ability); + // Calculate ratios from properties. + var amountByCasterMaxHPRatio = action.amountByCasterMaxHPRatio.get(properties, 0); + var amountByCasterAttackRatio = action.amountByCasterAttackRatio.get(properties, 0); + var amountByCasterCurrentHPRatio = action.amountByCasterCurrentHPRatio.get(properties, 0); + var amountByTargetCurrentHPRatio = action.amountByTargetCurrentHPRatio.get(properties, 0); + var amountByTargetMaxHPRatio = action.amountByTargetMaxHPRatio.get(properties, 0); - Grasscutter.getLogger().trace("amountByCasterMaxHPRatio: " + amountByCasterMaxHPRatio); - Grasscutter.getLogger().trace("amountByCasterAttackRatio: " + amountByCasterAttackRatio); - Grasscutter.getLogger().trace("amountByCasterCurrentHPRatio: " + amountByCasterCurrentHPRatio); - Grasscutter.getLogger().trace("amountByTargetCurrentHPRatio: " + amountByTargetCurrentHPRatio); - Grasscutter.getLogger().trace("amountByTargetMaxHPRatio: " + amountByTargetMaxHPRatio); - - var amountToRegenerate = action.amount.get(ability); - Grasscutter.getLogger().trace("Base amount: " + amountToRegenerate); + var amountToRegenerate = action.amount.get(properties, 0); amountToRegenerate += amountByCasterMaxHPRatio * owner.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP); @@ -57,25 +59,17 @@ public final class ActionHealHP extends AbilityActionHandler { amountToRegenerate += amountByCasterCurrentHPRatio * owner.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP); - Grasscutter.getLogger().trace("amountToRegenerate: " + amountToRegenerate); - var abilityRatio = 1.0f; - Grasscutter.getLogger().trace("Base abilityRatio: " + abilityRatio); - if (!action.ignoreAbilityProperty) abilityRatio += target.getFightProperty(FightProperty.FIGHT_PROP_HEAL_ADD) + target.getFightProperty(FightProperty.FIGHT_PROP_HEALED_ADD); - Grasscutter.getLogger().trace("abilityRatio: " + abilityRatio); - - Grasscutter.getLogger().trace("Sub-regenerate amount: " + amountToRegenerate); amountToRegenerate += amountByTargetCurrentHPRatio * target.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP); amountToRegenerate += amountByTargetMaxHPRatio * target.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP); - Grasscutter.getLogger().trace("Healing {} without ratios", amountToRegenerate); target.heal( amountToRegenerate * abilityRatio * action.healRatio.get(ability, 1f), action.muteHealEffect);