Support for Bandit's cloud presets mod (v15)

This commit is contained in:
Raffson
2024-12-26 01:35:30 +01:00
parent f3b1964e06
commit 3ef6ae20c7
8 changed files with 398 additions and 5 deletions

View File

@@ -462,7 +462,7 @@ class Settings:
"range is defined in the helicopter's yaml specification."
),
)
# Campaign management
# General
squadron_random_chance: int = bounded_int_option(
@@ -501,6 +501,13 @@ class Settings:
"assigned to their primary task."
),
)
use_bandit_clouds: bool = boolean_option(
"Use Bandit's clouds",
page=CAMPAIGN_MANAGEMENT_PAGE,
section=GENERAL_SECTION,
default=False,
detail=("If checked, Bandit's cloud presets will become available."),
)
# Pilots and Squadrons
ai_pilot_levelling: bool = boolean_option(

View File

@@ -2,9 +2,10 @@ from __future__ import annotations
import random
from dataclasses import dataclass, field
from math import ceil, floor
from typing import Optional
from dcs.cloud_presets import Clouds as PydcsClouds
from dcs.cloud_presets import CLOUD_PRESETS
from dcs.weather import Weather as PydcsWeather, CloudPreset
@@ -18,14 +19,14 @@ class Clouds:
@classmethod
def random_preset(cls, rain: bool) -> Clouds:
clouds = (p.value for p in PydcsClouds)
clouds = (p.value for _, p in CLOUD_PRESETS.items())
if rain:
presets = [p for p in clouds if "Rain" in p.name]
else:
presets = [p for p in clouds if "Rain" not in p.name]
preset = random.choice(presets)
return Clouds(
base=random.randint(preset.min_base, preset.max_base),
base=random.randint(ceil(preset.min_base), floor(preset.max_base)),
density=0,
thickness=0,
precipitation=PydcsWeather.Preceptions.None_,