From 5575599221d01fb772991181f44b2653114d42cb Mon Sep 17 00:00:00 2001 From: David Brown Date: Fri, 3 Jan 2020 22:57:47 +0000 Subject: [PATCH] jsonize swim speed modifier as per walk cost mutation modifier --- data/json/mutations/mutations.json | 6 ++++++ src/character.cpp | 1 + src/mutation.h | 1 + src/mutation_data.cpp | 1 + src/player.cpp | 23 +++-------------------- 5 files changed, 12 insertions(+), 20 deletions(-) diff --git a/data/json/mutations/mutations.json b/data/json/mutations/mutations.json index 932266ca20252..ca9582f4632e2 100644 --- a/data/json/mutations/mutations.json +++ b/data/json/mutations/mutations.json @@ -1789,6 +1789,7 @@ "category": [ "CHIMERA", "RAPTOR", "LIZARD" ], "prereqs": [ "SKIN_ROUGH" ], "changes_to": [ "THICK_SCALES", "SLEEK_SCALES" ], + "movecost_swim_modifier": 0.9, "wet_protection": [ { "part": "HEAD", "ignored": 3 }, { "part": "LEG_L", "ignored": 10 }, @@ -1842,6 +1843,7 @@ "types": [ "SKIN" ], "prereqs": [ "SCALES" ], "category": [ "FISH" ], + "movecost_swim_modifier": 0.75, "wet_protection": [ { "part": "HEAD", "good": 7 }, { "part": "LEG_L", "good": 21 }, @@ -3134,6 +3136,7 @@ "prereqs": [ "TAIL_STUB" ], "category": [ "FISH" ], "wet_protection": [ { "part": "LEG_L", "good": 3 }, { "part": "LEG_R", "good": 3 } ], + "movecost_swim_modifier": 0.75, "restricts_gear": [ "LEG_L", "LEG_R" ], "allow_soft_gear": true }, @@ -3818,6 +3821,7 @@ "prereqs": [ "STR_UP", "STR_UP_2", "STR_UP_3", "STR_UP_4" ], "leads_to": [ "HIBERNATE" ], "category": [ "URSINE" ], + "movecost_swim_modifier": 0.95, "armor": [ { "parts": "ALL", "bash": 1 } ], "movecost_modifier": 1.05 }, @@ -5681,6 +5685,7 @@ "description": "Your legs have transformed into six tentacles. This decreases your speed on land by 20%, makes your movement silent, increases your swimming speed, and reduces wet penalties.", "types": [ "LEGS" ], "leads_to": [ "LEG_TENT_BRACE" ], + "movecost_swim_modifier": 0.85, "category": [ "CEPHALOPOD" ], "wet_protection": [ { "part": "LEG_L", "neutral": 21 }, @@ -5974,6 +5979,7 @@ "description": "You're as comfortable in water as on land, and your body has adapted around that fact. Your base swimming speed is greatly increased, and weight will hinder you much less while swimming.", "category": [ "FISH" ], "threshreq": [ "THRESH_FISH" ], + "movecost_swim_modifier": 0.45, "purifiable": false }, { diff --git a/src/character.cpp b/src/character.cpp index 2fefebdea9db5..46fdf2be6bc28 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -5010,6 +5010,7 @@ mutation_value_map = { { "max_stamina_modifier", calc_mutation_value_multiplicative<&mutation_branch::max_stamina_modifier> }, { "weight_capacity_modifier", calc_mutation_value_multiplicative<&mutation_branch::weight_capacity_modifier> }, { "hearing_modifier", calc_mutation_value_multiplicative<&mutation_branch::hearing_modifier> }, + { "movecost_swim_modifier", calc_mutation_value_multiplicative<&mutation_branch::movecost_swim_modifier> }, { "noise_modifier", calc_mutation_value_multiplicative<&mutation_branch::noise_modifier> }, { "overmap_sight", calc_mutation_value_multiplicative<&mutation_branch::overmap_sight> }, { "overmap_multiplier", calc_mutation_value_multiplicative<&mutation_branch::overmap_multiplier> }, diff --git a/src/mutation.h b/src/mutation.h index ee12948f04fbb..75edd8a4ff5e8 100644 --- a/src/mutation.h +++ b/src/mutation.h @@ -140,6 +140,7 @@ struct mutation_branch { float max_stamina_modifier = 1.0f; float weight_capacity_modifier = 1.0f; float hearing_modifier = 1.0f; + float movecost_swim_modifier = 1.0f; float noise_modifier = 1.0f; float scent_modifier = 1.0f; cata::optional scent_intensity; diff --git a/src/mutation_data.cpp b/src/mutation_data.cpp index f3c9209783917..a0426b2cba72b 100644 --- a/src/mutation_data.cpp +++ b/src/mutation_data.cpp @@ -335,6 +335,7 @@ void mutation_branch::load( const JsonObject &jo, const std::string & ) optional( jo, was_loaded, "movecost_modifier", movecost_modifier, 1.0f ); optional( jo, was_loaded, "movecost_flatground_modifier", movecost_flatground_modifier, 1.0f ); optional( jo, was_loaded, "movecost_obstacle_modifier", movecost_obstacle_modifier, 1.0f ); + optional( jo, was_loaded, "movecost_swim_modifier", movecost_swim_modifier, 1.0f ); optional( jo, was_loaded, "attackcost_modifier", attackcost_modifier, 1.0f ); optional( jo, was_loaded, "max_stamina_modifier", max_stamina_modifier, 1.0f ); optional( jo, was_loaded, "weight_capacity_modifier", weight_capacity_modifier, 1.0f ); diff --git a/src/player.cpp b/src/player.cpp index 067d76e01bf1e..638762df1934d 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -176,7 +176,6 @@ static const bionic_id bio_synaptic_regen( "bio_synaptic_regen" ); static const bionic_id afs_bio_linguistic_coprocessor( "afs_bio_linguistic_coprocessor" ); static const trait_id trait_ACIDBLOOD( "ACIDBLOOD" ); -static const trait_id trait_AMPHIBIAN( "AMPHIBIAN" ); static const trait_id trait_ANTENNAE( "ANTENNAE" ); static const trait_id trait_ANTLERS( "ANTLERS" ); static const trait_id trait_CANNIBAL( "CANNIBAL" ); @@ -758,12 +757,9 @@ int player::swim_speed() const float hand_bonus_mult = ( usable.test( bp_hand_l ) ? 0.5f : 0.0f ) + ( usable.test( bp_hand_r ) ? 0.5f : 0.0f ); - if( !has_trait( trait_AMPHIBIAN ) ) { - ret = 440 + weight_carried() / 60_gram - 50 * get_skill_level( skill_swimming ); - /** AMPHIBIAN increases base swim speed */ - } else { - ret = 200 + weight_carried() / 120_gram - 50 * get_skill_level( skill_swimming ); - } + // base swim speed. + ret = ( 440 * mutation_value( "movecost_swim_modifier" ) ) + weight_carried() / + ( 60_gram / mutation_value( "movecost_swim_modifier" ) ) - 50 * get_skill_level( skill_swimming ); /** @EFFECT_STR increases swim speed bonus from PAWS */ if( has_trait( trait_PAWS ) ) { ret -= hand_bonus_mult * ( 20 + str_cur * 3 ); @@ -784,19 +780,6 @@ int player::swim_speed() const if( has_trait( trait_WEBBED ) ) { ret -= hand_bonus_mult * ( 60 + str_cur * 5 ); } - /** @EFFECT_STR increases swim speed bonus from TAIL_FIN */ - if( has_trait( trait_TAIL_FIN ) ) { - ret -= 100 + str_cur * 10; - } - if( has_trait( trait_SLEEK_SCALES ) ) { - ret -= 100; - } - if( has_trait( trait_LEG_TENTACLES ) ) { - ret -= 60; - } - if( has_trait( trait_FAT ) ) { - ret -= 30; - } /** @EFFECT_SWIMMING increases swim speed */ ret += ( 50 - get_skill_level( skill_swimming ) * 2 ) * ( ( encumb( bp_leg_l ) + encumb( bp_leg_r ) ) / 10 );