diff --git a/game/event/event.py b/game/event/event.py index ea377e1c..39692148 100644 --- a/game/event/event.py +++ b/game/event/event.py @@ -79,7 +79,7 @@ class Event: self.operation.prepare(self.game.theater.terrain, is_quick=False) self.operation.generate() - self.operation.mission.save(persistency.mission_path_for("liberation_nextturn.miz")) + self.operation.current_mission.save(persistency.mission_path_for("liberation_nextturn.miz")) self.environment_settings = self.operation.environment_settings def generate_quick(self): @@ -88,7 +88,7 @@ class Event: self.operation.prepare(self.game.theater.terrain, is_quick=True) self.operation.generate() - self.operation.mission.save(persistency.mission_path_for("liberation_nextturn_quick.miz")) + self.operation.current_mission.save(persistency.mission_path_for("liberation_nextturn_quick.miz")) def commit(self, debriefing: Debriefing): for country, losses in debriefing.destroyed_units.items(): diff --git a/game/game.py b/game/game.py index 3215202f..f3f003a8 100644 --- a/game/game.py +++ b/game/game.py @@ -80,7 +80,7 @@ AWACS_BUDGET_COST = 4 # Initial budget value PLAYER_BUDGET_INITIAL = 170 # Base post-turn bonus value -PLAYER_BUDGET_BASE = 17 +PLAYER_BUDGET_BASE = 14 # Bonus multiplier logarithm base PLAYER_BUDGET_IMPORTANCE_LOG = 2 diff --git a/game/operation/baseattack.py b/game/operation/baseattack.py index 3c11a203..f87ced61 100644 --- a/game/operation/baseattack.py +++ b/game/operation/baseattack.py @@ -37,13 +37,13 @@ class BaseAttackOperation(Operation): self.attackers_starting_position = None conflict = Conflict.capture_conflict( - attacker=self.mission.country(self.attacker_name), - defender=self.mission.country(self.defender_name), + attacker=self.current_mission.country(self.attacker_name), + defender=self.current_mission.country(self.defender_name), from_cp=self.from_cp, to_cp=self.to_cp, theater=self.game.theater ) - self.initialize(mission=self.mission, + self.initialize(mission=self.current_mission, conflict=conflict) def generate(self): diff --git a/game/operation/frontlineattack.py b/game/operation/frontlineattack.py index d8b11c86..bc131a22 100644 --- a/game/operation/frontlineattack.py +++ b/game/operation/frontlineattack.py @@ -26,14 +26,14 @@ class FrontlineAttackOperation(Operation): self.defenders_starting_position = None conflict = Conflict.frontline_cas_conflict( - attacker=self.mission.country(self.attacker_name), - defender=self.mission.country(self.defender_name), + attacker=self.current_mission.country(self.attacker_name), + defender=self.current_mission.country(self.defender_name), from_cp=self.from_cp, to_cp=self.to_cp, theater=self.game.theater ) - self.initialize(mission=self.mission, + self.initialize(mission=self.current_mission, conflict=conflict) def generate(self): diff --git a/game/operation/frontlinepatrol.py b/game/operation/frontlinepatrol.py index 0761aa2a..877b8299 100644 --- a/game/operation/frontlinepatrol.py +++ b/game/operation/frontlinepatrol.py @@ -32,14 +32,14 @@ class FrontlinePatrolOperation(Operation): self.defenders_starting_position = None conflict = Conflict.frontline_cap_conflict( - attacker=self.mission.country(self.attacker_name), - defender=self.mission.country(self.defender_name), + attacker=self.current_mission.country(self.attacker_name), + defender=self.current_mission.country(self.defender_name), from_cp=self.from_cp, to_cp=self.to_cp, theater=self.game.theater ) - self.initialize(mission=self.mission, + self.initialize(mission=self.current_mission, conflict=conflict) def generate(self): diff --git a/game/operation/infantrytransport.py b/game/operation/infantrytransport.py index b35f0973..4ff4128d 100644 --- a/game/operation/infantrytransport.py +++ b/game/operation/infantrytransport.py @@ -15,14 +15,14 @@ class InfantryTransportOperation(Operation): super(InfantryTransportOperation, self).prepare(terrain, is_quick) conflict = Conflict.transport_conflict( - attacker=self.mission.country(self.attacker_name), - defender=self.mission.country(self.defender_name), + attacker=self.current_mission.country(self.attacker_name), + defender=self.current_mission.country(self.defender_name), from_cp=self.from_cp, to_cp=self.to_cp, theater=self.game.theater ) - self.initialize(mission=self.mission, + self.initialize(mission=self.current_mission, conflict=conflict) def generate(self): diff --git a/game/operation/insurgentattack.py b/game/operation/insurgentattack.py index 1f1c1cba..0afe950c 100644 --- a/game/operation/insurgentattack.py +++ b/game/operation/insurgentattack.py @@ -17,14 +17,14 @@ class InsurgentAttackOperation(Operation): super(InsurgentAttackOperation, self).prepare(terrain, is_quick) conflict = Conflict.ground_attack_conflict( - attacker=self.mission.country(self.attacker_name), - defender=self.mission.country(self.defender_name), + attacker=self.current_mission.country(self.attacker_name), + defender=self.current_mission.country(self.defender_name), from_cp=self.from_cp, to_cp=self.to_cp, theater=self.game.theater ) - self.initialize(mission=self.mission, + self.initialize(mission=self.current_mission, conflict=conflict) def generate(self): diff --git a/game/operation/intercept.py b/game/operation/intercept.py index b1ad1ee2..14d4e344 100644 --- a/game/operation/intercept.py +++ b/game/operation/intercept.py @@ -28,14 +28,14 @@ class InterceptOperation(Operation): self.attackers_starting_position = None conflict = Conflict.intercept_conflict( - attacker=self.mission.country(self.attacker_name), - defender=self.mission.country(self.defender_name), + attacker=self.current_mission.country(self.attacker_name), + defender=self.current_mission.country(self.defender_name), from_cp=self.from_cp, to_cp=self.to_cp, theater=self.game.theater ) - self.initialize(mission=self.mission, + self.initialize(mission=self.current_mission, conflict=conflict) def generate(self): diff --git a/game/operation/navalintercept.py b/game/operation/navalintercept.py index fb373d23..b4ab9157 100644 --- a/game/operation/navalintercept.py +++ b/game/operation/navalintercept.py @@ -23,14 +23,14 @@ class NavalInterceptionOperation(Operation): self.attackers_starting_position = None conflict = Conflict.naval_intercept_conflict( - attacker=self.mission.country(self.attacker_name), - defender=self.mission.country(self.defender_name), + attacker=self.current_mission.country(self.attacker_name), + defender=self.current_mission.country(self.defender_name), from_cp=self.from_cp, to_cp=self.to_cp, theater=self.game.theater ) - self.initialize(self.mission, conflict) + self.initialize(self.current_mission, conflict) def generate(self): self.prepare_carriers(db.unitdict_from(self.strikegroup)) diff --git a/game/operation/operation.py b/game/operation/operation.py index 2631da4e..509228da 100644 --- a/game/operation/operation.py +++ b/game/operation/operation.py @@ -11,7 +11,9 @@ class Operation: attackers_starting_position = None # type: db.StartingPosition defenders_starting_position = None # type: db.StartingPosition - mission = None # type: dcs.Mission + current_mission = None # type: dcs.Mission + regular_mission = None # type: dcs.Mission + quick_mission = None # type: dcs.Mission conflict = None # type: Conflict armorgen = None # type: ArmorConflictGenerator airgen = None # type: AircraftConflictGenerator @@ -51,7 +53,7 @@ class Operation: return True def initialize(self, mission: Mission, conflict: Conflict): - self.mission = mission + self.current_mission = mission self.conflict = conflict self.armorgen = ArmorConflictGenerator(mission, conflict) self.airgen = AircraftConflictGenerator(mission, conflict, self.game.settings) @@ -72,8 +74,13 @@ class Operation: with open("resources/default_options.lua", "r") as f: options_dict = loads(f.read())["options"] - self.mission = dcs.Mission(terrain) - self.mission.options.load_from_dict(options_dict) + self.current_mission = dcs.Mission(terrain) + if is_quick: + self.quick_mission = self.current_mission + else: + self.regular_mission = self.current_mission + + self.current_mission.options.load_from_dict(options_dict) self.is_quick = is_quick if is_quick: @@ -107,11 +114,11 @@ class Operation: self.briefinggen.append_frequency("AWACS", "133 MHz AM") # combined arms - self.mission.groundControl.pilot_can_control_vehicles = self.ca_slots > 0 - if self.game.player in [country.name for country in self.mission.coalition["blue"].countries.values()]: - self.mission.groundControl.blue_tactical_commander = self.ca_slots + self.current_mission.groundControl.pilot_can_control_vehicles = self.ca_slots > 0 + if self.game.player in [country.name for country in self.current_mission.coalition["blue"].countries.values()]: + self.current_mission.groundControl.blue_tactical_commander = self.ca_slots else: - self.mission.groundControl.red_tactical_commander = self.ca_slots + self.current_mission.groundControl.red_tactical_commander = self.ca_slots # ground infrastructure self.groundobjectgen.generate() diff --git a/game/operation/strike.py b/game/operation/strike.py index 647434bd..b368ed8a 100644 --- a/game/operation/strike.py +++ b/game/operation/strike.py @@ -24,14 +24,14 @@ class StrikeOperation(Operation): self.attackers_starting_position = None conflict = Conflict.strike_conflict( - attacker=self.mission.country(self.attacker_name), - defender=self.mission.country(self.defender_name), + attacker=self.current_mission.country(self.attacker_name), + defender=self.current_mission.country(self.defender_name), from_cp=self.from_cp, to_cp=self.to_cp, theater=self.game.theater ) - self.initialize(mission=self.mission, + self.initialize(mission=self.current_mission, conflict=conflict) def generate(self): diff --git a/gen/triggergen.py b/gen/triggergen.py index 3bf77a0b..d01b2fdb 100644 --- a/gen/triggergen.py +++ b/gen/triggergen.py @@ -16,7 +16,7 @@ from gen.airsupportgen import AirSupportConflictGenerator from gen import * PUSH_TRIGGER_SIZE = 3000 -PUSH_TRIGGER_ACTIVATION_AGL = 100 +PUSH_TRIGGER_ACTIVATION_AGL = 25 REGROUP_ZONE_DISTANCE = 12000 REGROUP_ALT = 5000 @@ -25,7 +25,7 @@ TRIGGER_WAYPOINT_OFFSET = 2 TRIGGER_MIN_DISTANCE_FROM_START = 10000 TRIGGER_RADIUS_MINIMUM = 20000 -TRIGGER_RADIUS_SMALL = 30000 +TRIGGER_RADIUS_SMALL = 50000 TRIGGER_RADIUS_MEDIUM = 100000 TRIGGER_RADIUS_LARGE = 150000 diff --git a/ui/eventmenu.py b/ui/eventmenu.py index 4cb7335b..64b9c580 100644 --- a/ui/eventmenu.py +++ b/ui/eventmenu.py @@ -194,6 +194,12 @@ class EventMenu(Menu): self.error_label["text"] = "Need at least one player in flight {}".format(self.event.flight_name(task)) return + if isinstance(self.event, FrontlineAttackEvent) or isinstance(self.event, FrontlinePatrolEvent): + if tasks_scramble_counts.get(PinpointStrike, 0) == 0: + self.error_label["text"] = "No ground vehicles assigned to attack!" + return + + if self.game.is_player_attack(self.event): self.event.player_attacking(flights) else: diff --git a/ui/eventresultsmenu.py b/ui/eventresultsmenu.py index 40d7ef05..2424f9f5 100644 --- a/ui/eventresultsmenu.py +++ b/ui/eventresultsmenu.py @@ -99,12 +99,14 @@ class EventResultsMenu(Menu): Label(self.frame, text="{}".format(count), **STYLES["widget"]).grid(column=1, row=row) row += 1 - Button(self.frame, text="Okay", command=self.dismiss, **STYLES["btn-primary"]).grid(columnspan=1, row=row); + Button(self.frame, text="Okay", command=self.dismiss, **STYLES["btn-primary"]).grid(columnspan=1, row=row) row += 1 def process_debriefing(self, debriefing: Debriefing): self.debriefing = debriefing - debriefing.calculate_units(mission=self.event.operation.mission, + + debriefing.calculate_units(regular_mission=self.event.operation.regular_mission, + quick_mission=self.event.operation.quick_mission, player_name=self.game.player, enemy_name=self.game.enemy) diff --git a/userdata/debriefing.py b/userdata/debriefing.py index 895b8dac..5a5cabb7 100644 --- a/userdata/debriefing.py +++ b/userdata/debriefing.py @@ -60,11 +60,12 @@ def parse_mutliplayer_debriefing(contents: str): class Debriefing: - def __init__(self, dead_units): + def __init__(self, dead_units, trigger_state): self.destroyed_units = {} # type: typing.Dict[str, typing.Dict[UnitType, int]] self.alive_units = {} # type: typing.Dict[str, typing.Dict[UnitType, int]] self.destroyed_objects = [] # type: typing.List[str] + self._trigger_state = trigger_state self._dead_units = dead_units @classmethod @@ -99,18 +100,11 @@ class Debriefing: if event_type in ["crash", "dead"]: parse_dead_object(event) - """ - initiator_components = event["initiator"].split("|") + trigger_state = table.get("debriefing", {}).get("triggers_state", {}) - if initiator_components[0] in CATEGORY_MAP: - parse_dead_object(event) - else: - parse_dead_unit(event) - """ + return Debriefing(dead_units, trigger_state) - return Debriefing(dead_units) - - def calculate_units(self, mission: Mission, player_name: str, enemy_name: str): + def calculate_units(self, regular_mission: Mission, quick_mission: Mission, player_name: str, enemy_name: str): def count_groups(groups: typing.List[UnitType]) -> typing.Dict[UnitType, int]: result = {} for group in groups: @@ -129,6 +123,8 @@ class Debriefing: return result + mission = regular_mission if len(self._trigger_state) else quick_mission + player = mission.country(player_name) enemy = mission.country(enemy_name)