Skip to content

Commit

Permalink
Generate AA & armor to defend airbase. Destruction status correctly t…
Browse files Browse the repository at this point in the history
…racked.
  • Loading branch information
Khopa committed Oct 13, 2019
1 parent bd66dcb commit 09b8ff6
Show file tree
Hide file tree
Showing 55 changed files with 289 additions and 117 deletions.
7 changes: 5 additions & 2 deletions game/factions/china_2000.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@

Mi_8MT,

AirDefence.AAA_ZU_23_Closed,
AirDefence.Rapier_FSA_Launcher, # Standing as PL-9C Shorad
AirDefence.SAM_SA_10_S_300PS_LN_5P85C, # Standing as HQ-9+
AirDefence.SAM_SA_6_Kub_LN_2P25,
AirDefence.HQ_7_Self_Propelled_LN,
Expand All @@ -41,5 +39,10 @@
Bulk_cargo_ship_Yakushev,
Dry_cargo_ship_Ivanov,
Tanker_Elnya_160
],
"shorad":[
AirDefence.AAA_ZU_23_Closed,
AirDefence.Rapier_FSA_Launcher, # Standing as PL-9C Shorad
AirDefence.HQ_7_Self_Propelled_LN
]
}
4 changes: 4 additions & 0 deletions game/factions/france_1995.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,9 @@
CVN_74_John_C__Stennis,
LHA_1_Tarawa,
Armed_speedboat,

], "shorad":[
AirDefence.HQ_7_Self_Propelled_LN,
AirDefence.SAM_Roland_ADS
]
}
5 changes: 4 additions & 1 deletion game/factions/germany_1990.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@
Unarmed.Transport_M818,
Infantry.Infantry_M4,

AirDefence.SPAAA_Gepard,
AirDefence.SAM_Roland_ADS,
AirDefence.SAM_Hawk_PCP,

CVN_74_John_C__Stennis,
LHA_1_Tarawa,
Armed_speedboat,
],
"shorad":[
AirDefence.SPAAA_Gepard,
AirDefence.SAM_Roland_ADS,
]
}
11 changes: 8 additions & 3 deletions game/factions/india_2010.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,17 @@

AirDefence.SAM_SA_6_Kub_LN_2P25,
AirDefence.SAM_SA_3_S_125_LN_5P73,
AirDefence.SAM_SA_8_Osa_9A33,
AirDefence.SAM_SA_13_Strela_10M3_9A35M3,
AirDefence.SAM_SA_19_Tunguska_2S6,

CVN_74_John_C__Stennis,
LHA_1_Tarawa,
Armed_speedboat,
],
"shorad":[
AirDefence.SAM_SA_8_Osa_9A33,
AirDefence.AAA_ZU_23_Emplacement,
AirDefence.SPAAA_ZSU_23_4_Shilka,
AirDefence.SAM_SA_13_Strela_10M3_9A35M3,
AirDefence.SAM_SA_8_Osa_9A33,
AirDefence.SAM_SA_19_Tunguska_2S6
]
}
4 changes: 4 additions & 0 deletions game/factions/iran_2015.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,9 @@
Bulk_cargo_ship_Yakushev,
Dry_cargo_ship_Ivanov,
Tanker_Elnya_160
],
"shorad":[
AirDefence.HQ_7_Self_Propelled_LN,
AirDefence.AAA_ZU_23_Insurgent_Closed
]
}
3 changes: 3 additions & 0 deletions game/factions/israel_2000.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,8 @@
CVN_74_John_C__Stennis,
LHA_1_Tarawa,
Armed_speedboat,
],
"shorad":[
AirDefence.SAM_Avenger_M1097
]
}
4 changes: 3 additions & 1 deletion game/factions/italy_1990.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@
CVN_74_John_C__Stennis,
LHA_1_Tarawa,
Armed_speedboat,
]
], "shorad":[
AirDefence.SAM_Avenger_M1097,
]
}
3 changes: 3 additions & 0 deletions game/factions/netherlands_1990.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@
CVN_74_John_C__Stennis,
LHA_1_Tarawa,
Armed_speedboat,
],
"shorad":[
AirDefence.SAM_Avenger_M1097
]
}
4 changes: 4 additions & 0 deletions game/factions/north_korea_2000.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,9 @@
Bulk_cargo_ship_Yakushev,
Dry_cargo_ship_Ivanov,
Tanker_Elnya_160
],
"shorad":[
AirDefence.AAA_ZU_23_Emplacement,
AirDefence.SPAAA_ZSU_23_4_Shilka
]
}
4 changes: 3 additions & 1 deletion game/factions/russia_1965.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

