anti AA operations; number of minor fixes; added harrier

This commit is contained in:
Vasyl Horbachenko
2018-06-21 01:21:43 +03:00
parent e6ccc3ceea
commit 5e42ca08c2
18 changed files with 215 additions and 72 deletions

View File

@@ -12,26 +12,27 @@ PRICES = {
C_101CC: 8,
MiG_23MLD: 20,
MiG_25PD: 24,
MiG_31: 28,
MiG_31: 26,
Su_27: 24,
Su_33: 25,
MiG_29A: 28,
MiG_29A: 26,
AJS37: 13,
F_5E: 8,
F_5E: 6,
MiG_15bis: 5,
MiG_21Bis: 8,
MiG_21Bis: 6,
AJS37: 8,
M_2000C: 18,
FA_18C_hornet: 22,
F_15C: 28,
AV8BNA: 13,
M_2000C: 13,
FA_18C_hornet: 18,
F_15C: 24,
# bomber
Su_25T: 15,
Su_24M: 18,
Su_17M4: 13,
Su_25T: 13,
Su_24M: 15,
Su_17M4: 10,
L_39ZA: 10,
MiG_29G: 18,
MiG_29G: 15,
Su_34: 22,
A_10A: 18,
@@ -97,6 +98,7 @@ UNIT_BY_TASK = {
CAS: [
MiG_15bis,
L_39ZA,
AV8BNA,
A_10A,
A_10C,
Su_25T,
@@ -148,6 +150,10 @@ SAM_BAN = [
AirDefence.SAM_SA_8_Osa_9A33,
]
TAKEOFF_BAN = [
AV8BNA,
]
EXTRA_AA = {
"Russia": AirDefence.SAM_SA_9_Strela_1_9P31,
"USA": AirDefence.SAM_Patriot_EPP_III,
@@ -167,6 +173,7 @@ UNIT_BY_COUNTRY = {
MiG_21Bis,
MiG_29A,
M_2000C,
AV8BNA,
A_10A,
A_10C,
@@ -209,6 +216,7 @@ UNIT_BY_COUNTRY = {
A_10A,
A_10C,
AV8BNA,
S_3B_Tanker,
C_130,
@@ -229,8 +237,11 @@ UNIT_BY_COUNTRY = {
PLANE_PAYLOAD_OVERRIDES = {
FA_18C_hornet: {
Escort: "AIM-9M*6, AIM-7M*2, FUEL*3",
CAP: "AIM-9M*6, AIM-7M*2, FUEL*3",
"*": "AIM-9M*6, AIM-7M*2, FUEL*3",
},
AV8BNA: {
CAS: "AS 2",
},
# TODO: figure out a way to setup su33 loadout

View File

@@ -3,3 +3,4 @@ from .groundintercept import *
from .intercept import *
from .capture import *
from .navalintercept import *
from .antiaastrike import *

View File

@@ -51,7 +51,7 @@ class AntiAAStrikeEvent(Event):
self.to_cp.base.affect_strength(-0.1)
def player_attacking(self, strikegroup: db.PlaneDict, clients: db.PlaneDict):
self.targets = self.to_cp.base.assemble_aa()
self.targets = self.to_cp.base.assemble_aa(count=self.to_cp.base.total_aa)
op = AntiAAStrikeOperation(game=self.game,
attacker_name=self.attacker_name,

View File

@@ -79,6 +79,7 @@ class CaptureEvent(Event):
self.operation = op
def player_attacking(self, cas: db.PlaneDict, escort: db.PlaneDict, armor: db.ArmorDict, clients: db.PlaneDict):
# TODO: also include CAS planes
interceptors = self.to_cp.base.scramble_sweep()
op = CaptureOperation(game=self.game,
@@ -93,6 +94,7 @@ class CaptureEvent(Event):
escort=escort,
attack=armor,
intercept=interceptors,
# TODO: should strength affect this?
defense=self.to_cp.base.armor,
aa=self.to_cp.base.assemble_aa())

View File

@@ -9,6 +9,7 @@ from userdata.debriefing import Debriefing
from theater import *
from . import db
from .settings import Settings
from .event import *
COMMISION_LIMITS_SCALE = 2
@@ -33,29 +34,32 @@ ENEMY_INTERCEPT_PROBABILITY_BASE = 5
ENEMY_CAPTURE_PROBABILITY_BASE = 4
ENEMY_GROUNDINTERCEPT_PROBABILITY_BASE = 5
ENEMY_NAVALINTERCEPT_PROBABILITY_BASE = 5
ENEMY_ANTIAASTRIKE_PROBABILITY_BASE = 5
ENEMY_INTERCEPT_GLOBAL_PROBABILITY_BASE = 5
PLAYER_INTERCEPT_PROBABILITY_BASE = 35
PLAYER_GROUNDINTERCEPT_PROBABILITY_BASE = 35
PLAYER_NAVALINTERCEPT_PROBABILITY_BASE = 35
PLAYER_ANTIAASTRIKE_PROBABILITY_BASE = 35
PLAYER_INTERCEPT_GLOBAL_PROBABILITY_BASE = 25
PLAYER_INTERCEPT_GLOBAL_PROBABILITY_LOG = 2
PLAYER_BUDGET_INITIAL = 90
PLAYER_BUDGET_BASE = 20
PLAYER_BUDGET_INITIAL = 120
PLAYER_BUDGET_BASE = 30
PLAYER_BUDGET_IMPORTANCE_LOG = 2
AWACS_BUDGET_COST = 4
class Game:
settings = None # type: Settings
budget = PLAYER_BUDGET_INITIAL
events = None # type: typing.List[Event]
pending_transfers = None # type: typing.Dict[]
player_skill = "Good"
enemy_skill = "Average"
ignored_cps = None # type: typing.Collection[ControlPoint]
def __init__(self, player_name: str, enemy_name: str, theater: ConflictTheater):
self.settings = Settings()
self.events = []
self.theater = theater
self.player = player_name
@@ -73,12 +77,12 @@ class Game:
to_cp=to_cp,
game=self))
def _generate_enemy_caps(self, ignored_cps: typing.Collection[ControlPoint] = None):
def _generate_enemy_caps(self):
for from_cp, to_cp in self.theater.conflicts(False):
if from_cp.base.total_planes == 0 or from_cp.base.total_armor == 0:
continue
if ignored_cps and to_cp in ignored_cps:
if to_cp in self.ignored_cps:
continue
if self._roll(ENEMY_CAPTURE_PROBABILITY_BASE, from_cp.base.strength):
@@ -90,13 +94,12 @@ class Game:
break
def _generate_interceptions(self):
enemy_interception = False
for from_cp, to_cp in self.theater.conflicts(False):
if from_cp.base.total_units(CAP) == 0:
continue
if enemy_interception:
break
if to_cp in self.ignored_cps:
continue
if self._roll(ENEMY_INTERCEPT_PROBABILITY_BASE, from_cp.base.strength):
self.events.append(InterceptEvent(attacker_name=self.enemy,
@@ -104,7 +107,6 @@ class Game:
from_cp=from_cp,
to_cp=to_cp,
game=self))
enemy_interception = True
break
if to_cp in self.theater.conflicts(False):
@@ -118,7 +120,6 @@ class Game:
from_cp=from_cp,
to_cp=to_cp,
game=self))
enemy_interception = True
break
for from_cp, to_cp in self.theater.conflicts(True):
@@ -141,6 +142,9 @@ class Game:
break
for from_cp, to_cp in self.theater.conflicts(False):
if to_cp in self.ignored_cps:
continue
if self._roll(ENEMY_GROUNDINTERCEPT_PROBABILITY_BASE, from_cp.base.strength):
self.events.append(GroundInterceptEvent(attacker_name=self.enemy,
defender_name=self.player,
@@ -166,6 +170,9 @@ class Game:
if to_cp.radials == LAND:
continue
if to_cp in self.ignored_cps:
continue
if self._roll(ENEMY_NAVALINTERCEPT_PROBABILITY_BASE, from_cp.base.strength):
self.events.append(NavalInterceptEvent(attacker_name=self.enemy,
defender_name=self.player,
@@ -188,6 +195,34 @@ class Game:
game=self))
break
def _generate_aastrikes(self):
for from_cp, to_cp in self.theater.conflicts(True):
if to_cp.base.total_aa == 0:
continue
if self._roll(PLAYER_ANTIAASTRIKE_PROBABILITY_BASE, from_cp.base.strength):
self.events.append(AntiAAStrikeEvent(attacker_name=self.player,
defender_name=self.enemy,
from_cp=from_cp,
to_cp=to_cp,
game=self))
break
for from_cp, to_cp in self.theater.conflicts(False):
if to_cp in self.ignored_cps:
continue
if to_cp.base.total_aa == 0:
continue
if self._roll(ENEMY_ANTIAASTRIKE_PROBABILITY_BASE, from_cp.base.strength):
self.events.append(AntiAAStrikeEvent(attacker_name=self.enemy,
defender_name=self.player,
from_cp=from_cp,
to_cp=to_cp,
game=self))
break
def _commision_units(self, cp: ControlPoint):
for for_task in [PinpointStrike, CAS, CAP, AirDefence]:
limit = COMMISION_LIMITS_FACTORS[for_task] * math.pow(cp.importance, COMMISION_LIMITS_SCALE)
@@ -253,11 +288,16 @@ class Game:
for cp in self.theater.enemy_points():
self._commision_units(cp)
self.ignored_cps = []
if ignored_cps:
self.ignored_cps = ignored_cps
self.events = [] # type: typing.List[Event]
self._fill_cap_events()
self._generate_enemy_caps(ignored_cps=ignored_cps)
self._generate_enemy_caps()
self._generate_interceptions()
self._generate_globalinterceptions()
self._generate_groundinterceptions()
self._generate_navalinterceptions()
self._generate_aastrikes()

View File

@@ -44,7 +44,7 @@ class Operation:
self.conflict = conflict
self.armorgen = ArmorConflictGenerator(mission, conflict)
self.airgen = AircraftConflictGenerator(mission, conflict)
self.airgen = AircraftConflictGenerator(mission, conflict, self.game.settings)
self.aagen = AAConflictGenerator(mission, conflict)
self.shipgen = ShipGenerator(mission, conflict)
self.awacsgen = AWACSConflictGenerator(mission, conflict, self.game)

5
game/settings.py Normal file
View File

@@ -0,0 +1,5 @@
class Settings:
player_skill = "Good"
enemy_skill = "Average"
only_player_takeoff = False