mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-22 05:19:17 +00:00
Factor fight properties into healing calculation
This commit is contained in:
parent
1f15d6219b
commit
43467ebc85
@ -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<String>();
|
||||
// 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);
|
||||
|
Loading…
Reference in New Issue
Block a user