Mi_8MT,

AirDefence.AAA_ZU_23_Closed,
AirDefence.SAM_SA_6_Kub_LN_2P25,
AirDefence.SAM_SA_2_LN_SM_90,
AirDefence.SAM_SA_3_S_125_LN_5P73,
Expand All @@ -41,5 +40,8 @@
Bulk_cargo_ship_Yakushev,
Dry_cargo_ship_Ivanov,
Tanker_Elnya_160
],
"shorad":[
AirDefence.AAA_ZU_23_Closed
]
}
4 changes: 4 additions & 0 deletions game/factions/russia_1975.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,9 @@
Bulk_cargo_ship_Yakushev,
Dry_cargo_ship_Ivanov,
Tanker_Elnya_160
],
"shorad":[
AirDefence.AAA_ZU_23_Emplacement,
AirDefence.SPAAA_ZSU_23_4_Shilka
]
}
5 changes: 5 additions & 0 deletions game/factions/russia_1990.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,10 @@
Bulk_cargo_ship_Yakushev,
Dry_cargo_ship_Ivanov,
Tanker_Elnya_160
],
"shorad":[
AirDefence.SAM_SA_9_Strela_1_9P31,
AirDefence.SAM_SA_13_Strela_10M3_9A35M3,
AirDefence.SPAAA_ZSU_23_4_Shilka
]
}
5 changes: 4 additions & 1 deletion game/factions/russia_2010.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
Ka_50,
Mi_8MT,

AirDefence.SPAAA_ZSU_23_4_Shilka,
AirDefence.SAM_SA_19_Tunguska_2S6,
AirDefence.SAM_SA_11_Buk_LN_9A310M1,
AirDefence.SAM_SA_10_S_300PS_LN_5P85C,
Expand All @@ -46,5 +45,9 @@
Bulk_cargo_ship_Yakushev,
Dry_cargo_ship_Ivanov,
Tanker_Elnya_160,
],
"shorad":[
AirDefence.SAM_SA_19_Tunguska_2S6,
AirDefence.SAM_SA_13_Strela_10M3_9A35M3
]
}
2 changes: 2 additions & 0 deletions game/factions/spain_1990.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@
CVN_74_John_C__Stennis,
LHA_1_Tarawa,
Armed_speedboat,
], "shorad":[
AirDefence.SAM_Avenger_M1097,
]
}
5 changes: 4 additions & 1 deletion game/factions/turkey_2005.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

Armor.MBT_Leopard_2,
Armor.MBT_Leopard_1A3,
Armor.MBT_M60A3_Patton, # Standing as VAB
Armor.MBT_M60A3_Patton,
Armor.APC_Cobra,
Armor.APC_BTR_80,

Expand All @@ -33,5 +33,8 @@
CVN_74_John_C__Stennis,
LHA_1_Tarawa,
Armed_speedboat,
], "shorad":[
AirDefence.AAA_ZU_23_Emplacement,
AirDefence.SPAAA_ZSU_23_4_Shilka
]
}
3 changes: 3 additions & 0 deletions game/factions/usa_1960.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@
CVN_74_John_C__Stennis,
LHA_1_Tarawa,
Armed_speedboat,
],
"shorad":[
AirDefence.AAA_Vulcan_M163
]
}
5 changes: 4 additions & 1 deletion game/factions/usa_1965.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@
Unarmed.Transport_M818,
Infantry.Infantry_M4,

AirDefence.AAA_Vulcan_M163,
AirDefence.SAM_Chaparral_M48,
AirDefence.SAM_Hawk_PCP,

CVN_74_John_C__Stennis,
LHA_1_Tarawa,
Armed_speedboat,
],
"shorad":[
AirDefence.AAA_Vulcan_M163,
AirDefence.SAM_Chaparral_M48
]
}
4 changes: 3 additions & 1 deletion game/factions/usa_1990.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@
Infantry.Infantry_M4,

AirDefence.SAM_Hawk_PCP,
AirDefence.SAM_Avenger_M1097,


CVN_74_John_C__Stennis,
LHA_1_Tarawa,
Armed_speedboat,
], "shorad":[
AirDefence.SAM_Avenger_M1097,
]
}
2 changes: 2 additions & 0 deletions game/factions/usa_2005.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,7 @@
CVN_74_John_C__Stennis,
LHA_1_Tarawa,
Armed_speedboat,
], "shorad":[
AirDefence.SAM_Avenger_M1097,
]
}
2 changes: 1 addition & 1 deletion game/operation/operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def generate(self):
else:
self.current_mission.groundControl.red_tactical_commander = self.ca_slots

