41 Commits

Author SHA1 Message Date
RndName
4b0215c16f
Remove dcs capture event from state json
With the latest change we added capture zones and corresponding trigger rules for all Airfields as well so we do not need to rely on the dcs capture event S_EVENT_BASE_CAPTURED anymore.
2022-11-26 16:26:12 +01:00
Dan Albert
039ac9ec74 Replace CP integer ID with a UUID.
This allows unique identification across saves. The front-end needs to
be able to differentiate the first carrier in game A and the first
carrier in game B, but because carriers (and other non-airfield CPs) are
assigned IDs sequentially, collisions were to be expected. The front-end
can't tell the difference between a reloaded game and a new turn, so we
need to ensure different IDs across games.

This is a handy cleanup anyway, since callers constructing CPs no longer
need to manually track the CP ID counter.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2078.
2022-03-20 16:00:29 -07:00
Dan Albert
2585dcc130 Add (very!) rough simulation of frozen combat.
There are some TODOs here but th behavior is flagged off by default. The
biggest TODO here is that the time spent frozen is not simulated, so
flights that are engaged by SAMs will unfreeze, move slightly, then re-
freeze.

https://github.com/dcs-liberation/dcs_liberation/issues/1680
2022-02-26 13:01:46 -08:00
RndName
2c17a9a52e Refactor Templates to Layouts, Review and Cleanup
- Fix tgogenerator
- Fix UI for ForceGroup and Layouts
- Fix ammo depot handling
- Split bigger files in smaller meaningful files (TGO, layouts, forces)
- Renamed Template to Layout
- Renamed GroundGroup to TheaterGroup and GroundUnit to TheaterUnit
- Reorganize Layouts and UnitGroups to a ArmedForces class and ForceGroup similar to the AirWing and Squadron
- Reworded the UnitClass, GroupRole, GroupTask (adopted to PEP8) and reworked the connection from Role and Task
- added comments
- added missing unit classes
- added temp workaround for missing classes
- add repariable property to TheaterUnit
- Review and Cleanup

Added serialization for loaded templates

Loading the templates from the .miz files takes a lot of computation time and in the future there will be more templates added to the system. Therefore a local pickle serialization for the loaded templates was re-added:
- The pickle will be created the first time the TemplateLoader will be accessed
- Pickle is stored in Liberation SaveDir
- Added UI option to (re-)import templates
2022-02-21 20:45:41 +01:00
RndName
d154069877 Refactor ground objects and prepare template system
- completly refactored the way TGO handles groups and replaced the usage of the pydcs ground groups (vehicle, ship, static) with an own Group and Unit class.
- this allows us to only take care of dcs group generation during miz generation, where it should have always been.
- We can now have any type of unit (even statics) in the same logic ground group we handle in liberation. this is independent from the dcs group handling. the dcs group will only be genarted when takeoff is pressed.
- Refactored the unitmap and the scenery object handling to adopt to changes that now TGOs can hold all Units we want.
- Cleaned up many many many lines of uneeded hacks to build stuff around dcs groups.
- Removed IDs for TGOs as the names we generate are unique and for liberation to work we need no ids. Unique IDs for dcs will be generated for the units and groups only.
2022-02-21 20:45:41 +01:00
RndName
4139258508
Cleanup the killed map objects recognition
removed the extra array to track killed_map_objects and reuse the existing killed_ground_units routine to remove duplicate code and possible confusion
2022-01-02 12:55:10 +01:00
RndName
abe76ea003
Rework killed map_objects recognition
- removed the map_object_id from the TGO
- add a new TriggerRule with the MapObjectIsDead Condition which adds the map object to the killed_map_objects array in the state.json
- Use the trigger_zone_name as the unique identifier used for the unit_map to recognize the kill
2022-01-02 01:19:23 +01:00
Dan Albert
fb10a8d28e Add frozen combat modelling.
This doesn't do anything yet, but sets up the data model handling for
frozen combat. The next step is to show combat in the map view, since
that will be helpful when debugging the step after that one: resolving
frozen combat.

