Skip to content

Commit

Permalink
Merge pull request CleverRaven#56728 from Fris0uman/nutrition
Browse files Browse the repository at this point in the history
Transition nutrition to kcal for good
  • Loading branch information
kevingranade authored Apr 11, 2022
2 parents e91b253 + af75c36 commit 666fb27
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 55 deletions.
66 changes: 33 additions & 33 deletions data/json/mutations/mutations.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@
"name": { "str": "Reflex Photophore" },
"points": -1,
"description": "A photophore has grown from your head. You can't consciously control it, and it might start to shine in response to your emotions or your physiological state.",
"cost": 1,
"cost": 9,
"time": 810000,
"hunger": true,
"kcal": true,
"encumbrance_covered": [ [ "head", 5 ] ],
"changes_to": [ "BIOLUM1" ],
"types": [ "BIOLUM" ],
Expand Down Expand Up @@ -205,9 +205,9 @@
"points": 1,
"description": "A photophore has grown from your head; you can make it glow softly. This will make you very visible in the dark, ideal for attracting a partner during mating season.",
"active": true,
"cost": 1,
"cost": 9,
"time": 810000,
"hunger": true,
"kcal": true,
"encumbrance_covered": [ [ "head", 5 ] ],
"types": [ "BIOLUM" ],
"prereqs": [ "BIOLUM0" ],
Expand All @@ -232,9 +232,9 @@
"points": 2,
"description": "You can make your photophore glow brightly.",
"active": true,
"cost": 1,
"cost": 9,
"time": 405000,
"hunger": true,
"kcal": true,
"encumbrance_covered": [ [ "head", 5 ] ],
"types": [ "BIOLUM" ],
"prereqs": [ "BIOLUM1" ],
Expand Down Expand Up @@ -883,10 +883,10 @@
"prereqs": [ "ADRENALINE" ],
"category": [ "BEAST" ],
"active": true,
"cost": 10,
"cost": 90,
"time": 10,
"fatigue": true,
"hunger": true,
"kcal": true,
"thirst": true,
"dodge_modifier": 2,
"movecost_modifier": 0.9
Expand Down Expand Up @@ -2726,8 +2726,8 @@
"ugliness": 3,
"description": "Some of the quills on your arms have become quite loose. By flinging your arms, you can fire off these quills as projectiles.",
"active": true,
"cost": 10,
"hunger": true,
"cost": 90,
"kcal": true,
"ranged_mutation": { "type": "mut_quills", "message": "You fire off some of your quills." },
"prereqs": [ "QUILLS" ]
},
Expand Down Expand Up @@ -2914,8 +2914,8 @@
"threshreq": [ "THRESH_MYCUS" ],
"category": [ "MYCUS" ],
"active": true,
"cost": 8,
"hunger": true,
"cost": 69,
"kcal": true,
"thirst": true
},
{
Expand Down Expand Up @@ -2949,8 +2949,8 @@
"threshreq": [ "THRESH_MYCUS" ],
"category": [ "MYCUS" ],
"active": true,
"cost": 10,
"hunger": true,
"cost": 90,
"kcal": true,
"thirst": true,
"fatigue": true
},
Expand All @@ -2968,8 +2968,8 @@
"threshreq": [ "THRESH_MYCUS" ],
"category": [ "MYCUS" ],
"active": true,
"cost": 10,
"hunger": true,
"cost": 90,
"kcal": true,
"thirst": true,
"fatigue": true
},
Expand Down Expand Up @@ -3138,7 +3138,7 @@
"category": [ "INSECT" ],
"threshreq": [ "THRESH_INSECT" ],
"active": true,
"cost": 15,
"cost": 95,
"thirst": true,
"attacks": [
{
Expand Down Expand Up @@ -3782,9 +3782,9 @@
"description": "You're burning calories like crazy to heal your wounds.",
"copy-from": "EATHEALTH",
"valid": false,
"cost": 1,
"cost": 9,
"time": 1,
"hunger": true,
"kcal": true,
"healing_awake": 300.0,
"healing_resting": 350.0,
"transform": { "target": "EATHEALTH", "msg_transform": "Your hyper-metabolism slows down.", "active": false, "moves": 0 }
Expand Down Expand Up @@ -4404,10 +4404,10 @@
"prereqs": [ "WINGS_STUB" ],
"category": [ "INSECT" ],
"active": true,
"cost": 20,
"cost": 174,
"time": 10,
"fatigue": true,
"hunger": true,
"kcal": true,
"thirst": true,
"movecost_modifier": 0.75
},
Expand Down Expand Up @@ -4548,10 +4548,10 @@
"prereqs": [ "MUCUS_SECRETION" ],
"category": [ "GASTROPOD" ],
"active": true,
"cost": 20,
"cost": 174,
"time": 100,
"thirst": true,
"hunger": true
"kcal": true
},
{
"type": "mutation",
Expand Down Expand Up @@ -4658,9 +4658,9 @@
"category": [ "SPIDER" ],
"leads_to": [ "WEB_RAPPEL", "WEB_ROPE" ],
"active": true,
"cost": 8,
"cost": 69,
"time": 100,
"hunger": true,
"kcal": true,
"thirst": true
},
{
Expand All @@ -4673,8 +4673,8 @@
"threshreq": [ "THRESH_SPIDER" ],
"category": [ "SPIDER" ],
"active": true,
"cost": 15,
"hunger": true,
"cost": 95,
"kcal": true,
"active_flags": [ "WEB_RAPPEL" ]
},
{
Expand All @@ -4687,8 +4687,8 @@
"threshreq": [ "THRESH_SPIDER" ],
"category": [ "SPIDER" ],
"active": true,
"cost": 30,
"hunger": true,
"cost": 260,
"kcal": true,
"thirst": true,
"spawn_item": { "type": "rope_30", "message": "You spin a rope from your silk." }
},
Expand Down Expand Up @@ -6216,8 +6216,8 @@
"threshreq": [ "THRESH_SLIME" ],
"category": [ "SLIME" ],
"active": true,
"cost": 40,
"hunger": true,
"cost": 347,
"kcal": true,
"thirst": true
},
{
Expand Down Expand Up @@ -6335,8 +6335,8 @@
"threshreq": [ "THRESH_PLANT" ],
"category": [ "PLANT" ],
"active": true,
"cost": 10,
"hunger": true,
"cost": 90,
"kcal": true,
"thirst": true,
"spawn_item": { "type": "vine_30", "message": "You detach a vine from your body." },
"attacks": [
Expand Down
2 changes: 1 addition & 1 deletion doc/JSON_INFO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2190,7 +2190,7 @@ The `id` must be exact as it is hardcoded to look for that.
"starts_active" : true, //When true, this 'active' mutation starts active (default: false, requires 'active')
"cost" : 8, // Cost to activate this mutation. Needs one of the hunger, thirst, or fatigue values set to true. (default: 0)
"time" : 100, //Sets the amount of (turns * current player speed ) time units that need to pass before the cost is to be paid again. Needs to be higher than one to have any effect. (default: 0)
"hunger" : true, //If true, activated mutation increases hunger by cost. (default: false)
"kcal" : true, //If true, activated mutation consumes `cost` kcal. (default: false)
"thirst" : true, //If true, activated mutation increases thirst by cost. (default: false)
"fatigue" : true, //If true, activated mutation increases fatigue by cost. (default: false)
"scent_modifier": 0.0,// float affecting the intensity of your smell. (default: 1.0)
Expand Down
4 changes: 2 additions & 2 deletions src/activity_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ void dig_activity_actor::finish( player_activity &act, Character &who )
}

const int helpersize = get_player_character().get_num_crafting_helpers( 3 );
who.mod_stored_nutr( 5 - helpersize );
who.mod_stored_kcal( 43 - 9 * helpersize );
who.mod_thirst( 5 - helpersize );
who.mod_fatigue( 10 - ( helpersize * 2 ) );
if( grave ) {
Expand Down Expand Up @@ -671,7 +671,7 @@ void dig_channel_activity_actor::finish( player_activity &act, Character &who )
}

const int helpersize = get_player_character().get_num_crafting_helpers( 3 );
who.mod_stored_nutr( 5 - helpersize );
who.mod_stored_kcal( 43 - 9 * helpersize );
who.mod_thirst( 5 - helpersize );
who.mod_fatigue( 10 - ( helpersize * 2 ) );
who.add_msg_if_player( m_good, _( "You finish digging up %s." ),
Expand Down
6 changes: 0 additions & 6 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4010,12 +4010,6 @@ void Character::mod_stored_calories( int ncal, const bool ignore_weariness )
set_stored_calories( stored_calories + ncal );
}

void Character::mod_stored_nutr( int nnutr )
{
// nutr is legacy type code, this function simply converts old nutrition to new kcal
mod_stored_kcal( -1 * std::round( nnutr * 2500.0f / ( 12 * 24 ) ) );
}

void Character::set_stored_kcal( int kcal )
{
set_stored_calories( kcal * 1000 );
Expand Down
1 change: 0 additions & 1 deletion src/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,6 @@ class Character : public Creature, public visitable

/** Modifiers for need values exclusive to characters */
void mod_stored_kcal( int nkcal, bool ignore_weariness = false );
void mod_stored_nutr( int nnutr );
void mod_hunger( int nhunger );
void mod_thirst( int nthirst );
void mod_fatigue( int nfatigue );
Expand Down
4 changes: 2 additions & 2 deletions src/construction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1591,7 +1591,7 @@ void construct::done_digormine_stair( const tripoint &p, bool dig )

int no_mut_penalty = dig_muts ? 10 : 0;
int mine_penalty = dig ? 0 : 10;
player_character.mod_stored_nutr( 5 + mine_penalty + no_mut_penalty );
player_character.mod_stored_kcal( 43 + 9 * mine_penalty + 9 * no_mut_penalty );
player_character.mod_thirst( 5 + mine_penalty + no_mut_penalty );
player_character.mod_fatigue( 10 + mine_penalty + no_mut_penalty );

Expand Down Expand Up @@ -1663,7 +1663,7 @@ void construct::done_mine_upstair( const tripoint &p )
player_character.has_trait( trait_STOCKY_TROGLO );

int no_mut_penalty = dig_muts ? 15 : 0;
player_character.mod_stored_nutr( 20 + no_mut_penalty );
player_character.mod_stored_kcal( 174 + 9 * no_mut_penalty );
player_character.mod_thirst( 20 + no_mut_penalty );
player_character.mod_fatigue( 25 + no_mut_penalty );

Expand Down
4 changes: 2 additions & 2 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11190,15 +11190,15 @@ cata::optional<tripoint> game::find_or_make_stairs( map &mp, const int z_after,
add_msg( m_bad, _( "You descend on your vines, though leaving a part of you behind stings." ) );
u.mod_pain( 5 );
u.apply_damage( nullptr, bodypart_id( "torso" ), 5 );
u.mod_stored_nutr( 10 );
u.mod_stored_kcal( 87 );
u.mod_thirst( 10 );
} else {
add_msg( _( "You gingerly descend using your vines." ) );
}
} else {
add_msg( _( "You effortlessly lower yourself and leave a vine rooted for future use." ) );
rope_ladder = true;
u.mod_stored_nutr( 10 );
u.mod_stored_kcal( 87 );
u.mod_thirst( 10 );
}
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/iuse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,7 @@ static void marloss_common( Character &p, item &it, const trait_id &current_colo
p.mutate();
// Gruss dich, mutation drain, missed you!
p.mod_pain( 2 * rng( 1, 5 ) );
p.mod_stored_nutr( 10 );
p.mod_stored_kcal( 87 );
p.mod_thirst( 10 );
p.mod_fatigue( 5 );
} else if( effect <= 6 ) { // Radiation cleanse is below
Expand Down Expand Up @@ -1538,7 +1538,7 @@ cata::optional<int> iuse::mycus( Character *p, item *it, bool, const tripoint &
!p->has_trait( trait_M_DEPENDENT ) ) { // OK, now set the hook.
if( !one_in( 3 ) ) {
p->mutate_category( mutation_category_MYCUS );
p->mod_stored_nutr( 10 );
p->mod_stored_kcal( 87 );
p->mod_thirst( 10 );
p->mod_fatigue( 5 );
p->add_morale( MORALE_MARLOSS, 25, 200 ); // still covers up mutation pain
Expand All @@ -1552,7 +1552,7 @@ cata::optional<int> iuse::mycus( Character *p, item *it, bool, const tripoint &
_( "This tastes really weird! You're not sure it's good for you…" ) );
p->mutate();
p->mod_pain( 2 * rng( 1, 5 ) );
p->mod_stored_nutr( 10 );
p->mod_stored_kcal( 87 );
p->mod_thirst( 10 );
p->mod_fatigue( 5 );
p->vomit(); // no hunger/quench benefit for you
Expand Down
2 changes: 1 addition & 1 deletion src/mutation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ void Character::activate_mutation( const trait_id &mut )
}
if( mdata.hunger ) {
// burn some energy
mod_stored_nutr( cost );
mod_stored_kcal( cost );
}
if( mdata.thirst ) {
mod_thirst( cost );
Expand Down
2 changes: 1 addition & 1 deletion src/mutation_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ void mutation_branch::load( const JsonObject &jo, const std::string & )
optional( jo, was_loaded, "allow_soft_gear", allow_soft_gear, false );
optional( jo, was_loaded, "cost", cost, 0 );
optional( jo, was_loaded, "time", cooldown, 0 );
optional( jo, was_loaded, "hunger", hunger, false );
optional( jo, was_loaded, "kcal", hunger, false );
optional( jo, was_loaded, "thirst", thirst, false );
optional( jo, was_loaded, "fatigue", fatigue, false );
optional( jo, was_loaded, "valid", valid, true );
Expand Down
4 changes: 2 additions & 2 deletions src/player_hardcoded_effects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ static void eff_fun_sleep( Character &u, effect &it )
if( u.get_hunger() >= -30 ) {
u.mod_hunger( -5 );
// photosynthesis warrants absorbing kcal directly
u.mod_stored_nutr( -5 );
u.mod_stored_kcal( -43 );
}
}
if( u.get_thirst() >= -40 ) {
Expand Down Expand Up @@ -1031,7 +1031,7 @@ static void eff_fun_sleep( Character &u, effect &it )
if( u.has_trait( trait_THRESH_MYCUS ) ) {
if( one_in( 8 ) ) {
u.mutate_category( mutation_category_MYCUS );
u.mod_stored_nutr( 10 );
u.mod_stored_kcal( 87 );
u.mod_thirst( 10 );
u.mod_fatigue( 5 );
}
Expand Down
2 changes: 1 addition & 1 deletion src/suffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ void suffer::mutation_power( Character &you, const trait_id &mut_id )
you.deactivate_mutation( mut_id );
} else {
// does not directly modify hunger, but burns kcal
you.mod_stored_nutr( mut_id->cost );
you.mod_stored_kcal( mut_id->cost );
}
}
if( mut_id->thirst ) {
Expand Down

0 comments on commit 666fb27

Please sign in to comment.