Set carrier speed for recovery.

https://github.com/Khopa/dcs_liberation/issues/543
(cherry picked from commit d316836e909e12d46c79389d54a678e0f5f3e007)
This commit is contained in:
Dan Albert 2020-12-11 19:19:08 -08:00
parent fe658eb877
commit 1a062e2170
2 changed files with 25 additions and 2 deletions

View File

@ -37,6 +37,7 @@ def knots_to_kph(value_in_knots: float) -> int:
""" """
return int(value_in_knots * 1.852) return int(value_in_knots * 1.852)
def mps_to_knots(value_in_mps: float) -> int: def mps_to_knots(value_in_mps: float) -> int:
"""Converts Meters Per Second To Knots """Converts Meters Per Second To Knots
@ -44,6 +45,23 @@ def mps_to_knots(value_in_mps: float) -> int:
""" """
return int(value_in_mps * 1.943) return int(value_in_mps * 1.943)
def mps_to_kph(speed: float) -> int:
"""Converts meters per second to kilometers per hour.
:arg speed Speed in m/s.
"""
return int(speed * 3.6)
def kph_to_mps(speed: float) -> int:
"""Converts kilometers per hour to meters per second.
:arg speed Speed in KPH.
"""
return int(speed / 3.6)
def heading_sum(h, a) -> int: def heading_sum(h, a) -> int:
h += a h += a
if h > 360: if h > 360:

View File

@ -34,6 +34,7 @@ from game.theater.theatergroundobject import (
LhaGroundObject, ShipGroundObject, LhaGroundObject, ShipGroundObject,
) )
from game.unitmap import UnitMap from game.unitmap import UnitMap
from game.utils import knots_to_kph, kph_to_mps, mps_to_kph
from .radios import RadioFrequency, RadioRegistry from .radios import RadioFrequency, RadioRegistry
from .runways import RunwayData from .runways import RunwayData
from .tacan import TacanBand, TacanChannel, TacanRegistry from .tacan import TacanBand, TacanChannel, TacanRegistry
@ -243,12 +244,16 @@ class GenericCarrierGenerator(GenericGroundObjectGenerator):
return ship return ship
def steam_into_wind(self, group: ShipGroup) -> Optional[int]: def steam_into_wind(self, group: ShipGroup) -> Optional[int]:
brc = self.m.weather.wind_at_ground.direction + 180 wind = self.game.conditions.weather.wind.at_0m
brc = wind.direction + 180
# Aim for 25kts over the deck.
carrier_speed = knots_to_kph(25) - mps_to_kph(wind.speed)
for attempt in range(5): for attempt in range(5):
point = group.points[0].position.point_from_heading( point = group.points[0].position.point_from_heading(
brc, 100000 - attempt * 20000) brc, 100000 - attempt * 20000)
if self.game.theater.is_in_sea(point): if self.game.theater.is_in_sea(point):
group.add_waypoint(point) group.points[0].speed = kph_to_mps(carrier_speed)
group.add_waypoint(point, carrier_speed)
return brc return brc
return None return None