Skip to content

Commit

Permalink
Merge pull request #30519 from mlangsdorf/boat_push_fish
Browse files Browse the repository at this point in the history
Boats push creatures in water out of the way
  • Loading branch information
kevingranade authored May 15, 2019
2 parents 8643feb + 502285f commit b68b6ca
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/monmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ void monster::move()

// don't move if a passenger in a moving vehicle
auto vp = g->m.veh_at( pos() );
if( vp && vp->vehicle().is_moving() && vp->vehicle().get_pet( vp->part_index() ) ) {
if( friendly && vp && vp->vehicle().is_moving() && vp->vehicle().get_pet( vp->part_index() ) ) {
moves = 0;
return;
}
Expand Down
24 changes: 21 additions & 3 deletions src/vehicle_move.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,27 @@ veh_collision vehicle::part_collision( int part, const tripoint &p,
return ret;
}

// critters on a BOARDABLE part in this vehicle aren't colliding
if( is_body_collision && ovp && ( &ovp->vehicle() == this ) && get_pet( ovp->part_index() ) ) {
return ret;
if( is_body_collision ) {
// critters on a BOARDABLE part in this vehicle aren't colliding
if( ovp && ( &ovp->vehicle() == this ) && get_pet( ovp->part_index() ) ) {
return ret;
}
// we just ran into a fish, so move it out of the way
if( g->m.has_flag( "SWIMMABLE", critter->pos() ) ) {
tripoint end_pos = critter->pos();
tripoint start_pos;
const int angle = move.dir() + 45 * ( parts[part].mount.x > pivot_point().x ? -1 : 1 );
std::set<tripoint> &cur_points = get_points( true );
// push the animal out of way until it's no longer in our vehicle and not in
// anyone else's position
while( g->critter_at( end_pos, true ) ||
cur_points.find( end_pos ) != cur_points.end() ) {
start_pos = end_pos;
calc_ray_end( angle, 2, start_pos, end_pos );
}
critter->setpos( end_pos );
return ret;
}
}

// Damage armor before damaging any other parts
Expand Down

0 comments on commit b68b6ca

Please sign in to comment.