diff --git a/data/json/game_balance.json b/data/json/game_balance.json index 7628961159695..6a6f6f3e42228 100644 --- a/data/json/game_balance.json +++ b/data/json/game_balance.json @@ -125,13 +125,6 @@ "stype": "bool", "value": false }, - { - "type": "EXTERNAL_OPTION", - "name": "SLEEP_DEPRIVATION", - "info": "Enables sleep deprivation mechanics. If true, stimulants will only help you so far, and you might have to enforce proper sleep hygiene for a while.", - "stype": "bool", - "value": true - }, { "type": "EXTERNAL_OPTION", "name": "CBM_SLOTS_ENABLED", diff --git a/data/json/item_actions.json b/data/json/item_actions.json index d18b67bae7e7a..ede621ccbe690 100644 --- a/data/json/item_actions.json +++ b/data/json/item_actions.json @@ -54,11 +54,6 @@ "id": "PICKAXE", "name": "Dig through rock" }, - { - "type": "item_action", - "id": "MELATONIN_TABLET", - "name": "Take a melatonin tablet" - }, { "type": "item_action", "id": "PACK_CBM", diff --git a/data/json/items/comestibles/med.json b/data/json/items/comestibles/med.json index 51b60dba8fa6f..2fe8d170f9c94 100644 --- a/data/json/items/comestibles/med.json +++ b/data/json/items/comestibles/med.json @@ -27,7 +27,11 @@ "stack_size": 30, "symbol": "!", "color": "yellow", - "use_action": "MELATONIN_TABLET" + "use_action": { + "type": "consume_drug", + "activation_message": "You pop a melatonin tablet.", + "effects": [ { "id": "melatonin", "duration": "16 h" } ] + } }, { "id": "adderall", diff --git a/src/character.cpp b/src/character.cpp index 0d3a360342c25..f10e4d7bc83c2 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -3569,10 +3569,6 @@ int Character::get_fatigue() const int Character::get_sleep_deprivation() const { - if( !get_option< bool >( "SLEEP_DEPRIVATION" ) ) { - return 0; - } - return sleep_deprivation; } @@ -3913,18 +3909,17 @@ void Character::update_needs( int rate_multiplier ) int fatigue_roll = roll_remainder( rates.fatigue * rate_multiplier ); mod_fatigue( fatigue_roll ); - if( get_option< bool >( "SLEEP_DEPRIVATION" ) ) { - // Synaptic regen bionic stops SD while awake and boosts it while sleeping - if( !has_active_bionic( bio_synaptic_regen ) ) { - // fatigue_roll should be around 1 - so the counter increases by 1 every minute on average, - // but characters who need less sleep will also get less sleep deprived, and vice-versa. + // Synaptic regen bionic stops SD while awake and boosts it while sleeping + if( !has_active_bionic( bio_synaptic_regen ) ) { + // fatigue_roll should be around 1 - so the counter increases by 1 every minute on average, + // but characters who need less sleep will also get less sleep deprived, and vice-versa. - // Note: Since needs are updated in 5-minute increments, we have to multiply the roll again by - // 5. If rate_multiplier is > 1, fatigue_roll will be higher and this will work out. - mod_sleep_deprivation( fatigue_roll * 5 ); - } + // Note: Since needs are updated in 5-minute increments, we have to multiply the roll again by + // 5. If rate_multiplier is > 1, fatigue_roll will be higher and this will work out. + mod_sleep_deprivation( fatigue_roll * 5 ); } + if( npc_no_food && get_fatigue() > TIRED ) { set_fatigue( TIRED ); set_sleep_deprivation( 0 ); @@ -3942,41 +3937,40 @@ void Character::update_needs( int rate_multiplier ) recovered *= .5; } mod_fatigue( -recovered ); - if( get_option< bool >( "SLEEP_DEPRIVATION" ) ) { - // Sleeping on the ground, no bionic = 1x rest_modifier - // Sleeping on a bed, no bionic = 2x rest_modifier - // Sleeping on a comfy bed, no bionic= 3x rest_modifier - - // Sleeping on the ground, bionic = 3x rest_modifier - // Sleeping on a bed, bionic = 6x rest_modifier - // Sleeping on a comfy bed, bionic = 9x rest_modifier - float rest_modifier = ( has_active_bionic( bio_synaptic_regen ) ? 3 : 1 ); - // Melatonin supplements also add a flat bonus to recovery speed - if( has_effect( effect_melatonin_supplements ) ) { - rest_modifier += 1; - } - - comfort_level comfort = base_comfort_value( pos() ); + // Sleeping on the ground, no bionic = 1x rest_modifier + // Sleeping on a bed, no bionic = 2x rest_modifier + // Sleeping on a comfy bed, no bionic= 3x rest_modifier + + // Sleeping on the ground, bionic = 3x rest_modifier + // Sleeping on a bed, bionic = 6x rest_modifier + // Sleeping on a comfy bed, bionic = 9x rest_modifier + float rest_modifier = ( has_active_bionic( bio_synaptic_regen ) ? 3 : 1 ); + // Melatonin supplements also add a flat bonus to recovery speed + if( has_effect( effect_melatonin_supplements ) ) { + rest_modifier += 1; + } - if( comfort >= comfort_level::very_comfortable ) { - rest_modifier *= 3; - } else if( comfort >= comfort_level::comfortable ) { - rest_modifier *= 2.5; - } else if( comfort >= comfort_level::slightly_comfortable ) { - rest_modifier *= 2; - } + comfort_level comfort = base_comfort_value( pos() ); - // If we're just tired, we'll get a decent boost to our sleep quality. - // The opposite is true for very tired characters. - if( get_fatigue() < DEAD_TIRED ) { - rest_modifier += 2; - } else if( get_fatigue() >= EXHAUSTED ) { - rest_modifier = ( rest_modifier > 2 ) ? rest_modifier - 2 : 1; - } + if( comfort >= comfort_level::very_comfortable ) { + rest_modifier *= 3; + } else if( comfort >= comfort_level::comfortable ) { + rest_modifier *= 2.5; + } else if( comfort >= comfort_level::slightly_comfortable ) { + rest_modifier *= 2; + } - // Recovered is multiplied by 2 as well, since we spend 1/3 of the day sleeping - mod_sleep_deprivation( -rest_modifier * ( recovered * 2 ) ); + // If we're just tired, we'll get a decent boost to our sleep quality. + // The opposite is true for very tired characters. + if( get_fatigue() < DEAD_TIRED ) { + rest_modifier += 2; + } else if( get_fatigue() >= EXHAUSTED ) { + rest_modifier = ( rest_modifier > 2 ) ? rest_modifier - 2 : 1; } + + // Recovered is multiplied by 2 as well, since we spend 1/3 of the day sleeping + mod_sleep_deprivation( -rest_modifier * ( recovered * 2 ) ); + } } } diff --git a/src/item_factory.cpp b/src/item_factory.cpp index e68b9eb9176be..c62af69187322 100644 --- a/src/item_factory.cpp +++ b/src/item_factory.cpp @@ -803,7 +803,6 @@ void Item_factory::init() add_iuse( "WEED_CAKE", &iuse::weed_cake ); add_iuse( "XANAX", &iuse::xanax ); add_iuse( "BREAK_STICK", &iuse::break_stick ); - add_iuse( "MELATONIN_TABLET", &iuse::melatonin_tablet ); add_actor( std::make_unique() ); add_actor( std::make_unique() ); diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index 34fd35111e0a8..3866284cf3127 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -561,8 +561,13 @@ std::unique_ptr consume_drug_iuse::clone() const static effect_data load_effect_data( const JsonObject &e ) { - return effect_data( efftype_id( e.get_string( "id" ) ), - time_duration::from_turns( e.get_int( "duration", 0 ) ), + time_duration time; + if( e.has_string( "duration" ) ) { + time = read_from_json_string( *e.get_raw( "duration" ), time_duration::units ); + } else { + time = time_duration::from_turns( e.get_int( "duration", 0 ) ); + } + return effect_data( efftype_id( e.get_string( "id" ) ), time, get_body_part_token( e.get_string( "bp", "NUM_BP" ) ), e.get_bool( "permanent", false ) ); } diff --git a/tests/stomach_contents_test.cpp b/tests/stomach_contents_test.cpp index ee5a439a92519..8bca831c1d6e1 100644 --- a/tests/stomach_contents_test.cpp +++ b/tests/stomach_contents_test.cpp @@ -50,6 +50,8 @@ static time_duration time_until_hungry( player &p ) { unsigned int thirty_minutes = 0; do { + p.set_sleep_deprivation( 0 ); + p.set_fatigue( 0 ); pass_time( p, 30_minutes ); thirty_minutes++; } while( p.get_hunger() < 40 ); // hungry