Skip to content

Commit

Permalink
feat(content): Add sleepdebt effect (#3673)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
3 people authored Nov 15, 2023
1 parent 5cab4a4 commit 596a577
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ translation:
- lang/**/*

docs:
- docs/**/*
- doc/**/*

scripts:
- scripts/**/*
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 11 additions & 0 deletions src/character_turn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down
10 changes: 10 additions & 0 deletions src/effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" );
Expand Down

0 comments on commit 596a577

Please sign in to comment.