summaryrefslogtreecommitdiff |
diff options
author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2018-08-28 21:20:32 +0200 |
---|---|---|
committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2018-08-28 21:20:32 +0200 |
commit | 68d3f1d7fd3703a8aef68bd6e9f89a84eab5e539 (patch) | |
tree | b8030460c3a3ad790b8cf473655f72fbeb67eab1 /src/shared/struct/shr_omnimods.erl | |
parent | 8005656eb5d6a08464dc3718ab18c0a441f79025 (diff) |
Adds 'base' defense, applied to all damage types.
Since it's applied to all damage types, 'base' defense points are much
more valuable than defense points that are only applied when facing a
specific element.
Diffstat (limited to 'src/shared/struct/shr_omnimods.erl')
-rw-r--r-- | src/shared/struct/shr_omnimods.erl | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/shared/struct/shr_omnimods.erl b/src/shared/struct/shr_omnimods.erl index 4abfef2..03ec5af 100644 --- a/src/shared/struct/shr_omnimods.erl +++ b/src/shared/struct/shr_omnimods.erl @@ -63,7 +63,7 @@ cleanup_entry_list (ModList) -> -spec apply_coefficient_to_mods (float(), mods()) -> mods(). apply_coefficient_to_mods (Coef, Mods) -> - dict:map(fun ({_Name, Val}) -> shr_util:ceil(Coef * Val) end, Mods). + dict:map(fun (_Name, Val) -> shr_math_util:ceil(Coef * Val) end, Mods). -spec merge_mods (mods(), mods()) -> mods(). merge_mods (ModsA, ModsB) -> @@ -164,11 +164,18 @@ get_attack_damage (AttackModifier, AttackerOmnimods, DefenderOmnimods) -> AttackerOmnimodsAttmods = AttackerOmnimods#omnimods.atkmods, DefenderOmnimodsDefmods = DefenderOmnimods#omnimods.defmods, + BaseDefense = + case dict:find(base, DefenderOmnimodsDefmods) of + {ok, BaseDefValue} -> BaseDefValue; + _ -> 0 + end, + Result = dict:fold ( fun (Name, BaseDmg, CurrentResult) -> - ModifiedDmg = shr_math:ceil(BaseDmg * AttackModifier), + ModifiedDmg = + (shr_math_util:ceil(BaseDmg * AttackModifier) - BaseDefense), case dict:find(Name, DefenderOmnimodsDefmods) of {ok, Def} when (Def >= ModifiedDmg) -> CurrentResult; {ok, Def} -> (CurrentResult + (ModifiedDmg - Def)); |