frontline attack ops

This commit is contained in:
Vasyl Horbachenko
2018-07-16 23:58:01 +03:00
parent 1fbf4e292a
commit e4c3f8bce2
19 changed files with 205 additions and 206 deletions

View File

@@ -1,3 +1,4 @@
from random import randint
from itertools import zip_longest
from game import db
@@ -13,6 +14,10 @@ from dcs.country import *
SPREAD_DISTANCE_FACTOR = 0.1, 0.3
SPREAD_DISTANCE_SIZE_FACTOR = 0.1
FRONTLINE_CAS_FIGHTS_COUNT = 4, 8
FRONTLINE_CAS_GROUP_MIN = 1, 2
FRONTLINE_CAS_PADDING = 12000
class ArmorConflictGenerator:
def __init__(self, mission: Mission, conflict: Conflict):
@@ -50,7 +55,7 @@ class ArmorConflictGenerator:
side=self.conflict.attackers_side,
unit=type,
count=count,
at=position.point_from_heading(self.conflict.heading - 90, 600),
at=position.point_from_heading(self.conflict.heading - 90, 5000),
to=position)
if defenders:
@@ -59,7 +64,7 @@ class ArmorConflictGenerator:
side=self.conflict.defenders_side,
unit=type,
count=count,
at=position.point_from_heading(self.conflict.heading + 90, 600),
at=position.point_from_heading(self.conflict.heading + 90, 1000),
to=position)
def generate(self, attackers: db.ArmorDict, defenders: db.ArmorDict):
@@ -78,16 +83,16 @@ class ArmorConflictGenerator:
at=self.conflict.ground_defenders_location)
def generate_vec(self, attackers: db.ArmorDict, defenders: db.ArmorDict):
defender_groups = list(db.unitdict_split(defenders, 6))
distance_between_groups = min(self.conflict.distance / len(defender_groups), 12000)
total_distance = distance_between_groups * len(defender_groups)
fights_count = randint(*FRONTLINE_CAS_FIGHTS_COUNT)
single_fight_defenders_count = min(int(sum(defenders.values()) / fights_count), randint(*FRONTLINE_CAS_GROUP_MIN))
defender_groups = list(db.unitdict_split(defenders, single_fight_defenders_count))
attacker_groups = list(db.unitdict_split(attackers,
int(sum(attackers.values()) / len(defender_groups))))
single_fight_attackers_count = min(int(sum(attackers.values()) / len(defender_groups)), randint(*FRONTLINE_CAS_GROUP_MIN))
attacker_groups = list(db.unitdict_split(attackers, single_fight_attackers_count))
position = self.conflict.center.point_from_heading(self.conflict.opposite_heading, total_distance / 2)
for attacker_group_dict, target_group_dict in zip_longest(attacker_groups, defender_groups):
position = position.point_from_heading(self.conflict.heading, distance_between_groups)
position = self.conflict.position.point_from_heading(self.conflict.heading,
random.randint(FRONTLINE_CAS_PADDING, int(self.conflict.distance - FRONTLINE_CAS_PADDING)))
self._generate_fight_at(attacker_group_dict, target_group_dict, position)
def generate_passengers(self, count: int):

View File

@@ -38,8 +38,9 @@ NAVAL_INTERCEPT_DISTANCE_FACTOR = 1
NAVAL_INTERCEPT_DISTANCE_MAX = 40000
NAVAL_INTERCEPT_STEP = 5000
FRONT_SMOKE_MIN_DISTANCE = 5000
FRONT_SMOKE_DISTANCE_FACTOR = 0.5
FRONTLINE_LENGTH = 80000
FRONTLINE_MIN_CP_DISTANCE = 5000
FRONTLINE_DISTANCE_STRENGTH_FACTOR = 0.7
def _opposite_heading(h):
@@ -127,7 +128,7 @@ 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) * FRONT_SMOKE_DISTANCE_FACTOR * to_cp.base.strength, FRONT_SMOKE_MIN_DISTANCE)
distance = max(from_cp.position.distance_to_point(to_cp.position) * 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
@@ -136,7 +137,7 @@ class Conflict:
center_position, heading = cls.frontline_position(from_cp, to_cp)
left_position = center_position
for offset in range(0, 80000, 1000):
for offset in range(0, int(FRONTLINE_LENGTH / 2), 1000):
pos = center_position.point_from_heading(_heading_sum(heading, -90), offset)
if not theater.is_on_land(pos):
break
@@ -144,7 +145,7 @@ class Conflict:
left_position = pos
right_position = center_position
for offset in range(0, 80000, 1000):
for offset in range(0, int(FRONTLINE_LENGTH / 2), 1000):
pos = center_position.point_from_heading(_heading_sum(heading, 90), offset)
if not theater.is_on_land(pos):
break

View File

@@ -62,7 +62,6 @@ def __monkey_static_dict(self: Static):
__original_static_dict = Static.dict
Static.dict = __monkey_static_dict
FRONT_SMOKE_LENGTH = 80000
FRONT_SMOKE_SPACING = 800
FRONT_SMOKE_RANDOM_SPREAD = 4000
FRONT_SMOKE_TYPE_CHANCES = {
@@ -100,9 +99,9 @@ class VisualGenerator:
def _generate_frontline_smokes(self):
for from_cp, to_cp in self.game.theater.conflicts():
point, heading = Conflict.frontline_position(from_cp, to_cp)
plane_start = point.point_from_heading(turn_heading(heading, 90), FRONT_SMOKE_LENGTH / 2)
plane_start = point.point_from_heading(turn_heading(heading, 90), FRONTLINE_LENGTH / 2)
for offset in range(0, FRONT_SMOKE_LENGTH, FRONT_SMOKE_SPACING):
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():