summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/struct/sh_armor.erl4
-rw-r--r--src/shared/struct/sh_weapon.erl6
-rw-r--r--src/shared/util/sh_math_util.erl30
3 files changed, 35 insertions, 5 deletions
diff --git a/src/shared/struct/sh_armor.erl b/src/shared/struct/sh_armor.erl
index f328fdf..dcbb379 100644
--- a/src/shared/struct/sh_armor.erl
+++ b/src/shared/struct/sh_armor.erl
@@ -119,7 +119,7 @@ apply_to_attributes (Ar, Att) ->
Speed = sh_attributes:get_speed(Att),
Strength = sh_attributes:get_strength(Att),
Mind = sh_attributes:get_mind(Att),
- Impact = erlang:ceil(20.0 * Ar#armor.coef),
+ Impact = sh_math_util:ceil(20.0 * Ar#armor.coef),
Category = Ar#armor.category,
case Category of
@@ -166,4 +166,4 @@ get_resistance_to (DamageType, Armor) ->
ArmorCoefficient = Armor#armor.coef,
ActualResistance = (ArmorCoefficient * BaseResistance),
- erlang:ceil(ActualResistance).
+ sh_math_util:ceil(ActualResistance).
diff --git a/src/shared/struct/sh_weapon.erl b/src/shared/struct/sh_weapon.erl
index db402af..2cd3fda 100644
--- a/src/shared/struct/sh_weapon.erl
+++ b/src/shared/struct/sh_weapon.erl
@@ -124,7 +124,7 @@ get_ranges (Wp) ->
get_damages (Wp) ->
Coef = Wp#weapon.coef,
{Min, Max} = damages_of_type(Wp#weapon.range_type, Wp#weapon.damage_mod),
- {erlang:ceil(Min * Coef), erlang:ceil(Max * Coef)}.
+ {sh_math_util:ceil(Min * Coef), sh_math_util:ceil(Max * Coef)}.
-spec can_parry (type()) -> boolean().
can_parry (Wp) -> (Wp#weapon.range_type == melee).
@@ -397,8 +397,8 @@ apply_to_attributes (Weapon, Attributes) ->
DamageModifier = Weapon#weapon.damage_mod,
Impact = (20.0 * Weapon#weapon.coef),
- FullImpact = erlang:ceil(Impact),
- QuarterImpact = erlang:ceil(Impact / 4.0),
+ FullImpact = sh_math_util:ceil(Impact),
+ QuarterImpact = sh_math_util:ceil(Impact / 4.0),
ResultingDexterity =
case RangeModifier of
diff --git a/src/shared/util/sh_math_util.erl b/src/shared/util/sh_math_util.erl
new file mode 100644
index 0000000..b2e2109
--- /dev/null
+++ b/src/shared/util/sh_math_util.erl
@@ -0,0 +1,30 @@
+-module(sh_math_util).
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+-export
+(
+ [
+ % Somehow, erlang:ceil is not defined on 2 out of my 4 dev computers.
+ ceil/1
+ ]
+).
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+-spec ceil (float()) -> integer().
+ceil (Float) ->
+ Int = trunc(Float),
+
+ case (Int /= Float) of
+ true -> (Int + 1);
+ _ -> Int
+ end.