aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2019-09-10 21:07:44 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2019-09-10 21:07:44 +0200
commitcfdd37c261bfb814740aa8cec30177f9c5f85d36 (patch)
treebabd5443c8219186d80d8dbbdb3d6340db1748ea
parentefc878dc634cdbf9ba976858ee6872fc7a59b485 (diff)
downloadtacticians-server-cfdd37c261bfb814740aa8cec30177f9c5f85d36.zip
tacticians-server-cfdd37c261bfb814740aa8cec30177f9c5f85d36.tar.bz2
Should fix damage calculation.
-rw-r--r--src/battle/mechanic/action/btl_action_attack.erl2
-rw-r--r--src/shared/struct/shr_omnimods.erl29
2 files changed, 15 insertions, 16 deletions
diff --git a/src/battle/mechanic/action/btl_action_attack.erl b/src/battle/mechanic/action/btl_action_attack.erl
index 62c58f8..ef4d9d3 100644
--- a/src/battle/mechanic/action/btl_action_attack.erl
+++ b/src/battle/mechanic/action/btl_action_attack.erl
@@ -303,7 +303,7 @@ effect_of_attack
(
PrecisionModifier
* CriticalModifier
- * shr_attributes:get_damage_modifier(AttackerAttributes)
+ * shr_attributes:get_damage_multiplier(AttackerAttributes)
),
shr_character:get_omnimods(AttackerBaseCharacter),
shr_character:get_omnimods(DefenderBaseCharacter)
diff --git a/src/shared/struct/shr_omnimods.erl b/src/shared/struct/shr_omnimods.erl
index f452e34..c31e372 100644
--- a/src/shared/struct/shr_omnimods.erl
+++ b/src/shared/struct/shr_omnimods.erl
@@ -1,5 +1,7 @@
-module(shr_omnimods).
+-include("tacticians/attributes.hrl").
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -268,31 +270,27 @@ apply_to_attributes (Omnimods, Attributes) ->
Omnimods#omnimods.attmods
).
-% FIXME: 'base' is no longer used.
-spec get_attack_damage (float(), type(), type()) -> non_neg_integer().
-get_attack_damage (AttackModifier, AttackerOmnimods, DefenderOmnimods) ->
- AttackerOmnimodsAttmods = AttackerOmnimods#omnimods.atkmods,
+get_attack_damage (AttackMultiplier, AttackerOmnimods, DefenderOmnimods) ->
+ AttackerOmnimodsAtkmods = AttackerOmnimods#omnimods.atkmods,
DefenderOmnimodsDefmods = DefenderOmnimods#omnimods.defmods,
io:format("Attack!~n"),
- BaseDefense =
- case dict:find(base, DefenderOmnimodsDefmods) of
- {ok, BaseDefValue} -> BaseDefValue;
- _ -> 0
- end,
-
- io:format("Defender base defense: ~p~n", [BaseDefense]),
-
Result =
dict:fold
(
fun (Name, BaseDmg, CurrentResult) ->
io:format("Precalc damage from ~p: ~p~n", [Name, BaseDmg]),
NormDmg = max(0, BaseDmg),
- ModifiedDmg =
- (shr_math_util:ceil(NormDmg * AttackModifier) - BaseDefense),
- io:format("Actual attack damage from ~p: ~p~n", [Name, ModifiedDmg]),
+ ModifiedDmg = (shr_math_util:ceil(NormDmg * AttackMultiplier)),
+
+ io:format
+ (
+ "Actual attack damage from ~p: ~p~n",
+ [Name, ModifiedDmg]
+ ),
+
case dict:find(Name, DefenderOmnimodsDefmods) of
{ok, Def} when (Def >= ModifiedDmg) ->
io:format
@@ -310,6 +308,7 @@ get_attack_damage (AttackModifier, AttackerOmnimods, DefenderOmnimods) ->
[Def, Name, DamageTaken]
),
(CurrentResult + DamageTaken);
+
_ ->
io:format
(
@@ -320,7 +319,7 @@ get_attack_damage (AttackModifier, AttackerOmnimods, DefenderOmnimods) ->
end
end,
0,
- AttackerOmnimodsAttmods
+ AttackerOmnimodsAtkmods
),
io:format("Defender took a total of ~p damage.~n", [Result]),