From 85aa15a6fbf8fa22587b1b6786b2e15b74b38cd9 Mon Sep 17 00:00:00 2001 From: Kamejeir <99511880+Kamejeir@users.noreply.github.com> Date: Wed, 15 May 2024 19:45:49 +0000 Subject: [PATCH] Tip Ectothermic into really not liking cold for the purposes of being active, while giving it immunity to getting harmed by it. This was for implementing the fix suggested by anid in 66539 with acclimatization and homeostasis, that was never followed up on. In addition, fixed some bark inconsistencies I saw, and a case of Muscle Consolidation being weirdly "missable". --- data/json/mutations/mutation_jmath.json | 9 +++++++++ data/json/mutations/mutations.json | 25 +++++++++++++++---------- src/character_body.cpp | 12 ++++++++---- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/data/json/mutations/mutation_jmath.json b/data/json/mutations/mutation_jmath.json index 9b77a9285ea6a..e28171e6f0fd7 100644 --- a/data/json/mutations/mutation_jmath.json +++ b/data/json/mutations/mutation_jmath.json @@ -18,5 +18,14 @@ "//example3": "temperature_speed_mod(65, 0.2), but character has mutation, that gives CLIMATE_CONTROL_HEAT 5; it would make you lose 0.2 speed, if temperature around is lower than 60 F; temperature of 55 F would result in `(65-5-55)*0.2 = 5*0.2 = 1` 1 move speed decrease", "num_args": 2, "return": "min((fahrenheit(weather('temperature')) - _0 + u_climate_control_str_heat()) * _1, 0)" + }, + { + "type": "jmath_function", + "id": "temperature_sleepiness_mod", + "//": "Increases need for sleep, if it's below of some temperature. Never negative", + "//_0": "Temperature limit, after which sleepiness starts to change, in farenheit", + "//_1": "How many percentage units the sleepiness changes per 1 degree", + "num_args": 2, + "return": "max(min((fahrenheit(weather('temperature')) - _0 + u_climate_control_str_heat()) * _1, 0), 0)" } ] diff --git a/data/json/mutations/mutations.json b/data/json/mutations/mutations.json index 693706ebec38e..7f58c78e57124 100644 --- a/data/json/mutations/mutations.json +++ b/data/json/mutations/mutations.json @@ -3424,7 +3424,7 @@ "ugliness": 3, "description": "All the hair on your body has turned to long, grass-like leaves. Apart from being physically striking, these provide you with a minor amount of nutrients while in sunlight when your head is uncovered. Slightly reduces wet effects.", "types": [ "HAIR" ], - "prereqs": [ "PLANTSKIN", "BARK" ], + "prereqs": [ "PLANTSKIN", "BARK", "BARK2_a", "BARK2_b", "BARK2_c" ], "changes_to": [ "LEAVES2" ], "category": [ "PLANT", "ELFA" ], "wet_protection": [ { "part": "head", "ignored": 1 } ] @@ -3470,7 +3470,7 @@ "visibility": 0, "ugliness": 0, "description": "You body has begun moving nutrients via the evaporation of water. This increases your thirst when it's hot, but reduces it when it's cold.", - "prereqs": [ "PLANTSKIN", "BARK" ], + "prereqs": [ "PLANTSKIN", "BARK", "BARK2_a", "BARK2_b", "BARK2_c" ], "prereqs2": [ "LEAVES" ], "threshreq": [ "THRESH_PLANT" ], "category": [ "PLANT" ] @@ -3483,7 +3483,7 @@ "visibility": 10, "ugliness": -4, "description": "You've started blooming where your scalp used to be. Your blossoms have a pleasant aroma, are visually striking, and are quite sensitive.", - "prereqs": [ "PLANTSKIN", "BARK" ], + "prereqs": [ "PLANTSKIN", "BARK", "BARK2_a", "BARK2_b", "BARK2_c" ], "prereqs2": [ "HAIRROOTS" ], "types": [ "SCENT" ], "threshreq": [ "THRESH_PLANT", "THRESH_ELFA" ], @@ -4035,7 +4035,7 @@ "points": 1, "visibility": 1, "description": "Your extremities have gained strength but lost fine motor skills. -1 Dexterity +2 Strength.", - "changes_to": [ "GASTROPOD_EXTREMITY2" ], + "leads_to": [ "GASTROPOD_EXTREMITY2" ], "category": [ "GASTROPOD" ], "enchantments": [ { "values": [ { "value": "STRENGTH", "add": 2 }, { "value": "DEXTERITY", "add": -1 } ] } ] }, @@ -7497,7 +7497,7 @@ "ugliness": 5, "description": "You have developed several vines sprouting from your shoulder area. They're bulky, and get in the way.", "types": [ "WINGS" ], - "prereqs": [ "PLANTSKIN", "BARK" ], + "prereqs": [ "PLANTSKIN", "BARK", "BARK2_a", "BARK2_b", "BARK2_c" ], "changes_to": [ "VINES2" ], "category": [ "PLANT" ], "encumbrance_always": [ [ "torso", 10 ] ] @@ -7511,7 +7511,7 @@ "ugliness": 5, "description": "You've developed the ability to control your vines; they make good lashes. You can even rappel down sheer drops using them, but disconnecting HURTS.", "types": [ "WINGS" ], - "prereqs": [ "PLANTSKIN", "BARK" ], + "prereqs": [ "PLANTSKIN", "BARK", "BARK2_a", "BARK2_b", "BARK2_c" ], "prereqs2": [ "VINES1" ], "changes_to": [ "VINES3" ], "category": [ "PLANT" ], @@ -7534,7 +7534,7 @@ "ugliness": 6, "description": "You have full control of your vines, and can grow new ones and detach old ones more or less at will.", "types": [ "WINGS" ], - "prereqs": [ "PLANTSKIN", "BARK" ], + "prereqs": [ "PLANTSKIN", "BARK", "BARK2_a", "BARK2_b", "BARK2_c" ], "prereqs2": [ "VINES2" ], "threshreq": [ "THRESH_PLANT" ], "category": [ "PLANT" ], @@ -7716,17 +7716,19 @@ "name": { "str": "Ectothermic" }, "points": 0, "mixed_effect": true, - "description": "Your body has become permanently cold-blooded. Your speed lowers or raises 1% for every 2 (1.1) degrees below or above 65 F (18.3 C). You eat much less than you otherwise would.", + "description": "Your body has become permanently cold-blooded. Your speed lowers or raises 1% for every 2 (1.1) degrees below or above 65 F (18.3 C). You eat much less than you otherwise would, and your body has developed trouble staying active and alert while trying to endure extreme cold.", "types": [ "ECTOTHERMIC" ], "prereqs": [ "COLDBLOOD3" ], "threshreq": [ "THRESH_LIZARD", "THRESH_PLANT", "THRESH_BATRACHIAN" ], "purifiable": false, + "leads_to": [ "RESISTCHILL_RESISTWARM" ], "category": [ "LIZARD", "PLANT", "BATRACHIAN" ], "enchantments": [ { "values": [ { "value": "METABOLISM", "multiply": -0.5 }, - { "value": "SPEED", "add": { "math": [ "temperature_speed_mod(65, 0.5)" ] } } + { "value": "SPEED", "add": { "math": [ "temperature_speed_mod(65, 0.5)" ] } }, + { "value": "SLEEPINESS", "multiply": { "math": [ "temperature_sleepiness_mod(65, -2.5)" ] } } ] } ] @@ -9533,6 +9535,7 @@ "description": "You are now even less bothered by the heat and it is harder for you to overheat or even sweat. When you do though, it'll hit just as hard as it did before.", "prereqs": [ "RESISTWARM" ], "types": [ "ACCLIMATIZATION" ], + "changes_to": [ "RESISTCHILL_RESISTWARM" ], "category": [ "FISH", "CEPHALOPOD", "GASTROPOD", "LIZARD", "BATRACHIAN", "PLANT" ], "threshreq": [ "THRESH_FISH", "THRESH_CEPHALOPOD", "THRESH_GASTROPOD", "THRESH_LIZARD", "THRESH_BATRACHIAN" ], "enchantments": [ { "condition": "ALWAYS", "values": [ { "value": "CLIMATE_CONTROL_CHILL", "add": 25 } ] } ] @@ -9587,7 +9590,9 @@ "points": 5, "valid": true, "description": "You are now not at all bothered by the heat and it is harder for you to overheat or freeze at all. When you do though, it'll hit just as hard as it did before.", - "prereqs": [ "RESISTWARM" ], + "prereqs": [ "STRONGER_RESISTWARM" ], + "prereqs2": [ "COLDBLOOD4" ], + "purifiable": false, "types": [ "ACCLIMATIZATION" ], "category": [ "PLANT" ], "threshreq": [ "THRESH_PLANT" ], diff --git a/src/character_body.cpp b/src/character_body.cpp index fa9a6a4246d8f..e102f06c4f7ed 100644 --- a/src/character_body.cpp +++ b/src/character_body.cpp @@ -102,6 +102,9 @@ static const json_character_flag json_flag_NO_THIRST( "NO_THIRST" ); static const json_character_flag json_flag_PAIN_IMMUNE( "PAIN_IMMUNE" ); static const trait_id trait_BARK( "BARK" ); +static const trait_id trait_BARK2_a( "BARK2_a" ); +static const trait_id trait_BARK2_b( "BARK2_b" ); +static const trait_id trait_BARK2_c( "BARK2_c" ); static const trait_id trait_CHITIN_FUR( "CHITIN_FUR" ); static const trait_id trait_CHITIN_FUR2( "CHITIN_FUR2" ); static const trait_id trait_CHITIN_FUR3( "CHITIN_FUR3" ); @@ -458,7 +461,7 @@ void Character::update_bodytemp() int bp_windpower = get_local_windpower( weather_man.windspeed + vehwindspeed, cur_om_ter, get_location(), weather_man.winddirection, sheltered ); // Let's cache this not to check it for every bodyparts - const bool has_bark = has_trait( trait_BARK ); + const bool has_bark = has_trait( trait_BARK ) || has_trait( trait_BARK2_a ) || has_trait( trait_BARK2_b ) || has_trait( trait_BARK2_c ); const bool has_sleep = has_effect( effect_sleep ); const bool has_sleep_state = has_sleep || in_sleep_state(); const bool heat_immune = has_flag( json_flag_HEAT_IMMUNE ); @@ -728,12 +731,13 @@ void Character::update_bodytemp() set_part_temp_cur( bp, temp_before + temp_difference * convergence_multiplier ); const units::temperature temp_after = get_part_temp_cur( bp ); + const bool cold_immune = has_flag( json_flag_ECTOTHERM ); // PENALTIES - if( temp_after < BODYTEMP_FREEZING ) { + if( temp_after < BODYTEMP_FREEZING && !cold_immune ) { add_effect( effect_cold, 1_turns, bp, true, 3 ); - } else if( temp_after < BODYTEMP_VERY_COLD ) { + } else if( temp_after < BODYTEMP_VERY_COLD && !cold_immune ) { add_effect( effect_cold, 1_turns, bp, true, 2 ); - } else if( temp_after < BODYTEMP_COLD ) { + } else if( temp_after < BODYTEMP_COLD && !cold_immune ) { add_effect( effect_cold, 1_turns, bp, true, 1 ); } else if( temp_after > BODYTEMP_SCORCHING && !heat_immune ) { add_effect( effect_hot, 1_turns, bp, true, 3 );