How to Train Units in Groups

Article written by Sarn
Published on 07-06-2016; updated on 07-06-2016
Tags: Advanced Genie Editor, Data Modding, Unit Modding

Introduction

Being able to train units in groups has been something that players of AoK have been wanting for quite a while. For most of the game's existence, no one has known how, but with BF_Tanks' research into annex units, it is now possible. This guide will teach you how to train any unit in a group of 4, as well as give pointers on other variations of this method.

Before you do anything, back up your data files. Then open up AGE 2 and load the data files. Here's the basic setup we'll be creating: The normal unit immediately dies, creating a building with 4 annexes, which also immediately die. Each of the annexes has a copy of the original unit as its Dead Unit, which creates a copy unit for each annex.

Step 1: Creating the new unit

In order to train units in groups, you will need to make a copy of the unit you want to group-train. We'll use the Archer for this example. Find the Archer unit, and then create a duplicate of it (Copy, Add, Paste). You should now have an identical copy of the Archer. Briefly scroll down to the "Train Location" and put -1 in the box to prevent any problems.

Step 2: Creating the Spawner

Find the Outpost (ID 598) and make a duplicate unit (Copy, Add, Paste). Rename this new unit something like "Spawner." (Also, change all three of the Language Dll boxes to 0.) In the duplicate unit, erase all the graphics (Construction, Snow, Standing, Dying, and all the Damage Graphics) and change the HP to -1000. Any unit with negative HP will die immediately. It's important that you use a large negative number because some technologies and civ bonuses give extra HP. Now, change the Line of Sight to 0. Scroll down to the "Hide in Editor" box and check it, then go to the Dead Unit box and enter -1. Next, go to the "Terrain" box and change it to -1 (None). Go down to the Size Radius, Editor Radius, and Selection Radius and change them all to 0. Now, change the "Selection Mask" to 2 (Which removes any outline on the building or any outlines on units behind it.) Change the "Train Location" to -1 and "Train Time" to 0. Finally, Scroll down to the sounds section and remove them all (It should only have Construction and Selection Sound.) We have now effectively made it impossible to tell this unit exists ingame.

Step 3: Creating the Spawn Annexes

Now, copy the Spawner you just created and make a duplicate and rename it "Spawn Annex."

Step 4: Changing the old unit

Now, go up to the original Archer. Remove all the graphics (Attack, Standing, Walking, and Dying). Now, scroll down to the "Hit Points" box. Enter "-100." Any unit with negative HP will die immediately. It's important that you use a large negative number because some technologies and civ bonuses give extra HP (Bloodlines comes to mind). Next, change the "Line Of Sight" to 0. You can also clear the speed, attack, and armor for good measure. Scroll down to the "Hide in Editor" box and check it. Next, change the Train Time to 0 and then scroll to the "Resource Storage" section. Change the third column (Type 19 – Military Room) to -1. This is just a cosmetic adjustment to make the end-game statistics accurate. Next, right above this, change the third column (Population Headroom) to -1 (None). Scroll down to the Sounds section and clear them all (Train, Selection, Move, and Stop). Finally, scroll down to "Commands" and clear them all.

Step 5: Linking them together

Still on the original Archer, scroll to the "Dead Unit" box and enter the ID for the "Spawner" (if this is the only editing you've done, it will probably be ID 867.) Next, go to the Spawner and scroll down to the Annex section. In each of the four "Annex Units" boxes, put the ID of the Spawn Annex (probably 868). Next, you'll need to spread the annex units apart a little. I'd recommend about a .3 distance, so go to the Annex Units Misplacement boxes*. In the first pair, enter .3 and .3; in the second, -.3 and .3; in the third, .3 and -.3; and in the fourth, -.3 and -.3. The order is important here, so make sure you get it right. Next, go to the Spawn Annex, scroll down to the Dead Unit box, and then enter the ID of your duplicate Archer.

*NOTE: the pairing layout of the annex unit misplacement boxes is:

A B C D
A B C D

Step 6: Enjoy

Now, save the dat file, open up Age of Kings, and test out your changes.

Possible Variations

Let's say you want to train units in groups, but you only want to train them in pairs or groups of three. The fix is simple: remove one of the annexes. Then just experiment with the misplacement until you get the units spaced out properly.

If you want to train units and have different units spawn (ie, 2 archers and 2 skirmishers), you need to create a different Spawn Annex for each different unit. Then just make two of the annexes the archer-producing Spawn Annex and make the other two the Skirmisher-producing Spawn Annex.

You can even train larger groups, but it is a larger, more complicated process. It involves creating a third outpost spawner called "Spawner Misplacement." The Dead Unit of the Spawner should be the Spawner Misplacement, which will have an annex approximately .5 distance away, which has a duplicate of the spawner (can't use the same one) as it's dead unit.

NOTE: This method has a few shortcomings. First, units created in groups will not go to a gather point like normal. Second, in order to make this effective for computer players, you will need to edit the AI file. Otherwise, the standard AI will not function properly (I will address this more later.) Finally, When the group is created, there will be two texts that show up on the left of the screen: "---Archer Created---" and "--- Built---".

For the first problem, there's nothing we can do, for the second, it's essentially understanding that the unit that the AI needs to create and the unit it needs to measure are two different unit Ids: for example, you'd need to structure your AI like: AI has less than 10 of unit A (Duplicate unit), create Unit B (original unit). Finally, for the last problem, I've asked around and experimented and haven't been able to fix it.


Do you want to comment on this article? Thank the author? Tribute resources for its improvement? Raze it to the ground?

Come by and visit its thread in the University Forum!