Skip to content

Commit

Permalink
Unhardcode bio recycler, add hunger enchantment (#47637)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramza13 authored and ZhilkinSerg committed Apr 20, 2021
1 parent 4544085 commit 54a4e7f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
12 changes: 11 additions & 1 deletion data/json/bionics.json
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,17 @@
"name": { "str": "Recycler Unit" },
"description": "Your digestive system has been outfitted with a series of filters and processors, allowing you to reclaim waste liquid and, to a lesser degree, nutrients. The net effect is a greatly reduced need to eat and drink.",
"occupied_bodyparts": [ [ "torso", 15 ] ],
"flags": [ "BIONIC_NPC_USABLE" ]
"flags": [ "BIONIC_NPC_USABLE" ],
"enchantments": [
{
"condition": "ALWAYS",
"values": [
{ "value": "HUNGER", "multiply": -0.5 },
{ "value": "THIRST", "multiply": -0.5 },
{ "value": "METABOLISM", "multiply": -0.5 }
]
}
]
},
{
"id": "bio_remote",
Expand Down
1 change: 1 addition & 0 deletions doc/MAGIC.md
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ Effects for the character that has the enchantment:
* REGEN_STAMINA
* MAX_HP
* REGEN_HP
* HUNGER
* THIRST
* FATIGUE
* PAIN
Expand Down
10 changes: 1 addition & 9 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ static const bionic_id bio_jointservo( "bio_jointservo" );
static const bionic_id bio_leukocyte( "bio_leukocyte" );
static const bionic_id bio_memory( "bio_memory" );
static const bionic_id bio_railgun( "bio_railgun" );
static const bionic_id bio_recycler( "bio_recycler" );
static const bionic_id bio_shock_absorber( "bio_shock_absorber" );
static const bionic_id bio_tattoo_led( "bio_tattoo_led" );
static const bionic_id bio_ups( "bio_ups" );
Expand Down Expand Up @@ -5978,7 +5977,6 @@ void Character::update_needs( int rate_multiplier )
needs_rates Character::calc_needs_rates() const
{
const effect &sleep = get_effect( effect_sleep );
const bool has_recycler = has_bionic( bio_recycler );
const bool asleep = !sleep.is_null();

needs_rates rates;
Expand All @@ -6001,13 +5999,6 @@ needs_rates Character::calc_needs_rates() const
static const std::string fatigue_modifier( "fatigue_modifier" );
rates.fatigue *= 1.0f + mutation_value( fatigue_modifier );

// Note: intentionally not in metabolic rate
if( has_recycler ) {
// Recycler won't help much with mutant metabolism - it is intended for human one
rates.hunger = std::min( rates.hunger, std::max( 0.5f, rates.hunger - 0.5f ) );
rates.thirst = std::min( rates.thirst, std::max( 0.5f, rates.thirst - 0.5f ) );
}

if( asleep ) {
static const std::string fatigue_regen_modifier( "fatigue_regen_modifier" );
rates.recovery = 1.0f + mutation_value( fatigue_regen_modifier );
Expand Down Expand Up @@ -6052,6 +6043,7 @@ needs_rates Character::calc_needs_rates() const
rates.thirst *= 0.25f;
}

rates.hunger = enchantment_cache->modify_value( enchant_vals::mod::HUNGER, rates.hunger );
rates.fatigue = enchantment_cache->modify_value( enchant_vals::mod::FATIGUE, rates.fatigue );
rates.thirst = enchantment_cache->modify_value( enchant_vals::mod::THIRST, rates.thirst );

Expand Down
1 change: 1 addition & 0 deletions src/magic_enchantment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ namespace io
case enchant_vals::mod::REGEN_STAMINA: return "REGEN_STAMINA";
case enchant_vals::mod::MAX_HP: return "MAX_HP";
case enchant_vals::mod::REGEN_HP: return "REGEN_HP";
case enchant_vals::mod::HUNGER: return "HUNGER";
case enchant_vals::mod::THIRST: return "THIRST";
case enchant_vals::mod::FATIGUE: return "FATIGUE";
case enchant_vals::mod::PAIN: return "PAIN";
Expand Down
1 change: 1 addition & 0 deletions src/magic_enchantment.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ enum class mod : int {
REGEN_STAMINA,
MAX_HP, // for all limbs! use with caution
REGEN_HP,
HUNGER, // hunger rate
THIRST, // thirst rate
FATIGUE, // fatigue rate
PAIN, // cost or regen over time
Expand Down

0 comments on commit 54a4e7f

Please sign in to comment.