This would benefit from caching the Shapely data for SAM threat zones.
Right now it's generating them once per tick and the stuttering is
visible at max speed.

https://github.com/dcs-liberation/dcs_liberation/issues/1680
2021-12-21 14:52:28 -08:00
Dan Albert
87bf3110c8 Add play/pause features to the sim.
There's no UI feedback for this yet other than the log messages.

https://github.com/dcs-liberation/dcs_liberation/issues/1704
2021-11-02 23:34:51 -07:00
Dan Albert
b728fcc2d6 Clean up mission result handling. 2021-10-22 14:36:51 -07:00
Dan Albert
be69d17345 Move Flight and its related components out of gen. 2021-10-22 11:30:28 -07:00
RndName
b5b0d82a1a
Open all files with utf-8 encoding
- will not be used for binary read/writes (rb,wb)!
- prevents a bug where units with special characters in the unit name can not be tracked anymore as there will be a name mismatch due to wrong encoding
2021-08-14 13:10:43 +02:00
Dan Albert
17c19d453b Factor out Coalition from Game. 2021-07-13 14:29:40 -07:00
Dan Albert
96c7b87ac7 More adaptation for pydcs updates.
This is as much as we can do until pydcs actually adds the py.typed
file. Once that's added there are a few ugly monkey patching corners
that will just need `# type: ignore` for now, but we can't pre-add those
since we have mypy warning us about superfluous ignore comments.
2021-07-09 16:35:03 -07:00
Dan Albert
fb9a0fe833 Flesh out typing information, enforce. 2021-07-07 17:41:29 -07:00
Dan Albert
ddaef1fb64 Retry reading state.json on failure.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1313
2021-06-23 20:18:06 -07:00
Dan Albert
09704b6f37 Add a wrapper type for ground unit info. 2021-06-17 22:09:17 -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
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
cd6de191d1 Track pilot deaths.
https://github.com/dcs-liberation/dcs_liberation/issues/276
2021-05-26 18:54:07 -07:00
SnappyComebacks
bb1a066ff7
Let map objects be Strike targets.
This PR allows campaign creators to incorporate map objects (referred to as Scenery in the code) into their Liberation campaign.

Map objects are defined using white trigger zones created by right clicking on scenery and clicking `assign as...`.   Objective groups are defined by creating a blue TriggerZone surrounding the centers of the white trigger zones.  The type of objective is determined by the campaign creator, assigning the value of the first property of the blue TriggerZone with the objective type.

Map objects maintain their visually dead state by assigning a `Mission Start` `Scenery Object Dead` trigger to the trigger zone.  It is important for the Liberation generated TriggerZone to be as small as possible so that no other scenery is marked dead by DCS.

TriggerZones are hidden during gameplay (DCS behavior.  I don't know if it's possible to turn that off.)  TriggerZones are visible in the mission editor and mission planner however.  If a player is using an older plane, it is important for them to remember where the target is.

In the mission planner, the trigger zones' will be blue or red depending on which faction the map objects belong to.

Inherent Resolve campaign has been modified to integrate scenery objects.