self.extra_aagen.generate()
#self.extra_aagen.generate()

# triggers
if self.game.is_player_attack(self.conflict.attackers_country):
Expand Down
2 changes: 1 addition & 1 deletion gen/aircraft.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def generate_patrol_group(self, cp: ControlPoint, country):

patrolled = []
for ground_object in cp.ground_objects:
if not ground_object.group_id in patrolled:
if not ground_object.group_id in patrolled and not ground_object.airbase_group:
group.add_waypoint(ground_object.position, patrol_alt)
patrolled.append(ground_object.group_id)

Expand Down
24 changes: 24 additions & 0 deletions gen/defenses/armor_group_generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import random

from dcs.vehicles import Armor

from game import db
from gen.defenses.armored_group_generator import ArmoredGroupGenerator


def generate_armor_group(faction:str, game, ground_object):
"""
This generate a SAM group
:param parentCp: The parent control point
:param ground_object: The ground object which will own the sam group
:param country: Owner country
:return: Nothing, but put the group reference inside the ground object
"""

possible_unit = [u for u in db.FACTIONS[faction]["units"] if u in Armor.__dict__.values()]
if len(possible_unit) > 0:
unit_type = random.choice(possible_unit)
generator = ArmoredGroupGenerator(game, ground_object, unit_type)
generator.generate()
return generator.get_generated_group()
return None
27 changes: 27 additions & 0 deletions gen/defenses/armored_group_generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import random

from gen.sam.group_generator import GroupGenerator


class ArmoredGroupGenerator(GroupGenerator):

def __init__(self, game, ground_object, unit_type):
super(ArmoredGroupGenerator, self).__init__(game, ground_object)
self.unit_type = unit_type

def generate(self):

grid_x = random.randint(2, 3)
grid_y = random.randint(1, 2)

spacing = random.randint(30, 80)

index = 0
for i in range(grid_x):
for j in range(grid_y):
index = index + 1
self.add_unit(self.unit_type, "Armor#" + str(index),
self.position.x + spacing * i,
self.position.y + spacing * j, self.heading)


4 changes: 2 additions & 2 deletions gen/sam/aaa_bofors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

from dcs.vehicles import AirDefence

from gen.sam.group_generator import AntiAirGroupGenerator
from gen.sam.group_generator import GroupGenerator


class BoforsGenerator(AntiAirGroupGenerator):
class BoforsGenerator(GroupGenerator):
"""
This generate a Bofors flak artillery group
"""
Expand Down
4 changes: 2 additions & 2 deletions gen/sam/aaa_flak36.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

from dcs.vehicles import AirDefence

from gen.sam.group_generator import AntiAirGroupGenerator
from gen.sam.group_generator import GroupGenerator


class Flak36Generator(AntiAirGroupGenerator):
class Flak36Generator(GroupGenerator):
"""
This generate a Bofors flak artillery group
"""
Expand Down
4 changes: 2 additions & 2 deletions gen/sam/aaa_zu23_insurgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

from dcs.vehicles import AirDefence

from gen.sam.group_generator import AntiAirGroupGenerator
from gen.sam.group_generator import GroupGenerator


class ZU23InsurgentGenerator(AntiAirGroupGenerator):
class ZU23InsurgentGenerator(GroupGenerator):
"""
This generate a ZU23 insurgent flak artillery group
"""
Expand Down
4 changes: 2 additions & 2 deletions gen/sam/group_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from dcs.unit import Vehicle


class AntiAirGroupGenerator():
class GroupGenerator():

def __init__(self, game, ground_object, group_object_group_id):
def __init__(self, game, ground_object):
self.game = game
self.go = ground_object
self.position = ground_object.position
Expand Down
4 changes: 2 additions & 2 deletions gen/sam/sam_avenger.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

from dcs.vehicles import AirDefence, Unarmed

from gen.sam.group_generator import AntiAirGroupGenerator
from gen.sam.group_generator import GroupGenerator


class AvengerGenerator(AntiAirGroupGenerator):
class AvengerGenerator(GroupGenerator):
"""
This generate an Avenger group
"""
Expand Down
Loading

0 comments on commit 09b8ff6

Please sign in to comment.