From c41e76dc8fcbef9b64bee69e921304a2cad2fdd4 Mon Sep 17 00:00:00 2001 From: nsensfel Date: Tue, 28 Aug 2018 18:30:19 +0200 Subject: Adds the structure for omnimods, merges *_tile.erl --- src/shared/struct/shr_armor.erl.m4 | 96 ++------------------------------------ 1 file changed, 5 insertions(+), 91 deletions(-) (limited to 'src/shared/struct/shr_armor.erl.m4') diff --git a/src/shared/struct/shr_armor.erl.m4 b/src/shared/struct/shr_armor.erl.m4 index 5db4b36..01d810a 100644 --- a/src/shared/struct/shr_armor.erl.m4 +++ b/src/shared/struct/shr_armor.erl.m4 @@ -5,23 +5,19 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -type id() :: non_neg_integer(). --type category() :: 'kinetic' | 'leather' | 'chain' | 'plate'. - -record ( armor, { id :: id(), name :: binary(), - category :: category(), - coef :: float() + omnimods :: shr_omnimods:type() } ). -opaque type() :: #armor{}. -export_type([type/0, id/0]). --export_type ([category/0]). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -32,8 +28,7 @@ [ get_id/1, get_name/1, - get_coefficient/1, - get_category/1 + get_omnimods/1 ] ). @@ -41,9 +36,7 @@ ( [ random_id/0, - from_id/1, - apply_to_attributes/2, - get_resistance_to/2 + from_id/1 ] ). @@ -62,11 +55,8 @@ get_id (Ar) -> Ar#armor.id. -spec get_name (type()) -> binary(). get_name (Ar) -> Ar#armor.name. --spec get_coefficient (type()) -> float(). -get_coefficient (Ar) -> Ar#armor.coef. - --spec get_category (type()) -> category(). -get_category (Ar) -> Ar#armor.category. +-spec get_omnimods (type()) -> shr_omnimods:type(). +get_omnimods (Ar) -> Ar#armor.omnimods. -spec from_id (id()) -> type(). m4_include(__MAKEFILE_DATA_DIR/armor/global.m4.conf)m4_dnl @@ -76,79 +66,3 @@ from_id(_) -> -spec random_id () -> id(). random_id () -> shr_roll:between(0, 4). - --spec apply_to_attributes - ( - type(), - shr_attributes:type() - ) - -> shr_attributes:type(). -apply_to_attributes (Ar, Att) -> - Constitution = shr_attributes:get_constitution(Att), - Dexterity = shr_attributes:get_dexterity(Att), - Speed = shr_attributes:get_speed(Att), - Strength = shr_attributes:get_strength(Att), - Mind = shr_attributes:get_mind(Att), - Impact = shr_math_util:ceil(20.0 * Ar#armor.coef), - HalfImpact = shr_math_util:ceil(10.0 * Ar#armor.coef), - Category = Ar#armor.category, - - case Category of - kinetic -> shr_attributes:set_unsafe_mind((Mind - Impact), Att); - leather -> - shr_attributes:set_unsafe_constitution - ( - (Constitution - HalfImpact), - shr_attributes:set_unsafe_dexterity((Dexterity - HalfImpact), Att) - ); - - chain -> - shr_attributes:set_unsafe_constitution - ( - (Constitution - HalfImpact), - shr_attributes:set_unsafe_dexterity - ( - (Dexterity - HalfImpact), - shr_attributes:set_unsafe_speed((Speed - Impact), Att) - ) - ); - - plate -> - shr_attributes:set_unsafe_constitution - ( - (Constitution - HalfImpact), - shr_attributes:set_unsafe_dexterity - ( - (Dexterity - HalfImpact), - shr_attributes:set_unsafe_speed - ( - (Speed - Impact), - shr_attributes:set_unsafe_strength((Strength - Impact), Att) - ) - ) - ) - end. - --spec get_resistance_to (shr_weapon:damage_type(), type()) -> non_neg_integer(). -get_resistance_to (DamageType, Armor) -> - ArmorCategory = Armor#armor.category, - BaseResistance = - case {DamageType, ArmorCategory} of - {slash, kinetic} -> 0.0; - {slash, leather} -> 20.0; - {slash, chain} -> 30.0; - {slash, plate} -> 30.0; - {blunt, kinetic} -> 20.0; - {blunt, leather} -> 20.0; - {blunt, chain} -> 20.0; - {blunt, plate} -> 20.0; - {pierce, kinetic} -> 20.0; - {pierce, leather} -> 20.0; - {pierce, chain} -> 20.0; - {pierce, plate} -> 30.0 - end, - - ArmorCoefficient = Armor#armor.coef, - ActualResistance = (ArmorCoefficient * BaseResistance), - - shr_math_util:ceil(ActualResistance). -- cgit v1.2.3-70-g09d2