mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
lots of fixes to the mission generation
This commit is contained in:
parent
e03342b3ff
commit
b1109b582b
@ -20,6 +20,8 @@ class CaptureOperation(Operation):
|
|||||||
defense = None # type: db.ArmorDict
|
defense = None # type: db.ArmorDict
|
||||||
aa = None # type: db.AirDefenseDict
|
aa = None # type: db.AirDefenseDict
|
||||||
|
|
||||||
|
trigger_radius = TRIGGER_RADIUS_SMALL
|
||||||
|
|
||||||
def setup(self,
|
def setup(self,
|
||||||
cas: db.PlaneDict,
|
cas: db.PlaneDict,
|
||||||
escort: db.PlaneDict,
|
escort: db.PlaneDict,
|
||||||
|
|||||||
@ -10,6 +10,8 @@ class InterceptOperation(Operation):
|
|||||||
interceptors = None # type: db.PlaneDict
|
interceptors = None # type: db.PlaneDict
|
||||||
airdefense = None # type: db.AirDefenseDict
|
airdefense = None # type: db.AirDefenseDict
|
||||||
|
|
||||||
|
trigger_radius = TRIGGER_RADIUS_LARGE
|
||||||
|
|
||||||
def setup(self,
|
def setup(self,
|
||||||
escort: db.PlaneDict,
|
escort: db.PlaneDict,
|
||||||
transport: db.PlaneDict,
|
transport: db.PlaneDict,
|
||||||
|
|||||||
@ -22,6 +22,7 @@ class Operation:
|
|||||||
envgen = None # type: EnvironmentGenerator
|
envgen = None # type: EnvironmentGenerator
|
||||||
|
|
||||||
environment_settings = None
|
environment_settings = None
|
||||||
|
trigger_radius = TRIGGER_RADIUS_MEDIUM
|
||||||
is_quick = None
|
is_quick = None
|
||||||
is_awacs_enabled = False
|
is_awacs_enabled = False
|
||||||
|
|
||||||
@ -77,7 +78,7 @@ class Operation:
|
|||||||
self.awacsgen.generate()
|
self.awacsgen.generate()
|
||||||
|
|
||||||
self.extra_aagen.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:
|
if self.environment_settings is None:
|
||||||
self.environment_settings = self.envgen.generate()
|
self.environment_settings = self.envgen.generate()
|
||||||
|
|||||||
@ -10,14 +10,14 @@ from dcs.task import *
|
|||||||
from dcs.terrain.terrain import NoParkingSlotError
|
from dcs.terrain.terrain import NoParkingSlotError
|
||||||
|
|
||||||
SPREAD_DISTANCE_FACTOR = 1, 2
|
SPREAD_DISTANCE_FACTOR = 1, 2
|
||||||
ESCORT_MAX_DIST = 80000
|
ESCORT_ENGAGEMENT_MAX_DIST = 100000
|
||||||
WORKAROUND_WAYP_DIST = 1000
|
WORKAROUND_WAYP_DIST = 1000
|
||||||
|
|
||||||
WARM_START_ALTITUDE = 4600
|
WARM_START_ALTITUDE = 3000
|
||||||
INTERCEPTION_ALT = 4600
|
INTERCEPTION_ALT = 3000
|
||||||
CAS_ALTITUDE = 4600
|
CAS_ALTITUDE = 1000
|
||||||
RTB_ALTITUDE = 4600
|
RTB_ALTITUDE = 1000
|
||||||
TRANSPORT_LANDING_ALT = 4600
|
TRANSPORT_LANDING_ALT = 1000
|
||||||
HELI_ALT = 900
|
HELI_ALT = 900
|
||||||
|
|
||||||
WARM_START_AIRSPEED = 550
|
WARM_START_AIRSPEED = 550
|
||||||
@ -108,7 +108,7 @@ class AircraftConflictGenerator:
|
|||||||
assert count > 0
|
assert count > 0
|
||||||
assert unit is not None
|
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))
|
pos = Point(at.x + random.randint(100, 200), at.y + random.randint(100, 200))
|
||||||
|
|
||||||
return self.m.flight_group(
|
return self.m.flight_group(
|
||||||
@ -188,7 +188,7 @@ class AircraftConflictGenerator:
|
|||||||
self._setup_group(group, CAP, client_count)
|
self._setup_group(group, CAP, client_count)
|
||||||
|
|
||||||
for group in self.escort_targets:
|
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)
|
groups.append(group)
|
||||||
return groups
|
return groups
|
||||||
|
|||||||
@ -16,6 +16,8 @@ from dcs.country import *
|
|||||||
|
|
||||||
from theater import *
|
from theater import *
|
||||||
|
|
||||||
|
AIR_DISTANCE = 40000
|
||||||
|
|
||||||
|
|
||||||
GROUND_DISTANCE_FACTOR = 1
|
GROUND_DISTANCE_FACTOR = 1
|
||||||
GROUNDINTERCEPT_DISTANCE_FACTOR = 6
|
GROUNDINTERCEPT_DISTANCE_FACTOR = 6
|
||||||
@ -122,8 +124,8 @@ class Conflict:
|
|||||||
defenders_side=defender,
|
defenders_side=defender,
|
||||||
ground_attackers_location=attackers_location,
|
ground_attackers_location=attackers_location,
|
||||||
ground_defenders_location=defenders_location,
|
ground_defenders_location=defenders_location,
|
||||||
air_attackers_location=position.point_from_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), AIR_DISTANCE)
|
air_defenders_location=position.point_from_heading(_opposite_heading(attack_raw_heading), CAPTURE_AIR_DEFENDERS_DISTANCE)
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
@ -9,6 +9,7 @@ from dcs.action import *
|
|||||||
from dcs.unit import Skill
|
from dcs.unit import Skill
|
||||||
from dcs.point import MovingPoint, PointProperties
|
from dcs.point import MovingPoint, PointProperties
|
||||||
from dcs.action import *
|
from dcs.action import *
|
||||||
|
from dcs.weather import *
|
||||||
|
|
||||||
from game import db
|
from game import db
|
||||||
from theater import *
|
from theater import *
|
||||||
@ -28,9 +29,9 @@ RANDOM_TIME = {
|
|||||||
|
|
||||||
RANDOM_WEATHER = {
|
RANDOM_WEATHER = {
|
||||||
1: 5, # heavy rain
|
1: 5, # heavy rain
|
||||||
2: 20, # rain
|
2: 15, # rain
|
||||||
3: 30, # dynamic
|
3: 25, # dynamic
|
||||||
4: 40, # clear
|
4: 35, # clear
|
||||||
5: 100, # random
|
5: 100, # random
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,9 +69,7 @@ class EnviromentGenerator:
|
|||||||
break
|
break
|
||||||
|
|
||||||
print("generated weather {}".format(weather_type))
|
print("generated weather {}".format(weather_type))
|
||||||
if weather_type == 0:
|
if weather_type == 1:
|
||||||
self.mission.weather.random_thunderstorm()
|
|
||||||
elif weather_type == 1:
|
|
||||||
self.mission.weather.heavy_rain()
|
self.mission.weather.heavy_rain()
|
||||||
elif weather_type == 2:
|
elif weather_type == 2:
|
||||||
self.mission.weather.heavy_rain()
|
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_density = random.randint(*WEATHER_CLOUD_DENSITY)
|
||||||
self.mission.weather.clouds_thickness = random.randint(*WEATHER_CLOUD_THICKNESS)
|
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:
|
if self.mission.weather.clouds_density > 0:
|
||||||
self.mission.weather.clouds_base = max(self.mission.weather.clouds_base, WEATHER_CLOUD_BASE_MIN)
|
self.mission.weather.clouds_base = max(self.mission.weather.clouds_base, WEATHER_CLOUD_BASE_MIN)
|
||||||
|
|
||||||
self.mission.random_weather = False
|
|
||||||
|
|
||||||
def generate(self) -> EnvironmentSettings:
|
def generate(self) -> EnvironmentSettings:
|
||||||
self._gen_random_time()
|
self._gen_random_time()
|
||||||
self._gen_random_weather()
|
self._gen_random_weather()
|
||||||
|
|||||||
@ -14,15 +14,19 @@ from game import db
|
|||||||
from theater import *
|
from theater import *
|
||||||
from gen import *
|
from gen import *
|
||||||
|
|
||||||
ACTIVATION_TRIGGER_SIZE = 100000
|
|
||||||
ACTIVATION_TRIGGER_MIN_DISTANCE = 10000
|
|
||||||
|
|
||||||
PUSH_TRIGGER_SIZE = 3000
|
PUSH_TRIGGER_SIZE = 3000
|
||||||
|
|
||||||
REGROUP_ZONE_DISTANCE = 12000
|
REGROUP_ZONE_DISTANCE = 12000
|
||||||
REGROUP_ALT = 5000
|
REGROUP_ALT = 5000
|
||||||
|
|
||||||
|
|
||||||
|
TRIGGER_MIN_DISTANCE_FROM_START = 10000
|
||||||
|
|
||||||
|
TRIGGER_RADIUS_SMALL = 40000
|
||||||
|
TRIGGER_RADIUS_MEDIUM = 100000
|
||||||
|
TRIGGER_RADIUS_LARGE = 150000
|
||||||
|
|
||||||
|
|
||||||
class Silence(Option):
|
class Silence(Option):
|
||||||
Key = 7
|
Key = 7
|
||||||
|
|
||||||
@ -33,7 +37,7 @@ class TriggersGenerator:
|
|||||||
self.conflict = conflict
|
self.conflict = conflict
|
||||||
self.game = game
|
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 = []
|
activate_by_trigger = []
|
||||||
for coalition_name, coalition in self.mission.coalition.items():
|
for coalition_name, coalition in self.mission.coalition.items():
|
||||||
for country in coalition.countries.values():
|
for country in coalition.countries.values():
|
||||||
@ -47,7 +51,7 @@ class TriggersGenerator:
|
|||||||
activate_by_trigger.append(vehicle_group)
|
activate_by_trigger.append(vehicle_group)
|
||||||
|
|
||||||
zone_distance_to_aircraft = self.conflict.from_cp.position.distance_to_point(self.conflict.position)
|
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_zone = self.mission.triggers.add_triggerzone(self.conflict.position, zone_size, name="Activation zone")
|
||||||
activation_trigger = TriggerOnce(Event.NoEvent, "Activation trigger")
|
activation_trigger = TriggerOnce(Event.NoEvent, "Activation trigger")
|
||||||
@ -82,7 +86,9 @@ class TriggersGenerator:
|
|||||||
|
|
||||||
w1.tasks.append(Silence(True))
|
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.points[3].tasks.append(Silence(False))
|
||||||
|
|
||||||
plane_group.add_trigger_action(SwitchWaypoint(to_waypoint=4))
|
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))
|
push_trigger.add_condition(AllOfCoalitionOutsideZone(player_coalition, push_trigger_zone.id))
|
||||||
for group in push_by_trigger:
|
for group in push_by_trigger:
|
||||||
push_trigger.add_action(AITaskPush(group.id, 1))
|
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(MessageToAll(message_string, clearview=True))
|
||||||
push_trigger.add_action(SetFlagValue())
|
push_trigger.add_action(SetFlagValue())
|
||||||
|
|
||||||
@ -123,7 +129,7 @@ class TriggersGenerator:
|
|||||||
for vehicle_group in country.vehicle_group:
|
for vehicle_group in country.vehicle_group:
|
||||||
vehicle_group.set_skill(Skill(skill_level))
|
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"
|
player_coalition = self.game.player == "USA" and "blue" or "red"
|
||||||
enemy_coalition = player_coalition == "blue" and "red" or "blue"
|
enemy_coalition = player_coalition == "blue" and "red" or "blue"
|
||||||
|
|
||||||
@ -135,5 +141,5 @@ class TriggersGenerator:
|
|||||||
|
|
||||||
if not is_quick:
|
if not is_quick:
|
||||||
# TODO: waypoint parts of this should not be post-hacked but added in airgen
|
# 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)
|
self._gen_push_trigger(player_coalition)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user