infantry transport missions for helis

This commit is contained in:
Vasyl Horbachenko
2018-06-25 03:26:42 +03:00
parent 0110af0bec
commit f9e66dec21
54 changed files with 203 additions and 4186 deletions

View File

@@ -18,6 +18,7 @@ INTERCEPTION_ALT = 4600
CAS_ALTITUDE = 4600
RTB_ALTITUDE = 4600
TRANSPORT_LANDING_ALT = 4600
HELI_ALT = 900
WARM_START_AIRSPEED = 540
INTERCEPTION_AIRSPEED = 1000
@@ -297,3 +298,21 @@ class AircraftConflictGenerator:
self._setup_group(group, CAP, clients)
group.add_waypoint(self.conflict.from_cp.position, RTB_ALTITUDE)
def generate_passenger_transport(self, helis: db.HeliDict, clients: db.HeliDict, at: db.StartingPosition):
for heli_type, count, client_count in self._split_to_groups(helis, clients):
group = self._generate_group(
name=namegen.next_transport_group_name(),
side=self.conflict.attackers_side,
unit_type=heli_type,
count=count,
client_count=client_count,
at=at and at or self._group_point(self.conflict.air_attackers_location)
)
group.add_waypoint(
pos=self.conflict.position,
altitude=HELI_ALT,
)
self._setup_group(group, Transport, clients)

View File

@@ -52,16 +52,13 @@ class ArmorConflictGenerator:
count=count,
at=self.conflict.ground_defenders_location)
def generate_passengers(self, group_to_embark: Group, at: Point):
unit_type = db.find_unittype(Nothing, self.conflict.attackers_side.name)
def generate_passengers(self, count: int):
unit_type = random.choice(db.find_unittype(Nothing, self.conflict.attackers_side.name))
group = self.m.vehicle_group(
self.m.vehicle_group(
country=self.conflict.attackers_side,
name=namegen.next_passenger_group_name(),
_type=unit_type,
position=at,
group_size=6
position=self.conflict.ground_attackers_location,
group_size=count
)
wayp = group.add_waypoint(at)
wayp.tasks.append(EmbarkToTransport())

View File

@@ -87,11 +87,11 @@ class Conflict:
@classmethod
def _find_ground_location(cls, initial: Point, max_distance: int, heading: int, theater: ConflictTheater) -> Point:
for _ in range(0, int(max_distance), 100):
for _ in range(0, int(max_distance), 800):
if theater.is_on_land(initial):
return initial
initial = initial.point_from_heading(heading, 100)
initial = initial.point_from_heading(heading, 800)
print("Didn't find ground position!")
return None
@@ -145,7 +145,7 @@ class Conflict:
@classmethod
def ground_attack_conflict(cls, attacker: Country, defender: Country, from_cp: ControlPoint, to_cp: ControlPoint, theater: ConflictTheater):
heading = from_cp.position.heading_between_point(to_cp.position)
heading = random.choice(to_cp.radials)
initial_location = to_cp.position.random_point_within(*GROUND_ATTACK_DISTANCE)
position = Conflict._find_ground_location(initial_location, GROUND_INTERCEPT_SPREAD, _heading_sum(heading, 180), theater)
if not position:
@@ -257,3 +257,26 @@ class Conflict:
air_attackers_location=position.point_from_heading(attacker_heading, AIR_DISTANCE),
air_defenders_location=position.point_from_heading(_opposite_heading(attacker_heading), AIR_DISTANCE)
)
@classmethod
def transport_conflict(cls, attacker: Country, defender: Country, from_cp: ControlPoint, to_cp: ControlPoint, theater: ConflictTheater):
frontline_position = cls._frontline_position(from_cp, to_cp)
heading = to_cp.position.heading_between_point(from_cp.position)
initial_dest = frontline_position.point_from_heading(heading, TRANSPORT_FRONTLINE_DIST)
dest = cls._find_ground_location(initial_dest, from_cp.position.distance_to_point(to_cp.position) / 3, heading, theater)
if not dest:
radial = to_cp.find_radial(to_cp.position.heading_between_point(from_cp.position))
dest = to_cp.position.point_from_heading(radial, to_cp.size * GROUND_DISTANCE_FACTOR)
return cls(
position=dest,
theater=theater,
from_cp=from_cp,
to_cp=to_cp,
attackers_side=attacker,
defenders_side=defender,
ground_attackers_location=from_cp.position,
ground_defenders_location=frontline_position,
air_attackers_location=from_cp.position.point_from_heading(0, 100),
air_defenders_location=frontline_position
)

View File

@@ -14,7 +14,7 @@ from game import db
from theater import *
from gen import *
ACTIVATION_TRIGGER_SIZE = 40000
ACTIVATION_TRIGGER_SIZE = 100000
ACTIVATION_TRIGGER_MIN_DISTANCE = 20000
PUSH_TRIGGER_SIZE = 3000

View File

@@ -11,6 +11,14 @@ from .conflictgen import *
#from game.game import Game
class MarkerSmoke(unittype.StaticType):
id = "big_smoke"
category = "Effects"
name = "big_smoke"
shape_name = 5
rate = 100
class Smoke(unittype.StaticType):
id = "big_smoke"
category = "Effects"
@@ -35,6 +43,12 @@ class MassiveSmoke(unittype.StaticType):
rate = 100
class Outpost(unittype.StaticType):
id = "outpost"
name = "outpost"
category = "Fortifications"
def __monkey_static_dict(self: Static):
global __original_static_dict
@@ -87,7 +101,7 @@ class VisualGenerator:
for from_cp, to_cp in self.game.theater.conflicts():
distance = max(from_cp.position.distance_to_point(to_cp.position) * FRONT_SMOKE_DISTANCE_FACTOR * to_cp.base.strength, FRONT_SMOKE_MIN_DISTANCE)
heading = to_cp.position.heading_between_point(from_cp.position)
point = to_cp.position.point_from_heading(heading, distance)
point = Conflict._frontline_position(from_cp, to_cp)
plane_start = point.point_from_heading(turn_heading(heading, 90), FRONT_SMOKE_LENGTH / 2)
for offset in range(0, FRONT_SMOKE_LENGTH, FRONT_SMOKE_SPACING):
@@ -122,5 +136,22 @@ class VisualGenerator:
position=position)
break
def generate_transportation_marker(self, at: Point):
self.mission.static_group(
self.mission.country(self.game.player),
"",
_type=MarkerSmoke,
position=at
)
def generate_transportation_destination(self, at: Point):
self.generate_transportation_marker(at.point_from_heading(0, 20))
self.mission.static_group(
self.mission.country(self.game.player),
"",
_type=Outpost,
position=at
)
def generate(self):
self._generate_frontline_smokes()