mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Fix odd frontline unit spawns
* Modfied frontline vector to ensure start point stays outside of exclusion zone. (Previously it could be up to 100m inside) * Change randomization in offset distance from frontline to be based on a percentage of the unit type's fixed offset instead of the width of frontline. (Prevents units from being far from their expected distance from frontline) * Change visualgen to use the same frontline vector calculation as the unit spawns
This commit is contained in:
parent
55573bf40a
commit
29b894f8b0
@ -54,4 +54,4 @@ def heading_sum(h, a) -> int:
|
|||||||
return h
|
return h
|
||||||
|
|
||||||
def opposite_heading(h):
|
def opposite_heading(h):
|
||||||
return h+180
|
return heading_sum(h, 180)
|
||||||
17
gen/armor.py
17
gen/armor.py
@ -112,12 +112,13 @@ class GroundConflictGenerator:
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
def _group_point(self, point: Point) -> Point:
|
@staticmethod
|
||||||
|
def _group_point(point: Point, base_distance) -> Point:
|
||||||
distance = random.randint(
|
distance = random.randint(
|
||||||
int(self.conflict.size * SPREAD_DISTANCE_FACTOR[0]),
|
int(base_distance * SPREAD_DISTANCE_FACTOR[0]),
|
||||||
int(self.conflict.size * SPREAD_DISTANCE_FACTOR[1]),
|
int(base_distance * SPREAD_DISTANCE_FACTOR[1]),
|
||||||
)
|
)
|
||||||
return point.random_point_within(distance, self.conflict.size * SPREAD_DISTANCE_SIZE_FACTOR)
|
return point.random_point_within(distance, base_distance * SPREAD_DISTANCE_SIZE_FACTOR)
|
||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
position = Conflict.frontline_position(self.conflict.from_cp, self.conflict.to_cp, self.game.theater)
|
position = Conflict.frontline_position(self.conflict.from_cp, self.conflict.to_cp, self.game.theater)
|
||||||
@ -495,7 +496,8 @@ class GroundConflictGenerator:
|
|||||||
group.units[0],
|
group.units[0],
|
||||||
len(group.units),
|
len(group.units),
|
||||||
final_position,
|
final_position,
|
||||||
heading=opposite_heading(spawn_heading)
|
distance_from_frontline,
|
||||||
|
heading=opposite_heading(spawn_heading),
|
||||||
)
|
)
|
||||||
if is_player:
|
if is_player:
|
||||||
g.set_skill(self.game.settings.player_skill)
|
g.set_skill(self.game.settings.player_skill)
|
||||||
@ -514,8 +516,9 @@ class GroundConflictGenerator:
|
|||||||
unit: VehicleType,
|
unit: VehicleType,
|
||||||
count: int,
|
count: int,
|
||||||
at: Point,
|
at: Point,
|
||||||
|
distance_from_frontline,
|
||||||
move_formation: PointAction = PointAction.OffRoad,
|
move_formation: PointAction = PointAction.OffRoad,
|
||||||
heading=0
|
heading=0,
|
||||||
) -> VehicleGroup:
|
) -> VehicleGroup:
|
||||||
|
|
||||||
if side == self.conflict.attackers_country:
|
if side == self.conflict.attackers_country:
|
||||||
@ -527,7 +530,7 @@ class GroundConflictGenerator:
|
|||||||
group = self.mission.vehicle_group(
|
group = self.mission.vehicle_group(
|
||||||
side,
|
side,
|
||||||
namegen.next_unit_name(side, cp.id, unit), unit,
|
namegen.next_unit_name(side, cp.id, unit), unit,
|
||||||
position=self._group_point(at),
|
position=self._group_point(at, distance_from_frontline),
|
||||||
group_size=count,
|
group_size=count,
|
||||||
heading=heading,
|
heading=heading,
|
||||||
move_formation=move_formation)
|
move_formation=move_formation)
|
||||||
|
|||||||
@ -82,24 +82,21 @@ class Conflict:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def extend_ground_position(cls, initial: Point, max_distance: int, heading: int, theater: ConflictTheater) -> Point:
|
def extend_ground_position(cls, initial: Point, max_distance: int, heading: int, theater: ConflictTheater) -> Point:
|
||||||
"""Finds a valid ground position in one heading from an initial point"""
|
"""Finds the first intersection with an exclusion zone in one heading from an initial point up to max_distance"""
|
||||||
pos = initial
|
pos = initial
|
||||||
for distance in range(0, int(max_distance), 100):
|
for distance in range(0, int(max_distance), 100):
|
||||||
if not theater.is_on_land(pos):
|
|
||||||
return pos
|
|
||||||
pos = initial.point_from_heading(heading, distance)
|
pos = initial.point_from_heading(heading, distance)
|
||||||
if theater.is_on_land(pos):
|
if not theater.is_on_land(pos):
|
||||||
return pos
|
return initial.point_from_heading(heading, distance - 100)
|
||||||
logging.error("Didn't find ground position ({})!".format(initial))
|
return pos
|
||||||
return initial
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def find_ground_position(cls, initial: Point, max_distance: int, heading: int, theater: ConflictTheater) -> Point:
|
def find_ground_position(cls, initial: Point, max_distance: int, heading: int, theater: ConflictTheater) -> Point:
|
||||||
"""Finds the nearest ground position along a provided heading and it's inverse"""
|
"""Finds the nearest valid ground position along a provided heading and it's inverse"""
|
||||||
pos = initial
|
pos = initial
|
||||||
|
if theater.is_on_land(pos):
|
||||||
|
return pos
|
||||||
for distance in range(0, int(max_distance), 100):
|
for distance in range(0, int(max_distance), 100):
|
||||||
if theater.is_on_land(pos):
|
|
||||||
return pos
|
|
||||||
pos = initial.point_from_heading(heading, distance)
|
pos = initial.point_from_heading(heading, distance)
|
||||||
if theater.is_on_land(pos):
|
if theater.is_on_land(pos):
|
||||||
return pos
|
return pos
|
||||||
|
|||||||
@ -103,15 +103,12 @@ class VisualGenerator:
|
|||||||
if from_cp.is_global or to_cp.is_global:
|
if from_cp.is_global or to_cp.is_global:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
frontline = Conflict.frontline_position(from_cp, to_cp, self.game.theater)
|
plane_start, heading, distance = Conflict.frontline_vector(from_cp, to_cp, self.game.theater)
|
||||||
if not frontline:
|
if not plane_start:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
point, heading = frontline
|
for offset in range(0, distance, FRONT_SMOKE_SPACING):
|
||||||
plane_start = point.point_from_heading(turn_heading(heading, 90), FRONTLINE_LENGTH / 2)
|
position = plane_start.point_from_heading(heading, offset)
|
||||||
|
|
||||||
for offset in range(0, FRONTLINE_LENGTH, FRONT_SMOKE_SPACING):
|
|
||||||
position = plane_start.point_from_heading(turn_heading(heading, - 90), offset)
|
|
||||||
|
|
||||||
for k, v in FRONT_SMOKE_TYPE_CHANCES.items():
|
for k, v in FRONT_SMOKE_TYPE_CHANCES.items():
|
||||||
if random.randint(0, 100) <= k:
|
if random.randint(0, 100) <= k:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user