Skip to content

Commit b1a2ced

Browse files
committed
make melatonin make sense
1 parent 94ea8d5 commit b1a2ced

File tree

6 files changed

+22
-27
lines changed

6 files changed

+22
-27
lines changed

data/json/effects.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,11 +1353,12 @@
13531353
"type": "effect_type",
13541354
"id": "melatonin",
13551355
"name": [ "Melatonin Supplements" ],
1356-
"desc": [ "You took some melatonin supplements. These will help with sleep deprivation." ],
1357-
"max_duration": 100800,
1358-
"dur_add_perc": 60,
1359-
"rating": "good",
1360-
"blood_analysis_description": "Melatonin"
1356+
"desc": [ "You took some melatonin supplements. It makes you sleep more." ],
1357+
"max_duration": "1 d",
1358+
"dur_add_perc": 30,
1359+
"rating": "neutral",
1360+
"base_mods": { "sleepiness_min": [ 2 ], "sleepiness_chance": [ 500 ], "sleepiness_max_val": [ 150 ] },
1361+
"blood_analysis_description": "Elevated sleep hormone levels (Melatonin)"
13611362
},
13621363
{
13631364
"type": "effect_type",

data/json/items/comestibles/med.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"subtypes": [ "COMESTIBLE" ],
66
"comestible_type": "MED",
77
"name": { "str": "melatonin tablet" },
8-
"description": "An over-the-counter melatonin supplement, 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.",
8+
"description": "An over-the-counter sleep hormone. Melatonin can help you fall asleep faster and stay asleep longer. Using it may help restore your sleep schedule, but you might wake up feeling groggy.",
99
"material": [ "drug_filler" ],
1010
"weight": "1 g",
1111
"volume": "8 ml",
@@ -17,9 +17,11 @@
1717
"flags": [ "IRREPLACEABLE_CONSUMABLE", "WATER_DISSOLVE", "NO_TEMP" ],
1818
"use_action": {
1919
"type": "consume_drug",
20-
"activation_message": "You pop a melatonin tablet.",
21-
"effects": [ { "id": "melatonin", "duration": "16 h" } ]
22-
}
20+
"activation_message": "You take a melatonin tablet.",
21+
"effects": [ { "id": "melatonin", "duration": "14 h" } ]
22+
},
23+
"sleepiness_mod": -20,
24+
"healthy": -1
2325
},
2426
{
2527
"id": "adderall",

src/character.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ static const efftype_id effect_incorporeal( "incorporeal" );
198198
static const efftype_id effect_infected( "infected" );
199199
static const efftype_id effect_masked_scent( "masked_scent" );
200200
static const efftype_id effect_mech_recon_vision( "mech_recon_vision" );
201+
static const efftype_id effect_melatonin( "melatonin" );
201202
static const efftype_id effect_meth( "meth" );
202203
static const efftype_id effect_monster_saddled( "monster_saddled" );
203204
static const efftype_id effect_narcosis( "narcosis" );
@@ -5317,7 +5318,11 @@ void Character::fall_asleep()
53175318
// In practice, the sleepiness from filling the tank from (no msg) to Time For Bed
53185319
// will last about 8 days.
53195320
} else {
5320-
fall_asleep( 10_hours ); // default max sleep time.
5321+
time_duration sleep_duration = 10_hours; // default max sleep time
5322+
if( has_effect( effect_melatonin ) ) {
5323+
sleep_duration = 12_hours; // Artificial sleep hormone boost allows you to sleep longer
5324+
}
5325+
fall_asleep( sleep_duration );
53215326
}
53225327
}
53235328

src/character_health.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,6 +1467,9 @@ void Character::update_needs( int rate_multiplier )
14671467
if( has_effect( effect_disrupted_sleep ) || has_effect( effect_recently_coughed ) ) {
14681468
recovered *= .5;
14691469
}
1470+
if( has_effect( effect_melatonin ) ) {
1471+
recovered *= .9;
1472+
}
14701473
mod_sleepiness( -recovered );
14711474

14721475
// Sleeping on the ground, no bionic = 1x rest_modifier
@@ -1477,10 +1480,6 @@ void Character::update_needs( int rate_multiplier )
14771480
// Sleeping on a bed, bionic = 6x rest_modifier
14781481
// Sleeping on a comfy bed, bionic = 9x rest_modifier
14791482
float rest_modifier = ( has_flag( json_flag_STOP_SLEEP_DEPRIVATION ) ? 3 : 1 );
1480-
// Melatonin supplements also add a flat bonus to recovery speed
1481-
if( has_effect( effect_melatonin ) ) {
1482-
rest_modifier += 1;
1483-
}
14841483

14851484
const int comfort = get_comfort_at( pos_bub() ).comfort;
14861485
if( comfort >= comfort_data::COMFORT_VERY_COMFORTABLE ) {
@@ -1509,6 +1508,7 @@ void Character::update_needs( int rate_multiplier )
15091508
mod_sleepiness( -3 ); // Fish sleep less in water
15101509
}
15111510
}
1511+
15121512
if( is_avatar() && wasnt_sleepinessd && get_sleepiness() > sleepiness_levels::DEAD_TIRED &&
15131513
!lying ) {
15141514
if( !activity ) {
@@ -1518,7 +1518,6 @@ void Character::update_needs( int rate_multiplier )
15181518
g->cancel_activity_query( _( "You're feeling tired." ) );
15191519
}
15201520
}
1521-
15221521
if( current_stim < 0 ) {
15231522
set_stim( std::min( current_stim + rate_multiplier, 0 ) );
15241523
} else if( current_stim > 0 ) {

src/iuse.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8839,17 +8839,6 @@ std::optional<int> iuse::post_up( Character *p, item *it, const tripoint_bub_ms
88398839
return 0;
88408840
}
88418841

8842-
std::optional<int> iuse::melatonin_tablet( Character *p, item *it, const tripoint_bub_ms & )
8843-
{
8844-
p->add_msg_if_player( _( "You pop a %s." ), it->tname() );
8845-
if( p->has_effect( effect_melatonin ) ) {
8846-
p->add_msg_if_player( m_warning,
8847-
_( "Simply taking more melatonin won't help. You have to go to sleep for it to work." ) );
8848-
}
8849-
p->add_effect( effect_melatonin, 16_hours );
8850-
return 1;
8851-
}
8852-
88538842
std::optional<int> iuse::coin_flip( Character *p, item *it, const tripoint_bub_ms & )
88548843
{
88558844
p->add_msg_if_player( m_info, _( "You flip a %s." ), it->tname() );

src/iuse.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ std::optional<int> ebooksave( Character *, item *, const tripoint_bub_ms & );
139139
std::optional<int> makemound( Character *, item *, const tripoint_bub_ms & );
140140
std::optional<int> mace( Character *, item *, const tripoint_bub_ms & );
141141
std::optional<int> manage_exosuit( Character *, item *, const tripoint_bub_ms & );
142-
std::optional<int> melatonin_tablet( Character *, item *, const tripoint_bub_ms & );
143142
std::optional<int> mininuke( Character *, item *, const tripoint_bub_ms & );
144143
std::optional<int> mop( Character *, item *it, const tripoint_bub_ms & );
145144
std::optional<int> mp3( Character *, item *, const tripoint_bub_ms & );

0 commit comments

Comments
 (0)