From b1109b582ba585a3ab496c3fe480c89b7e08dcab Mon Sep 17 00:00:00 2001 From: Vasyl Horbachenko Date: Sat, 30 Jun 2018 04:56:48 +0300 Subject: [PATCH] lots of fixes to the mission generation --- game/operation/capture.py | 2 ++ game/operation/intercept.py | 2 ++ game/operation/operation.py | 3 ++- gen/aircraft.py | 16 ++++++++-------- gen/conflictgen.py | 6 ++++-- gen/environmentgen.py | 19 ++++++++++--------- gen/triggergen.py | 24 +++++++++++++++--------- 7 files changed, 43 insertions(+), 29 deletions(-) diff --git a/game/operation/capture.py b/game/operation/capture.py index 4ec3f163..851f9488 100644 --- a/game/operation/capture.py +++ b/game/operation/capture.py @@ -20,6 +20,8 @@ class CaptureOperation(Operation): defense = None # type: db.ArmorDict aa = None # type: db.AirDefenseDict + trigger_radius = TRIGGER_RADIUS_SMALL + def setup(self, cas: db.PlaneDict, escort: db.PlaneDict, diff --git a/game/operation/intercept.py b/game/operation/intercept.py index 4d99bc44..1d3d8ac5 100644 --- a/game/operation/intercept.py +++ b/game/operation/intercept.py @@ -10,6 +10,8 @@ class InterceptOperation(Operation): interceptors = None # type: db.PlaneDict airdefense = None # type: db.AirDefenseDict + trigger_radius = TRIGGER_RADIUS_LARGE + def setup(self, escort: db.PlaneDict, transport: db.PlaneDict, diff --git a/game/operation/operation.py b/game/operation/operation.py index caab84e6..73d0bc02 100644 --- a/game/operation/operation.py +++ b/game/operation/operation.py @@ -22,6 +22,7 @@ class Operation: envgen = None # type: EnvironmentGenerator environment_settings = None + trigger_radius = TRIGGER_RADIUS_MEDIUM is_quick = None is_awacs_enabled = False @@ -77,7 +78,7 @@ class Operation: self.awacsgen.generate() self.extra_aagen.generate() - self.triggersgen.generate(self.is_quick) + self.triggersgen.generate(self.is_quick, self.trigger_radius) if self.environment_settings is None: self.environment_settings = self.envgen.generate() diff --git a/gen/aircraft.py b/gen/aircraft.py index 3cf12635..8f60d48a 100644 --- a/gen/aircraft.py +++ b/gen/aircraft.py @@ -10,14 +10,14 @@ from dcs.task import * from dcs.terrain.terrain import NoParkingSlotError SPREAD_DISTANCE_FACTOR = 1, 2 -ESCORT_MAX_DIST = 80000 +ESCORT_ENGAGEMENT_MAX_DIST = 100000 WORKAROUND_WAYP_DIST = 1000 -WARM_START_ALTITUDE = 4600 -INTERCEPTION_ALT = 4600 -CAS_ALTITUDE = 4600 -RTB_ALTITUDE = 4600 -TRANSPORT_LANDING_ALT = 4600 +WARM_START_ALTITUDE = 3000 +INTERCEPTION_ALT = 3000 +CAS_ALTITUDE = 1000 +RTB_ALTITUDE = 1000 +TRANSPORT_LANDING_ALT = 1000 HELI_ALT = 900 WARM_START_AIRSPEED = 550 @@ -108,7 +108,7 @@ class AircraftConflictGenerator: assert count > 0 assert unit is not None - alt = WARM_START_ALTITUDE + random.randint(500, 3000) + alt = WARM_START_ALTITUDE + random.randint(50, 200) pos = Point(at.x + random.randint(100, 200), at.y + random.randint(100, 200)) return self.m.flight_group( @@ -188,7 +188,7 @@ class AircraftConflictGenerator: self._setup_group(group, CAP, client_count) for group in self.escort_targets: - wayp.tasks.append(EscortTaskAction(group.id, engagement_max_dist=ESCORT_MAX_DIST)) + wayp.tasks.append(EscortTaskAction(group.id, engagement_max_dist=ESCORT_ENGAGEMENT_MAX_DIST)) groups.append(group) return groups diff --git a/gen/conflictgen.py b/gen/conflictgen.py index acb1e629..c94c3551 100644 --- a/gen/conflictgen.py +++ b/gen/conflictgen.py @@ -16,6 +16,8 @@ from dcs.country import * from theater import * +AIR_DISTANCE = 40000 + GROUND_DISTANCE_FACTOR = 1 GROUNDINTERCEPT_DISTANCE_FACTOR = 6 @@ -122,8 +124,8 @@ class Conflict: defenders_side=defender, ground_attackers_location=attackers_location, ground_defenders_location=defenders_location, - air_attackers_location=position.point_from_heading(attack_raw_heading, AIR_DISTANCE), - air_defenders_location=position.point_from_heading(_opposite_heading(attack_raw_heading), AIR_DISTANCE) + air_attackers_location=position.point_from_heading(attack_raw_heading, CAPTURE_AIR_ATTACKERS_DISTANCE), + air_defenders_location=position.point_from_heading(_opposite_heading(attack_raw_heading), CAPTURE_AIR_DEFENDERS_DISTANCE) ) @classmethod diff --git a/gen/environmentgen.py b/gen/environmentgen.py index 6a419d07..789f9d20 100644 --- a/gen/environmentgen.py +++ b/gen/environmentgen.py @@ -9,6 +9,7 @@ from dcs.action import * from dcs.unit import Skill from dcs.point import MovingPoint, PointProperties from dcs.action import * +from dcs.weather import * from game import db from theater import * @@ -28,9 +29,9 @@ RANDOM_TIME = { RANDOM_WEATHER = { 1: 5, # heavy rain - 2: 20, # rain - 3: 30, # dynamic - 4: 40, # clear + 2: 15, # rain + 3: 25, # dynamic + 4: 35, # clear 5: 100, # random } @@ -68,9 +69,7 @@ class EnviromentGenerator: break print("generated weather {}".format(weather_type)) - if weather_type == 0: - self.mission.weather.random_thunderstorm() - elif weather_type == 1: + if weather_type == 1: self.mission.weather.heavy_rain() elif weather_type == 2: self.mission.weather.heavy_rain() @@ -84,13 +83,15 @@ class EnviromentGenerator: self.mission.weather.clouds_density = random.randint(*WEATHER_CLOUD_DENSITY) self.mission.weather.clouds_thickness = random.randint(*WEATHER_CLOUD_THICKNESS) - self.mission.weather.random(self.mission.start_time, self.conflict.theater.terrain) + wind_direction = random.randint(0, 360) + wind_speed = random.randint(0, 13) + self.mission.weather.wind_at_ground = Wind(wind_direction, wind_speed) + self.mission.weather.wind_at_2000 = Wind(wind_direction, wind_speed * 2) + self.mission.weather.wind_at_8000 = Wind(wind_direction, wind_speed * 3) if self.mission.weather.clouds_density > 0: self.mission.weather.clouds_base = max(self.mission.weather.clouds_base, WEATHER_CLOUD_BASE_MIN) - self.mission.random_weather = False - def generate(self) -> EnvironmentSettings: self._gen_random_time() self._gen_random_weather() diff --git a/gen/triggergen.py b/gen/triggergen.py index 3eef5404..7c409689 100644 --- a/gen/triggergen.py +++ b/gen/triggergen.py @@ -14,15 +14,19 @@ from game import db from theater import * from gen import * -ACTIVATION_TRIGGER_SIZE = 100000 -ACTIVATION_TRIGGER_MIN_DISTANCE = 10000 - PUSH_TRIGGER_SIZE = 3000 REGROUP_ZONE_DISTANCE = 12000 REGROUP_ALT = 5000 +TRIGGER_MIN_DISTANCE_FROM_START = 10000 + +TRIGGER_RADIUS_SMALL = 40000 +TRIGGER_RADIUS_MEDIUM = 100000 +TRIGGER_RADIUS_LARGE = 150000 + + class Silence(Option): Key = 7 @@ -33,7 +37,7 @@ class TriggersGenerator: self.conflict = conflict self.game = game - def _gen_activation_trigger(self, player_coalition: str, enemy_coalition: str): + def _gen_activation_trigger(self, radius: int, player_coalition: str, enemy_coalition: str): activate_by_trigger = [] for coalition_name, coalition in self.mission.coalition.items(): for country in coalition.countries.values(): @@ -47,7 +51,7 @@ class TriggersGenerator: activate_by_trigger.append(vehicle_group) zone_distance_to_aircraft = self.conflict.from_cp.position.distance_to_point(self.conflict.position) - zone_size = min(zone_distance_to_aircraft - ACTIVATION_TRIGGER_MIN_DISTANCE, ACTIVATION_TRIGGER_SIZE) + zone_size = min(zone_distance_to_aircraft - TRIGGER_MIN_DISTANCE_FROM_START, radius) activation_trigger_zone = self.mission.triggers.add_triggerzone(self.conflict.position, zone_size, name="Activation zone") activation_trigger = TriggerOnce(Event.NoEvent, "Activation trigger") @@ -82,7 +86,9 @@ class TriggersGenerator: w1.tasks.append(Silence(True)) - w2.tasks.append(SwitchWaypoint(from_waypoint=3, to_waypoint=2)) + switch_waypoint_task = ControlledTask(SwitchWaypoint(from_waypoint=3, to_waypoint=2)) + switch_waypoint_task.start_if_user_flag(1, False) + w2.tasks.append(switch_waypoint_task) plane_group.points[3].tasks.append(Silence(False)) plane_group.add_trigger_action(SwitchWaypoint(to_waypoint=4)) @@ -93,7 +99,7 @@ class TriggersGenerator: push_trigger.add_condition(AllOfCoalitionOutsideZone(player_coalition, push_trigger_zone.id)) for group in push_by_trigger: push_trigger.add_action(AITaskPush(group.id, 1)) - message_string = self.mission.string("Task force is in the air, proceed with the objective.") + message_string = self.mission.string("Task force is in the air, proceed with the objective (activate waypoint 3).") push_trigger.add_action(MessageToAll(message_string, clearview=True)) push_trigger.add_action(SetFlagValue()) @@ -123,7 +129,7 @@ class TriggersGenerator: for vehicle_group in country.vehicle_group: vehicle_group.set_skill(Skill(skill_level)) - def generate(self, is_quick: bool): + def generate(self, is_quick: bool, activation_trigger_radius: int): player_coalition = self.game.player == "USA" and "blue" or "red" enemy_coalition = player_coalition == "blue" and "red" or "blue" @@ -135,5 +141,5 @@ class TriggersGenerator: if not is_quick: # TODO: waypoint parts of this should not be post-hacked but added in airgen - self._gen_activation_trigger(player_coalition, enemy_coalition) + self._gen_activation_trigger(activation_trigger_radius, player_coalition, enemy_coalition) self._gen_push_trigger(player_coalition)