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

Boats push creatures in water out of the way #30519

Merged
merged 2 commits into from
May 15, 2019
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
2 changes: 1 addition & 1 deletion src/monmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,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