51 Commits

Author SHA1 Message Date
Dan Albert
24f6aff8c8 Reduce mission planning dependence on Game. 2021-07-13 15:20:42 -07:00
Dan Albert
17c19d453b Factor out Coalition from Game. 2021-07-13 14:29:40 -07:00
Dan Albert
fb9a0fe833 Flesh out typing information, enforce. 2021-07-07 17:41:29 -07:00
Dan Albert
69c3d41a8a Disallow partially specified generics. 2021-07-07 16:01:20 -07:00
RndName
8ba27cdaea remove completely destroyed units from the convoy 2021-07-05 15:51:34 -07:00
Dan Albert
4cfed08247 Disband unfilled incompletable transfers.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1317
2021-06-26 10:54:09 -07:00
Dan Albert
3ddfc47d3a Add a feature flag for pilot limits.
This doesn't currently interact very well with the auto purchase since
the procurer might by aircraft that don't have pilots available. That
should be fixed, but for the short term we should just default to not
enabling this new feature.
2021-06-23 18:47:34 -07:00
Dan Albert
aa19787654 Document high level concepts of unit transfers. 2021-06-23 16:50:54 -07:00
bgreman
3274f3ec35
Fix empty convoys (#1327)
* Hopefully getting rid of empty convoys for good

* changing Dict to dict for type checks
2021-06-23 19:48:16 -04:00
Dan Albert
e96210f48c Don't order transports for incapable factions.
If these orders can't be fulfilled for the faction it will prevent the
faction from ordering any non-reserve aircraft since transports are
given priority after reserve missions, and they'll never be fulfillable.
As such, no non-reserve aircraft will ever be purchased for factions
without transport aircraft.

Factions without transport aircraft are screwed in other ways, but this
will fix their air planning for campaigns that aren't dependent on
airlift.
2021-06-20 23:44:00 -07:00
Mike
bb2bf78e8a
Fix current_airlift_capacity always returning 0.
Squadron.aircraft is of type AircraftType, while TRANSPORT_CAPABLE is
a list of pydcs DcsUnitTypes. As a result, the intersection was always
empty causing the function to always return 0.
2021-06-20 13:56:00 -07:00
Dan Albert
09704b6f37 Add a wrapper type for ground unit info. 2021-06-17 22:09:17 -07:00
Dan Albert
ace42019fb Cap squadron size, limit replenishment rate.
This caps squadrons to 12 pilots and limits their replenishment rate to
1 pilot per turn. Should probably make those values configurable, but
they aren't currently.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1136
2021-06-13 14:40:15 -07:00
Dan Albert
4a3ef42e67 Wrap the pydcs FlyingType in our own AircraftType.
This is an attempt to remove a lot of our supposedly unnecessary error
handling. Every aircraft should have a price, a description, a name,
etc; and none of those should require carrying around the faction's
country as context.

This moves all the data for aircraft into yaml files (only one converted
here as an example). Most of the "extended unit info" isn't actually
being read yet.

To replace the renaming of units based on the county, we instead
generate multiple types of each unit when necessary. The CF-18 is just
as much a first-class type as the F/A-18 is.

This doesn't work in its current state because it does break all the
existing names for aircraft that are used in the faction and squadron
files, and we no longer let those errors go as a warning. It will be an
annoying one time switch, but it allows us to define the names that get
used in these files instead of being sensitive to changes as they happen
in pydcs, and allows faction designers to specifically choose, for
example, the Su-22 instead of the Su-17.

One thing not handled by this is aircraft task capability. This is
because the lists in ai_flight_planner_db.py are a priority list, and to
move it out to a yaml file we'd need to assign a weight to it that would
be used to stack rank each aircraft. That's doable, but it makes it much
more difficult to see the ordering of aircraft at a glance, and much
more annoying to move aircraft around in the priority list. I don't
think this is worth doing, and the priority lists will remain in their
own separate lists.

This includes the converted I used to convert all the old unit info and
factions to the new format. This doesn't need to live long, but we may
want to reuse it in the future so we want it in the version history.
2021-06-12 20:13:45 -07:00
Dan Albert
ef35ad90b8 Remove one user of UNIT_BY_TASK. 2021-06-07 18:01:31 -07:00
Dan Albert
96cdea2a94 Load two units per cargo plane.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1029
2021-06-05 12:21:34 -07:00
Dan Albert
cb159e3341 Fix canceling transfers.
singledispatchmethod only overloads on the first argument.
2021-06-05 12:00:43 -07:00
Dan Albert
a0833e8943 Allow selection of auto-assigned mission types.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1176
2021-06-04 17:50:21 -07:00
Dan Albert
37748ef3bd Obey squadron mission types when planning airlift.
https://github.com/dcs-liberation/dcs_liberation/issues/276
2021-05-27 19:58:45 -07:00
Dan Albert
8b8e018521 Fix cases where pilots were not returned.
https://github.com/dcs-liberation/dcs_liberation/issues/276
2021-05-26 18:49:19 -07:00
Dan Albert
4147d2f684 Initial squadrons implementation.
Doesn't actually do anything yet, but squadrons are created for each
aircraft type and pilots will be created as needed to fill flights.

https://github.com/dcs-liberation/dcs_liberation/issues/276
2021-05-26 17:49:53 -07:00
Dan Albert
6b30f47588 Fix airlifts always using player country. 2021-05-26 16:48:36 -07:00
Dan Albert
62b743025a Fix supply route clobbering, make immutable.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1083
2021-05-23 17:30:50 -07:00
Dan Albert
e721a234e1 Clean up front line code.
The routes do not need be be recreated each time we create a
`FrontLine`. The front lines follow the convoy routes, which are static.
Add the convoy route data to the `ControlPoint` the way we do for
shipping lanes and have `FrontLine` load the data from there.
2021-05-08 16:46:02 -07:00
Dan Albert
9e2e593825 Improve transport descriptions. 2021-04-25 17:38:05 -07:00
Dan Albert
028bfc11eb Fix convoys skipping intermediate stops. 2021-04-25 17:38:05 -07:00
Dan Albert
b6cf7a4534 Fix cancelling convoys and cargo ships.
Not sure when I broke this but all transports were being cancelled as if
they were airlifts.
2021-04-25 17:10:24 -07:00
Dan Albert
0779679b99 Connect networks to enable multi-mode transfers.
Removing the per-transit type supply routes allows us to find the best
route from A to B even if the unit needs to switch transit modes along
the way.

The "best" route is the one that will generate better gameplay. That is,
convoys are preferred to ships (use cases for GMT are rare in DCS), and
ships are preferred to airlift (reasons to attack cargo ships are also
rare). Avoiding airlift is also a good strategic choice generally since
it consumes aircraft that could be performing other missions.

The extreme weight against airlift in the pathfinding algorithm could
probably be scaled way down so that airlift would be given preference
over a very long trip, possibly only for urgent transfers.

Later when we add rail that will probably be given the most preference,
but possibly between road and shipping.

https://github.com/Khopa/dcs_liberation/issues/823
2021-04-25 17:02:18 -07:00
Dan Albert
a48ef69e41 Disband cargo ships after processing.
Shipping lanes that received a ship would never lose their ships when
transfers completed, so the line on the map was staying solid (and
probably targetable).
2021-04-25 14:43:25 -07:00
Dan Albert
7e40d58d04 Add cargo ships to the sim, track kills.
Not targetable yet.

https://github.com/Khopa/dcs_liberation/issues/826
2021-04-25 14:12:59 -07:00
Dan Albert
ba8fafcc95 First pass at cargo ships.
The simple form of this works, but without the multi-mode routing it'll
only get used when the final destination is a port with a link to a port
with a factory.

These also aren't targetable or simulated yet.

https://github.com/Khopa/dcs_liberation/issues/826
2021-04-25 12:10:06 -07:00
Dan Albert
17751e52fd Clear transports when disbanding convoys.
Also changes when we clear the convoys. Because we plan when transfers
are added (to plan UI orders immediately) we were planning convoys when
delivering units, then clearing the convoys, then planning them again.

Aside from the wasted effort, when we cleared the convoys we forgot to
tell the transfer that they no longer had transport, so when replanning
they did not get a new convoy.
2021-04-24 15:18:45 -07:00
Dan Albert
6016ebd3b4 Get transports from the closest airfield.
https://github.com/Khopa/dcs_liberation/issues/825
2021-04-23 23:24:25 -07:00
Dan Albert
8a44fc19ee Limit range for transport helicopters.
https://github.com/Khopa/dcs_liberation/issues/825
2021-04-23 23:24:25 -07:00
Dan Albert
f69450e2ae Add auto-procurment for airlift assets.
https://github.com/Khopa/dcs_liberation/issues/825
2021-04-23 23:24:25 -07:00
Dan Albert
c8b4fd1690 Use any (and only) transport aircraft for airlift.
https://github.com/Khopa/dcs_liberation/issues/825
2021-04-23 22:06:38 -07:00
Dan Albert
20d8cc2b47 Plan transports at the beginning of the turn.
https://github.com/Khopa/dcs_liberation/issues/823
2021-04-23 20:31:52 -07:00
Dan Albert
d3fdbdbca5 Fix convoys not spawning where they should. 2021-04-23 20:23:23 -07:00
Dan Albert
d80f7ebf3b Refactor transfers to support unfulfilled orders.
This gives a clean break between the transfer request and the type of
transport allocated to make way for transports that need to switch
types (to support driving to a port, then getting on a ship, to a train,
then back on the road, etc).

https://github.com/Khopa/dcs_liberation/issues/823
2021-04-23 20:10:29 -07:00
Dan Albert
c258409a8d Add AI planning for airlifts.
Downside to the current implementation is that whether or not transports
that were purchased last turn will be available for airlift this turn is
arbitrary. This is because transfers are created at the same time as
units are delivered, and units are delivered in an arbitrary order per
CP. If the helicopters are delivered before the ground units they'll
have access to the transports, otherwise they'll be refunded. This will
be fixed later when I rework the transfer requests to not require
immediate fulfillment.

https://github.com/Khopa/dcs_liberation/issues/825
2021-04-23 01:10:03 -07:00
Dan Albert
26cd2d3fef Add todo for transfer refactor. 2021-04-22 22:24:57 -07:00
Dan Albert
29b70b3247 Track airlift cargo kills.
https://github.com/Khopa/dcs_liberation/issues/825
2021-04-22 19:22:41 -07:00
Dan Albert
481f195725 Airlift support.
UI isn't finished. Bulk transfers where the player doesn't care what
aircraft get used work (though they're chosen with no thought at all),
but being able to plan your own airlift flight isn't here yet.

Cargo planes are not implemented yet.

No way to view the cargo of a flight (will come with the cargo flight
planning UI).

The airlift flight/package creation should probably be moved out of the
UI and into the game code.

AI doesn't use these yet.

https://github.com/Khopa/dcs_liberation/issues/825
2021-04-22 00:30:18 -07:00
Dan Albert
489b4d6acf Add AI convoy attack planning.
Like the comment says this rarely has any effect due to the ordering of
flight planning and convoy creation. Could be separated, but opfor will
still not be able to target any convoys that the player creates in the
UI on that turn because they planning is done before the player can use
the UI.

Multi-turn transfers will be targetable, however.
2021-04-20 22:56:53 -07:00
Dan Albert
6cffc47f3c Clean up convoy code. 2021-04-20 22:21:42 -07:00
Dan Albert
50d8e08a34 Redo convoy attack flight plans.
The previous flight plan only makes sense if the convoy will make it a
significant distance from its starting point. At road speeds over the
typical mission duration this is not true, so we can actually plan this
as if it was a strike mission near the origin point and that's close
enough.

There's some cleanup work to do here that I've added todos for.

Fixes https://github.com/Khopa/dcs_liberation/issues/996
2021-04-20 22:04:57 -07:00
Dan Albert
2a5b37b9ad Show convoys on the map. 2021-04-19 20:37:15 -07:00
Dan Albert
81d5cddac9 Remove weird single-CP supply route edge case.
A CP with a factory would be able to supply itself, but was not in a
supply route if it was the only connected friendly CP. When the player
starts with only one base against an enemy base this meant that it was
in no supply route, causing it to not be a recruitment location or a
place to buy more than a reserve of vehicles automatically.
2021-04-19 17:15:41 -07:00
Dan Albert
5dd7ea3060 Spawn convoys for transfers.
Destroying these units currently has no effect.

https://github.com/Khopa/dcs_liberation/issues/824
2021-04-18 16:22:51 -07:00
Dan Albert
bd9cbf5e3b Move transfers one CP per turn.
https://github.com/Khopa/dcs_liberation/issues/824
2021-04-18 16:22:51 -07:00