Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mainline sleep deprivation #37317

Merged
merged 1 commit into from
Jan 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions data/json/bionics.json
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,17 @@
"occupied_bodyparts": [ [ "TORSO", 1 ], [ "ARM_L", 2 ], [ "ARM_R", 2 ], [ "LEG_L", 3 ], [ "LEG_R", 3 ] ],
"flags": [ "BIONIC_FAULTY" ]
},
{
"id": "bio_synaptic_regen",
"type": "bionic",
"name": "Synaptic Regeneration System",
"description": "An electromagnetic stimulator has been surgically implanted on the back of your head and along your spine, continually draining power. As long as it's active, you won't become sleep deprived; and if you're sleep deprived already, it will boost the rate of recovery while you sleep.",
"flags": [ "BIONIC_TOGGLED" ],
"occupied_bodyparts": [ [ "HEAD", 1 ], [ "TORSO", 1 ] ],
"act_cost": 0,
"react_cost": "1 kJ",
"time": 100
},
{
"id": "bio_shock",
"type": "bionic",
Expand Down
20 changes: 20 additions & 0 deletions data/json/effects.json
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,26 @@
"max_duration": "15 m",
"base_mods": { "vomit_chance": [ 60 ] }
},
{
"type": "effect_type",
"id": "sleep_deprived",
"name": [ "Sleep Deprived" ],
"desc": [ "Your sleep debt has been steadily increasing for a while. You should get some rest." ],
"rating": "bad",
"max_intensity": 20160,
"int_dur_factor": 240,
"base_mods": { "speed_mod": [ -5 ] },
"scaling_mods": { "speed_mod": [ -1 ], "int_mod": [ -0.33 ], "per_mod": [ -0.33 ], "str_mod": [ -0.17 ], "dex_mod": [ -0.17 ] },
"apply_message": "You feel weary, your body tired from lack of quality sleep.",
"remove_message": "You have finally caught up with your lost sleep, and you feel refreshed and awake for a change."
},
{
"type": "effect_type",
"id": "melatonin",
"name": [ "Melatonin Supplements" ],
"desc": [ "You took some melatonin supplements. These will help with sleep deprivation." ],
"rating": "good"
},
{
"type": "effect_type",
"id": "beartrap",
Expand Down
2 changes: 1 addition & 1 deletion data/json/game_balance.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
"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": false
"value": true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This option should be removed now.

},
{
"type": "EXTERNAL_OPTION",
Expand Down
5 changes: 5 additions & 0 deletions data/json/item_actions.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
"id": "PICKAXE",
"name": "Dig through rock"
},
{
"type": "item_action",
"id": "MELATONIN_TABLET",
"name": "Take a melatonin tablet"
},
{
"type": "item_action",
"id": "PACK_CBM",
Expand Down
1 change: 1 addition & 0 deletions data/json/itemgroups/bionics.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
[ "bio_face_mask", 10 ],
[ "bio_scent_mask", 10 ],
[ "bio_cloak", 10 ],
[ "bio_synaptic_regen", 12 ],
[ "bio_fingerhack", 10 ],
[ "bio_lockpick", 10 ],
[ "bio_night", 10 ],
Expand Down
1 change: 1 addition & 0 deletions data/json/itemgroups/locations.json
Original file line number Diff line number Diff line change
Expand Up @@ -2114,6 +2114,7 @@
[ "con_milk", 20 ],
[ "milk_evap", 15 ],
[ "milk_UHT", 10 ],
{ "item": "melatonin_tablet", "count": 20, "prob": 20 },
[ "can_spam", 30 ],
[ "can_tuna", 35 ],
[ "can_salmon", 25 ],
Expand Down
9 changes: 9 additions & 0 deletions data/json/items/bionics.json
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,15 @@
"weight": "100 g",
"difficulty": 11
},
{
"id": "bio_synaptic_regen",
"copy-from": "bionic_general",
"type": "BIONIC_ITEM",
"name": "Synaptic Regeneration System CBM",
"description": "An electromagnetic stimulator has been surgically implanted on the back of your head and along your spine, continually draining power. As long as it's active, you won't become sleep deprived; and if you're sleep deprived already, it will boost the rate of recovery.",
"price": 10000,
"difficulty": 8
},
{
"id": "bio_spasm",
"copy-from": "bionic_general_faulty",
Expand Down
15 changes: 15 additions & 0 deletions data/json/items/comestibles/med.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@
"use_action": "DISASSEMBLE",
"flags": [ "NO_REPAIR" ]
},
{
"id": "melatonin_tablet",
"type": "COMESTIBLE",
"comestible_type": "MED",
"name": "melatonin tablet",
"description": "Over-the-counter melatonin supplements, commonly prescribed to treat sleep deprivation and to mitigate its effects. One tablet a day combined with a good night's sleep will help you recover faster.",
"weight": "1 g",
"volume": "250 ml",
"price": 400,
"price_postapoc": 4000,
"stack_size": 30,
"symbol": "!",
"color": "yellow",
"use_action": "MELATONIN_TABLET"
},
{
"id": "adderall",
"type": "COMESTIBLE",
Expand Down
5 changes: 5 additions & 0 deletions data/json/items/migration.json
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,11 @@
"type": "MIGRATION",
"replace": "40x53mm_m1001"
},
{
"id": "magnesium_tablet",
"type": "MIGRATION",
"replace": "melatonin_tablet"
},
{
"id": "40mm_frag",
"type": "MIGRATION",
Expand Down
7 changes: 7 additions & 0 deletions data/json/items/obsolete.json
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,13 @@
"valid_mod_locations": [ [ "sling", 1 ], [ "stock", 1 ], [ "rail mount", 1 ] ],
"relative": { "reload": 4 }
},
{
"type": "effect_type",
"id": "magnesium",
"name": [ "Magnesium Supplements" ],
"desc": [ "You took some magnesium supplements. These will help with sleep deprivation." ],
"rating": "good"
},
{
"id": "bio_furnace",
"copy-from": "bionic_general",
Expand Down
1 change: 1 addition & 0 deletions data/json/monsterdrops/zombie_lab.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
[ "bio_night_vision", 1 ],
[ "bio_infrared", 2 ],
[ "bio_scent_vision", 5 ],
[ "bio_synaptic_regen", 12 ],
[ "bio_gills", 5 ],
[ "bio_climate", 2 ],
[ "bio_heatsink", 2 ],
Expand Down
7 changes: 7 additions & 0 deletions data/json/obsolete.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@
"occupied_bodyparts": [ [ "TORSO", 32 ] ],
"flags": [ "BIONIC_NPC_USABLE", "BIONIC_SHOCKPROOF" ]
},
{
"type": "effect_type",
"id": "magnesium",
"name": [ "Magnesium Supplements" ],
"desc": [ "You took some magnesium supplements. These will help with sleep deprivation." ],
"rating": "good"
},
{
"type": "recipe",
"result": "reloaded_270",
Expand Down
13 changes: 0 additions & 13 deletions data/mods/Sleep_Deprivation/bionics.json

This file was deleted.

22 changes: 0 additions & 22 deletions data/mods/Sleep_Deprivation/effects.json

This file was deleted.

8 changes: 0 additions & 8 deletions data/mods/Sleep_Deprivation/game_balance.json

This file was deleted.

7 changes: 0 additions & 7 deletions data/mods/Sleep_Deprivation/item_actions.json

This file was deleted.

27 changes: 0 additions & 27 deletions data/mods/Sleep_Deprivation/item_groups.json

This file was deleted.

8 changes: 0 additions & 8 deletions data/mods/Sleep_Deprivation/itemgroups/drugs.json

This file was deleted.

11 changes: 0 additions & 11 deletions data/mods/Sleep_Deprivation/items/bionics.json

This file was deleted.

18 changes: 0 additions & 18 deletions data/mods/Sleep_Deprivation/items/comestibles/med.json

This file was deleted.

1 change: 1 addition & 0 deletions data/mods/Sleep_Deprivation/modinfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"maintainers": [ "Kevin Giovinazzo" ],
"description": "Enables sleep deprivation mechanics independently of a player's fatigue.",
"category": "rebalance",
"obsolete": true,
"dependencies": [ "dda" ]
}
]
2 changes: 1 addition & 1 deletion src/cata_string_consts.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ static const efftype_id effect_jetinjector( "jetinjector" );
static const efftype_id effect_lack_sleep( "lack_sleep" );
static const efftype_id effect_lightsnare( "lightsnare" );
static const efftype_id effect_lying_down( "lying_down" );
static const efftype_id effect_magnesium_supplements( "magnesium" );
static const efftype_id effect_melatonin_supplements( "melatonin" );
static const efftype_id effect_masked_scent( "masked_scent" );
static const efftype_id effect_mending( "mending" );
static const efftype_id effect_meth( "meth" );
Expand Down
4 changes: 2 additions & 2 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3951,8 +3951,8 @@ void Character::update_needs( int rate_multiplier )
// 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 );
// Magnesium supplements also add a flat bonus to recovery speed
if( has_effect( effect_magnesium_supplements ) ) {
// Melatonin supplements also add a flat bonus to recovery speed
if( has_effect( effect_melatonin_supplements ) ) {
rest_modifier += 1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/item_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ 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( "MAGNESIUM_TABLET", &iuse::magnesium_tablet );
add_iuse( "MELATONIN_TABLET", &iuse::melatonin_tablet );

add_actor( std::make_unique<ammobelt_actor>() );
add_actor( std::make_unique<bandolier_actor>() );
Expand Down
10 changes: 5 additions & 5 deletions src/iuse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ static const efftype_id effect_weak_antibiotic( "weak_antibiotic" );
static const efftype_id effect_weak_antibiotic_visible( "weak_antibiotic_visible" );
static const efftype_id effect_webbed( "webbed" );
static const efftype_id effect_weed_high( "weed_high" );
static const efftype_id effect_magnesium_supplements( "magnesium" );
static const efftype_id effect_melatonin_supplements( "melatonin" );

static const trait_id trait_ACIDBLOOD( "ACIDBLOOD" );
static const trait_id trait_ACIDPROOF( "ACIDPROOF" );
Expand Down Expand Up @@ -9693,14 +9693,14 @@ int iuse::gobag_personal( player *p, item *it, bool, const tripoint & )
return gobag( p, it, true );
}

int iuse::magnesium_tablet( player *p, item *it, bool, const tripoint & )
int iuse::melatonin_tablet( player *p, item *it, bool, const tripoint & )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need an iuse for this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Presumably for the message if you've already taken it. Not a super strong justification, but that's what I can come up with.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's information we shouldn't give to the player. We don't warn for excessive use of other drugs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, will look into cutting that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's worth noting that additional doses of melatonin just generally don't do anything

{
p->add_msg_if_player( _( "You pop a %s." ), it->tname() );
if( p->has_effect( effect_magnesium_supplements ) ) {
if( p->has_effect( effect_melatonin_supplements ) ) {
p->add_msg_if_player( m_warning,
_( "Simply taking more magnesium won't help. You have to go to sleep for it to work." ) );
_( "Simply taking more melatonin won't help. You have to go to sleep for it to work." ) );
}
p->add_effect( effect_magnesium_supplements, 16_hours );
p->add_effect( effect_melatonin_supplements, 16_hours );
return it->type->charges_to_use();
}

Expand Down
2 changes: 1 addition & 1 deletion src/iuse.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class iuse
int weak_antibiotic( player *, item *, bool, const tripoint & );
int strong_antibiotic( player *, item *, bool, const tripoint & );
int panacea( player *, item *, bool, const tripoint & );
int magnesium_tablet( player *, item *, bool, const tripoint & );
int melatonin_tablet( player *, item *, bool, const tripoint & );
int coin_flip( player *, item *, bool, const tripoint & );
int play_game( player *, item *, bool, const tripoint & );
int magic_8_ball( player *, item *, bool, const tripoint & );
Expand Down
1 change: 1 addition & 0 deletions tests/stomach_contents_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ TEST_CASE( "hunger" )
reset_time();
clear_stomach( dummy );
dummy.initialize_stomach_contents();
dummy.clear_effects();

if( print_tests ) {
printf( "\n\n" );
Expand Down