From a7e202bbc80447733c401d255f5bfbc709d3e774 Mon Sep 17 00:00:00 2001 From: Khopa Date: Sun, 13 Oct 2019 05:16:34 +0200 Subject: [PATCH] Made it possible to capture airbase ingame; --- game/event/event.py | 33 ++++++++++++++++++++++++++++ game/event/strike.py | 3 ++- resources/scripts/dcs_liberation.lua | 2 +- userdata/debriefing.py | 6 +++++ 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/game/event/event.py b/game/event/event.py index 13dc259c..841093e7 100644 --- a/game/event/event.py +++ b/game/event/event.py @@ -1,6 +1,7 @@ import typing import logging +from dcs.action import Coalition from dcs.unittype import UnitType from dcs.task import * from dcs.vehicles import AirDefence @@ -189,6 +190,38 @@ class Event: if ucount == 0: ground_object.is_dead = True + # ------------------------------ + # Captured bases + + if self.game.player_country in db.BLUEFOR_FACTIONS: + coalition = 2 # Value in DCS mission event for BLUE + else: + coalition = 1 # Value in DCS mission event for RED + + for captured in debriefing.base_capture_events: + try: + id = int(captured.split("||")[0]) + new_owner_coalition = int(captured.split("||")[1]) + + for cp in self.game.theater.controlpoints: + if cp.id == id: + if cp.captured and new_owner_coalition != coalition: + cp.captured = False + cp.base.aircraft = {} + cp.base.armor = {} + cp.base.aa = {} + for g in cp.ground_objects: + g.groups = [] + elif not(cp.captured) and new_owner_coalition == coalition: + cp.captured = True + cp.base.aircraft = {} + cp.base.armor = {} + cp.base.aa = {} + for g in cp.ground_objects: + g.groups = [] + except Exception as e: + print(e) + def skip(self): pass diff --git a/game/event/strike.py b/game/event/strike.py index 9fc35bcc..1f6aa3e8 100644 --- a/game/event/strike.py +++ b/game/event/strike.py @@ -50,7 +50,8 @@ class StrikeEvent(Event): def commit(self, debriefing: Debriefing): super(StrikeEvent, self).commit(debriefing) - self.to_cp.base.affect_strength(-self.SINGLE_OBJECT_STRENGTH_INFLUENCE * len(debriefing.destroyed_objects)) + #self.to_cp.base.affect_strength(-self.SINGLE_OBJECT_STRENGTH_INFLUENCE * len(debriefing.destroyed_objects)) + pass def player_attacking(self, flights: db.TaskForceDict): assert CAP in flights and CAS in flights and SEAD in flights and len(flights) == 3, "Invalid flights" diff --git a/resources/scripts/dcs_liberation.lua b/resources/scripts/dcs_liberation.lua index a45bba90..467042d5 100644 --- a/resources/scripts/dcs_liberation.lua +++ b/resources/scripts/dcs_liberation.lua @@ -52,7 +52,7 @@ local function onEvent(event) end if event.id == world.event.S_EVENT_BASE_CAPTURED and event.place then - base_capture_events[#base_capture_events + 1] = event.place.getName(event.place) .. "||" .. event.place.getCoalition(event.place) + base_capture_events[#base_capture_events + 1] = event.place.getID(event.place) .. "||" .. event.place.getCoalition(event.place) .. "||" .. event.place.getName(event.place) end if event.id == world.event.S_EVENT_MISSION_END then diff --git a/userdata/debriefing.py b/userdata/debriefing.py index e40a52cc..9b04de4a 100644 --- a/userdata/debriefing.py +++ b/userdata/debriefing.py @@ -33,6 +33,12 @@ class Debriefing: self.weapons_fired = state_data["weapons_fired"] self.mission_ended = state_data["mission_ended"] + print(self.base_capture_events) + print(self.killed_aircrafts) + print(self.killed_ground_units) + print(self.weapons_fired) + print(self.mission_ended) + self.player_country_id = db.country_id_from_name(game.player_country) self.enemy_country_id = db.country_id_from_name(game.enemy_country)