155 Commits

Author SHA1 Message Date
Simon Clark
6a0e18c0e9 Change the logic for culling missile sites.
Missile sites now generate a 2.5km culling circle around themselves, rather than using the standard full culling zone size.

Fixes #850.
2021-02-06 22:20:02 +00:00
Simon Clark
768d239840 Adds missile sites to the do-not-cull list.
Contributes-to: #700
2021-01-30 18:34:57 +00:00
Dan Albert
6cbc2b707a Fix type of Game.budget.
This *is* a float, since the income multiplier is a float. The type
annotations were wrong.
2021-01-01 13:56:33 -08:00
Dan Albert
9671542bdf Decouple unit deliveries and conflict events.
Fixes https://github.com/Khopa/dcs_liberation/issues/692 and lets us
clean up the interface quite a bit.
2021-01-01 13:48:23 -08:00
Dan Albert
de325c1208 Refunding unfulfilled orders on capture.
Fixes https://github.com/Khopa/dcs_liberation/issues/682
2021-01-01 13:23:58 -08:00
Dan Albert
436725b38e Don't award base capture bonuses.
If anything we should be granting the loser extra income so they can
recover. For now just remove.
2020-12-27 19:52:42 -08:00
Dan Albert
922d935bc1 Tweak default budget and turn 0 allocation.
AI wasn't buying many ground vehicles. Keep the turn 0 air budget about
where it was but bump up the ground budget from ~120M to ~600M.
2020-12-27 19:48:03 -08:00
Dan Albert
3a9f585b6b Plan multiple CAP rounds per turn.
On station time for CAP is only 30 minutes, so plan three cycles to give
~90 minutes of CAP coverage.

Default starting budget has increased significantly to account for the
greatly increased aircraft needs on turn 1.

Fixes https://github.com/Khopa/dcs_liberation/issues/673
2020-12-26 17:26:07 -08:00
Dan Albert
c7f9bfbb43 Sell off incomplete opfor squadrons.
Short term fix for https://github.com/Khopa/dcs_liberation/issues/41.
2020-12-25 18:45:58 -08:00
Dan Albert
1d76ee4871 Add basic intel window.
Currently only shows the enemy's economic information.

https://github.com/Khopa/dcs_liberation/issues/658
2020-12-25 03:24:33 -08:00
Dan Albert
bff905fae5 Use navmeshes to improve TARCAP flight plans.
Started with TARCAP because they're simple, but will follow and extend
this to the other flight plans next.

This works by building navigation meshes (navmeshes) of the theater
based on the threat regions. A navmesh is created for each faction to
allow the unique pathing around each side's threats. Navmeshes are built
such that there are nav edges around threat zones to allow the planner
to pick waypoints that (slightly) route around threats before
approaching the target.

Using the navmesh, routes are found using A*. Performance appears
adequate, and could probably be improved with a cache if needed since
the small number of origin points means many flights will share portions
of their flight paths.

This adds a few visual debugging tools to the map. They're disabled by
default, but changing the local `debug` variable in `DisplayOptions` to
`True` will make them appear in the display options menu. These are:

* Display navmeshes (red and blue). Displaying either navmesh will draw
  each navmesh polygon on the map view and highlight the mesh that
  contains the cursor. Neighbors are indicated by a small yellow line
  pointing from the center of the polygon's edge/vertext that is shared
  with its neighbor toward the centroid of the zone.
* Shortest path from control point to mouse location. The first control
  point for the selected faction is arbitrarily selected, and the
  shortest path from that control point to the mouse cursor will be
  drawn on the map.
* TARCAP plan near mouse location. A TARCAP will be planned from the
  faction's first control point to the target nearest the mouse cursor.

https://github.com/Khopa/dcs_liberation/issues/292
2020-12-23 17:09:34 -08:00
Dan Albert
86558bdef6 Add threat zone modeling.
Creates threat zones around airfields and non-trivial air defenses (it's
not worth dodging anything with a threat range under 3nm). These threat
zones can be used to aid mission planning and waypoint placement.

