|
28 | 28 | #include "game_constants.h"
|
29 | 29 | #include "game_inventory.h"
|
30 | 30 | #include "gun_mode.h"
|
| 31 | +#include "input_context.h" |
31 | 32 | #include "inventory.h"
|
32 | 33 | #include "item.h"
|
33 | 34 | #include "item_location.h"
|
|
49 | 50 | #include "output.h"
|
50 | 51 | #include "pimpl.h"
|
51 | 52 | #include "player_activity.h"
|
| 53 | +#include "popup.h" |
52 | 54 | #include "point.h"
|
53 | 55 | #include "projectile.h"
|
54 | 56 | #include "ranged.h"
|
55 | 57 | #include "ret_val.h"
|
56 | 58 | #include "rng.h"
|
| 59 | +#include "string_formatter.h" |
57 | 60 | #include "translations.h"
|
58 | 61 | #include "type_id.h"
|
| 62 | +#include "ui_manager.h" |
59 | 63 | #include "uilist.h"
|
60 | 64 | #include "veh_type.h"
|
61 | 65 | #include "vehicle.h"
|
@@ -534,7 +538,34 @@ bool avatar_action::move( avatar &you, map &m, const tripoint_rel_ms &d )
|
534 | 538 | }
|
535 | 539 | return true;
|
536 | 540 | }
|
| 541 | + |
| 542 | + const tripoint_abs_ms old_abs_pos = you.pos_abs(); |
| 543 | + const tripoint_abs_ms abs_dest_loc = here.get_abs( dest_loc ); |
537 | 544 | if( g->walk_move( dest_loc, via_ramp ) ) {
|
| 545 | + // AUTOPEEK: If safe mode would be triggered after the move, look around and move back |
| 546 | + if( g->safe_mode == SAFE_MODE_ON && !you.is_running() && |
| 547 | + you.pos_abs() == abs_dest_loc ) { |
| 548 | + here.build_map_cache( dest_loc.z() ); |
| 549 | + here.update_visibility_cache( dest_loc.z() ); |
| 550 | + g->mon_info_update(); |
| 551 | + if( !g->check_safe_mode_allowed() && !you.is_hauling() ) { |
| 552 | + input_context ctxt( "LOOK" ); |
| 553 | + static_popup popup; |
| 554 | + popup.message( "%s " + colorize( _( "to go back." ), c_light_gray ) + |
| 555 | + "\n%s " + colorize( _( "to move anyway." ), c_light_gray ), |
| 556 | + ctxt.get_desc( "QUIT" ), |
| 557 | + ctxt.get_desc( "CONFIRM" ) ).on_top( true ); |
| 558 | + ui_manager::redraw(); |
| 559 | + // Get bub coords again after build_map_cache |
| 560 | + const tripoint_bub_ms src_loc = here.get_bub( old_abs_pos ); |
| 561 | + tripoint_bub_ms center( src_loc.x(), src_loc.y(), dest_loc.z() ); |
| 562 | + const look_around_result result = g->look_around( false, center, center, false, false, true ); |
| 563 | + if( result.peek_action != PA_MOVE ) { |
| 564 | + g->walk_move( src_loc, via_ramp ); |
| 565 | + } |
| 566 | + return false; // cancel automove |
| 567 | + } |
| 568 | + } |
538 | 569 | return true;
|
539 | 570 | }
|
540 | 571 | if( g->phasing_move_enchant( dest_loc, you.calculate_by_enchantment( 0,
|
|
0 commit comments