-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented grid based positioning and layout handling in space battles. #1126
Conversation
Implemented fighter splitting grouping. Adjusted layout maps, added new colour for battleships. Added interface class for pathfinding units.
Since this update all battleships (both sides) are positioned in the top left corner upon each other. Could you please advise? |
Could you post a save just before the battle? |
Could you also verify the game files via the launcher? |
save.zip |
Indeed. I tried to verify, reinstall, whatever... Still. X-file. Thank you again anyway. |
Could you post a windowed screenshot of the issue? |
Very weird. Could you please delete any file named |
No change. I even tried a full reinstall. Anyway special thanks for the support, I never imagined such a prompt and thorough investigation :). |
This looks suss. Map.Entry reuse bug?
|
Looking at the screenshots posted it seems the layout images were not updated with the new ones containig battleship positions. |
Oh I see there was a full reinstall. |
It's alive!!!! Thank you guys for your help, much appreciated!! :) |
What did fix it? 244, deleting the zip, verifying files? |
244, deleting the zip, and upgrade zip, deleting all image directories, then verification. Not sure if all were necessary. |
The first intent of this PR was to implement pathfinding in spaceware battles, but for that I first needed to move the layout ship handling to a grid based logic so I did that instead.
Therefore some pre-work related to pathfinding also made it into this PR, most prominently a new WarUnit interface class for pathfinding objects. This class extracts some of the base functionality needed for allowing the already existing pathfinding code to be used also for space battles.
But most of the code here is related to grid handling and layouts.
The grid size is calculated by a set cell size given in pixels and how many of these cells can be fit into the battle space image. Currently that size is 26x26 pixels of the battle space, which results in a 19*38 sized grid.
If the cell size is changed, all grid based calculations will scale to the new cell sizes layouts included. This can be used for later optimizations of pathfinding or implementing different battle sizes etc.
In original IG the grid size is 18x36 and that can still be used if needed, but I found when playing with the original that all the ship layouts have an odd height and fitting them neatly was just not possible with the og grid size.
The ship layouts and their handling/usage was reworked.
First the handling of layout images/maps:
All layouts were given an extra colored dot for battleships, as in the original all battleships have pre-determined places in the layout, even if it is not showed in the icons. The parser now uses the ResearchSubCategory to differentiate between ship types.
When parsing the layouts simply the pixel locations are read and used as layout locations as-is. For this to work in a precise manner the layout images' size was reduced to 19x38 to match the grid size. These are then upscaled when drawing the layout icons in the layout selection tab.
(The layout placement positions are also scaled according to the grid size when used for ship placement, if the grid size is different than 19x38)
Some og IG layouts were adjusted a bit as some of the placements went against the pathfinding rules of the og IG(ie. battleship overlapping with cruiser areas when deploying) These are minor 1 cell movements of some placements.
The ship placements using layouts:
For placing ships the og IG object passability rules are used:
When entering combat the layout_1 is used by default for both sides. In og IG a slight variation of that layout is used by alien fleets so it is used here as well.
(This is not usable layout by the player fleet for some reason, maybe because it only has 4 fighter placements, but who knows. It should be possible to create a layout image that represents that layout and use that for aliens as a hidden layout.)
In planetary defense the planet image size is converted to grid size and that is used as an offset to the defending fleet when applying the layout. Same goes for space stations(but this might be changed to hard coded 3*3 when pathing is implemented.)
Any planetary defense fighters are laid out together with the defending fleet if there is one nearby. If no fleet is available layout_10(wall) is used for them.
The options of fighter splitting/grouping was implemented for the player. For aliens or defending player split placement is the default.
All structures placed on the battlespace are added to a pathfinding helper map the same as in ground war. Currently this is only used for checking if a structure fits in a desired position when placing.
Other: