diff --git a/src/map.cpp b/src/map.cpp index fa4334e0c4a4c..64d75795fc5c6 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1108,10 +1108,6 @@ void map::register_vehicle_zone( vehicle *veh, const int zlev ) } bool map::deregister_vehicle_zone( zone_data &zone ) const -// returns a list of tripoints which contain parts from moving vehicles within \p max_range -// distance from \p source position, if any parts are CONTROLS, ENGINE or WHEELS returns a -// list of tripoints with exclusively such parts instead. Used for monster gun actor targeting. -std::set get_moving_vehicle_targets( const Creature &source, int max_range ); { if( const std::optional vp = veh_at( getlocal( zone.get_start_point() ) ).part_with_feature( "CARGO", false ) ) { @@ -1161,7 +1157,6 @@ std::set map::get_moving_vehicle_targets( const Creature &z, in return !priority.empty() ? priority : visible; } - // 3D vehicle functions VehicleList map::get_vehicles( const tripoint &start, const tripoint &end ) diff --git a/src/map.h b/src/map.h index 959d02196b47a..e98630af5c1c4 100644 --- a/src/map.h +++ b/src/map.h @@ -675,6 +675,10 @@ class map std::vector get_vehicle_zones( int zlev ); void register_vehicle_zone( vehicle *, int zlev ); bool deregister_vehicle_zone( zone_data &zone ) const; + // returns a list of tripoints which contain parts from moving vehicles within \p max_range + // distance from \p source position, if any parts are CONTROLS, ENGINE or WHEELS returns a + // list of tripoints with exclusively such parts instead. Used for monster gun actor targeting. + std::set get_moving_vehicle_targets( const Creature &source, int max_range ); // Removes vehicle from map and returns it in unique_ptr std::unique_ptr detach_vehicle( vehicle *veh ); diff --git a/src/mattack_actors.cpp b/src/mattack_actors.cpp index 6cf828b9ae2be..025aef2691fe3 100644 --- a/src/mattack_actors.cpp +++ b/src/mattack_actors.cpp @@ -831,8 +831,6 @@ int gun_actor::get_max_range() const return max_range; } - - bool gun_actor::call( monster &z ) const { Creature *target; @@ -856,6 +854,7 @@ bool gun_actor::call( monster &z ) const } aim_at = target->pos(); } else { + target = z.attack_target(); aim_at = target ? target->pos() : tripoint_zero; if( !target || !z.sees( *target ) || ( !target->is_monster() && !z.aggro_character ) ) { if( !target_moving_vehicles ) { @@ -867,7 +866,7 @@ bool gun_actor::call( monster &z ) const if( moving_veh_parts.empty() ) { return false; } - aim_at = random_entry( moving_veh_parts, tripoint_bub_ms() ).raw() + aim_at = random_entry( moving_veh_parts, tripoint_bub_ms() ).raw(); } }