1535 Commits

Author SHA1 Message Date
Dan Albert
dc0e41c8c1 Dump develop version to 9.0.0. 2023-06-20 18:47:07 -07:00
Dan Albert
59c10f5d71 Remove save compat hacks for saves from 7.
Save compat was broken by pydcs anyway, so these now do nothing but hide
initialization bugs.
2023-06-20 18:47:07 -07:00
Dan Albert
001e7dfed9 Ignore inconsistent DCS beacon information.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3021.
2023-06-20 18:28:17 -07:00
zhexu14
c74b603d81
restore killed_ground_units as it is relied on to track scenery kills
This PR fixes a regression introduced in
https://github.com/dcs-liberation/dcs_liberation/pull/2792 where
refactoring meant that scenery deaths were not tracked correctly.

This PR has been tested by striking a scenery target and confirming that
it appears in state.json and is updated in Liberation. I've also
confirmed that ground units are tracked.
2023-06-15 03:07:54 +00:00
Dan Albert
9d43eb8f03 Handle game over.
The contents are completely uninteresting, but at least it's visible.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/978.
2023-06-12 23:43:26 -07:00
Dan Albert
36c4bb88be Sinai support.
The rest of the work is done, so bump the campaign version and update
the changelog.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2979.
2023-06-12 17:56:38 -07:00
Dan Albert
b18b371904 Basic Sinai support.
Not ready (most importantly no landmap).

https://github.com/dcs-liberation/dcs_liberation/issues/2979
2023-06-11 23:54:41 -07:00
Dan Albert
4fd2bb131b Warn for new squadron rules with old campaigns.
It's not feasible to actually check the parking limits because we can't
identify parking limits for carriers until the theater is populated.
Doing so is expensive (and depends on other NGW inputs). Instead,
compare against the version of the campaign and guess.

A new (minor) campaign version has been introduced which makes this
required to improve the UI hint. Campaigns that are compatible with the
new rules should update their version to advertise support.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2909.
2023-06-03 21:32:42 +00:00
Dan Albert
cb61dfccc4 Show parking capacities in air wing config.
This does show the theoretical parking use of full squadrons even when
the new rules are not enabled. Since limits can be enabled manually
later in the game, it's still useful information, even if it's a bit
misleading.

https://github.com/dcs-liberation/dcs_liberation/issues/2910
2023-06-03 19:31:35 +00:00
Dan Albert
7798e2970c Minor campaign version bump for Normandy 2.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2804.
2023-05-30 23:49:42 -07:00
Dan Albert
4bb60cb500 Tolerate empty settings files. 2023-05-30 23:24:58 -07:00
Dan Albert
fe96a415be Add settings for battlefield commander slots.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2235.
2023-05-30 22:06:47 -07:00
Dan Albert
6699289bf7 Add performance option to prevent missile tasks.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2508.
2023-05-30 21:47:16 -07:00
zhexu14
e50ee976ed
Add ability to convert landmap to/from miz.
This PR adds utility functions that import/export landmap files to .miz
polygons. In addition to the unit test, this PR has been tested by
writing the Caucuses & Syria landmaps to a .miz file, loading the
generated .miz file back in and checking that the loaded landmap object
is identical to the original files.
2023-05-30 21:01:05 -07:00
zhexu14
e024013093 issue 2922: make BAI plannable against missile and costal sites 2023-05-30 20:39:39 -07:00
Dan Albert
49dfa95c61 Save the TOT offset in the flight plan.
Prep work for exposing this to the UI.
2023-05-25 22:35:50 -07:00
Dan Albert
c80e5b259f Allow save compat to exist for two versions.
We want to clean up eventually, but allowing it to exist in both develop
and the release branch makes cherry picks easier.
2023-05-25 22:35:50 -07:00
Dan Albert
24e72475b4 Checkpoint game before sim, auto-revert on abort.
An alternative to
https://github.com/dcs-liberation/dcs_liberation/pull/2891 that I ended
up liking much better (I had assumed some part of the UI would fail or
at least look terrible with this approach, but it seems to work quite
well).

