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

Auto-travel; prompt when overburdened, and allow stamina-resting #38113

Merged
merged 8 commits into from Feb 20, 2020
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
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