From 596a57736c9059f9e16e1332700c531f84f83334 Mon Sep 17 00:00:00 2001 From: RoyalFox <112293514+RoyalFox2140@users.noreply.github.com> Date: Tue, 14 Nov 2023 21:27:37 -0500 Subject: [PATCH] feat(content): Add sleepdebt effect (#3673) * sleep debt effect add sleep debt fields for effects idk * documentation what is life without passing our knowledge on? * style(autofix.ci): automated formatting * ci: invalid `docs` label path --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: scarf --- .github/labeler.yml | 2 +- .../en/mod/json/reference/creatures/effects_json.md | 9 +++++++++ src/character_turn.cpp | 11 +++++++++++ src/effect.cpp | 10 ++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/.github/labeler.yml b/.github/labeler.yml index b925d99aec27..cd5c12e5afef 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -14,7 +14,7 @@ translation: - lang/**/* docs: - - docs/**/* + - doc/**/* scripts: - scripts/**/* diff --git a/doc/src/content/docs/en/mod/json/reference/creatures/effects_json.md b/doc/src/content/docs/en/mod/json/reference/creatures/effects_json.md index be402f017e2f..b164147b02b8 100644 --- a/doc/src/content/docs/en/mod/json/reference/creatures/effects_json.md +++ b/doc/src/content/docs/en/mod/json/reference/creatures/effects_json.md @@ -491,6 +491,15 @@ Valid arguments: "thirst_chance_bot" "thirst_tick" - Defaults to every tick +"sleepdebt_amount" - Amount of sleep debt it can give/take. +"sleepdebt_min" - Minimal amount of sleep, certain effect will give/take +"sleepdebt_max" - if 0 or missing value will be exactly "sleepdebt_min" +"sleepdebt_min_val" - Defaults to 0, which means uncapped +"sleepdebt_max_val" - Defaults to 0, which means uncapped +"sleepdebt_chance" - Chance to give more sleep +"sleepdebt_chance_bot" - Min chance, unsure, needs auditing +"sleepdebt_tick" - Defaults to every tick + "fatigue_amount" - Amount of fatigue it can give/take. After certain amount character will need to sleep. "fatigue_min" - Minimal amount of fatigue, certain effect will give/take "fatigue_max" - if 0 or missing value will be exactly "fatigue_min" diff --git a/src/character_turn.cpp b/src/character_turn.cpp index b962ecddd4dd..99fbd73e1a93 100644 --- a/src/character_turn.cpp +++ b/src/character_turn.cpp @@ -422,6 +422,17 @@ void Character::process_one_effect( effect &it, bool is_new ) } } + // Handle sleep debt + val = get_effect( "SLEEPDEBT", reduced ); + if( val != 0 ) { + mod = 1; + if( is_new || it.activated( calendar::turn, "SLEEPDEBT", val, reduced, mod ) ) { + mod_sleep_deprivation( bound_mod_to_vals( get_sleep_deprivation(), val, it.get_max_val( "SLEEPDEBT", + reduced ), + it.get_min_val( "SLEEPDEBT", reduced ) ) ); + } + } + // Handle Radiation val = get_effect( "RAD", reduced ); if( val != 0 ) { diff --git a/src/effect.cpp b/src/effect.cpp index b3901271139d..53c94fc2d543 100644 --- a/src/effect.cpp +++ b/src/effect.cpp @@ -367,6 +367,16 @@ bool effect_type::load_mod_data( const JsonObject &jo, const std::string &member extract_effect( j, mod_data, "fatigue_chance_bot", member, "FATIGUE", "chance_bot" ); extract_effect( j, mod_data, "fatigue_tick", member, "FATIGUE", "tick" ); + // Then sleep debt + extract_effect( j, mod_data, "sleepdebt_amount", member, "SLEEPDEBT", "amount" ); + extract_effect( j, mod_data, "sleepdebt_min", member, "SLEEPDEBT", "min" ); + extract_effect( j, mod_data, "sleepdebt_max", member, "SLEEPDEBT", "max" ); + extract_effect( j, mod_data, "sleepdebt_min_val", member, "SLEEPDEBT", "min_val" ); + extract_effect( j, mod_data, "sleepdebt_max_val", member, "SLEEPDEBT", "max_val" ); + extract_effect( j, mod_data, "sleepdebt_chance", member, "SLEEPDEBT", "chance_top" ); + extract_effect( j, mod_data, "sleepdebt_chance_bot", member, "SLEEPDEBT", "chance_bot" ); + extract_effect( j, mod_data, "sleepdebt_tick", member, "SLEEPDEBT", "tick" ); + // Then stamina extract_effect( j, mod_data, "stamina_amount", member, "STAMINA", "amount" ); extract_effect( j, mod_data, "stamina_min", member, "STAMINA", "min" );