### **Limitations:**
- Objective definitions (Any Blue TriggerZones) in campaign definition cannot overlap.
- Map object deaths in `state.json` is tracking integers.  You won't know what died until debriefing.
- No images for the various buildings.  In theory it can be done, but an unreasonable amount of work.
- Every blue trigger zone must have a unique name.  (If you let DCS auto increment the names this is not a concern.
- No output to screen when scenery object is dead.  You can see the building drawn as dead in the F10 map though.


### **Pictures:**

An objective:
![CampaignCreation](https://user-images.githubusercontent.com/74509817/117526797-c294af00-af84-11eb-9fb7-3940db64c5d8.png)

How the objective looks once in the mission planner/editor.  This objective belongs to the enemy faction:
![MissionPlanner](https://user-images.githubusercontent.com/74509817/117526819-ece66c80-af84-11eb-9db0-64000dedcf89.png)
2021-05-14 17:18:03 -07:00
Dan Albert
2b8dfc9dbc Stop counting neutral base captures in status.
These had no effect but were being counted on the waiting for mission
results page. Cleaned up the implementation a bunch while I was here.

Fixes https://github.com/Khopa/dcs_liberation/issues/1037
2021-04-26 17:54:32 -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
29b70b3247 Track airlift cargo kills.
https://github.com/Khopa/dcs_liberation/issues/825
2021-04-22 19:22:41 -07:00
Dan Albert
6cffc47f3c Clean up convoy code. 2021-04-20 22:21:42 -07:00
Dan Albert
65ed110ab7 Track convoy kills.
https://github.com/Khopa/dcs_liberation/issues/824
2021-04-18 16:22:51 -07:00
Dan Albert
a47bef1f13 Blacken. 2021-02-12 20:10:45 -08:00
Dan Albert
3d0b47a181 Fix exception in building debrief.
There are always a bunch of integer dead ground units. Not sure what
they are.
2021-01-30 18:24:25 -08:00
Simon Clark
cc3cd95e2d Test for unit_name + " object" in the debrief.
This is because all building objects have " object" appended to the end in the unit map, but not in the state.json. Therefore, we should now find destroyed building objects in the unit map.

Should fix #793.
2021-01-30 15:00:40 +00:00
Dan Albert
edfaaacd04 Determine player vs enemy early in debriefing.
This way the results of committing the debriefing can't alter the view
of the debriefing. It looks like it was probably that case that
debriefing information displays (but not the committed results) would be
incorrect after a base capture because the results might be shown after
the results were committed.

Maybe fixes https://github.com/Khopa/dcs_liberation/issues/513
2020-12-06 20:20:08 -08:00
Dan Albert
84b8613cf5 Cleanup debriefing signals.
We don't need most of this information.
2020-12-06 20:20:08 -08:00
Dan Albert
b8e64d4369 Revert "Revert "Migrate buildings and TGOs to unit map.""
With fixed tracking for TGO groups and fortification "buildings".

Fixes https://github.com/Khopa/dcs_liberation/issues/485

This reverts commit 72ac8ca8724573efa14e5d15880b697aaaa4eacd.
2020-12-05 14:26:16 -08:00
Dan Albert
72ac8ca872 Revert "Migrate buildings and TGOs to unit map."
Not registering kills correctly. It was in my limited testing, so need
to dig deeper.

https://github.com/Khopa/dcs_liberation/issues/494

This reverts commit 90697194a1a4ca67b53eb7b4056e4f7f5416ac58.
2020-12-04 23:57:58 -08:00
Dan Albert
90697194a1 Migrate buildings and TGOs to unit map.
Fixes https://github.com/Khopa/dcs_liberation/issues/485.
2020-12-04 01:10:18 -08:00
Dan Albert
4f37610dfb Convert front line units to UnitMap.
https://github.com/Khopa/dcs_liberation/issues/485
2020-12-01 01:25:51 -08:00
Dan Albert
0c4e920af3 Handle runway damage in the debrief.
Apparently we were already getting this info because it's a unit like
any other according to the event system, so if runways were actually
sufficiently damaged we'd emit a ton of exceptions.

This doesn't do anything yet, but tracks the damage state. Will add the
ability to repair them next, and then finally make the damage render the
runway inoperable.
2020-11-25 13:12:46 -08:00
Dan Albert
493e53c28f Perform aircraft transfers at the end of the turn. 2020-11-22 18:44:16 -08: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
walterroach
18f9b38d25 Keep only last base capture per base in debrief 2020-11-07 15:14:02 -08:00
Dan Albert
853ee5aac4 Cleanup Theater Ground Object.
A whole bunch of this data is redundant.
2020-11-07 13:10:06 -08:00
Dan Albert
5f1601a2da Remove the userdata package. 2020-10-06 17:01:37 -07:00