mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
randomized strike objects with templates; forbid ground objects and vehicles placement on mountains and in forests; updated push trigger so it include player group; adjacent CP missions could be initiated from carriers
This commit is contained in:
@@ -21,6 +21,10 @@ class AirSupportConflictGenerator:
|
||||
self.conflict = conflict
|
||||
self.game = game
|
||||
|
||||
@classmethod
|
||||
def support_tasks(cls) -> typing.Collection[typing.Type[MainTask]]:
|
||||
return [Refueling, AWACS]
|
||||
|
||||
def generate(self, is_awacs_enabled):
|
||||
player_cp = self.conflict.from_cp if self.conflict.from_cp.captured else self.conflict.to_cp
|
||||
tanker_unit = db.find_unittype(Refueling, self.conflict.attackers_side.name)[0]
|
||||
|
||||
@@ -130,19 +130,22 @@ class Conflict:
|
||||
return self.to_cp.size * GROUND_DISTANCE_FACTOR
|
||||
|
||||
def find_insertion_point(self, other_point: Point) -> Point:
|
||||
dx = self.position.x - self.tail.x
|
||||
dy = self.position.y - self.tail.y
|
||||
dr2 = float(dx ** 2 + dy ** 2)
|
||||
if self.is_vector:
|
||||
dx = self.position.x - self.tail.x
|
||||
dy = self.position.y - self.tail.y
|
||||
dr2 = float(dx ** 2 + dy ** 2)
|
||||
|
||||
lerp = ((other_point.x - self.tail.x) * dx + (other_point.y - self.tail.y) * dy) / dr2
|
||||
if lerp < 0:
|
||||
lerp = 0
|
||||
elif lerp > 1:
|
||||
lerp = 1
|
||||
lerp = ((other_point.x - self.tail.x) * dx + (other_point.y - self.tail.y) * dy) / dr2
|
||||
if lerp < 0:
|
||||
lerp = 0
|
||||
elif lerp > 1:
|
||||
lerp = 1
|
||||
|
||||
x = lerp * dx + self.tail.x
|
||||
y = lerp * dy + self.tail.y
|
||||
return Point(x, y)
|
||||
x = lerp * dx + self.tail.x
|
||||
y = lerp * dy + self.tail.y
|
||||
return Point(x, y)
|
||||
else:
|
||||
return self.position
|
||||
|
||||
def find_ground_position(self, at: Point, heading: int, max_distance: int = 40000) -> typing.Optional[Point]:
|
||||
return Conflict._find_ground_position(at, max_distance, heading, self.theater)
|
||||
@@ -153,7 +156,10 @@ class Conflict:
|
||||
|
||||
@classmethod
|
||||
def frontline_position(cls, from_cp: ControlPoint, to_cp: ControlPoint) -> typing.Tuple[Point, int]:
|
||||
distance = max(from_cp.position.distance_to_point(to_cp.position) * FRONTLINE_DISTANCE_STRENGTH_FACTOR * to_cp.base.strength, FRONTLINE_MIN_CP_DISTANCE)
|
||||
cp_distance = from_cp.position.distance_to_point(to_cp.position)
|
||||
cp_distance -= cp_distance * to_cp.frontline_offset + cp_distance * from_cp.frontline_offset
|
||||
|
||||
distance = max(cp_distance * FRONTLINE_DISTANCE_STRENGTH_FACTOR * to_cp.base.strength, FRONTLINE_MIN_CP_DISTANCE)
|
||||
heading = to_cp.position.heading_between_point(from_cp.position)
|
||||
return to_cp.position.point_from_heading(heading, distance), heading
|
||||
|
||||
@@ -172,7 +178,6 @@ class Conflict:
|
||||
if pos:
|
||||
left_position = pos
|
||||
center_position = pos
|
||||
print("{} - {} {}".format(from_cp, to_cp, center_position))
|
||||
|
||||
if left_position is None:
|
||||
left_position = cls._extend_ground_position(center_position, int(FRONTLINE_LENGTH/2), _heading_sum(heading, -90), theater)
|
||||
|
||||
@@ -19,11 +19,15 @@ class GroundObjectsGenerator:
|
||||
self.game = game
|
||||
|
||||
def generate_farps(self, number_of_units=1) -> typing.Collection[StaticGroup]:
|
||||
assert self.conflict.is_vector, "FARP could be generated only on frontline conflicts!"
|
||||
|
||||
for i, _ in enumerate(range(0, number_of_units, self.FARP_CAPACITY)):
|
||||
if self.conflict.is_vector:
|
||||
center = self.conflict.center
|
||||
heading = self.conflict.heading - 90
|
||||
position = self.conflict.find_ground_position(self.conflict.center.point_from_heading(heading, FARP_FRONTLINE_DISTANCE), heading)
|
||||
else:
|
||||
center, heading = self.conflict.frontline_position(self.conflict.from_cp, self.conflict.to_cp)
|
||||
heading -= 90
|
||||
|
||||
position = self.conflict.find_ground_position(center.point_from_heading(heading, FARP_FRONTLINE_DISTANCE), heading)
|
||||
for i, _ in enumerate(range(0, number_of_units, self.FARP_CAPACITY)):
|
||||
position = position.point_from_heading(0, i * 275)
|
||||
|
||||
yield self.m.farp(
|
||||
@@ -64,6 +68,10 @@ class GroundObjectsGenerator:
|
||||
else:
|
||||
static_type = fortification_map[ground_object.dcs_identifier]
|
||||
|
||||
if not static_type:
|
||||
print("Didn't find {} in static _map(s)!".format(ground_object.dcs_identifier))
|
||||
continue
|
||||
|
||||
group = self.m.static_group(
|
||||
country=side,
|
||||
name=ground_object.string_identifier,
|
||||
|
||||
@@ -12,9 +12,11 @@ from dcs.action import *
|
||||
|
||||
from game import db
|
||||
from theater import *
|
||||
from gen.airsupportgen import AirSupportConflictGenerator
|
||||
from gen import *
|
||||
|
||||
PUSH_TRIGGER_SIZE = 3000
|
||||
PUSH_TRIGGER_ACTIVATION_AGL = 100
|
||||
|
||||
REGROUP_ZONE_DISTANCE = 12000
|
||||
REGROUP_ALT = 5000
|
||||
@@ -51,6 +53,11 @@ class TriggersGenerator:
|
||||
vehicle_group.late_activation = True
|
||||
activate_by_trigger.append(vehicle_group)
|
||||
|
||||
for plane_group in country.plane_group:
|
||||
if plane_group.task in [x.name for x in AirSupportConflictGenerator.support_tasks()]:
|
||||
plane_group.late_activation = True
|
||||
activate_by_trigger.append(plane_group)
|
||||
|
||||
conflict_distance = player_cp.position.distance_to_point(self.conflict.position)
|
||||
minimum_radius = max(conflict_distance - TRIGGER_MIN_DISTANCE_FROM_START, TRIGGER_RADIUS_MINIMUM)
|
||||
if minimum_radius < 0:
|
||||
@@ -79,9 +86,6 @@ class TriggersGenerator:
|
||||
if player_cp.position.distance_to_point(group.position) > PUSH_TRIGGER_SIZE * 3:
|
||||
continue
|
||||
|
||||
if group.units[0].is_human():
|
||||
continue
|
||||
|
||||
regroup_heading = self.conflict.to_cp.position.heading_between_point(player_cp.position)
|
||||
|
||||
pos1 = group.position.point_from_heading(regroup_heading, REGROUP_ZONE_DISTANCE)
|
||||
@@ -109,7 +113,9 @@ class TriggersGenerator:
|
||||
push_trigger = TriggerOnce(Event.NoEvent, "Push trigger")
|
||||
|
||||
for group in push_by_trigger:
|
||||
push_trigger.add_condition(AllOfGroupOutsideZone(group.id, push_trigger_zone.id))
|
||||
for unit in group.units:
|
||||
push_trigger.add_condition(UnitAltitudeHigherAGL(unit.id, PUSH_TRIGGER_ACTIVATION_AGL))
|
||||
|
||||
push_trigger.add_action(AITaskPush(group.id, 1))
|
||||
|
||||
message_string = self.mission.string("Task force is in the air, proceed with the objective (activate waypoint 3).")
|
||||
|
||||
Reference in New Issue
Block a user