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

Add hunger/thirst crafting distractions #55913

Merged
merged 6 commits into from
Apr 24, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 3 additions & 1 deletion src/enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,9 @@ enum class distraction_type : int {
weather_change,
portal_storm_popup,
eoc,
dangerous_field
dangerous_field,
hunger,
thirst
};

enum game_message_type : int {
Expand Down
29 changes: 28 additions & 1 deletion src/player_activity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ static const activity_id ACT_CHOP_LOGS( "ACT_CHOP_LOGS" );
static const activity_id ACT_CHOP_PLANKS( "ACT_CHOP_PLANKS" );
static const activity_id ACT_CHOP_TREE( "ACT_CHOP_TREE" );
static const activity_id ACT_CLEAR_RUBBLE( "ACT_CLEAR_RUBBLE" );
static const activity_id ACT_CONSUME( "ACT_CONSUME" );
static const activity_id ACT_CONSUME_DRINK_MENU( "ACT_CONSUME_DRINK_MENU" );
static const activity_id ACT_CONSUME_FOOD_MENU( "ACT_CONSUME_FOOD_MENU" );
static const activity_id ACT_CONSUME_MEDS_MENU( "ACT_CONSUME_MEDS_MENU" );
static const activity_id ACT_CONSUME_FUEL_MENU( "ACT_CONSUME_FUEL_MENU" );
dseguin marked this conversation as resolved.
Show resolved Hide resolved
static const activity_id ACT_EAT_MENU( "ACT_EAT_MENU" );
static const activity_id ACT_FILL_PIT( "ACT_FILL_PIT" );
static const activity_id ACT_FIRSTAID( "ACT_FIRSTAID" );
Expand All @@ -63,6 +65,14 @@ static const activity_id ACT_WORKOUT_HARD( "ACT_WORKOUT_HARD" );
static const activity_id ACT_WORKOUT_LIGHT( "ACT_WORKOUT_LIGHT" );
static const activity_id ACT_WORKOUT_MODERATE( "ACT_WORKOUT_MODERATE" );

static const std::vector<activity_id> consuming {
ACT_CONSUME,
ACT_EAT_MENU,
ACT_CONSUME_FOOD_MENU,
ACT_CONSUME_DRINK_MENU,
ACT_CONSUME_MEDS_MENU,
ACT_CONSUME_FUEL_MENU };

static const efftype_id effect_nausea( "nausea" );
dseguin marked this conversation as resolved.
Show resolved Hide resolved

player_activity::player_activity() : type( activity_id::NULL_ID() ) { }
Expand Down Expand Up @@ -471,7 +481,8 @@ void player_activity::inherit_distractions( const player_activity &other )
std::map<distraction_type, std::string> player_activity::get_distractions()
{
std::map < distraction_type, std::string > res;
if( id() != ACT_AIM && moves_left > 0 ) {
activity_id act_id = id();
if( act_id != ACT_AIM && moves_left > 0 ) {
if( !is_distraction_ignored( distraction_type::hostile_spotted_near ) ) {
Creature *hostile_critter = g->is_hostile_very_close( true );
if( hostile_critter != nullptr ) {
Expand All @@ -487,6 +498,22 @@ std::map<distraction_type, std::string> player_activity::get_distractions()
g->is_in_dangerous_field()->name() ) );
}
}
// Nested in the !ACT_AIM to avoid nuisance during combat
// If this is too bothersome, maybe a list of just ACT_CRAFT, ACT_DIG etc
//if( act_id != ACT_CONSUME && act_id != ACT_EAT_MENU ) {
Arokha marked this conversation as resolved.
Show resolved Hide resolved
if( std::find( consuming.begin(), consuming.end(), act_id ) == consuming.end() ) {
avatar &player_character = get_avatar();
if( !is_distraction_ignored( distraction_type::hunger ) ) {
if( player_character.get_hunger() >= 300 && player_character.get_starvation() > 2500 ) {
res.emplace( distraction_type::hunger, "You are at risk of starving!" );
Arokha marked this conversation as resolved.
Show resolved Hide resolved
}
}
if( !is_distraction_ignored( distraction_type::thirst ) ) {
if( player_character.get_thirst() > 520 ) {
res.emplace( distraction_type::thirst, "You are dangerously dehydrated!" );
Arokha marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
}

return res;
Expand Down