diff --git a/src/monmove.cpp b/src/monmove.cpp index 7134d1a3fc288..65e571b41862e 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -623,7 +623,7 @@ void monster::move() g->m.i_clear( pos() ); } // record position before moving to put the player there if we're dragging - tripoint drag_to = pos(); + tripoint drag_to = g->m.getabs( pos() ); const bool pacified = has_effect( effect_pacified ); @@ -820,6 +820,7 @@ void monster::move() // in both circular and roguelike distance modes. const float distance_to_target = trig_dist( pos(), destination ); for( const tripoint &candidate : squares_closer_to( pos(), destination ) ) { + tripoint candidate_abs = g->m.getabs( candidate ); if( candidate.z != posz() ) { bool can_z_move = true; if( !g->m.valid_move( pos(), candidate, false, true ) ) { @@ -862,7 +863,7 @@ void monster::move() if( att == A_HOSTILE ) { // When attacking an adjacent enemy, we're direct. moved = true; - next_step = candidate; + next_step = candidate_abs; break; } else if( att == A_FRIENDLY && ( target->is_player() || target->is_npc() ) ) { continue; // Friendly firing the player or an NPC is illegal for gameplay reasons @@ -876,7 +877,6 @@ void monster::move() // Try to shove vehicle out of the way shove_vehicle( destination, candidate ); - // Bail out if we can't move there and we can't bash. if( !pathed && !can_move_to( candidate ) ) { if( !can_bash ) { @@ -900,7 +900,7 @@ void monster::move() // Randomly pick one of the viable squares to move to weighted by distance. if( progress > 0 && ( !moved || x_in_y( progress, switch_chance ) ) ) { moved = true; - next_step = candidate; + next_step = candidate_abs; // If we stumble, pick a random square, otherwise take the first one, // which is the most direct path. // Except if the direct path is bad, then check others @@ -920,7 +920,8 @@ void monster::move() ( !pacified && can_open_doors && g->m.open_door( next_step, !g->m.is_outside( pos() ) ) ) || ( !pacified && bash_at( next_step ) ) || ( !pacified && push_to( next_step, 0, 0 ) ) || - move_to( next_step, false, get_stagger_adjust( pos(), destination, next_step ) ); + move_to( g->m.getlocal( next_step ), false, get_stagger_adjust( pos(), destination, + g->m.getlocal( next_step ) ) ); if( !did_something ) { moves -= 100; // If we don't do this, we'll get infinite loops. @@ -930,8 +931,9 @@ void monster::move() if( !dragged_foe->has_effect( effect_grabbed ) ) { dragged_foe = nullptr; remove_effect( effect_dragging ); - } else if( drag_to != pos() && g->critter_at( drag_to ) == nullptr ) { - dragged_foe->setpos( drag_to ); + } else if( g->m.getlocal( drag_to ) != pos() && + g->critter_at( g->m.getlocal( drag_to ) ) == nullptr ) { + dragged_foe->setpos( g->m.getlocal( drag_to ) ); } } } else {