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

feat(content): Add sleepdebt effect #3673

Merged
merged 4 commits into from
Nov 15, 2023
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
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
Loading