mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
AI Strike flight will bomb all their targets correctly
This commit is contained in:
parent
ab3ea84d70
commit
0b9d827ad6
@ -64,7 +64,7 @@ class Operation:
|
||||
def initialize(self, mission: Mission, conflict: Conflict):
|
||||
self.current_mission = mission
|
||||
self.conflict = conflict
|
||||
self.airgen = AircraftConflictGenerator(mission, conflict, self.game.settings)
|
||||
self.airgen = AircraftConflictGenerator(mission, conflict, self.game.settings, self.game)
|
||||
self.shipgen = ShipGenerator(mission, conflict)
|
||||
self.airsupportgen = AirSupportConflictGenerator(mission, conflict, self.game)
|
||||
self.triggersgen = TriggersGenerator(mission, conflict, self.game)
|
||||
@ -198,8 +198,6 @@ class Operation:
|
||||
self.briefinggen.append_frequency("AWACS", "133 MHz AM")
|
||||
|
||||
self.briefinggen.append_frequency("Flight", "251 MHz AM")
|
||||
if self.departure_cp.is_global or self.conflict.to_cp.is_global:
|
||||
self.briefinggen.append_frequency("Carrier", "20X/ICLS CHAN1")
|
||||
|
||||
# Generate the briefing
|
||||
self.briefinggen.generate()
|
||||
|
||||
@ -46,8 +46,9 @@ INTERCEPT_MAX_DISTANCE = 200000
|
||||
class AircraftConflictGenerator:
|
||||
escort_targets = [] # type: typing.List[typing.Tuple[FlyingGroup, int]]
|
||||
|
||||
def __init__(self, mission: Mission, conflict: Conflict, settings: Settings):
|
||||
def __init__(self, mission: Mission, conflict: Conflict, settings: Settings, game):
|
||||
self.m = mission
|
||||
self.game = game
|
||||
self.settings = settings
|
||||
self.conflict = conflict
|
||||
self.escort_targets = []
|
||||
@ -457,7 +458,12 @@ class AircraftConflictGenerator:
|
||||
for point in flight.points:
|
||||
group.add_waypoint(Point(point.x,point.y), point.alt)
|
||||
for t in point.targets:
|
||||
group.points[i].tasks.append(Bombing(t.position))
|
||||
if hasattr(t, "obj_name"):
|
||||
buildings = self.game.theater.find_ground_objects_by_obj_name(t.obj_name)
|
||||
for building in buildings:
|
||||
group.points[i].tasks.append(Bombing(building.position))
|
||||
else:
|
||||
group.points[i].tasks.append(Bombing(t.position))
|
||||
i = i + 1
|
||||
|
||||
|
||||
|
||||
@ -57,11 +57,7 @@ class BriefingGenerator:
|
||||
self.description += "-"*50 + "\n"
|
||||
|
||||
for planner in self.game.planners.values():
|
||||
for flight in planner.cap_flights:
|
||||
self.add_flight_description(flight)
|
||||
for flight in planner.cas_flights:
|
||||
self.add_flight_description(flight)
|
||||
for flight in planner.sead_flights:
|
||||
for flight in planner.flights:
|
||||
self.add_flight_description(flight)
|
||||
|
||||
if self.freqs:
|
||||
@ -82,7 +78,6 @@ class BriefingGenerator:
|
||||
self.description += "X"
|
||||
self.description += " " + str(cp.tacanI) + "\n"
|
||||
|
||||
|
||||
self.m.set_description_text(self.description)
|
||||
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ dcs.planes.FlyingType.payload_dirs = [os.path.join(os.path.dirname(os.path.realp
|
||||
|
||||
mis = dcs.Mission(dcs.terrain.PersianGulf())
|
||||
pos = dcs.terrain.PersianGulf().khasab().position
|
||||
airgen = AircraftConflictGenerator(mis, None, None)
|
||||
airgen = AircraftConflictGenerator(mis, None, None, None)
|
||||
|
||||
for t, uts in db.UNIT_BY_TASK.items():
|
||||
if t != dcs.task.CAP and t != dcs.task.CAS:
|
||||
|
||||
@ -72,6 +72,14 @@ class ConflictTheater:
|
||||
|
||||
self.controlpoints.append(point)
|
||||
|
||||
def find_ground_objects_by_obj_name(self, obj_name):
|
||||
found = []
|
||||
for cp in self.controlpoints:
|
||||
for g in cp.ground_objects:
|
||||
if g.obj_name == obj_name:
|
||||
found.append(g)
|
||||
return found
|
||||
|
||||
def is_in_sea(self, point: Point) -> bool:
|
||||
if not self.landmap:
|
||||
return False
|
||||
|
||||
@ -170,3 +170,10 @@ class ControlPoint:
|
||||
|
||||
return closest_radial
|
||||
|
||||
def find_ground_objects_by_obj_name(self, obj_name):
|
||||
found = []
|
||||
for g in self.ground_objects:
|
||||
if g.obj_name == obj_name:
|
||||
found.append(g)
|
||||
return found
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user