mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Made it possible to capture airbase ingame;
This commit is contained in:
parent
3f5f4f4bb1
commit
a7e202bbc8
@ -1,6 +1,7 @@
|
|||||||
import typing
|
import typing
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from dcs.action import Coalition
|
||||||
from dcs.unittype import UnitType
|
from dcs.unittype import UnitType
|
||||||
from dcs.task import *
|
from dcs.task import *
|
||||||
from dcs.vehicles import AirDefence
|
from dcs.vehicles import AirDefence
|
||||||
@ -189,6 +190,38 @@ class Event:
|
|||||||
if ucount == 0:
|
if ucount == 0:
|
||||||
ground_object.is_dead = True
|
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):
|
def skip(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@ -50,7 +50,8 @@ class StrikeEvent(Event):
|
|||||||
def commit(self, debriefing: Debriefing):
|
def commit(self, debriefing: Debriefing):
|
||||||
super(StrikeEvent, self).commit(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):
|
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"
|
assert CAP in flights and CAS in flights and SEAD in flights and len(flights) == 3, "Invalid flights"
|
||||||
|
|||||||
@ -52,7 +52,7 @@ local function onEvent(event)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if event.id == world.event.S_EVENT_BASE_CAPTURED and event.place then
|
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
|
end
|
||||||
|
|
||||||
if event.id == world.event.S_EVENT_MISSION_END then
|
if event.id == world.event.S_EVENT_MISSION_END then
|
||||||
|
|||||||
@ -33,6 +33,12 @@ class Debriefing:
|
|||||||
self.weapons_fired = state_data["weapons_fired"]
|
self.weapons_fired = state_data["weapons_fired"]
|
||||||
self.mission_ended = state_data["mission_ended"]
|
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.player_country_id = db.country_id_from_name(game.player_country)
|
||||||
self.enemy_country_id = db.country_id_from_name(game.enemy_country)
|
self.enemy_country_id = db.country_id_from_name(game.enemy_country)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user