In this tutorial, you will learn how to add a Shield Wall formation for any melee infantry unit in Warhammer 2 that, of course, carries a shield.
Tools used in this tutorial
You will need to use the following software for this tutorial:
RPFM ---> https://github.com/Frodo45127/rpfm/releases/latest (by Frodo)
Asset Editor ---> https://github.com/olekristianhomelien/TheAssetEditor/releases/latest (by Ole)
RME Editor ---> https://github.com/mr-phazer/RME_Release (by Phazer)
Overview of tables
These are the tables that you will be editing in order to make the Shield Wall formation.
You will also need to create a .loc file to write the name and tooltip of the formation ability (it will be based on the unit_abilities__.loc file).
Add all these tables in your .pack file using Rusted Pack File Manager (RPFM), the software you will primarily be using for this tutorial.
This is the first table we will be working on, where all the first and most basic aspects of the unit abilities in the game are.
Write any suitable name in the key column which you will find it easy to remember and identify, but for this tutorial we will write "mod_wh_formation_shield_wall".
In the Icon Name column you need to write the file name of the icon the ability will have on the user interface. The ability icon will be found in ui/battle ui/ability_icons/[ability name].png so if you want to create a custom icon for the shield wall ability, you will have to place it in this path. You can create an icon using Photoshop or any other graphics software by extracting an existing icon and editing it. For this tutorial, the icon name to be written in this column will be "formation_shield_wall".
Next you will need to choose of what type the ability is in the Type column. Choose "wh_type_formation". This will be displayed in the UI when you hover over the ability in the stats panel.
You then have the Uniqueness column, where you determine if the ability's rarity, whether it's common, rare etc. Just choose "wh_main_anc_group_common".
Finally, Source Type determines whether the ability is based on a Lord of a Unit. Choose Unit for this case.
The Is Unit Upgrade tick box determines whether the ability appears as an upgrade in custom battles which you can toggle on or off (presumably this only works for Lord/Hero characters), Is Hidden in Ui determines whether the ability will be visible in the stats panel or not and Is Hidden In Ui For Enemy determines whether the ability is hidden to you in the stats panel of enemy units. Leave all three of these unchecked.
That's all for the unit_abilities_tables.
In this table you determine important details regarding your ability, such as whether it has an infinite number of uses, how long it takes for it to recharge, if it is targeted towards allies or enemies etc.
There's a lot to go over here and explaining what each column does may well be a whole tutorial on its own, so for the sake of keeping things quick and simple, type "lance" (without the quotes) in the search bar below to find the data entry of the Lance formation ability (i.e. wedge formation for Bretonnian cavalry units). Copy the entire entry and paste it into a new one. Rename the key from "wh_dlc07_unit_formation_lance" to "mod_wh_formation_shield_wall".
Go to the Assume Specific Behaviour column. This determines what the behavior of the unit will be when the ability is active in battle, in this case choose "shield_wall_formation".
Now go to Unique Id column. The game will search for this when the ability is clicked, so it knows that this is the one that needs to be activated. Given that this entry was copied from another existing, you will need to change it to a unique number, otherwise it won't activate. To ensure it is unique, you can change the search filter to Unique Id and search the number you typed in. If no other entry shows up with the same number, you're good to go.
Special abilities have "phases" which determine things like health healed and damage over time for the duration of the phase. As previously, type "lance" in the search bar and copy the "wh_dlc07_unit_formation_lance" entry into a new one and rename it "mod_wh_formation_shield_wall". Ignore the "wh_dlc07_unit_formation_lance_buffer" entry, there's no real need to make a "buffer" phase for this ability.
This table determines which phases go to which ability and in what order they activate over time. Fill in both Special Ability and Phase columns with "mod_wh_formation_shield_wall" and just type 1 in the Order column.
Here it is determined under what circumstance an ability may not be used. In the case of a formation ability like the shield wall, it's best that it shouldn't be allowed to be used when climbing, manning equipment like Siege Towers and Rams and when on walls, so create three entries with "mod_wh_formation_shield_wall" in the Special Ability Column and "climbing", "manning_equipment" and "on_a_platform" in the Invalid Usage Flag column.
While not a strictly necessary step as you can have formation abilities without any stat effects if you want, you can go to this table and give a stat bonus of your choice to the unit when using the ability. In this case you can give it a bracing bonus of 20% by filling in the key of the ability phase in the Phase column, "1.2" in Value, "scalar_bracing" in Stat and "mult" (i.e. the value will be multiplied) in How.
At this point, most of the data entries important for the functioning of the ability have been completed. Now you'll want to assign the shield wall formation ability to a unit of your liking, preferably an infantry unit with a shield. For this tutorial we will be adding the shield wall to Swordsmen. Add "wh_main_emp_inf_swordsmen" in Land Unit and "mod_wh_formation_shield_wall" in Ability.
Because Warhammer was not created with unit formations in mind, it more or less doesn't have orderly, appropriate spacings to ensure the unit is in good shape when in formation. For this reason you should create a new entry in the unit_spacings_tables to then assign it to the Empire Swordsmen and name it something like "infantry_shieldwall_spacing". The Close Formation Spacing Horizonal/Vertical columns determine the space between unit models horizontally and vertically and spacing variation adds a degree of variance to the spacings of your own choosing, making them less uniform and tidy. In this case you'll want to give the swordsmen a Horizontal spacing of 1.2, a vertical spacing of 2 and a spacing variation of 0. You should only consider adding values to the Loose columns if you intend to give Swordsmen the ability to use Loose Spacing. Leave Horde and Is Chaotic Formation unchecked and Routing Space Variation to "3".
The last step to ensure the shield wall formation is properly shaped when activated is to adjust the radius of the model entities of the Swordsmen. The radius determines the distance at which the unit model will collide with other models around it. With the current values in vanilla, the radius tends to be too large for models and will cause them to collide with each other when they come closer together to form the shield wall. Find the entry used by the Swordsmen in battle_entities_tables, which in this case is "wh_main_infantry_standard_blood_dismembers" and change the value of the radius to "0.4".
Not much will need to be done here. Go to the Spacing column and fill in the key of the unit spacing you created earlier, in this case "infantry_shieldwall_spacing".
With all the technical aspects of the formation ability done, now it's time to add an appropriate name and description for it to be displayed in-game. You can take the unit_abilities__.loc file and add an entry to it, but it's much better to just create your own .loc file in the mod file to save space. Regardless what you choose to do, create two entries in the .loc file. For the name of the ability you'll need to add "unit_abilities_onscreen_name_" followed by the key of the ability, in which case the whole name of the entry will be "unit_abilities_onscreen_name_mod_wh_formation_shield_wall". For the description, you'll need to add "unit_abilities_tooltip_text_" followed by the name of the ability, in which case the full name of the entry will be "unit_abilities_tooltip_text_mod_wh_formation_shield_wall". Type "Shield Wall" for the name of the ability and any description you prefer for the tooltip text (e.g. "This unit will form a wall of shields, bracing against enemy attacks from the front").
And that's everything done for the ability itself. In-game it should be available for the Swordsmen with the appropriate name, description, icon and effects.
Shield Wall Animations
If you try the ability as it is now in-game, you will notice the Swordsmen will move closer together, but they won't actually raise their shields up as expected when idle, neither when walking. This is because they don't have the proper animations assigned to them.
You will need to add the animation_tables.animpack in the .pack file of your mod and select it. On the right side there will be a panel in which you can find all the animation fragments (.frg) stored in the animpack. You will need to find the "hu1_empire_sword_and_shield.frg" which is the animation fragment used by the Swordsmen, double-click it to add it into the .pack file.
Click on the .frg file and you should see a number of columns holding the Id, Slot, File Name, Metadata, Metadata Sound etc. You will also see a Minimum ID and Maximum ID at the top of the panel. The Maximum ID determines up to what animation Ids the game will consider and use from the fragment. Any Id with a number higher than the Maximum ID will not be used, so for this reason you'll want to increase the value of the Maximum ID.
The Id is the Id of the animation slot in the column right next to it and the Slot column is the key/name of the animation slot itself. Animation slots determine what animations will be used by the game in different circumstances. For example, the STAND slot determines the overall idle animation of the unit models when they're not doing anything and are just left standing there.
Right now the unit needs the correct animation slots and animations in order for the shield wall to be properly displayed in-game. When adding animation slots, it's important that they also have the correct Id as well. Create 3 new entries and add the following animation slots and their Ids:
The TURN_RIGHT_SHIELD_UP_90 slot is the one that determines the animation that will be used by the front row of the unit when using the shield_wall_behaviour. You'll want to add the appropriate animation where Swordsmen raise their shields up in readiness. Normally, you'd want to use Phazer's Rigid Model Editor to open the .variantmeshdefinition file of the Swordsmen and search for the desired animation to use in this animation slot, but to save you the time and trouble of doing that, the animation you'll want to use is the same one found in the COMBAT_READY slot. Copy the entire row of the COMBAT_READY slot, except for the Id and Slot columns of course, and paste them in the TURN_RIGHT_SHIELD_UP_90 entry you've just made moments ago. With this, the game will now recognize that the front row of the unit will have to play the specified animation when in Shield Wall, specifically the one where they raise their shields up in readiness.
It's not over though, now you'll want an appropriate animation of the Swordsmen walking with their shields raised up at the front. Unfortunately, there is no such animation in the game so you'll have to create a custom animation yourself. You can use the same animation as the one in the WALK_SHIELD_UP_1 slot if you can't be bothered to make a new animation, but this won't look very nice as it's the animation used when the unit is under missile fire, with the shields raised diagonally upwards, as opposed to the front which would be more appropriate for the shield wall formation.
In this tutorial you will use Asset Editor to create a new animation by editing an existing one. Once all or at least one CA pack file has been loaded, go to File, Open and select the .pack file of your mod.
Go to Tools and choose Animation Transfer Tool. On the right hand side, you'll see a Target and Source part, the one determining the target skeleton/model the animation will be "transferred" to and the Source being the skeleton/model from which the animation will be copied to. Click Browse for both Target and Source, find and select "emp_state_troops_sword_and_shieldmen.variantmeshdefinition".
Then click Animation, search and find "hu1_sws_shield_up_walk_01.anim" and select it for both Target and Source. This is the walk animation of the Swordsmen where they have their shields over their heads when under missile fire, which is most appropriate and easy to edit so that they hold the shield to the front instead.
The click on Open bone mapping window, click on Auto map based on hierarchy and then Ok. This will map the bones from the Source to the Target model/skeleton so the transfer of the animation can be made possible.
When you click on Animation at the bottom of the screen, you should now see the models playing the selected animation.
Now, click on the arrows besides Target and Source to hide these two sections to make way for the Settings for Selected Bone: section. Here you can select any bone you want and edit its position, you can rotate it or move it around the x,y,z axis by adding a value to the Translation/Rotation offset and then hitting Apply Settings. In this manner you can edit this animation until you get the desired result, being the Swordsmen holding their shield to the front when walking.
Once you're done editing the animation, click Save Animation, then right click on the .pack file on the left side of the screen to save the animation within the .pack file of your mod itself. The animation file should be named something like "cust_hu1_sws_shield_up_walk_01.anim". At this point you can now close Asset Editor and re-open the .pack file with RPFM to refresh and see the new animation file. You should rename it to something easier to identify, in this case something like "hu1_shield_wall_walk".
Go back to the .frg file and copy the entire row of the WALK_SHIELD_UP_1 slot, except for Id and Slot columns for both STAND_SHIELD_FRONT_TO_COMBAT_READY and STAND_SHIELD_FRONT_IDLE_2 slots and add the new animation file in the File Name column with the correct file path so the game can find and use the animation. Then delete and leave blank the Metadata column as that column is primarily used to replace and override the animation used in the File Name column. Once you do that, hit Save for the .packfile of the mod.
Finally, click animation_tables.animpack again, find the hu1_empire_sword_and_shield.frg in the left hand panel and double-click it so that you add it back into the animation_tables.animpack and override the previous version of the .frg file.
Now you should have a fully functional Shield Wall formation with all the appropriate animations!
This concludes the tutorial.