From c2919eedd666d57aff3040d47a9b7d53be7a2860 Mon Sep 17 00:00:00 2001 From: Mark Langsdorf Date: Tue, 14 May 2019 15:24:35 -0500 Subject: [PATCH 1/2] vehicles: displace creatures in water instead of colliding when a vehicle part collides with a creature while the creature is on a water tile, displace the creature 2 tiles on a 45 degree angle away from the vehicle's direction of movement until the creature is no longer colliding with the vehicle and the creature is not in the same tile as any other creature. --- src/vehicle_move.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/vehicle_move.cpp b/src/vehicle_move.cpp index 69713e382abef..8c33658d1df82 100644 --- a/src/vehicle_move.cpp +++ b/src/vehicle_move.cpp @@ -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 &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 From 502285f5e2f9f0ecd895ec3039a7ba3e59fbdf43 Mon Sep 17 00:00:00 2001 From: Mark Langsdorf Date: Tue, 14 May 2019 15:39:51 -0500 Subject: [PATCH 2/2] monsters: only friendly monsters stay still in vehicles Only friendly monsters passive ride in vehicles. Hostile monsters will continue moving around the vehicle. --- src/monmove.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/monmove.cpp b/src/monmove.cpp index a5717b80a05d5..034e7440bb01e 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -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; }