Compare commits

...

3 Commits

Author SHA1 Message Date
Dan Albert
5037a5c9d7 Bump version to 5.2.1. 2022-10-31 13:21:29 -07:00
Dan Albert
fb734d4f09 Note hold point fix in the changelog.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2494.

(cherry picked from commit 73b7be0606)
2022-10-31 13:21:29 -07:00
Raffson
173b99f610 Fix for orbit's broken stop condition
(cherry picked from commit 7e7c920816d384001ac1dbf1bcbcf8ccaad4a093)
(cherry picked from commit 73ee2ba4c0)
2022-10-31 13:21:29 -07:00
3 changed files with 36 additions and 4 deletions

View File

@@ -1,3 +1,9 @@
# 5.2.1
## Fixes
* **[Mission Generation]** Work around DCS 2.8 bug preventing the AI from leaving their hold point.
# 5.2.0 # 5.2.0
Saves from 5.1.0 are compatible with 5.2.0 Saves from 5.1.0 are compatible with 5.2.0

View File

@@ -3,7 +3,7 @@ from pathlib import Path
MAJOR_VERSION = 5 MAJOR_VERSION = 5
MINOR_VERSION = 2 MINOR_VERSION = 2
MICRO_VERSION = 0 MICRO_VERSION = 1
def _build_version_string() -> str: def _build_version_string() -> str:

View File

@@ -9,7 +9,7 @@ from functools import cached_property
from typing import Any, Dict, Iterable, List, Optional, TYPE_CHECKING, Type, Union from typing import Any, Dict, Iterable, List, Optional, TYPE_CHECKING, Type, Union
from dcs import helicopters from dcs import helicopters
from dcs.action import AITaskPush, ActivateGroup from dcs.action import AITaskPush, ActivateGroup, SetFlag
from dcs.condition import CoalitionHasAirdrome, TimeAfter from dcs.condition import CoalitionHasAirdrome, TimeAfter
from dcs.country import Country from dcs.country import Country
from dcs.flyingunit import FlyingUnit from dcs.flyingunit import FlyingUnit
@@ -1490,6 +1490,24 @@ class DefaultWaypointBuilder(PydcsWaypointBuilder):
pass pass
def create_stop_orbit_trigger(
orbit: ControlledTask, package: Package, mission: Mission, stop_after: int
) -> None:
orbit.stop_if_user_flag(id(package), True)
orbits = [
x
for x in mission.triggerrules.triggers
if x.comment == f"StopOrbit{id(package)}"
]
if not any(orbits):
stop_trigger = TriggerOnce(Event.NoEvent, f"StopOrbit{id(package)}")
stop_condition = TimeAfter(stop_after)
stop_action = SetFlag(id(package))
stop_trigger.add_condition(stop_condition)
stop_trigger.add_action(stop_action)
mission.triggerrules.triggers.append(stop_trigger)
class HoldPointBuilder(PydcsWaypointBuilder): class HoldPointBuilder(PydcsWaypointBuilder):
def build(self) -> MovingPoint: def build(self) -> MovingPoint:
waypoint = super().build() waypoint = super().build()
@@ -1506,7 +1524,11 @@ class HoldPointBuilder(PydcsWaypointBuilder):
return waypoint return waypoint
push_time = self.flight.flight_plan.push_time push_time = self.flight.flight_plan.push_time
self.waypoint.departure_time = push_time self.waypoint.departure_time = push_time
loiter.stop_after_time(int(push_time.total_seconds())) stop_after = int(push_time.total_seconds())
loiter.stop_after_time(stop_after)
# What follows is some code to cope with the broken 'stop after time' condition
create_stop_orbit_trigger(loiter, self.package, self.mission, stop_after)
# end of hotfix
waypoint.add_task(loiter) waypoint.add_task(loiter)
return waypoint return waypoint
@@ -1875,7 +1897,11 @@ class RaceTrackBuilder(PydcsWaypointBuilder):
racetrack = ControlledTask(orbit) racetrack = ControlledTask(orbit)
self.set_waypoint_tot(waypoint, flight_plan.patrol_start_time) self.set_waypoint_tot(waypoint, flight_plan.patrol_start_time)
racetrack.stop_after_time(int(flight_plan.patrol_end_time.total_seconds())) stop_after = int(flight_plan.patrol_end_time.total_seconds())
racetrack.stop_after_time(stop_after)
# What follows is some code to cope with the broken 'stop after time' condition
create_stop_orbit_trigger(racetrack, self.package, self.mission, stop_after)
# end of hotfix
waypoint.add_task(racetrack) waypoint.add_task(racetrack)
return waypoint return waypoint