From f40f83bb0995ba941167bccb7d258f3bc31a9783 Mon Sep 17 00:00:00 2001 From: Vasyl Horbachenko Date: Tue, 17 Jul 2018 05:22:41 +0300 Subject: [PATCH] fixes and improvements for fronline CAP --- game/event/frontlineattack.py | 4 ++-- game/event/frontlinepatrol.py | 12 +++++++----- game/operation/frontlinepatrol.py | 13 +++++++++---- gen/aircraft.py | 4 +++- gen/armor.py | 14 ++++++++++---- gen/environmentgen.py | 2 +- theater/base.py | 2 +- ui/eventmenu.py | 19 +++++++++++-------- 8 files changed, 44 insertions(+), 26 deletions(-) diff --git a/game/event/frontlineattack.py b/game/event/frontlineattack.py index 11146809..f89f5908 100644 --- a/game/event/frontlineattack.py +++ b/game/event/frontlineattack.py @@ -15,7 +15,7 @@ class FrontlineAttackEvent(Event): TARGET_AMOUNT_FACTOR = 0.5 ATTACKER_AMOUNT_FACTOR = 0.4 ATTACKER_DEFENDER_FACTOR = 0.7 - STRENGTH_INFLUENCE = 0.3 + STRENGTH_INFLUENCE = 0.2 SUCCESS_TARGETS_HIT_PERCENTAGE = 0.25 defenders = None # type: db.ArmorDict @@ -58,7 +58,7 @@ class FrontlineAttackEvent(Event): self.to_cp.base.affect_strength(-0.1) def player_attacking(self, armor: db.ArmorDict, strikegroup: db.PlaneDict, clients: db.PlaneDict): - self.defenders = self.to_cp.base.assemble_cap() + self.defenders = self.to_cp.base.assemble_attack() op = FrontlineAttackOperation(game=self.game, attacker_name=self.attacker_name, diff --git a/game/event/frontlinepatrol.py b/game/event/frontlinepatrol.py index ddce50f3..02fb9062 100644 --- a/game/event/frontlinepatrol.py +++ b/game/event/frontlinepatrol.py @@ -12,8 +12,8 @@ from userdata.debriefing import Debriefing class FrontlinePatrolEvent(Event): ESCORT_FACTOR = 0.5 - STRENGTH_INFLUENCE = 0.3 - SUCCESS_TARGETS_HIT_PERCENTAGE = 0.6 + STRENGTH_INFLUENCE = 0.2 + SUCCESS_TARGETS_HIT_PERCENTAGE = 0.33 cas = None # type: db.PlaneDict escort = None # type: db.PlaneDict @@ -61,12 +61,14 @@ class FrontlinePatrolEvent(Event): op = FrontlinePatrolOperation(game=self.game, attacker_name=self.attacker_name, defender_name=self.defender_name, - attacker_clients={}, - defender_clients=clients, + attacker_clients=clients, + defender_clients={}, from_cp=self.from_cp, to_cp=self.to_cp) op.setup(cas=self.cas, escort=self.escort, - interceptors=interceptors) + interceptors=interceptors, + armor_attackers=self.from_cp.base.assemble_attack(), + armor_defenders=self.to_cp.base.assemble_attack()) self.operation = op diff --git a/game/operation/frontlinepatrol.py b/game/operation/frontlinepatrol.py index fd486747..f4d7a355 100644 --- a/game/operation/frontlinepatrol.py +++ b/game/operation/frontlinepatrol.py @@ -23,11 +23,17 @@ class FrontlinePatrolOperation(Operation): escort = None # type: db.PlaneDict interceptors = None # type: db.PlaneDict - def setup(self, cas: db.PlaneDict, escort: db.PlaneDict, interceptors: db.PlaneDict): + armor_attackers = None # type: db.ArmorDict + armor_defenders = None # type: db.ArmorDict + + def setup(self, cas: db.PlaneDict, escort: db.PlaneDict, interceptors: db.PlaneDict, armor_attackers: db.ArmorDict, armor_defenders: db.ArmorDict): self.cas = cas self.escort = escort self.interceptors = interceptors + self.armor_attackers = armor_attackers + self.armor_defenders = armor_defenders + def prepare(self, terrain: Terrain, is_quick: bool): super(FrontlinePatrolOperation, self).prepare(terrain, is_quick) self.defenders_starting_position = None @@ -46,8 +52,7 @@ class FrontlinePatrolOperation(Operation): def generate(self): self.airgen.generate_defenders_cas(self.cas, {}, self.defenders_starting_position) self.airgen.generate_defenders_escort(self.escort, {}, self.defenders_starting_position) - self.airgen.generate_patrol(self.interceptors, self.defender_clients, self.attackers_starting_position) - - # todo: generate armor + self.airgen.generate_patrol(self.interceptors, self.attacker_clients, self.attackers_starting_position) + self.armorgen.generate_vec(self.armor_attackers, self.armor_defenders) super(FrontlinePatrolOperation, self).generate() diff --git a/gen/aircraft.py b/gen/aircraft.py index 4c1d7cc4..3071be1a 100644 --- a/gen/aircraft.py +++ b/gen/aircraft.py @@ -264,8 +264,10 @@ class AircraftConflictGenerator: pos = self.conflict.air_defenders_location.point_from_heading(self.conflict.heading-90, CAP_CAS_DISTANCE) waypoint = group.add_waypoint(pos, CAS_ALTITUDE, WARM_START_AIRSPEED) + if self.conflict.is_vector: - group.add_waypoint(self.conflict.tail, CAS_ALTITUDE, WARM_START_AIRSPEED) + destination_tail = self.conflict.tail.distance_to_point(pos) > self.conflict.position.distance_to_point(pos) + group.add_waypoint(destination_tail and self.conflict.tail or self.conflict.position, CAS_ALTITUDE, WARM_START_AIRSPEED) group.task = CAS.name self._setup_group(group, CAS, client_count) diff --git a/gen/armor.py b/gen/armor.py index c6bdb4c1..586f4601 100644 --- a/gen/armor.py +++ b/gen/armor.py @@ -50,22 +50,28 @@ class ArmorConflictGenerator: def _generate_fight_at(self, attackers: db.ArmorDict, defenders: db.ArmorDict, position: Point): if attackers: + attack_pos = position.point_from_heading(self.conflict.heading - 90, 8000) + attack_dest = position.point_from_heading(self.conflict.heading + 90, 25000) for type, count in attackers.items(): self._generate_group( side=self.conflict.attackers_side, unit=type, count=count, - at=position.point_from_heading(self.conflict.heading - 90, 5000), - to=position) + at=attack_pos, + to=attack_dest, + ) if defenders: + def_pos = position.point_from_heading(self.conflict.heading + 90, 4000) + def_dest = position.point_from_heading(self.conflict.heading + 90, 25000) for type, count in defenders.items(): self._generate_group( side=self.conflict.defenders_side, unit=type, count=count, - at=position.point_from_heading(self.conflict.heading + 90, 1000), - to=position) + at=def_pos, + to=def_dest, + ) def generate(self, attackers: db.ArmorDict, defenders: db.ArmorDict): for type, count in attackers.items(): diff --git a/gen/environmentgen.py b/gen/environmentgen.py index 789f9d20..3e106ffd 100644 --- a/gen/environmentgen.py +++ b/gen/environmentgen.py @@ -18,7 +18,7 @@ from gen import * WEATHER_CLOUD_BASE = 2000, 3000 WEATHER_CLOUD_DENSITY = 1, 8 WEATHER_CLOUD_THICKNESS = 100, 400 -WEATHER_CLOUD_BASE_MIN = 1200 +WEATHER_CLOUD_BASE_MIN = 2400 RANDOM_TIME = { "night": 5, diff --git a/theater/base.py b/theater/base.py index ff5d815f..b6b79ebc 100644 --- a/theater/base.py +++ b/theater/base.py @@ -167,7 +167,7 @@ class Base: def scramble_interceptors(self, multiplier: float) -> typing.Dict[PlaneType, int]: return self._find_best_planes(CAP, self.scramble_count(multiplier, CAP)) - def assemble_cap(self) -> typing.Dict[Armor, int]: + def assemble_attack(self) -> typing.Dict[Armor, int]: return self._find_best_armor(PinpointStrike, self.assemble_count()) def assemble_defense(self) -> typing.Dict[Armor, int]: diff --git a/ui/eventmenu.py b/ui/eventmenu.py index e2fe4992..f699100c 100644 --- a/ui/eventmenu.py +++ b/ui/eventmenu.py @@ -7,13 +7,13 @@ from game.event import * UNITTYPES_FOR_EVENTS = { - FrontlineAttackEvent: CAS, - FrontlinePatrolEvent: CAP, - InterceptEvent: CAP, - InsurgentAttackEvent: CAS, - NavalInterceptEvent: CAS, - AntiAAStrikeEvent: CAS, - InfantryTransportEvent: Embarking, + FrontlineAttackEvent: [CAS, PinpointStrike], + FrontlinePatrolEvent: [CAP], + InterceptEvent: [CAP], + InsurgentAttackEvent: [CAS], + NavalInterceptEvent: [CAS], + AntiAAStrikeEvent: [CAS], + InfantryTransportEvent: [Embarking], } @@ -102,7 +102,7 @@ class EventMenu(Menu): filter_to = UNITTYPES_FOR_EVENTS[self.event.__class__] for unit_type, count in self.base.aircraft.items(): - if filter_to and db.unit_task(unit_type) != filter_to: + if filter_to and db.unit_task(unit_type) not in filter_to: continue if unit_type in helicopter_map and self.event.__class__ != InsurgentAttackEvent: @@ -115,6 +115,9 @@ class EventMenu(Menu): label("Armor") for unit_type, count in self.base.armor.items(): + if filter_to and db.unit_task(unit_type) not in filter_to: + continue + scramble_armor_row(unit_type, count) if not self.base.total_armor: