Skip to content

Commit

Permalink
Revert "store abs pos in mon move incase shove vehicle submap shifts"
Browse files Browse the repository at this point in the history
This reverts commit fd1938a.
  • Loading branch information
davidpwbrown committed Jan 17, 2020
1 parent 9915387 commit c6c05ea
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/monmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,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 = g->m.getabs( pos() );
tripoint drag_to = pos();

const bool pacified = has_effect( effect_pacified );

Expand Down Expand Up @@ -829,7 +829,6 @@ 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 ) ) {
Expand Down Expand Up @@ -872,7 +871,7 @@ void monster::move()
if( att == A_HOSTILE ) {
// When attacking an adjacent enemy, we're direct.
moved = true;
next_step = candidate_abs;
next_step = candidate;
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
Expand All @@ -886,6 +885,7 @@ 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 ) {
Expand All @@ -909,7 +909,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_abs;
next_step = candidate;
// 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
Expand All @@ -929,8 +929,7 @@ 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( g->m.getlocal( next_step ), false, get_stagger_adjust( pos(), destination,
g->m.getlocal( next_step ) ) );
move_to( next_step, false, get_stagger_adjust( pos(), destination, next_step ) );

if( !did_something ) {
moves -= 100; // If we don't do this, we'll get infinite loops.
Expand All @@ -940,9 +939,8 @@ void monster::move()
if( !dragged_foe->has_effect( effect_grabbed ) ) {
dragged_foe = nullptr;
remove_effect( effect_dragging );
} 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 if( drag_to != pos() && g->critter_at( drag_to ) == nullptr ) {
dragged_foe->setpos( drag_to );
}
}
} else {
Expand Down

0 comments on commit c6c05ea

Please sign in to comment.