added missing assets; convoy strike event

This commit is contained in:
Vasyl Horbachenko
2018-11-06 02:33:38 +02:00
parent 9d0997624b
commit e1d50f1f27
18 changed files with 170 additions and 6 deletions

View File

@@ -36,7 +36,7 @@ class ArmorConflictGenerator:
return point.random_point_within(distance, self.conflict.size * SPREAD_DISTANCE_SIZE_FACTOR)
def _generate_group(self, side: Country, unit: VehicleType, count: int, at: Point, to: Point = None):
def _generate_group(self, side: Country, unit: VehicleType, count: int, at: Point, to: Point = None, move_formation: PointAction = PointAction.OffRoad):
for c in range(count):
logging.info("armorgen: {} for {}".format(unit, side.id))
group = self.m.vehicle_group(
@@ -45,7 +45,7 @@ class ArmorConflictGenerator:
unit,
position=self._group_point(at),
group_size=1,
move_formation=PointAction.OffRoad)
move_formation=move_formation)
vehicle: Vehicle = group.units[0]
vehicle.player_can_drive = True
@@ -53,7 +53,7 @@ class ArmorConflictGenerator:
if not to:
to = self.conflict.position.point_from_heading(0, 500)
wayp = group.add_waypoint(self._group_point(to))
wayp = group.add_waypoint(self._group_point(to), move_formation=move_formation)
wayp.tasks = []
def _generate_fight_at(self, attackers: db.ArmorDict, defenders: db.ArmorDict, position: Point):
@@ -109,6 +109,16 @@ class ArmorConflictGenerator:
random.randint(0, self.conflict.distance))
self._generate_fight_at(attacker_group_dict, target_group_dict, position)
def generate_convoy(self, units: db.ArmorDict):
for type, count in units.items():
self._generate_group(
side=self.conflict.defenders_side,
unit=type,
count=count,
at=self.conflict.ground_defenders_location,
to=self.conflict.position,
move_formation=PointAction.OnRoad)
def generate_passengers(self, count: int):
unit_type = random.choice(db.find_unittype(Nothing, self.conflict.attackers_side.name))

View File

@@ -321,6 +321,31 @@ class Conflict:
air_defenders_location=position.point_from_heading(heading, AIR_DISTANCE),
)
@classmethod
def convoy_strike_conflict(cls, attacker: Country, defender: Country, from_cp: ControlPoint, to_cp: ControlPoint, theater: ConflictTheater):
frontline_position, frontline_heading, frontline_length = Conflict.frontline_vector(from_cp, to_cp, theater)
if not frontline_position:
assert False
heading = _heading_sum(frontline_heading, +45)
starting_position = Conflict._find_ground_position(frontline_position.point_from_heading(heading, 15000),
GROUND_INTERCEPT_SPREAD,
_opposite_heading(heading), theater)
destination_position = frontline_position
return cls(
position=destination_position,
theater=theater,
from_cp=from_cp,
to_cp=to_cp,
attackers_side=attacker,
defenders_side=defender,
ground_attackers_location=None,
ground_defenders_location=starting_position,
air_attackers_location=starting_position.point_from_heading(_opposite_heading(heading), AIR_DISTANCE),
air_defenders_location=starting_position.point_from_heading(heading, AIR_DISTANCE),
)
@classmethod
def frontline_cas_conflict(cls, attacker: Country, defender: Country, from_cp: ControlPoint, to_cp: ControlPoint, theater: ConflictTheater):
assert cls.has_frontline_between(from_cp, to_cp)