https://github.com/Khopa/dcs_liberation/issues/292
2020-12-22 13:12:04 -08:00
Dan Albert
b9ade2295e Don't exclude BARCAP targets from culling.
Fixes https://github.com/Khopa/dcs_liberation/issues/597
2020-12-16 18:52:12 -08:00
Dan Albert
793b356c01 Fix crash in new game generation.
Fixes https://github.com/Khopa/dcs_liberation/issues/583
2020-12-15 10:16:21 -08:00
Dan Albert
25efdd3d4f Don't cull objects near package targets.
https://github.com/Khopa/dcs_liberation/issues/578
Fixes https://github.com/Khopa/dcs_liberation/issues/262
2020-12-14 23:47:31 -08:00
walterroach
c54f6ba4d2 Use set instead of dict 2020-12-09 18:25:24 -06:00
walterroach
2ea3f914f0 You Won message #419 2020-12-09 14:37:17 -06:00
Dan Albert
8f30e60e1b Use unplanned missions to guide aircraft purchase.
AI aircraft purchase decisions are now driven by the missions that the
flight planner was unable to fulfill. This way we're buying the aircraft
we actually need instead of buying them at random, in the locations we
need them, in the order they're needed.

There's a bit more that could be improved here:

* Unused aircraft could be ferried to where they would be more useful.
* Partial squadrons could be completed rather than buying a whole flight
  at a time.
* Aircraft could be ranked by their usefulness so we're not buying so
  many Hueys when a Hornet would do better.
* Purchase a buffer of CAP capable aircraft in case too many are shot
  down and they are not available next turn.

https://github.com/Khopa/dcs_liberation/issues/361
2020-12-06 00:59:04 -08:00
Dan Albert
f2d2fd7014 Add automation options to the new game wizard.
To have an effect on turn zero these need to be enabled in the wizard.
Since the last page was getting quite full I've split it into two pages:
one for the objective generation options and a second for the difficulty
and player assist options.

I also added an option to set the inital budget for opfor.
2020-12-05 23:16:17 -08:00
Dan Albert
d519aa1dad Move the AI to the normal procurement system.
The procurement AI now uses the same system as the players. Orders are
placed and take a turn to fulfill.

This has a few advantages:

* We no longer need special case purchase logic for the turn 0
  population of opfor airbases.
* Players using auto-purchase can cancel orders they don't like.
2020-12-05 22:41:05 -08:00
Dan Albert
f396ff7f12 Add procurement automation for players.
The allows the players to use the same auto-purchase mechanics that the
AI uses. The behavior is very bad, but it's no worse than what OPFOR
deals with.

There's a lot that needs to be improved before this is really a good
choice for the player:

* Option to adjust budget balance between front lines and airbases.
* Disallow negative budgets (which incidentally will cause more aircraft
  to be purchased, since the armor purchases currently accidentally
  spend the aircraft budget).
