Skip to content

Commit

Permalink
Merge pull request #40 from irwiss/Turrets-fire-at-vehicles
Browse files Browse the repository at this point in the history
Turrets fire at vehicles
  • Loading branch information
Maleclypse authored Apr 6, 2023
2 parents 52d8f22 + de59c09 commit 7cb4a48
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
5 changes: 0 additions & 5 deletions src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<tripoint_bub_ms> get_moving_vehicle_targets( const Creature &source, int max_range );
{
if( const std::optional<vpart_reference> vp = veh_at( getlocal(
zone.get_start_point() ) ).part_with_feature( "CARGO", false ) ) {
Expand Down Expand Up @@ -1161,7 +1157,6 @@ std::set<tripoint_bub_ms> 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 )
Expand Down
4 changes: 4 additions & 0 deletions src/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,10 @@ class map
std::vector<zone_data *> 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<tripoint_bub_ms> get_moving_vehicle_targets( const Creature &source, int max_range );

// Removes vehicle from map and returns it in unique_ptr
std::unique_ptr<vehicle> detach_vehicle( vehicle *veh );
Expand Down
5 changes: 2 additions & 3 deletions src/mattack_actors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -831,8 +831,6 @@ int gun_actor::get_max_range() const
return max_range;
}



bool gun_actor::call( monster &z ) const
{
Creature *target;
Expand All @@ -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 ) {
Expand All @@ -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();
}
}

Expand Down

0 comments on commit 7cb4a48

Please sign in to comment.