Merge remote-tracking branch 'wrycu/develop' into develop_khopa

# Conflicts:
#	gen/aaa.py
This commit is contained in:
Khopa
2019-07-03 19:45:03 +02:00
5 changed files with 309 additions and 210 deletions

View File

@@ -11,6 +11,33 @@ EXTRA_AA_MAX_DISTANCE = 150000
EXTRA_AA_POSITION_FROM_CP = 550
def num_sam_dead(sam_type, destroyed_count):
"""
Given a type and count of SAM units, determine if enough units were destroyed to warrant the
loss of a site
:param sam_type:
inidivudal unit name in SAM site which was destroyed
:param destroyed_count:
count of that unit type which was destroyed *in the sortie*
:return:
INT: number of sites lost
"""
sam_threshold = {
AirDefence.SAM_SR_P_19: 1,
AirDefence.SAM_SA_3_S_125_TR_SNR: 1,
AirDefence.SAM_SA_6_Kub_STR_9S91: 1,
AirDefence.SAM_SA_10_S_300PS_SR_5N66M: 1,
AirDefence.SAM_SA_10_S_300PS_TR_30N6: 1,
AirDefence.SAM_SA_10_S_300PS_CP_54K6: 1,
AirDefence.SAM_SA_10_S_300PS_SR_64H6E: 1,
AirDefence.SAM_SA_3_S_125_LN_5P73: 4,
AirDefence.SAM_SA_6_Kub_LN_2P25: 6,
AirDefence.SAM_SA_10_S_300PS_LN_5P85C: 8,
}
return int(destroyed_count / sam_threshold[sam_type])
def determine_positions(position, heading, num_units, launcher_distance, coverage=90):
"""
Given a position on the map, array a group of units in a circle a uniform distance from the unit
@@ -52,7 +79,7 @@ def determine_positions(position, heading, num_units, launcher_distance, coverag
def aaa_vehicle_group(self, country, name, _type: unittype.VehicleType, position: mapping.Point,
heading=0,
heading=0, group_size=1,
formation=unitgroup.VehicleGroup.Formation.Line,
move_formation: PointAction=PointAction.OffRoad):
"""
@@ -62,208 +89,208 @@ def aaa_vehicle_group(self, country, name, _type: unittype.VehicleType, position
"""
vg = unitgroup.VehicleGroup(self.next_group_id(), self.string(name))
heading = randint(0, 359)
if _type == AirDefence.SAM_SA_3_S_125_LN_5P73:
# 4 launchers (180 degrees all facing the same direction), 1 SR, 1 TR
num_launchers = 4
# search radar
v = self.vehicle(
name + " Unit #{nr}".format(nr=1),
AirDefence.SAM_SR_P_19,
)
v.position.x = position.x
v.position.y = position.y
v.heading = heading
vg.add_unit(v)
# track radar
v = self.vehicle(
name + " Unit #{nr}".format(nr=2),
AirDefence.SAM_SA_3_S_125_TR_SNR,
)
center_x = position.x + randint(20, 40)
center_y = position.y
v.position.x = center_x
v.position.y = center_y
v.heading = heading
vg.add_unit(v)
plop_positions = determine_positions(
position,
heading,
num_launchers,
launcher_distance=100,
coverage=180,
)
for x in range(0, num_launchers):
for i in range(1, group_size + 1):
heading = randint(0, 359)
if _type == AirDefence.SAM_SA_3_S_125_LN_5P73:
# 4 launchers (180 degrees all facing the same direction), 1 SR, 1 TR
num_launchers = 4
# search radar
v = self.vehicle(
name + " Unit #{nr}".format(nr=3+x),
AirDefence.SAM_SA_3_S_125_LN_5P73,
name + " Unit #{nr}-sr".format(nr=i),
AirDefence.SAM_SR_P_19,
)
v.position.x = position.x
v.position.y = position.y + (i - 1) * 20
v.heading = heading
vg.add_unit(v)
# track radar
v = self.vehicle(
name + " Unit #{nr}-tr".format(nr=i),
AirDefence.SAM_SA_3_S_125_TR_SNR,
)
v.position.x = plop_positions[x][0]
v.position.y = plop_positions[x][1]
v.heading = plop_positions[x][2]
center_x = position.x + randint(20, 40)
center_y = position.y + (i - 1) * 20
v.position.x = center_x
v.position.y = center_y
v.heading = heading
vg.add_unit(v)
plop_positions = determine_positions(
position,
heading,
num_launchers,
launcher_distance=100,
coverage=180,
)
for x in range(0, num_launchers):
v = self.vehicle(
name + " Unit #{nr}-{x}".format(nr=i, x=x),
AirDefence.SAM_SA_3_S_125_LN_5P73,
)
v.position.x = plop_positions[x][0]
v.position.y = plop_positions[x][1]
v.heading = plop_positions[x][2]
vg.add_unit(v)
elif _type == AirDefence.SAM_SA_6_Kub_LN_2P25:
# 6 launchers (360 degree coverage)
# 1 S/TR
# search/track radar
num_launchers = 6
v = self.vehicle(
name + " Unit #{nr}-str".format(nr=i),
AirDefence.SAM_SA_6_Kub_STR_9S91,
)
v.position.x = position.x
v.position.y = position.y + (i - 1) * 20
v.heading = heading
vg.add_unit(v)
elif _type == AirDefence.SAM_SA_6_Kub_LN_2P25:
# 6 launchers (360 degree coverage)
# 1 S/TR
# search/track radar
num_launchers = 6
v = self.vehicle(
name + " Unit #{nr}".format(nr=1),
AirDefence.SAM_SA_6_Kub_STR_9S91,
)
v.position.x = position.x
v.position.y = position.y
v.heading = heading
vg.add_unit(v)
plop_positions = determine_positions(
position,
heading,
num_launchers,
launcher_distance=100,
coverage=360,
)
for x in range(0, num_launchers):
v = self.vehicle(
name + " Unit #{nr}-{x}".format(nr=i, x=x),
AirDefence.SAM_SA_6_Kub_LN_2P25,
)
plop_positions = determine_positions(
position,
heading,
num_launchers,
launcher_distance=100,
coverage=360,
)
for x in range(0, num_launchers):
v.position.x = plop_positions[x][0]
v.position.y = plop_positions[x][1]
v.heading = plop_positions[x][2]
vg.add_unit(v)
elif _type == AirDefence.SAM_SA_10_S_300PS_LN_5P85C:
# 8 launchers - 4 directions, two in each direction
# 1 SR (offset)
# 1 TR (center)
# search radar
num_launchers = 8
v = self.vehicle(
name + " Unit #{nr}".format(nr=1+x),
AirDefence.SAM_SA_6_Kub_LN_2P25,
name + " Unit #{nr}-sr".format(nr=i),
AirDefence.SAM_SA_10_S_300PS_SR_5N66M,
)
v.position.x = position.x
v.position.y = position.y + (i - 1) * 20
v.heading = heading
vg.add_unit(v)
# track radar
v = self.vehicle(
name + " Unit #{nr}-tr".format(nr=i),
AirDefence.SAM_SA_10_S_300PS_TR_30N6,
)
v.position.x = plop_positions[x][0]
v.position.y = plop_positions[x][1]
v.heading = plop_positions[x][2]
center_x = position.x + randint(20, 40)
center_y = position.y + (i - 1) * 20
v.position.x = center_x
v.position.y = center_y
v.heading = heading
vg.add_unit(v)
elif _type == AirDefence.SAM_SA_10_S_300PS_LN_5P85C:
# 8 launchers - 4 directions, two in each direction
# 1 SR (offset)
# 1 TR (center)
# search radar
num_launchers = 8
v = self.vehicle(
name + " Unit #{nr}".format(nr=1),
AirDefence.SAM_SA_10_S_300PS_SR_5N66M,
)
v.position.x = position.x
v.position.y = position.y
v.heading = heading
vg.add_unit(v)
# track radar
v = self.vehicle(
name + " Unit #{nr}".format(nr=2),
AirDefence.SAM_SA_10_S_300PS_TR_30N6,
)
center_x = position.x + randint(20, 40)
center_y = position.y
v.position.x = center_x
v.position.y = center_y
v.heading = heading
vg.add_unit(v)
# command center
v = self.vehicle(
name + " Unit #{nr}".format(nr=3),
AirDefence.SAM_SA_10_S_300PS_CP_54K6,
)
center_x = position.x + randint(40, 60)
center_y = position.y
v.position.x = center_x
v.position.y = center_y
v.heading = heading
vg.add_unit(v)
plop_positions = determine_positions(
position,
heading,
num_launchers,
launcher_distance=150,
coverage=360,
)
for x in range(0, num_launchers):
# command center
v = self.vehicle(
name + " Unit #{nr}".format(nr=3+x),
AirDefence.SAM_SA_10_S_300PS_LN_5P85C,
name + " Unit #{nr}-c".format(nr=i),
AirDefence.SAM_SA_10_S_300PS_CP_54K6,
)
v.position.x = plop_positions[x][0]
v.position.y = plop_positions[x][1]
v.heading = plop_positions[x][2]
center_x = position.x + randint(40, 60)
center_y = position.y + (i - 1) * 20
v.position.x = center_x
v.position.y = center_y
v.heading = heading
vg.add_unit(v)
elif _type == AirDefence.SAM_SA_10_S_300PS_CP_54K6:
# 8 launchers - 4 directions, two in each direction
# 1 SR (offset)
# 1 TR (center)
# search radar
num_launchers = 8
v = self.vehicle(
name + " Unit #{nr}".format(nr=1),
AirDefence.SAM_SA_10_S_300PS_SR_64H6E,
)
v.position.x = position.x
v.position.y = position.y
v.heading = heading
vg.add_unit(v)
# track radar
v = self.vehicle(
name + " Unit #{nr}".format(nr=2),
AirDefence.SAM_SA_10_S_300PS_TR_30N6,
)
plop_positions = determine_positions(
position,
heading,
num_launchers,
launcher_distance=150,
coverage=360,
)
for x in range(0, num_launchers):
v = self.vehicle(
name + " Unit #{nr}-{x}".format(nr=i, x=x),
AirDefence.SAM_SA_10_S_300PS_LN_5P85C,
)
center_x = position.x + randint(20, 40)
center_y = position.y
v.position.x = plop_positions[x][0]
v.position.y = plop_positions[x][1]
v.heading = plop_positions[x][2]
vg.add_unit(v)
v.position.x = center_x
v.position.y = center_y
v.heading = heading
vg.add_unit(v)
# command center
v = self.vehicle(
name + " Unit #{nr}".format(nr=3),
AirDefence.SAM_SA_10_S_300PS_CP_54K6,
)
center_x = position.x + randint(40, 60)
center_y = position.y
v.position.x = center_x
v.position.y = center_y
v.heading = heading
vg.add_unit(v)
plop_positions = determine_positions(
position,
heading,
num_units=num_launchers,
launcher_distance=150,
coverage=360,
)
for x in range(0, num_launchers):
elif _type == AirDefence.SAM_SA_10_S_300PS_CP_54K6:
# 8 launchers - 4 directions, two in each direction
# 1 SR (offset)
# 1 TR (center)
# search radar
num_launchers = 8
v = self.vehicle(
name + " Unit #{nr}".format(nr=3+x),
AirDefence.SAM_SA_10_S_300PS_LN_5P85D,
name + " Unit #{nr}-sr".format(nr=i),
AirDefence.SAM_SA_10_S_300PS_SR_64H6E,
)
v.position.x = position.x
v.position.y = position.y + (i - 1) * 20
v.heading = heading
vg.add_unit(v)
# track radar
v = self.vehicle(
name + " Unit #{nr}-tr".format(nr=i),
AirDefence.SAM_SA_10_S_300PS_TR_30N6,
)
v.position.x = plop_positions[x][0]
v.position.y = plop_positions[x][1]
v.heading = plop_positions[x][2]
center_x = position.x + randint(20, 40)
center_y = position.y + (i - 1) * 20
v.position.x = center_x
v.position.y = center_y
v.heading = heading
vg.add_unit(v)
# command center
v = self.vehicle(
name + " Unit #{nr}-c".format(nr=i),
AirDefence.SAM_SA_10_S_300PS_CP_54K6,
)
center_x = position.x + randint(40, 60)
center_y = position.y + (i - 1) * 20
v.position.x = center_x
v.position.y = center_y
v.heading = heading
vg.add_unit(v)
plop_positions = determine_positions(
position,
heading,
num_units=num_launchers,
launcher_distance=150,
coverage=360,
)
for x in range(0, num_launchers):
v = self.vehicle(
name + " Unit #{nr}-{x}".format(nr=i, x=x),
AirDefence.SAM_SA_10_S_300PS_LN_5P85D,
)
v.position.x = plop_positions[x][0]
v.position.y = plop_positions[x][1]
v.heading = plop_positions[x][2]
vg.add_unit(v)
else:
v = self.vehicle(name + " Unit #{nr}-sam".format(nr=i), _type)
v.position.x = position.x
v.position.y = position.y + (i - 1) * 20
v.heading = heading
vg.add_unit(v)
else:
v = self.vehicle(name + " Unit #{nr}".format(nr=1), _type)
v.position.x = position.x
v.position.y = position.y # + (i - 1) * 20
v.heading = heading
vg.add_unit(v)
wp = vg.add_waypoint(vg.units[0].position, move_formation, 0)
wp.ETA_locked = True
if _type.eplrs:
wp.tasks.append(task.EPLRS(self.next_eplrs("vehicle")))
@@ -296,7 +323,8 @@ class AAConflictGenerator:
country=self.conflict.defenders_country,
name=namegen.next_unit_name(self.conflict.defenders_country, type),
_type=type,
position=p)
position=p,
group_size=1)
class ExtraAAConflictGenerator: