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

Turrets fire at vehicles #40

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
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