mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Fix random heading function, randomize wind better (#1619)
* Fix random heading function, randomize wind better * Use 359 as max default for random heading, for uniform distribution
This commit is contained in:
parent
90ca619839
commit
3e6d63e8f7
@ -224,7 +224,7 @@ class Heading:
|
|||||||
return cls(Heading.reduce_angle(deg))
|
return cls(Heading.reduce_angle(deg))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def random(cls, min_angle: int = 0, max_angle: int = 0) -> Heading:
|
def random(cls, min_angle: int = 0, max_angle: int = 359) -> Heading:
|
||||||
return Heading.from_degrees(random.randint(min_angle, max_angle))
|
return Heading.from_degrees(random.randint(min_angle, max_angle))
|
||||||
|
|
||||||
def __add__(self, other: Heading) -> Heading:
|
def __add__(self, other: Heading) -> Heading:
|
||||||
|
|||||||
@ -152,6 +152,8 @@ class Weather:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def random_wind(minimum: int, maximum: int) -> WindConditions:
|
def random_wind(minimum: int, maximum: int) -> WindConditions:
|
||||||
wind_direction = Heading.random()
|
wind_direction = Heading.random()
|
||||||
|
wind_direction_2000m = wind_direction + Heading.random(-90, 90)
|
||||||
|
wind_direction_8000m = wind_direction + Heading.random(-90, 90)
|
||||||
at_0m_factor = 1
|
at_0m_factor = 1
|
||||||
at_2000m_factor = 2
|
at_2000m_factor = 2
|
||||||
at_8000m_factor = 3
|
at_8000m_factor = 3
|
||||||
@ -160,8 +162,8 @@ class Weather:
|
|||||||
return WindConditions(
|
return WindConditions(
|
||||||
# Always some wind to make the smoke move a bit.
|
# Always some wind to make the smoke move a bit.
|
||||||
at_0m=Wind(wind_direction.degrees, max(1, base_wind * at_0m_factor)),
|
at_0m=Wind(wind_direction.degrees, max(1, base_wind * at_0m_factor)),
|
||||||
at_2000m=Wind(wind_direction.degrees, base_wind * at_2000m_factor),
|
at_2000m=Wind(wind_direction_2000m.degrees, base_wind * at_2000m_factor),
|
||||||
at_8000m=Wind(wind_direction.degrees, base_wind * at_8000m_factor),
|
at_8000m=Wind(wind_direction_8000m.degrees, base_wind * at_8000m_factor),
|
||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -220,7 +222,7 @@ class ClearSkies(Weather):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def generate_wind(self) -> WindConditions:
|
def generate_wind(self) -> WindConditions:
|
||||||
return self.random_wind(0, 0)
|
return self.random_wind(1, 4)
|
||||||
|
|
||||||
|
|
||||||
class Cloudy(Weather):
|
class Cloudy(Weather):
|
||||||
@ -240,7 +242,7 @@ class Cloudy(Weather):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def generate_wind(self) -> WindConditions:
|
def generate_wind(self) -> WindConditions:
|
||||||
return self.random_wind(0, 4)
|
return self.random_wind(1, 4)
|
||||||
|
|
||||||
|
|
||||||
class Raining(Weather):
|
class Raining(Weather):
|
||||||
@ -260,7 +262,7 @@ class Raining(Weather):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def generate_wind(self) -> WindConditions:
|
def generate_wind(self) -> WindConditions:
|
||||||
return self.random_wind(0, 6)
|
return self.random_wind(1, 6)
|
||||||
|
|
||||||
|
|
||||||
class Thunderstorm(Weather):
|
class Thunderstorm(Weather):
|
||||||
@ -281,7 +283,7 @@ class Thunderstorm(Weather):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def generate_wind(self) -> WindConditions:
|
def generate_wind(self) -> WindConditions:
|
||||||
return self.random_wind(0, 8)
|
return self.random_wind(1, 8)
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user