Thomas Slade

Total War Unit Modding: The Other Three Kingdoms

Total War Unit Modding: The Other Three Kingdoms

I’m taking a break from my Hearts of Iron modding to work on applications/other projects. In the meantime, I’ve also been really enjoying Total War: Three Kingdoms, the (second) latest TW game from Creative Assembly. I’m really blown away by the game’s tight, nothing-wasted design environment, and I’m also just a little bit in love with its setting - the decline of Han China.

And I figured it was time I tried some modding for TW, even as a quick exercise. So, I decided I would mod a new unit. This post will detail my approach, and hopefully help some other modders through the process.

Goguryeo and Databases

Unlike the Paradox games I’m used to modding, TW works with tables - basically big spreadsheets of property mappings. They provide their own suite of editing tools for adjusting these tables (called DAVE, or DAtabase Visual Editor). Community managed tools are also available for quicker edits: these are Pack File Manager and the re-implemented Rust Pack File Manager. I reccomend RPFM, since as of writing, it’s the only one that’s being kept up to date with the game’s table formats.

TableExample.png

For the sake of any modders who are struggling with the same thing, here’s the tables which I’m pretty sure you need for a new unit to load (marked with a red dash).

RequiredTables.png

Anyway, maybe you’re wondering what unit I’m actually planning on adding, and what ‘totk’ stands for (this is my mod prefix).

While researching the Romance of the Three Kingdoms (the semi-historic Chinese epic on which the game is based), I got curious and started reading up on what Korea was up to while China was in this state of imperial decline. Korea, it turns out, had its own Three Kingdoms: these were the northern, semi-pastoral Gogoryeo, the south-western and maritime Baekje, and the south-eastern Silla. There was also a very cute, very small 4th polity on Korea’s southernmost coast - Gaya.

Korea.jpg

The interactions between these three kingdoms (Gogoryeo in particular) and the Han dynasty and its successors was actually very lively. It’s the sort of thing I’d love to see expanded on in the game, adding greater flavour to the yellow-sea region of the map, providing diplomatic exploits (which were frequent) for Han factions, or a delicate game of appease-and-oppose for Korean precursor kingdoms.

So I decided to name this mod The Other Three Kingdoms.

The particular unit I want to add is called a Maek Bowman. Like so many things from the Three Kingdoms period, this type of soldier is highly dubious, and I’m able to take some pretty wide liberties with what they were like. But in any case, the Maek were a subset of the Kingdom of Gogoryeo, situated somewhere near the border of the Korean kingdoms and the northern Yan breakoff polity of China (playable in game under Gongsun Zan). According to K.H.J Gardener’s The Kung-sun Warlords of Liao-tung, this tribe of people were known for their excellent bows, and were a potential motive for Gogoryeo’s raid into China during the Cao-Goguryeo war.

This sort of tidbit is perfect for Total War: control this province, and unlock a special unit. It provides a strategic opportunity for both entities bordering the Lieao-tung region, and gives a Gogoryeo player a reason to sour their relations with the larger, scarier Han factions.

Adding and editing this content can be a slightly complicated process, though it makes perfect sense once you’ve been through it once or twice. The following Youtube channel has some great tutorials on the whole workflow:

Designing the Maek Bowmen

Getting the unit to just appear in game took some time, as I mentioned earlier. TW doesn’t seem to provide an error log to warn you of any table mistakes, so I undertook a lot of trial and error. One trick is to just make sure your mod is actually running by editing some localised text:

But eventually I did get my unit in game, unlocked and ready to build for all Han factions (until I add a Goguryeo faction, this will have to do). My next job was to balance the unit’s stats.

The niche behind Maek bowmen is roughly as follows:

  • They should be early/mid-tier units, on par with regular Han bowmen or, maybe, slightly lower in stats (this should be reflected in their price).

  • They should have more of a punch than standard bowmen. This might mean more range, more damage, both, or something else entirely. These archers famously had good bows.

  • They’re only available to factions controlling a certain province. This is an unorthodox condition in Total War, though Three Kingdoms has really fleshed out the conditions required to unlock special battalions (now tech, character skill, and resources are all involved), so requiring control of a certain province doesn’t seem like such a far-cry. Plus, I’m pretty sure the new Nanman DLC works with this sort of mechanic.

  • The archers should provide a serious advantage to the Korean states against the Han, being a strong enough incentive for an invasion. This could mean all sorts of things, but so far I’ve interpreted it as needing to stand up to either the Yan’s special units (cavalry archers), or Cao Cao’s particular forte of tough melee cavalry (which, according to the game’s Wu Xing system, should traditionally counter archers). I’m writing this mid-implementation, and it’s really pointless to speculate on what will be the best fit without some playtesting, but for now this is my motive behind adding the unit.

