mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
De-spawn AI flights on RTB if start-type was set to In-Flight
Resolve #73
This commit is contained in:
parent
bc26eb3f5e
commit
0b060d3110
@ -34,6 +34,7 @@
|
||||
* **[Mission Generator]** F-15E Strike targets are automatically added as Mission Set 1
|
||||
* **[Mission Generator]** Set F-14's IP waypoint according to the flight-plan's ingress point
|
||||
* **[Mission Generator]** Automatically de-spawn aircraft when arrival/divert is an off-map spawn
|
||||
* **[Options]** Option to de-spawn AI flights in the air if their start-type was manually set to In-Flight
|
||||
|
||||
## Fixes
|
||||
* **[Mission Generation]** Anti-ship strikes should use "group attack" in their attack-task
|
||||
|
||||
@ -7,12 +7,18 @@ from .pydcswaypointbuilder import PydcsWaypointBuilder
|
||||
class LandingPointBuilder(PydcsWaypointBuilder):
|
||||
def build(self) -> MovingPoint:
|
||||
waypoint = super().build()
|
||||
waypoint.type = "Land"
|
||||
waypoint.action = PointAction.Landing
|
||||
if (control_point := self.waypoint.control_point) is not None:
|
||||
if isinstance(control_point, NavalControlPoint):
|
||||
waypoint.helipad_id = control_point.airdrome_id_for_landing
|
||||
waypoint.link_unit = control_point.airdrome_id_for_landing
|
||||
else:
|
||||
waypoint.airdrome_id = control_point.airdrome_id_for_landing
|
||||
if self.ai_despawn(waypoint):
|
||||
waypoint.alt = round(
|
||||
self.flight.coalition.doctrine.max_patrol_altitude.meters
|
||||
)
|
||||
waypoint.alt_type = "BARO"
|
||||
else:
|
||||
waypoint.type = "Land"
|
||||
waypoint.action = PointAction.Landing
|
||||
if (control_point := self.waypoint.control_point) is not None:
|
||||
if isinstance(control_point, NavalControlPoint):
|
||||
waypoint.helipad_id = control_point.airdrome_id_for_landing # type: ignore
|
||||
waypoint.link_unit = control_point.airdrome_id_for_landing # type: ignore
|
||||
else:
|
||||
waypoint.airdrome_id = control_point.airdrome_id_for_landing
|
||||
return waypoint
|
||||
|
||||
@ -11,6 +11,7 @@ from dcs.unitgroup import FlyingGroup
|
||||
|
||||
from game.ato import Flight, FlightWaypoint
|
||||
from game.ato.flightwaypointtype import FlightWaypointType
|
||||
from game.ato.starttype import StartType
|
||||
from game.ato.traveltime import GroundSpeed
|
||||
from game.missiongenerator.missiondata import MissionData
|
||||
from game.theater import MissionTarget, TheaterUnit, OffMapSpawn
|
||||
@ -81,12 +82,20 @@ class PydcsWaypointBuilder:
|
||||
self.add_tasks(waypoint)
|
||||
return waypoint
|
||||
|
||||
def add_tasks(self, waypoint: MovingPoint) -> None:
|
||||
def ai_despawn(
|
||||
self, waypoint: MovingPoint, ignore_landing_wpt: bool = False
|
||||
) -> bool:
|
||||
if self.flight.roster.members[0].is_player:
|
||||
return False
|
||||
arrival = self.flight.arrival
|
||||
divert = self.flight.divert
|
||||
offmap = isinstance(arrival, OffMapSpawn) or isinstance(divert, OffMapSpawn)
|
||||
pos = waypoint.position
|
||||
if offmap and (arrival.position == pos or divert and divert.position == pos):
|
||||
offmap = isinstance(arrival, OffMapSpawn)
|
||||
ai_despawn = self.flight.coalition.game.settings.perf_ai_despawn_airstarted
|
||||
ai_despawn &= self.flight.start_type == StartType.IN_FLIGHT
|
||||
is_landing_wpt = arrival.position == waypoint.position
|
||||
return (offmap or ai_despawn) and (is_landing_wpt or ignore_landing_wpt)
|
||||
|
||||
def add_tasks(self, waypoint: MovingPoint) -> None:
|
||||
if self.ai_despawn(waypoint):
|
||||
waypoint.tasks.append(
|
||||
RunScript(
|
||||
f"local g = Group.getByName('{self.group.name}')\n"
|
||||
|
||||
@ -1,16 +1,12 @@
|
||||
from dcs.point import MovingPoint
|
||||
from dcs.task import RefuelingTaskAction, ControlledTask
|
||||
|
||||
from game.theater import OffMapSpawn
|
||||
from .pydcswaypointbuilder import PydcsWaypointBuilder
|
||||
|
||||
|
||||
class RefuelPointBuilder(PydcsWaypointBuilder):
|
||||
def add_tasks(self, waypoint: MovingPoint) -> None:
|
||||
offmap = isinstance(self.flight.arrival, OffMapSpawn)
|
||||
if self.flight.divert:
|
||||
offmap |= isinstance(self.flight.divert, OffMapSpawn)
|
||||
if not offmap:
|
||||
if not self.ai_despawn(waypoint, True):
|
||||
refuel = ControlledTask(RefuelingTaskAction())
|
||||
refuel.start_probability(10)
|
||||
waypoint.add_task(refuel)
|
||||
|
||||
@ -961,6 +961,16 @@ class Settings:
|
||||
default=True,
|
||||
causes_expensive_game_update=True,
|
||||
)
|
||||
perf_ai_despawn_airstarted: bool = boolean_option(
|
||||
"De-spawn AI in the air upon RTB",
|
||||
page=MISSION_GENERATOR_PAGE,
|
||||
section=PERFORMANCE_SECTION,
|
||||
default=False,
|
||||
detail=(
|
||||
"If enabled, AI flights will de-spawn over their base "
|
||||
"if the start-up type was manually changed to 'In-Flight'."
|
||||
),
|
||||
)
|
||||
|
||||
# Cheating. Not using auto settings because the same page also has buttons which do
|
||||
# not alter settings.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user