Skip to content

Commit

Permalink
Add hunger/thirst crafting distractions (#55913)
Browse files Browse the repository at this point in the history
* Add hunger/thirst crafting distractions

* Update src/player_activity.cpp

Co-authored-by: Anton Burmistrov <[email protected]>

* Update src/player_activity.cpp

Co-authored-by: Anton Burmistrov <[email protected]>

* Update src/player_activity.cpp

Co-authored-by: Anton Burmistrov <[email protected]>

* Update src/player_activity.cpp

* Update src/player_activity.cpp

Co-authored-by: Anton Burmistrov <[email protected]>
Co-authored-by: David Seguin <[email protected]>
  • Loading branch information
3 people authored Apr 24, 2022
1 parent eb7a26b commit 526b9d3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
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
28 changes: 27 additions & 1 deletion src/player_activity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ 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_FUEL_MENU( "ACT_CONSUME_FUEL_MENU" );
static const activity_id ACT_CONSUME_MEDS_MENU( "ACT_CONSUME_MEDS_MENU" );
static const activity_id ACT_EAT_MENU( "ACT_EAT_MENU" );
static const activity_id ACT_FILL_PIT( "ACT_FILL_PIT" );
Expand Down Expand Up @@ -65,6 +67,14 @@ static const activity_id ACT_WORKOUT_MODERATE( "ACT_WORKOUT_MODERATE" );

static const efftype_id effect_nausea( "nausea" );

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 };

player_activity::player_activity() : type( activity_id::NULL_ID() ) { }

player_activity::player_activity( activity_id t, int turns, int Index, int pos,
Expand Down Expand Up @@ -474,7 +484,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 @@ -490,6 +501,21 @@ 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( 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!" ) );
}
}
if( !is_distraction_ignored( distraction_type::thirst ) ) {
if( player_character.get_thirst() > 520 ) {
res.emplace( distraction_type::thirst, _( "You are dangerously dehydrated!" ) );
}
}
}
}

return res;
Expand Down

0 comments on commit 526b9d3

Please sign in to comment.