To begin with, the obvious approach is to take a look at existing stats for main-line archer units, and slap some values somewhere in between. Building an excel sheet is very helpful here (and easy, since database tables can be opened in excel!).

Excel1.png

However, I have some real reservations about this sort of mid-way balance. Simply taking two units and slapping a value between them is certainly going to be safe (you’ll never get a unit with crazy attack). But this basically results in trying to fill a niche between two other units that probably doesn’t even exist. The result, in my opinion, can easily be a ‘mottled’ set of units that sort of feel like buffed/nerfed twins of the vanilla units. Nobody gets excited over these. Certainly, nobody invades China just to build them. A new unit (especially one you have to conquer a province to obtain) should make players say ‘wow, that’s an insane amount of [x]’, or maybe ‘god, this unit is really useful but you have to play in a totally different way’.

It is, however, a decent starting point. I just feel it needs to be warned against as a be-all and end-all balancing technique.

So, I plug these estimate values into my table, and load up TW:3K for a test match. My main objective here is to see how my new unit feels. Do I notice the difference from regular old Archer Militia? Do I need to play to the Maek Bowmen’s strengths and weaknesses?

After yet more technical difficulties, I ran through the early moves of a campaign with Gongsun Zan (I figure I may as well try these new units in the environment that they’ll be fighting in - northernmost China). The basic jist of the Maek Bowmens’ stats here were:

  • Really high range for an early-game unit, somewhere between the (mid-game) Main Archer and the (high-range/low-ammo) Crossbowman.

  • Damage, morale, and ammo falling between the Archer Militia and the Main Archer units.

The units are also ‘porly trained’, one step above Archer Militia. The idea here is that we have a band of pastoral proto-Korean people - known for their excellent bows - but still a little haphazard in their organisation.

What I found in my first battle was actually quite promising. The extra range of these archers could really make a dent in the way things played out: being able to outrange enemy formations from the safety of your retinue forces the enemy to make a move, which I was able to exploit with my shock cavalry and Gongsun Zan’s unique cavalry archers. I did genuinely feel like Maek Bowmen were worth having around, compared to regular archers.

But one battle isn’t enough to get a clear picture, so I continued my romp through the Yan commanderies.

Reverse Engineering Power Cost

Since I’m really just adding one unit, it’s fair to say that eye-balling all of my values and playtesting is a perfectly acceptable way of getting a balanced result. I can just write up some estimations based on existing units in excel, give the results a test-run in my campaign save, think about how the units played, rinse and repeat.

However, this is a design exercise and I eventually decided to try something more challenging. It wasn’t really necessary for this single unit that I’m modding, but I wanted to give it a shot.

When balancing units, weapons, characters, etc. designers sometimes talk about something called power cost. This is just a way of evaluating (imperfectly) how ‘powerful’ something is in the game’s combat environment. We can get a power cost - which is basically always some sort of estimation - by adding up the different stats and advantages of an item using some particular formula.

So, for example, if we’re designing a game with fighter planes, maybe the three main stats of a plane is its speed, armor, and damage.

PowerCost1.png

We can start by adding up all stats of a plane to try and estimate how valuable it is in the game. If all the values are roughly equal, then maybe it’s fair to say that all planes are viable options for a player (they’re all balanced).

But when we put these stats into the game and give it a test, it seems that the way we’ve been evaluating each stat is totally off, and that the Brrt, with its high damage, is pushing the other two planes out of the competition. In this case, we can start applying coefficients to each stat, placing more value on damage. This lets us do some re-shuffling to try and get those power numbers back to equality.

PowerCost2.png

