Slow, But Steady!

Spot any changes?

Spot any changes?

Before we start, those who prefer to watch a video rather than reading, should scroll down to the end of this post and watch the video there. For those that prefer to read, carry on, but I still highly recommend that you watch the video too!

The last month or so has seen a lot of work put into Ancient Armies. Alas, most of that work will not be visible to the user. :/

Adding column movement was proceeding rather smoothly, right up until the point where I had to add a unit’s text to the column model.

I discovered that there was no easy way to copy text from an original unit’s model to the column model. The reason for this was due to the fact that a unit’s text was not encapsulated and involved many calculations.

Calculations?

Yes!

For those that don’t know, Ancient Armies units are dynamic. They are sized based on the underlying data. This means that the text that appears on them has to be able to scale properly and fit within the constraints of the user designed unit.

This is no simple task. Every formation shape had a lot of arcane code to calculate the text sizes and positions for a variety of unit shapes and sizes.

Alas, this code was scattered all around the formations models system which makes it very difficult to copy text to the column model.

To get around this I would need to create a specific class to encapsulate the concept of unit based text. This seemed kind of simple until I discovered that the Ancient Armies graphical model system does not support this very well.

The upshot of all these observations was that I had to refactor the entire model graphics subsystem to enable me to create a text model. This was the task that sank most of my time.

Was it worth it?

Yes! (in my opinion)  😎

I now have a much simpler code base, though paradoxically, one that is also a lot more powerful.

A lot of duplicate code got removed and much of the technical debt that I had accumulated over the years got fixed as a result of this refactor. I was going to address this technical debt, but at some point in the future. However, the text issue forced my hand on the matter.

With the new system I can now easily copy text. But I also gain other advantages too. Text scaling now works properly:

Text now works with all sizes of unit!

Text now works with all sizes of unit – regardless of size!

Direct-X’s implementation of text has a flaw where if you change the font size, it makes no difference whatsoever! The older code had a particular approach to get around this limitation, but it wasn’t robust across a wide range of unit sizes – as seen in the upper unit above.

The new text class has custom code in it that addresses the scaling issue in a totally different and neater way. As a bonus, it now allows for the accurate positioning of text, as well as performing scaling in a robust manner across a myriad of unit sizes.

The new text code also incorporates a lot of additional functionality such as text clipping (needed by column movement). But the best thing of all is that this powerful code is now located in one place, neatly encapsulated within one class.

Thanks to the new text system we can now do this:

A unit in the process of stripping down to move into column.

A unit in the process of stripping down to move into column. (The window top left is the replay window)

Here a cavalry unit is in the process of stripping down to move into column (the column itself is not shown as that is still being developed). Notice how the text is perfectly clipped?

Without the new system there would be no clipping, and indeed, as far as the column model was concerned, no text at all!

Unit stripping and reassembly are one of the crucial parts of column movement. The implementation was non-trivial but we are now around 80% there. Once this part is done, I’ll be able to work on the actual columns themselves.

The column system is very flexible and allows a unit to be specified with multiple column formations:

Multiple column support

Multiple column support

In all I’m happy with the progress so far, despite the massively expanded scope of the column release:

Ouch! An explosion of work!

70 Issues – Ouch!

I am starting to win the fight on this release with only 20 more issues to crack. Had the architectural issues not reared their heads, I would have been a lot further along with column movement. But it is what it is.

At least I am now winning the fixes vs new issues battle! :

A month of swimming against the current!

A month of swimming against the current!

In addition to the start on column movement, I have also given the Ancient Armies fatigue system a few changes. Units now have their fatigue capped at 100%. They now slow down as they get near that figure, until eventually, they stop.

One of the things that grated me with the fatigue system, is that unlike cohesion, there was no visual feedback to the player. This has now changed:

We can now see fatigue!

We can now see fatigue!

The unit on the top left is heavily fatigued. This is now visualised by a unit’s colour getting paler as its fatigue increases. This provides instant visual recognition and works pretty well with the cohesion system’s visualisations too.

Other fixes also managed to be snuck in…

Rhomboids had an issue with their size calculations – this was only discovered whilst testing the column stripping functionality:

Rhomboids fixed!

Rhomboids fixed!

The fixed version is on the bottom. Although not as aesthetically pleasing, it is accurate and also reflects some of the ancient descriptions of these formations being described as lozenge shaped.

Below are some of my original notes that I used to meticulously check the calculated results:

Some of the original notes that I used to test the rhomboid formation calculations.

Funky rhomboid notes!

Another fix was the unit flags. These never used to scale at all. This resulted in them being very tiny on large units. Now they scale to the size of the parent unit to make them more visible.

This is can be seen by comparing the old and new rhomboid units above.

Another important fix was an issue with Chronos – the replay and time system.

I discovered that it wasn’t being used to playback a turn! It was only being used when the replay system was activated. This meant that the turn replays tended to slow down or speed up unpredictably. It also caused a number of bugs when using the game at high time compressions.

This has now been fixed and Chronos is now used for everything. We now have super-accurate timings regardless of the computer specifications running the game. Plus, as an added bonus a lot of redundant code got removed as Chronos took on the burden of animating the player’s turn.

That’s it for this post. I wasn’t originally going to put anything up, but then decided that a progress report would be good. After all, you folks need to know that the game is being actively worked on.

Below is a You-Tube video showcasing all of the new improvements. It’s worth watching as I cover a fair bit of ground not covered here! Best viewed in HD-4K 😎

Laters

RobP