cleanups & minor fixesh

This commit is contained in:
Vasyl Horbachenko
2019-03-27 10:41:26 +02:00
parent c152b49b88
commit b697a8b40a
8 changed files with 45 additions and 26 deletions

View File

@@ -69,9 +69,15 @@ class AircraftConflictGenerator:
else:
client_count = 0
if flying_type == F_14B:
# workaround since 2 and 3 tomcat collide on carrier
group_size = 2
else:
group_size = 4
while count > 0:
group_size = min(count, 4)
client_size = max(min(client_count, 4), 0)
group_size = min(count, group_size)
client_size = max(min(client_count, group_size), 0)
yield (flying_type, group_size, client_size)
count -= group_size
@@ -183,7 +189,9 @@ class AircraftConflictGenerator:
return self._generate_inflight(name, side, unit_type, count, client_count, at)
elif isinstance(at, Group):
takeoff_ban = unit_type in db.CARRIER_TAKEOFF_BAN
if not takeoff_ban:
ai_ban = client_count == 0 and self.settings.only_player_takeoff
if not takeoff_ban and not ai_ban:
return self._generate_at_group(name, side, unit_type, count, client_count, at)
else:
return self._generate_inflight(name, side, unit_type, count, client_count, at.position)

View File

@@ -49,8 +49,8 @@ class AirSupportConflictGenerator:
)
tanker_group.points[0].tasks.append(ActivateBeaconCommand(channel=97 + i, unit_id=tanker_group.id, aa=False))
tanker_group.tasks.append(SetInvisibleCommand(True))
tanker_group.tasks.append(SetImmortalCommand(True))
tanker_group.points[0].tasks.append(SetInvisibleCommand(True))
tanker_group.points[0].tasks.append(SetImmortalCommand(True))
if is_awacs_enabled:
awacs_unit = db.find_unittype(AWACS, self.conflict.attackers_side.name)[0]
@@ -65,5 +65,5 @@ class AirSupportConflictGenerator:
start_type=StartType.Warm,
)
awacs_flight.tasks.append(SetInvisibleCommand(True))
awacs_flight.tasks.append(SetImmortalCommand(True))
awacs_flight.points[0].tasks.append(SetInvisibleCommand(True))
awacs_flight.points[0].tasks.append(SetImmortalCommand(True))

View File

@@ -35,17 +35,19 @@ class ShipGenerator:
def generate_cargo(self, units: db.ShipDict) -> typing.Collection[ShipGroup]:
groups = []
offset = 0
for unit_type, unit_count in units.items():
logging.info("shipgen: {} ({}) for {}".format(unit_type, unit_count, self.conflict.defenders_side))
group = self.m.ship_group(
country=self.conflict.defenders_side,
name=namegen.next_unit_name(self.conflict.defenders_side, unit_type),
_type=unit_type,
position=self.conflict.ground_defenders_location.random_point_within(SHIP_RANDOM_SPREAD, SHIP_RANDOM_SPREAD),
group_size=unit_count,
)
for _ in range(unit_count):
offset += 1
logging.info("shipgen: {} ({}) for {}".format(unit_type, unit_count, self.conflict.defenders_side))
group = self.m.ship_group(
country=self.conflict.defenders_side,
name=namegen.next_unit_name(self.conflict.defenders_side, unit_type),
_type=unit_type,
position=self.conflict.ground_defenders_location.random_point_within(SHIP_RANDOM_SPREAD, SHIP_RANDOM_SPREAD).point_from_heading(0, offset * SHIP_RANDOM_SPREAD)
)
group.add_waypoint(self.conflict.to_cp.position)
groups.append(group)
group.add_waypoint(self.conflict.to_cp.position)
groups.append(group)
return groups

View File

@@ -134,7 +134,7 @@ class VisualGenerator:
mission_units.add(db.unit_type_of(unit))
for unit_type in mission_units:
self.mission.static_group(self.mission.country("USA"), "a", unit_type, Point(0, 0))
self.mission.static_group(self.mission.country("USA"), "a", unit_type, Point(0, 300000), hidden=True)
def generate_target_smokes(self, target):
spread = target.size * DESTINATION_SMOKE_DISTANCE_FACTOR