Skip to content

Commit

Permalink
Auto-travel; prompt when overburdened, and allow stamina-resting (#38113
Browse files Browse the repository at this point in the history
)
  • Loading branch information
davidpwbrown authored Feb 20, 2020
1 parent 2bf1c1e commit bac0389
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/overmap_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1483,7 +1483,13 @@ static tripoint display( const tripoint &orig, const draw_data_t &data = draw_da
}
const tripoint player_omt_pos = g->u.global_omt_location();
if( !g->u.omt_path.empty() && g->u.omt_path.front() == curs ) {
if( query_yn( _( "Travel to this point?" ) ) ) {
std::string confirm_msg;
if( g->u.weight_carried() > g->u.weight_capacity() ) {
confirm_msg = _( "You are overburdened, are you sure you want to travel (it may be painful)?" );
} else {
confirm_msg = _( "Travel to this point?" );
}
if( query_yn( confirm_msg ) ) {
// renew the path incase of a leftover dangling path point
g->u.omt_path = overmap_buffer.get_npc_path( player_omt_pos, curs, ptype );
if( g->u.in_vehicle && g->u.controlling_vehicle ) {
Expand Down
11 changes: 9 additions & 2 deletions src/player_activity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,18 @@ void player_activity::do_turn( player &p )
p.drop_invalid_inventory();
return;
}

const bool travel_activity = id() == ACT_TRAVELLING;
// This might finish the activity (set it to null)
type->call_do_turn( this, &p );
// Activities should never excessively drain stamina.
if( p.get_stamina() < previous_stamina && p.get_stamina() < p.get_stamina_max() / 3 ) {
// adjusted stamina because
// autotravel doesn't reduce stamina after do_turn()
// it just sets a destination, clears the activity, then moves afterwards
// so set stamina -1 if that is the case
// to simulate that the next step will surely use up some stamina anyway
// this is to ensure that resting will occur when travelling overburdened
const int adjusted_stamina = travel_activity ? p.get_stamina() - 1 : p.get_stamina();
if( adjusted_stamina < previous_stamina && p.get_stamina() < p.get_stamina_max() / 3 ) {
if( one_in( 50 ) ) {
p.add_msg_if_player( _( "You pause for a moment to catch your breath." ) );
}
Expand Down

0 comments on commit bac0389

Please sign in to comment.