Ascendant Dawn is an innovative grand strategy / 4X game where you command a nomadic tribe through the bronze age. I've released a few versions before but this is the update the puts the game in the state that is most representative of my work. All other public versions have been lacking major features. If you want to play it you can find the download link here https://nikousstudio.itch.io/ascendant-dawn .
Firstly I'll post of change log and then go into depth regarding one element at the end.
-Re-added armies
Armies Patrol, Merge, Dissolve, Raid and Annex
-Added new building icons
Barracks, Copper Mine, Glass workshop, gold mine, iron mine, murex farm, silver farm, spice fields, tin mine, vinyard, storehouse and sewers.
-Added key mappings
Got some feedback saying the key set up wasn't good on some keyboard configs.
-Improved army UI
Now shows number of troops instead of number of units
-Made the AI build sewers a little less
-Allowed AI to recruit more unit types
-Made AI with the mood dormant less likely to declare wars
-Made dormant AI lose war commitment quicker
- Tweaked war pull and commitment
-Fixed minor event text being off screen
-Decreased random event frequency
-Slightly increased the rock texture of the terrain.
-Improved the mesh for the mineral deposit resource node.
-Added a small aesthetic structure to the tutorial map.
- Added functionality to the slave market
You still can't buy slaves but you can free slaves and reduce security. Also slave escapes will now happen randomly based on security.
-Added more slave market UI
-Added escaped slaves
Re-adding armies was by far the most difficult part of this update. A while ago I'd figured out that armies are what was causing the game to randomly freeze. I deducted this by seeing that this bug only happened in levels where armies were present and that the bug happened between month ticks so it must have been a moving entity.
I was initially not to bothered that armies were the problem because I'd been intending to modify their code and so this bug wasn't too big a deal. However, when I'd modified the code there still seemed to be the problem yet I managed to figure out it was happening whenever the armies would fight a settlement. I removed the function that called the battle and everything worked fine so it must be the battle. Thus I put break points all throughout the battle code to determine which part was causing the problem. I quickly found out it was the code that performed casualties. How battles work is during the battle two maps are filled that show the casualties for each side by unit type then the perform casualties function removes troops from the units outside of the battle.
I wasn't too shocked that this bit of the code was causing the problem since I'd written it quite quickly without too much testing. So again I put break points throughout it to find the exact place where the problem was. Eventually, I found that the problem first occurred on an if statement that checked if the map contained a certain unit type. I noticed the map was empty since the code does remove map pairs once they have no more casualties associated with them. The break point was acting unusually as the code seemed to just hang on this if statement. It seemed unlikely to me that unreal engine had a problem with its map data type where it would cause a problem if empty and after looking at the source code it didn't look like there should be a problem. I just decided to add a check for empty maps but when that code was run the problem shifted to that if statement.
I tried a few more things but in the end all seemed to have the same problem. Eventually I just decided to cut my loses and use an approximation of a map made of two arrays. I was very spectacle if this would work since often problem are ingrained into the file, I even had tried moving the code and renaming the function. However, despite my specialism this did work.
What I've learned from this and is something that I believe to be important in solo game dev is sometimes its much better to do a quick solution or rather avoid a bug or problem but bypassing it than solving it. This is because when you're in a small team or on your own you simply don't have the time to debug every problem. I could have spent a lot longer figuring out what it was even though I'm fairly sure it's some really weird but perhaps with visual studio as I don't think there's a problem with unreal engine here. If I had spent a few more hours maybe I would have solved it and found perhaps some silly mistake or I might have found nothing. Either way in the time I would have spent doing that I added and improved more things to Ascendant Dawn.
The current solution
The bug is on line 461
Armies in the test area