* Buy less randomly: https://github.com/Khopa/dcs_liberation/issues/361.
* Obey parking limits.
* Use the delivery events rather than instant delivery (also allows the
  player to cancel orders they don't want).

Fixes https://github.com/Khopa/dcs_liberation/issues/362
2020-12-05 21:18:23 -08:00
Dan Albert
1adee0af17 Factor AI purchases out of Game.
For now this is mostly behavior preserving. I slightly improved the
ability to buy units when multiple front lines exist by removing full
bases as candidates, but it should be a minor change at best. A larger
improvement will come later.

This is also written such that it will work for the player as well. The
procurer currently runs for the player but with all the options off, so
it does nothing. The next patch allows adds options for the player to
use auto-procurement.
2020-12-05 20:42:02 -08:00
Dan Albert
bac47dad83 Add settings for scaling income.
This adds both player and enemy income multiplier options. Note that
previously the AI was only getting 75% of their income. I've changed
that to give them their full income by default since the player can now
influence it.
2020-12-05 18:06:57 -08:00
Dan Albert
80bc9d6b23 Support reparing damaged runways.
Repairing a damaged runway costs $100M and takes 4 turns (one day). The
AI will always repair runways if they can afford it. if a runway is
damaged again during the repair the process must begin again.

Runways are still operational despite what the UI says. Preventing the
player and AI from using damaged runways (except for with helicopters
and harriers) is next.
2020-11-25 18:07:51 -08:00
walterroach
34a7a37409 Operation refactor cleanup
Fix bug in closest cp algorithm
2020-11-23 22:27:12 -06:00
walterroach
da17d1e5d1 Change Operation to a static class
Removed always True "event successful"

Add `AirWarEvent` as the primary game `Event` applied to every miz

Cleanup of `FrontLineAttackEvent`

Change `Operation.is_awacs_enabled` to two bools for each side red/blue
Currently controlled by whether an AWACs is available for the faction
(and only ever true for Blue)
2020-11-23 18:14:25 -06:00
Dan Albert
f6fad30852 Add unit name -> Liberation object map.
Generated units are added to this during mission generation so we can
map destroyed units back to the data that generated them. Currently only
implemented for aircraft as a proof of concept.
2020-11-21 21:01:46 -08:00
Dan Albert
bf7df6721a Fix turn 0.
`Game.initialize_turn` doesn't run on turn zero, so we have to set up
the unit order events when we create the `Game`.
2020-11-21 15:00:49 -08:00
Khopa
f0480b033f Removed debug print 2020-11-21 17:30:31 +01:00
Khopa
fcf45554ef Fixed culling display and added setting to include/exclude carriers from culling area. 2020-11-21 17:01:50 +01:00
Dan Albert
c4b8a41742 Move calculation of aircraft amounts into game.
The planner needs to know how much space is still expected to be
available next turn.
2020-11-20 18:25:03 -08:00
Dan Albert
f8b2dbe283 Move unit delivery ownership out of the UI.
Breaks save compat, but we need to have this knowledge outside the UI so
we can know whether or not we can ferry aircraft to the airfield without
overflowing parking.
2020-11-20 18:04:27 -08:00
Dan Albert
ae68a35a1a Remove save compat since it's breaking anyway.
Removal of old paths/names for things that no longer exist.
2020-11-20 17:06:01 -08:00
Ignacio Muñoz Fernandez
5695cf4ac5 fix: fixes #325 Budget calculation and enemy reinforcement calculation now takes into account the destroyed buildings 2020-11-20 12:38:06 +01:00
Dan Albert
18b6f7b84c Add off-map spawn locations.
The AI isn't making use of these yet, but it's not smart enough to do so
anyway.

Would benefit from an icon to differentiate it on the map.

I'm stretching the definition of "control point" quite a bit. We might
want to put a class above `ControlPoint` for `AirSpawnLocation` to
represent types of spawn locations that can't be captured and don't have
ground objectives.

Fixes https://github.com/Khopa/dcs_liberation/issues/274
2020-11-20 02:19:03 -08:00
Dan Albert
8345063e84 Move theater into game. 2020-11-17 18:11:33 -08:00
walterroach
c1f88b4a5f frontline refactoring
`FrontLine` is tightly coupled with `ConflictTheater`.
  Moved into the same module to prevent circular imports.

Moved `ConflictTheater.frontline_data` from class var
to instance var to allow save games to have different
versions of frontlines.
2020-11-15 22:08:18 -06:00
walterroach
0b4e2d3b6b Merge branch 'develop' into new_frontline 2020-11-13 08:58:43 -06:00
Dan Albert
cec28351e7 Remove dead code. 2020-11-13 01:20:59 -08:00
walterroach
33885e2216 initial multi segment frontline implementation 2020-11-12 21:47:13 -06:00
Dan Albert
8827f7df34 Cleanup Lua plugin implementation.
* Move the UI code out of the plugin logic.
* Add types where needed.
* Move into game package.
* Improve error handling.
* Simplify settings behavior.
* Don't load disabled plugins.
* Remove knowledge of non-base plugins from game generation.

Fixes https://github.com/Khopa/dcs_liberation/issues/311
2020-11-08 17:53:52 -08:00
C. Perreau
acbd45341f
Merge pull request #249 from Khopa/faction_refactor
Moddable factions
2020-10-25 02:19:22 +02:00
Dan Albert
bfc602f22f Add cheat option to capture bases.
Capturing bases is sometimes really annoying because of the DCS unit
AI and our non-optimal ground victory heuristics. Add a cheat option
to allow the player to move on without the tedium.
2020-10-24 13:06:37 -07:00
Dan Albert
dd2b61edf3 Use FrontLine in ConflictTheater.conflicts. 2020-10-24 12:24:29 -07:00
Khopa
aa1ac56ec3 Faction rework, working :) 2020-10-22 13:33:18 +02:00
David Pierron
b1840ce2ca Merge 'upstream/develop' into new-plugin-system 2020-10-20 22:10:08 +02:00
David Pierron
ed92e9afb9 changed the system to make use of JSON files 2020-10-18 18:23:31 +02:00
Dan Albert
49b6951ac3 Generate weather conditions at turn start.
Weather and exact time of day information is helpful during mission
planning, so generate it at the start of the turn rather than at
takeoff time.

Another advantage aside from planning is that we can now use the wind
information to set carrier headings and takeoff runways appropriately.
2020-10-16 18:25:25 -07:00
David Pierron
191199d9de Merge remote-tracking branch 'upstream/develop' into new-plugin-system 2020-10-14 09:01:37 +02:00
Khopa
411e71b9a2 Added setting to display culling distance 2020-10-12 20:57:32 +02:00