On by default now since it's far less frightening than the previous
thing.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2735.
2023-05-19 17:44:18 -07:00
Dan Albert
4b4c45e90f Attempt to reset the simulation on abort.
This is optional because I really don't know if I trust it. I don't see
much wrong with it (aside from the warning about not using it with auto-
resolve, because it won't restore lost aircraft), but it's really not
something I'd built for since it's not going to be possible as the RTS
features grow.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2735.
2023-05-19 01:05:25 -07:00
Dan Albert
92c3087187 Advance develop to 8.0.0-preview. 2023-05-18 22:44:39 -07:00
Dan Albert
a8b7aca4fb Make wind speed moddable.
These should probably be overridable per theater and per season, but
even with that we'll want some defaults.

https://github.com/dcs-liberation/dcs_liberation/issues/2862
2023-05-16 00:52:51 -07:00
Dan Albert
799dbfa99c Move and split up weather.py.
This is getting out of hand, and I'm about to make it worse.
2023-05-16 00:52:51 -07:00
Dan Albert
eb31a0f038 Rework wind speed Weibull inputs, tune.
The previous method of using a uniform scalar of the MSL wind speed for
higher altitudes didn't offer enough control. In particular, the shape
needs to be quite different to skew low, mid, high.

This patch reworks that system so the parameters of each distribution
are configured per-altitude level. To keep some continuity between
altitudes (on a windy day, all levels should have higher wind speeds on
average), the wind speed of the lower altitude will be added to the
scale value of the higher altitude.

Since it wasn't practical to approximate the previous behavior with the
new system, this also handles the tuning of each. The low altitude
speeds remain mostly unchanged (typically around 5 knots expect for
thunderstorms), but the average speeds for other altitudes went up to
more closely match the previous intent but without the massive
overshoot. At 2000m wind speeds are typically in the 20-25 knot range
now, and 8000m 30-50 knots.

https://www.quora.com/What-is-the-average-wind-speed-at-different-altitudes
has some of the source data, and Quora is the most authoritative source
there is. It claims that cruise altitude winds can get "as high as 150
knots", but doesn't claim anything about the average. I had a
surprisingly difficult time finding good data for cruise altitude air
speeds for non-jet stream paths (though many of our maps are in jet
streams), so I just eyeballed it from
https://turbli.com/wind-during-flights/.

https://github.com/dcs-liberation/dcs_liberation/issues/2861

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2863.
2023-05-15 22:44:17 -07:00
Dan Albert
78e2da9196 Use weibull distribution for wind generation.
Wind speeds should not be uniformly distributed. This switches to a
Weibull distribution which allegedly (see the bug) is good enough.
Experimentally that seems true as well, though I know nothing about how
wind works irl. This at least looks like it'll generate reasonable
variation in missions while keeping the 1st through 3rd quartile
behaviors from getting out of hand.

I'm very uncertain about the scaling factor aspect of this. Naively the
wind speeds at different altitudes ought to be somewhat correlated, but
I'm not sure how much, and whether this kind of scaling is at all the
right way to do it. As before, meh, close enough?

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2861.
2023-05-15 21:37:43 -07:00
Dan Albert
ca96a232f0 Revert "Use the actual Country type instead of the name."
This reverts commit bd2ec12e0f039c9500ea0dd94e7b2e4f7d168fef.

Country is both the data (name, ID, etc) and the container for groups
added to the miz, so it can't be used across multiple mission
generations. See https://github.com/pydcs/dcs/issues/314 for potential
follow up work that would let us do this.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2864.
2023-05-15 18:23:48 -07:00
Dan Albert
97c238a4bb Warn players that take off disallows new flights. 2023-05-13 16:47:56 -07:00
Dan Albert
a6c5b03212 Do not create refueling tasks without tankers.
If the package does not have a tanker, the refueling task will cause AI
flights to go to an arbitrary tanker, which may cause them to fly
through enemy territory or even go farther than their arrival airbase.

It's also not remotely possible for every AI flight in the game to
refuel in most missions. There's typically one tanker and dozens of
aircraft that would previously attempt to refuel.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2716.
2023-05-13 16:23:31 -07:00
Dan Albert
4f7932ad8a Remove old aircraft selection mode.
New mode seems to be working well.
2023-05-13 12:47:51 -07:00
Dan Albert
bd2ec12e0f Use the actual Country type instead of the name.
We want other pieces of country information (in particular the short
names). This cleans up a lot of code anyway.

As an added bonus, this now catches squadrons that used invalid names
which would previously be passed through to pydcs and... then I don't
know what would happen.
2023-05-12 22:18:40 -07:00
Dan Albert
15fa73a514 Add option to limit squadron sizes and begin full.
Adding temporarily as an option to make sure it's not a terrible idea,
but the old mode will probably go away.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1583.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2808.
2023-05-05 18:16:42 -07:00
Dan Albert
7f94b34277 Add an option to prefer primary tasked aircraft.
We're still using mostly the same aircraft selection as we have before
we added squadrons: the closest aircraft is the best choice.

This adds an option to obey the primary task set by the campaign
designer (can be overridden by players), even if the squadron is farther
away than one that is capable of it as a secondary task.

I don't expect this option to live very long. I'm making it optional for
now to give people a chance to test it, but it'll either replace the old
selection strategy or will be removed.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1892.
2023-05-04 23:08:11 -07:00
zhexu14
c9e4b5eba4 enable AEWC missions on FOBs 2023-05-04 20:35:51 -07:00
zhexu14
352c2ddc56 make BAI plannable against vehicles only 2023-05-03 10:12:15 -07:00
zhexu14
aa2a888ed0 Handle edge case where aircraft have built in TPGs 2023-05-02 00:34:18 -07:00
Dan Albert
cce9592ac8 Use task priorities from aircraft yamls.
Preferred aircraft per task are now determined by a ranking of weights
stored in the aircraft yaml files. To aid in visualizing the priorities
across aircraft, Liberation can be run with the argument
dump-task-priorities to dump a yaml file in Saved
Games/DCS/Liberation/Debug/priorities.yaml, which will show each task
along with priority sorted aircraft and their weights.

The current weights in the data were exported from the existing lists,
where each position from the bottom of the list was worth 10 (to allow
some games for less shuffling later).

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2809.
2023-04-26 23:26:23 -07:00
Dan Albert
b69def652e Add debug command to dump aircraft priorities.
https://github.com/dcs-liberation/dcs_liberation/issues/2809
2023-04-26 23:26:23 -07:00
Dan Albert
6df83485e1 Load task priorities from YAML.
Not used yet.

https://github.com/dcs-liberation/dcs_liberation/issues/2809
2023-04-26 23:26:23 -07:00
Dan Albert
2f2ebff674 Fix merged classvars in UnitType descendants.
```
>>> class Foo:
...     bar = 0
...     @classmethod
...     def set_bar(cls, v):
...             cls.bar = v
...
>>> class Bar(Foo):
...     ...
...
>>> Bar.set_bar(1)
>>> Bar.bar
1
>>> Foo.bar
0
>>> class Foo:
...     bar = {}
...     @classmethod
...     def add(cls, k, v):
...             cls.bar[k] = v
...
>>> class Bar(Foo):
...     pass
...
>>> Bar.add(0, 1)
>>> Bar.bar
{0: 1}
>>> Foo.bar
{0: 1}
```

The collections are copied by reference into the descendants, whereas
_loaded is copied by value, so that one can stay. Before this patch,
every subtype was loading because _loaded was set per subclass, but they
were all registering with a common collection defined by UnitType rather
than their own class.
2023-04-26 23:09:57 -07:00
Dan Albert
06b74c4ca6 Update mypy, fastapi, pydantic.
mypy update is needed for typing.Self support. It caught an existing bug
(missing @property on override), and fixed a bug so we can drop an
ignore.

Upgrading mypy requires upgrading pydantic to get the newest pydantic
mypy plugin, and since that's what's driving fastapi it's probably smart
to upgrade those together.
2023-04-26 23:00:23 -07:00
zhexu14
f86709ebd0
Prevent decoy flights from overflying the target.
Force decoy flights to the next waypoints 120 seconds after the IP.
The duration is just an approximation, but it seems to work.

See discussion in https://github.com/dcs-liberation/dcs_liberation/pull/2810
for more details.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2781.
2023-04-26 19:30:34 -07:00
Dan Albert
47831d43b5 Remember mod choices in the NGW. 2023-04-26 00:36:34 -07:00
Dan Albert
cf47dd82d7 Remember player preferences for plugins. 2023-04-26 00:24:46 -07:00
Dan Albert
081c97583b Add a plugins page to the NGW. 2023-04-26 00:07:36 -07:00
Dan Albert
77f1706cbb Extract plugins from settings.
There isn't really any need for these two types to interact. The lua
plugin manager effectively fully owned its properties, it just delegated
all reads and writes to the settings object.

Instead, break the plugin settings out into the plugin manager and
preserve the manager in the Game. This will make it possible to expose
plugin options in the NGW without breaking the game on cancel.
2023-04-25 23:28:01 -07:00
Dan Albert
664efa3ace Document Lua plugin APIs.
Trying to fix the singleton-ness in the plugin manager because it
prevents injecting settings until the game is fully committed (new game
wizard completed). Added the docs describing what I think I've been able
to discover.
2023-04-25 21:32:36 -07:00
zhexu14
4bf8f25d31
Add decoy weapon type and configure AI tasks.
See https://github.com/dcs-liberation/dcs_liberation/pull/2810
for more discussion.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2780.
2023-04-25 20:02:30 -07:00
Dan Albert
e2c6d6788c Persist some campaign creation options.
We should also persist mod options, but those will go in a separate file
because they aren't a part of Settings.

Plugins need some work before that can be saved here. They're not
configurable in the NGW currently, so that needs to be fixed first. It
also appears that it may not be safe to inject the settings object with
plugin options until the game is created, but that needs more
investigation (see the comment in Settings.save_player_settings).

Another obvious candidate would be the desired player mission duration,
but we need to implement custom serialization for that first.
2023-04-24 22:49:30 -07:00
Nosajthedevil
1c20bc3966 Add DCS AI C-47 support 2023-04-24 22:49:09 -07:00
zhexu14
c31d76ec83
Reset flight's flight plan builder when changing task type.
The mechanism for how this bug arises is that the *WaypointGenerator*
uses the *FlightWaypoint.waypoint_type* to decide whether to generate
the waypoint in the .miz file using a *DeadIngressBuilder* or a
*SeadIngressBuilder*. This *waypoint_type* is set by
*ato.flightplans.<sead|dead>.Builder*, which is set when *ato.flight* is
initialised in the *Flight._flight_plan_builder* member variable based
on *Flight.flight_type*. When *Flight.flight_type* is updated when the
flight is changed from SEAD->DEAD, *Flight._flight_plan_builder* is not
updated in the development build, resulting in it continuing to generate
SEAD waypoints.

This PR adds *set_flight_type()* which sets the *flight_type* property
and updates *Flight._flight_plan_builder* and uses this function when
converting flight types. Ideally, *flight_type* should be made private
and only accessed through getter/setter functions that encapsulate this
behavior, but that would mess up any existing liberation save files.

This PR was tested by:
1. Opening the save file from Issue 2779 in the development build
2. Clicking "Take Off" and confirming that the Weapon Release Type is
"Guided" at the Ingress Waypoint as described in the issue.
3. Opening the save file from Issue 2779 in this PR
4. Converting the SEAD2DEAD flight from DEAD back to SEAD, and then from
SEAD to DEAD
5. Clicking "Take Off" and confirming in the mission editor that the
SEAD2DEAD flight has Weapon Release Type set to "Auto" at the Ingress
Waypoint.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2779.
2023-04-22 10:54:42 -07:00
zhexu14
4bc8bf52e7
Also use Tanker task for recovery tankers.
DCS apparently needs both to function.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2771.
2023-04-20 17:59:14 -07:00