Made it possible to capture airbase ingame;

This commit is contained in:
Khopa 2019-10-13 05:16:34 +02:00
parent 3f5f4f4bb1
commit a7e202bbc8
4 changed files with 42 additions and 2 deletions

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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)