aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2019-06-14 11:17:07 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2019-06-14 11:17:07 +0200
commit3f928c81070ab3c9efa5b0dfd2ae97ca7f7efcf6 (patch)
tree4b339592db77ae83eb27ed9f5d7c83c3f293eb87
parent6d6232f352b033797ffd339666699c2b84251f84 (diff)
downloadtacticians-server-attributes_removal.zip
tacticians-server-attributes_removal.tar.bz2
Makes it pass Dialyzer's checks again.attributes_removal
-rw-r--r--src/shared/struct/shr_attributes.erl167
-rw-r--r--src/shared/struct/shr_character.erl61
-rw-r--r--src/shared/struct/shr_omnimods.erl36
-rw-r--r--src/shared/struct/shr_statistics.erl172
4 files changed, 50 insertions, 386 deletions
diff --git a/src/shared/struct/shr_attributes.erl b/src/shared/struct/shr_attributes.erl
deleted file mode 100644
index c402e74..0000000
--- a/src/shared/struct/shr_attributes.erl
+++ /dev/null
@@ -1,167 +0,0 @@
--module(shr_attributes).
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--record
-(
- attributes,
- {
- constitution :: non_neg_integer(),
- dexterity :: non_neg_integer(),
- intelligence :: non_neg_integer(),
- mind :: non_neg_integer(),
- speed :: non_neg_integer(),
- strength :: non_neg_integer()
- }
-).
-
--opaque type() :: #attributes{}.
-
--export_type([type/0]).
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%% Accessors
--export
-(
- [
- get_constitution/1,
- get_dexterity/1,
- get_intelligence/1,
- get_mind/1,
- get_speed/1,
- get_strength/1,
-
- set_constitution/2,
- set_dexterity/2,
- set_intelligence/2,
- set_mind/2,
- set_speed/2,
- set_strength/2,
-
- set_unsafe_constitution/2,
- set_unsafe_dexterity/2,
- set_unsafe_intelligence/2,
- set_unsafe_mind/2,
- set_unsafe_speed/2,
- set_unsafe_strength/2,
-
- apply_mod/3
- ]
-).
-
-%%%% Accessors
--export
-(
- [
- default/0
- ]
-).
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--spec make_safe (integer()) -> non_neg_integer().
-make_safe (Val) -> max(0, min(100, Val)).
-
--spec mod_unsafe_constitution (integer(), type()) -> type().
-mod_unsafe_constitution (Val, Att) ->
- set_constitution(make_safe(get_constitution(Att) + Val), Att).
-
--spec mod_unsafe_dexterity (integer(), type()) -> type().
-mod_unsafe_dexterity (Val, Att) ->
- set_dexterity(make_safe(get_dexterity(Att) + Val), Att).
-
--spec mod_unsafe_intelligence (integer(), type()) -> type().
-mod_unsafe_intelligence (Val, Att) ->
- set_intelligence(make_safe(get_intelligence(Att) + Val), Att).
-
--spec mod_unsafe_mind (integer(), type()) -> type().
-mod_unsafe_mind (Val, Att) -> set_mind(make_safe(get_mind(Att) + Val), Att).
-
--spec mod_unsafe_speed (integer(), type()) -> type().
-mod_unsafe_speed (Val, Att) -> set_speed(make_safe(get_speed(Att) + Val), Att).
-
--spec mod_unsafe_strength (integer(), type()) -> type().
-mod_unsafe_strength (Val, Att) ->
- set_strength(make_safe(get_strength(Att) + Val), Att).
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%% Accessors
--spec get_constitution (type()) -> non_neg_integer().
-get_constitution (Att) -> Att#attributes.constitution.
-
--spec get_dexterity (type()) -> non_neg_integer().
-get_dexterity (Att) -> Att#attributes.dexterity.
-
--spec get_intelligence (type()) -> non_neg_integer().
-get_intelligence (Att) -> Att#attributes.intelligence.
-
--spec get_mind (type()) -> non_neg_integer().
-get_mind (Att) -> Att#attributes.mind.
-
--spec get_speed (type()) -> non_neg_integer().
-get_speed (Att) -> Att#attributes.speed.
-
--spec get_strength (type()) -> non_neg_integer().
-get_strength (Att) -> Att#attributes.strength.
-
--spec set_constitution (non_neg_integer(), type()) -> type().
-set_constitution (Val, Att) -> Att#attributes{ constitution = Val }.
-
--spec set_dexterity (non_neg_integer(), type()) -> type().
-set_dexterity (Val, Att) -> Att#attributes{ dexterity = Val }.
-
--spec set_intelligence (non_neg_integer(), type()) -> type().
-set_intelligence (Val, Att) -> Att#attributes{ intelligence = Val }.
-
--spec set_mind (non_neg_integer(), type()) -> type().
-set_mind (Val, Att) -> Att#attributes{ mind = Val }.
-
--spec set_speed (non_neg_integer(), type()) -> type().
-set_speed (Val, Att) -> Att#attributes{ speed = Val }.
-
--spec set_strength (non_neg_integer(), type()) -> type().
-set_strength (Val, Att) -> Att#attributes{ strength = Val }.
-
--spec set_unsafe_constitution (integer(), type()) -> type().
-set_unsafe_constitution (Val, Att) -> set_constitution(make_safe(Val), Att).
-
--spec set_unsafe_dexterity (integer(), type()) -> type().
-set_unsafe_dexterity (Val, Att) -> set_dexterity(make_safe(Val), Att).
-
--spec set_unsafe_intelligence (integer(), type()) -> type().
-set_unsafe_intelligence (Val, Att) -> set_intelligence(make_safe(Val), Att).
-
--spec set_unsafe_mind (integer(), type()) -> type().
-set_unsafe_mind (Val, Att) -> set_mind(make_safe(Val), Att).
-
--spec set_unsafe_speed (integer(), type()) -> type().
-set_unsafe_speed (Val, Att) -> set_speed(make_safe(Val), Att).
-
--spec set_unsafe_strength (integer(), type()) -> type().
-set_unsafe_strength (Val, Att) -> set_strength(make_safe(Val), Att).
-
--spec default () -> type().
-default () ->
- #attributes
- {
- constitution = 50,
- dexterity = 50,
- intelligence = 50,
- mind = 50,
- speed = 50,
- strength = 50
- }.
-
--spec apply_mod (atom(), integer(), type()) -> type().
-apply_mod (con, Value, Att) -> mod_unsafe_constitution(Value, Att);
-apply_mod (dex, Value, Att) -> mod_unsafe_dexterity(Value, Att);
-apply_mod (int, Value, Att) -> mod_unsafe_intelligence(Value, Att);
-apply_mod (min, Value, Att) -> mod_unsafe_mind(Value, Att);
-apply_mod (spe, Value, Att) -> mod_unsafe_speed(Value, Att);
-apply_mod (str, Value, Att) -> mod_unsafe_strength(Value, Att).
diff --git a/src/shared/struct/shr_character.erl b/src/shared/struct/shr_character.erl
index 27cf81d..c2155cf 100644
--- a/src/shared/struct/shr_character.erl
+++ b/src/shared/struct/shr_character.erl
@@ -25,7 +25,6 @@
equipment :: shr_equipment:type(),
is_using_secondary :: boolean(),
statistics :: shr_statistics:type(),
- attributes :: shr_attributes:type(),
equipment_but_weapons_omnimods :: shr_omnimods:type(),
extra_omnimods :: shr_omnimods:type(),
omnimods :: shr_omnimods:type()
@@ -46,7 +45,6 @@
[
get_name/1,
get_equipment/1,
- get_attributes/1,
get_statistics/1,
get_active_weapon/1,
get_inactive_weapon/1,
@@ -171,26 +169,14 @@ set_equipment (Eq, Char) when is_record(Char, shr_char) ->
Char#shr_char.extra_omnimods
),
- NewAttributes =
- shr_omnimods:apply_to_attributes
- (
- NewOmnimods,
- shr_attributes:default()
- ),
-
NewStatistics =
- shr_omnimods:apply_to_statistics
- (
- NewOmnimods,
- shr_statistics:new_raw(NewAttributes)
- ),
+ shr_omnimods:apply_to_statistics(NewOmnimods, shr_statistics:default()),
Char#shr_char
{
equipment = Eq,
equipment_but_weapons_omnimods = EquipmentButWeaponsOmnimods,
omnimods = NewOmnimods,
- attributes = NewAttributes,
statistics = NewStatistics
};
set_equipment (EqRef, CharRef) when is_record(CharRef, shr_char_ref) ->
@@ -246,25 +232,13 @@ switch_weapons (Char) when is_record(Char, shr_char) ->
ActiveWeaponOmnimods
),
- NewAttributes =
- shr_omnimods:apply_to_attributes
- (
- NewOmnimods,
- shr_attributes:default()
- ),
-
NewStatistics =
- shr_omnimods:apply_to_statistics
- (
- NewOmnimods,
- shr_statistics:new_raw(NewAttributes)
- ),
+ shr_omnimods:apply_to_statistics(NewOmnimods, shr_statistics:default()),
Char#shr_char
{
is_using_secondary = (not Char#shr_char.is_using_secondary),
omnimods = NewOmnimods,
- attributes = NewAttributes,
statistics = NewStatistics
};
switch_weapons (Char) when is_record(Char, shr_char_ref) ->
@@ -310,9 +284,6 @@ get_inactive_weapon (#shr_char_ref{ is_using_secondary = B, equipment = E }) ->
true -> shr_equipment:get_primary_weapon(E)
end.
--spec get_attributes (type()) -> shr_attributes:type().
-get_attributes (Char) -> Char#shr_char.attributes.
-
-spec get_statistics (type()) -> shr_statistics:type().
get_statistics (Char) -> Char#shr_char.statistics.
@@ -332,25 +303,13 @@ set_extra_omnimods (O, Char) ->
O
),
- NewAttributes =
- shr_omnimods:apply_to_attributes
- (
- NewOmnimods,
- shr_attributes:default()
- ),
-
NewStatistics =
- shr_omnimods:apply_to_statistics
- (
- NewOmnimods,
- shr_statistics:new_raw(NewAttributes)
- ),
+ shr_omnimods:apply_to_statistics(NewOmnimods, shr_statistics:default()),
Char#shr_char
{
extra_omnimods = O,
omnimods = NewOmnimods,
- attributes = NewAttributes,
statistics = NewStatistics
}.
@@ -371,19 +330,8 @@ resolve (LocalOmnimods, CharRef) ->
LocalOmnimods
),
- NewAttributes =
- shr_omnimods:apply_to_attributes
- (
- NewOmnimods,
- shr_attributes:default()
- ),
-
NewStatistics =
- shr_omnimods:apply_to_statistics
- (
- NewOmnimods,
- shr_statistics:new_raw(NewAttributes)
- ),
+ shr_omnimods:apply_to_statistics(NewOmnimods, shr_statistics:default()),
#shr_char
{
@@ -392,7 +340,6 @@ resolve (LocalOmnimods, CharRef) ->
equipment = Eq,
is_using_secondary = CharRef#shr_char_ref.is_using_secondary,
statistics = NewStatistics,
- attributes = NewAttributes,
omnimods = NewOmnimods,
extra_omnimods = LocalOmnimods
}.
diff --git a/src/shared/struct/shr_omnimods.erl b/src/shared/struct/shr_omnimods.erl
index 081477d..fd35a94 100644
--- a/src/shared/struct/shr_omnimods.erl
+++ b/src/shared/struct/shr_omnimods.erl
@@ -10,7 +10,6 @@
(
omnimods,
{
- attmods :: mods(),
stamods :: mods(),
atkmods :: mods(),
defmods :: mods()
@@ -29,7 +28,7 @@
(
[
default/0,
- new/4
+ new/3
]
).
@@ -46,7 +45,6 @@
-export
(
[
- apply_to_attributes/2,
apply_to_statistics/2,
get_attack_damage/3
]
@@ -90,32 +88,23 @@ encode_mods (Mods) ->
%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Creation
--spec new
-(
- list(entry()),
- list(entry()),
- list(entry()),
- list(entry())
- )
- -> type().
-new (AttributeMods, StatisticMods, AttackMods, DefenseMods) ->
+-spec new (list(entry()), list(entry()), list(entry())) -> type().
+new (StatisticMods, AttackMods, DefenseMods) ->
#omnimods
{
- attmods = dict:from_list(AttributeMods),
stamods = dict:from_list(StatisticMods),
atkmods = dict:from_list(AttackMods),
defmods = dict:from_list(DefenseMods)
}.
-spec default () -> type().
-default () -> new([], [], [], []).
+default () -> new([], [], []).
%%% Modification
-spec merge (type(), type()) -> type().
merge (OmniA, OmniB) ->
OmniA#omnimods
{
- attmods = merge_mods(OmniA#omnimods.attmods, OmniB#omnimods.attmods),
stamods = merge_mods(OmniA#omnimods.stamods, OmniB#omnimods.stamods),
atkmods = merge_mods(OmniA#omnimods.atkmods, OmniB#omnimods.atkmods),
defmods = merge_mods(OmniA#omnimods.defmods, OmniB#omnimods.defmods)
@@ -125,27 +114,11 @@ merge (OmniA, OmniB) ->
apply_coefficient (Coef, Omnimods) ->
Omnimods#omnimods
{
- attmods = apply_coefficient_to_mods(Coef, Omnimods#omnimods.attmods),
stamods = apply_coefficient_to_mods(Coef, Omnimods#omnimods.stamods),
atkmods = apply_coefficient_to_mods(Coef, Omnimods#omnimods.atkmods),
defmods = apply_coefficient_to_mods(Coef, Omnimods#omnimods.defmods)
}.
-%%% Access
--spec apply_to_attributes
- (
- type(),
- shr_attributes:type()
- )
- -> shr_attributes:type().
-apply_to_attributes (Omnimods, Attributes) ->
- dict:fold
- (
- fun shr_attributes:apply_mod/3,
- Attributes,
- Omnimods#omnimods.attmods
- ).
-
-spec apply_to_statistics
(
type(),
@@ -223,7 +196,6 @@ get_attack_damage (AttackModifier, AttackerOmnimods, DefenderOmnimods) ->
encode (Omnimods) ->
{
[
- {<<"attm">>, encode_mods(Omnimods#omnimods.attmods)},
{<<"stam">>, encode_mods(Omnimods#omnimods.stamods)},
{<<"atkm">>, encode_mods(Omnimods#omnimods.atkmods)},
{<<"defm">>, encode_mods(Omnimods#omnimods.defmods)}
diff --git a/src/shared/struct/shr_statistics.erl b/src/shared/struct/shr_statistics.erl
index 726d4bf..a5ba69f 100644
--- a/src/shared/struct/shr_statistics.erl
+++ b/src/shared/struct/shr_statistics.erl
@@ -9,12 +9,12 @@
{
movement_points :: non_neg_integer(),
health :: non_neg_integer(),
- dodges :: non_neg_integer(),
- parries :: non_neg_integer(),
- accuracy :: non_neg_integer(),
- double_hits :: non_neg_integer(),
- critical_hits :: non_neg_integer(),
- damage_modifier :: float()
+ dodges :: integer(),
+ parries :: integer(),
+ accuracy :: integer(),
+ double_hits :: integer(),
+ critical_hits :: integer(),
+ damage_modifier :: integer()
}
).
@@ -37,6 +37,7 @@
get_double_hits/1,
get_critical_hits/1,
get_damage_modifier/1,
+ get_damage_multiplier/1,
apply_mod/3
]
@@ -45,122 +46,49 @@
-export
(
[
- new_raw/1
+ default/0
]
).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--spec float_to_int (float()) -> integer().
-float_to_int (F) ->
- I = trunc(F),
- case (F > I) of
- true -> (I + 1);
- _ -> I
- end.
-
--spec min_max (number(), number(), number()) -> number().
-min_max (Min, Max, V) -> min(Max, max(Min, V)).
-
--spec average (list(number())) -> number().
-%average ([]) -> 0;
-average (L) -> lists:sum(L) / length(L).
-
-% V | 010 | 030 | 050 | 070 | 100 |
-% F | 004 | 023 | 058 | 104 | 200 |
--spec gentle_squared_growth (number()) -> non_neg_integer().
-gentle_squared_growth (V) -> float_to_int(math:pow(V, 1.8) / 20.0).
-
-% V | 010 | 030 | 050 | 070 | 100 |
-% F | 001 | 005 | 018 | 041 | 100 |
--spec sudden_squared_growth (number()) -> non_neg_integer().
-sudden_squared_growth (V) -> float_to_int(math:pow(V, 2.5) / 1000.0).
-
-% V | 010 | 030 | 050 | 070 | 100 |
-% F | 002 | 006 | 016 | 049 | 256 |
--spec sudden_exp_growth (number()) -> non_neg_integer().
-sudden_exp_growth (V) -> float_to_int(math:pow(4.0, V / 25.0)).
-
-% V | 010 | 030 | 050 | 070 | 100 |
-% F | 040 | 066 | 079 | 088 | 099 |
-% Seems too generous, values for attributes below 50 should dip faster and
-% lower.
-%-spec already_high_slow_growth (non_neg_integer()) -> non_neg_integer().
-%already_high_slow_growth (V) -> float_to_int(30 * math:log((V + 5)/4)).
-
--spec damage_base_modifier (non_neg_integer()) -> float().
-damage_base_modifier (Strength) -> (math:pow((Strength + 10)*4, 1.5) / 3000.0).
-
--spec make_movement_points_safe (non_neg_integer()) -> non_neg_integer().
-make_movement_points_safe (Val) -> min_max(0, 200, Val).
-
--spec make_health_safe (non_neg_integer()) -> non_neg_integer().
-make_health_safe (Val) -> max(1, Val).
-
--spec make_dodges_safe (non_neg_integer()) -> non_neg_integer().
-make_dodges_safe (Val) -> min_max(0, 100, Val).
-
--spec make_parries_safe (non_neg_integer()) -> non_neg_integer().
-make_parries_safe (Val) -> min_max(0, 75, Val).
-
--spec make_accuracy_safe (non_neg_integer()) -> non_neg_integer().
-make_accuracy_safe (Val) -> min_max(0, 100, Val).
-
--spec make_double_hits_safe (non_neg_integer()) -> non_neg_integer().
-make_double_hits_safe (Val) -> min_max(0, 100, Val).
-
--spec make_critical_hits_safe (non_neg_integer()) -> non_neg_integer().
-make_critical_hits_safe (Val) -> min_max(0, 100, Val).
-
-spec mod_movement_points (integer(), type()) -> type().
mod_movement_points (Mod, Stats) ->
Stats#statistics
{
- movement_points =
- make_movement_points_safe(get_movement_points(Stats) + Mod)
+ movement_points = (Stats#statistics.movement_points + Mod)
}.
-spec mod_health (integer(), type()) -> type().
mod_health (Mod, Stats) ->
- Stats#statistics
- {
- health = make_health_safe(get_health(Stats) + Mod)
- }.
+ Stats#statistics{ health = (Stats#statistics.health + Mod) }.
-spec mod_dodges (integer(), type()) -> type().
mod_dodges (Mod, Stats) ->
- Stats#statistics
- {
- dodges = make_dodges_safe(get_dodges(Stats) + Mod)
- }.
+ Stats#statistics{ dodges = (Stats#statistics.dodges + Mod) }.
-spec mod_parries (integer(), type()) -> type().
mod_parries (Mod, Stats) ->
- Stats#statistics
- {
- parries = make_parries_safe(get_parries(Stats) + Mod)
- }.
+ Stats#statistics{ parries = (Stats#statistics.parries + Mod) }.
-spec mod_accuracy (integer(), type()) -> type().
mod_accuracy (Mod, Stats) ->
- Stats#statistics
- {
- accuracy = make_accuracy_safe(get_accuracy(Stats) + Mod)
- }.
+ Stats#statistics{ accuracy = (Stats#statistics.accuracy + Mod) }.
-spec mod_double_hits (integer(), type()) -> type().
mod_double_hits (Mod, Stats) ->
- Stats#statistics
- {
- double_hits = make_double_hits_safe(get_double_hits(Stats) + Mod)
- }.
+ Stats#statistics{ double_hits = (Stats#statistics.double_hits + Mod) }.
-spec mod_critical_hits (integer(), type()) -> type().
mod_critical_hits (Mod, Stats) ->
+ Stats#statistics{ critical_hits = (Stats#statistics.critical_hits + Mod) }.
+
+-spec mod_damage_modifier (integer(), type()) -> type().
+mod_damage_modifier (Mod, Stats) ->
Stats#statistics
{
- critical_hits = make_critical_hits_safe(get_critical_hits(Stats) + Mod)
+ damage_modifier = (Stats#statistics.damage_modifier + Mod)
}.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -168,61 +96,44 @@ mod_critical_hits (Mod, Stats) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Accessors
-spec get_movement_points (type()) -> non_neg_integer().
-get_movement_points (Stats) -> Stats#statistics.movement_points.
+get_movement_points (Stats) -> max(0, Stats#statistics.movement_points).
-spec get_health (type()) -> non_neg_integer().
-get_health (Stats) -> Stats#statistics.health.
+get_health (Stats) -> max(1, Stats#statistics.health).
-spec get_dodges (type()) -> non_neg_integer().
-get_dodges (Stats) -> Stats#statistics.dodges.
+get_dodges (Stats) -> max(0, Stats#statistics.dodges).
-spec get_parries (type()) -> non_neg_integer().
-get_parries (Stats) -> Stats#statistics.parries.
+get_parries (Stats) -> max(0, Stats#statistics.parries).
-spec get_accuracy (type()) -> non_neg_integer().
-get_accuracy (Stats) -> Stats#statistics.accuracy.
+get_accuracy (Stats) -> max(0, Stats#statistics.accuracy).
-spec get_double_hits (type()) -> non_neg_integer().
-get_double_hits (Stats) -> Stats#statistics.double_hits.
+get_double_hits (Stats) -> max(0, Stats#statistics.double_hits).
-spec get_critical_hits (type()) -> non_neg_integer().
-get_critical_hits (Stats) -> Stats#statistics.critical_hits.
+get_critical_hits (Stats) -> max(0, Stats#statistics.critical_hits).
--spec get_damage_modifier (type()) -> float().
-get_damage_modifier (Stats) -> Stats#statistics.damage_modifier.
+-spec get_damage_modifier (type()) -> non_neg_integer().
+get_damage_modifier (Stats) -> max(0, Stats#statistics.damage_modifier).
--spec new_raw (shr_attributes:type()) -> type().
-new_raw (Attributes) ->
- Constitution = shr_attributes:get_constitution(Attributes),
- Dexterity = shr_attributes:get_dexterity(Attributes),
- Intelligence = shr_attributes:get_intelligence(Attributes),
- Mind = shr_attributes:get_mind(Attributes),
- Speed = shr_attributes:get_speed(Attributes),
- Strength = shr_attributes:get_strength(Attributes),
+-spec get_damage_multiplier (type()) -> float().
+get_damage_multiplier (Stats) -> (get_damage_modifier(Stats) / 100).
+-spec default () -> type().
+default () ->
#statistics
{
- movement_points =
- gentle_squared_growth
- (
- average([Mind, Constitution, Constitution, Speed, Speed, Speed])
- ),
- health =
- gentle_squared_growth
- (
- average([Constitution, Constitution, Constitution, Mind])
- ),
- dodges =
- sudden_exp_growth(average([Dexterity, Mind, Speed])),
- parries =
- sudden_exp_growth
- (
- average([Dexterity, Intelligence, Speed, Strength])
- ),
- accuracy = sudden_squared_growth(Dexterity),
- double_hits = sudden_squared_growth(average([Mind, Speed])),
- critical_hits = sudden_squared_growth(Intelligence),
- damage_modifier = damage_base_modifier(Strength)
+ movement_points = 0,
+ health = 1,
+ dodges = 0,
+ parries = 0,
+ accuracy = 0,
+ double_hits = 0,
+ critical_hits = 0,
+ damage_modifier = 100
}.
-spec apply_mod (atom(), integer(), type()) -> type().
@@ -232,4 +143,5 @@ apply_mod(dodg, Value, Stats) -> mod_dodges(Value, Stats);
apply_mod(pary, Value, Stats) -> mod_parries(Value, Stats);
apply_mod(accu, Value, Stats) -> mod_accuracy(Value, Stats);
apply_mod(dhit, Value, Stats) -> mod_double_hits(Value, Stats);
-apply_mod(crit, Value, Stats) -> mod_critical_hits(Value, Stats).
+apply_mod(crit, Value, Stats) -> mod_critical_hits(Value, Stats);
+apply_mod(dmgm, Value, Stats) -> mod_damage_modifier(Value, Stats).