Obviously this technique might seem clunky and contrived. And it is! But that’s exactly the point: power-budgeting can be used to give your initial balance iteration a touch of sanity, even if playtesting gut-feelings are still needed to make actual design decisions. You might be quick to argue that trying to calculate a power level for each plane is pointless, given that different maps or missions might suit different planes better. Well, in that case, we can factor the frequency of these maps into our budgeting. Maybe you’re reluctant because the utility of different planes might totally vary for players of different skill. But we can try and power-budget that, too!

I learned recently that Creative Assembly also use power-budgeting for Total War. Specifically, they use all other stats in a unit’s profile to spit out things like recruitment cost and upkeep cost. What this means, basically, is that money is the actual power-cost of a unit in the campaign map: more deadly units are more costly.

CA sadly did not elaborate on the formula they use to do this evaluation (it was probably quite complicated, and the result of extensive tweaking). But I decided that it might be possible for me to reverse-engineer it, using a similar method to the one I described above.

PowerCost3.png

The formula I’m using simply adds each stat multiplied by a coefficient, just as I did in the aeroplane example. However, I’ve also added a ‘starting value’ for each stat. The respective power of each stat for each unit, aid out in those bottom columns, is obtained with …

(Unit Stat - Starting Value) * Coefficient

… which is useful for when we don’t want zero of a stat to equal zero power. For example, maybe giving an archer 10 ammo is to be considered the bare minimum in terms of balance, and basically amounts to no power at all. In this case, we’d give primary_ammo a Starting Value of 10. But maybe ammo is insanely important to a unit’s performance in game? Then we’d just increase the Coefficient. In other words:

  • Coefficient = how important a stat is to a unit’s power.

  • Starting Value = the ‘bare minimum’ a stat should be, or how low a stat is when we consider it to be adding zero power to the unit’s utility.

The aim here is to get a calulated upkeep/recruitment cost for each unit that’s roughly equal to the actual costs that exist in-game. Once I have that, it might be fair to say that I have a formula resembling the one used by CA, at which point I’ll be able to test my own unit’s stats against the formula.

Side note: maybe you’re wondering how this is going to work with two indeterminate stats, those being Recruitment Cost and Upkeep Cost. How can power budget be split into two stats? Well, first of all, I got curious and took upkeep as a fraction of recruitment cost, to see if they were directly related.

PowerCost4.png

And it seems like most of them are (a unit costs about 4 times its upkeep in initial recruitment, variations probably due to CA aiming for nice, round numbers in their unit costs). The oddball here is White Horse Fellows - one of the unique faction units - which costs 8 times as much as its upkeep to recruit. This might be a mistake from CA’s balance team (or my spreadsheet), or it might be a special effort to increase the opportunity-investment of these early-game cavalry archers, decrease their upkeep for novice players, or both. I just thought that was interesting. Anyway, I can pretty safely have my Recruitment/Upkeep ratio follow the same pattern of 4:1, so problem solved.

Here’s how things looked after some initial tweaking. as you can see, the bottom four units are all very close to their actual vanilla power-evaulation, but a few of the top five are way off. The most deviant of all is crossbowmen, which are being overvalued in some way.

One stat that crossbowmen specialise in is armor piercing. So, I lowered the evaluation coefficient for that stat, and got some much less inflamed results.

PowerCost6.png

After some more tweaking, I eventially gave in and restarted. This process is obviously very trial-and-error, and it’s far from ideal (in a real design situation, I’d have access to the formula CA used, so that’s okay). This time around, I used a base coefficient to bring all values of a ‘bread and butter’ unit (in my case, the mainline archer) to around 1.

PowerCost4.png

Then I assigned the evaluation coefficients my best guess at the significance of each stat (I consider armor to be much more important than charge bonus, for example, so I gave armor a coefficient of 0.6 and charge bonus a coefficient of 0.1). After some more work, this was my result:

PowerCost8.png

Obviously, something is very, very wrong with Yi Archers. But nothing in their stats really sticks out, and I couldn’t crack it, so I decided to call it workable. It’s worth considering that I’ve only adopted some of the major unit stats into my spreadsheet: there are many more factors to a unit’s utility which CA might be considering in their formula. Or, maybe after some initial testing, they found Yi Archers to be far too powerful for their calculated cost, and just cranked up the price while disregarding what their model reccomended.

Now, at last, I can try and use my equation on my new unit.

PowerCost9.png

My spreadsheet reccomends pricing Maek Bowmen at around 300 gold to recruit (and consequently, something like 75 upkeep). This is somewhere between the Militia Archerss and Main Archerss price, which makes perfect sense, since I put a lot of the Maek Bowmen’s stats between these two.

But, as always, a huge benefit of this formula is that I can now make quick changes to the unit and see how the power-budget shapes up. Since I’m interested in shaping this unit as more of a long-distance endurance breaker, I can try increasing the primary ammo, effective range, and damage. After this, my formula tells me that Maek Bowmen should cost about 320 gold to recruit, which sounds about right to me in terms of estimated power.

One more thing to consider is that the Maek Bowmen have a final, very significant decrement to their supposed ‘power’: they’re being added with the intention of needing to control a province in order to build the unit. This opportunity cost is absolutely also a factor to the unit’s utility: if the player goes through all that trouble to gain control of Liaou-tung, they should be rewarded with a unit that provides more bang for its buck than the typical roster.

Results

This is footage of the Maek Bowmen at work after those first few adjustments to their stats. This little experiment has gone on for a while now, so I’m not in a position to continue working on them, but I will finish off with my thoughts on how they play:

  • At least in the opening phases of Gongsun Zan’s campaign, these units are extremely effective. In fact, once I got the hang of how to use them, I’d say they were certainly too effective: with my squad of three Maek Bowmen units, I was able to polish off incoming cavalry long before they got a chance to charge my ranks, on account of the increased range, damage, and ammunition.

  • The increased range absolutely makes a difference (which is good, since I was worried this unit would feel far too typical). That extra range allows you do face oncoming enemies from in front of your infantry line (doing an ‘archery hokey-pokey’) long before the enemy arrives. This is contrasted to the usual situation in Three Kingdoms, where putting your achers forward for some extra range usually playes them at a huge risk. The increased range really pushes the odds a bit too far, however, so I would definitely nudge it down to maybe 210 or so (putting it just above crossbows).

  • The increased damage is too much. I have half a mind to actually bring the Maek Bowmen’s damage below that of Archer Militia, putting them firmly into a ‘kill them with an unending stream of bugbites’ role. This runs the risk of just turning the unit into a permanent, mild debuff on the enemy army (bring a Maek Bowmen unit, keep it alive, and your opponend will lose 1% of its force every minute of the entire battle!), which is absolutely no fun. Still, the idea would be to give shock cavalry in particular a fighting chance of reaching your army’s formation before being routed.

  • To add to that, they’re good against (shock) cavalry, which is what I wanted. The idea is that against the Cao Wei (which would typically be headed by Cao Cao and his special shock-cavalry), Maek Bowmen would be a valuable addition to your roster. I’d also want to verify that these units are able to stand up to Gongsun Zan’s (who you’re much more likely to invade early-game, as Goguryeo) cavalry archers, but without console commands, setting such a playtest up takes more time than I have right now.

So, obviously, this is pushing the Maek Bowmen in the direction of - well, not so much a glass-cannon, but a glass-peashooter with lots of ammo. Weak and docile, but ranged and enduring. This seems sensible enough: protecting the Maek Bowmen becomes quite a fun challenge. But it does further contribute to the game’s ‘box formation meta’, which frankly I’d prefer to design against.

In addition, while reading up on Korean armour I was surprised to learn - if only from a brief Wikipedia snippet - that iron armour was very common for Goguryeo archers (mountain warfare in the Goguryeo heartland made direct conflicts less viable, so heavy-archery warfare became common). This is honestly the opposite of what I’d had in mind for the Maek Bowmen, who supposedly belonged to a fringe population of Goguryeo, in some distant, forested area. Naturally I had assumed that light armour, and limited access to metals, was the order of the day.

I would want to do more research, but early-game armour for archers is basically nonexistant in Three Kingdoms. Maybe pivoting to more of a mid-range low-risk skirmisher, or even an ambush unit, would be more appropriate (and fun) for the Maek Bowmen?

Anyway, that’s all for now. I may continue my work on a possible Korean mod for TW:TK in the future, time permitting.

Provincial: Code Review

Provincial: Code Review

The First World War Mod: Statecraft, Part II

The First World War Mod: Statecraft, Part II