This tutorial describes how to add one ancillary to the game. This tutorial assumes basic familiarity with PFM, and it is current as of patch 7, early August 2011.
The only tool you will need besides notepad is PFM. I have used version 1.66 with the additional data files I added in this thread. For basic instructions on PFM and creating mods, I recommend this thread. It is for NTW, but apart from some minor differences in pathnames, the steps apply to TWS2 also. I would like to keep this thread focused on ancillaries. So if you have not used PFM before, please try it out first and request PFM help in the PFM threads.
The key files are:
a. patch7.pack/db/ancillaries_tables. Defines the ancillary's icon.
b. patch7.pack/db/ancillary_to_effects_tables. Defines the ancillary's effects.
c. patch7.pack/db/ancillary_to_included_agents_tables. Defines the agent types which can have the ancillary.
d. patch7.pack/db/ancillary_included_subcultures_tables.
e. patch7.pack/db/ancillary_info_tables.
f. local_en_patch.pack/text/db/ancillaries.loc. Defines the ancillary's onscreen name and colour text.
g. patch5.pack/export_ancillary.lua. Defines the conditions under which the ancillary may be added to an agent.
The new ancillary we create will be a Barded Warhorse for a general, which gives the general's bodyguard a +1 charge bonus.
1. Create a temporary working folder. Using PFM, extract the files listed in (a-g) into this folder. I would like to keep this thread focused on ancillaries. So if you have not used PFM before, please try it out first and request PFM help in the PFM threads.
2. Use PFM to create a new pack file with the files (a-g). Rename each of the tables (a-e). For example, rename (a) from ancillaries to tut_ancillaries. Do not rename table (f) or lua file (g). Change the pack type to "movie".
3. Use PFM to open the table (a) in your new pack file. The first field gives the internal ID of the ancillary, and the second field gives the icon name. Scroll down a number lines to find the string "animal_horse" in the second field. Delete all the other lines except for this line. Change the first field of the line, which gives the internal ID of the ancillary, to "tut_barded_warhorse", and save the file. Here is a screenshot:
4. In PFM, open table (b) in your new pack file. The name of the effect we want is "general_bodyguard_charge_bonus". Finding useful effect names is outside the scope of this tutorial. Delete all but one of the lines from this table, and change the remaining line to have ID "tut_barded_warhorse", "general_bodyguard_charge_bonus", and the value "1".
5. In PFM, open table (c) in your new pack file. We want this ancillary to be available for generals. Delete all the lines and add one line with ID "tut_barded_warhorse" and the field "General".
6. In PFM, edit tables (d,e) so that they contain one data line, and change the first field of the data line to "tut_barded_warhorse".
7. For file (f), we need to add the onscreen name and colour text for the ancillary. Unlike the other tables, do not delete the other lines in this file. The lines of this table are not in any particular order. But for each ancillary, there are two strings defined: the "onscreen name" and the "colour text". At the bottom of the table, add these two lines:
ancillaries_onscreen_name_tut_barded_warhorse | Barded Warhorse | True
ancillaries_colour_text_tut_barded_warhorse | "On, Daiwa! To glory!" | True
8. In file (g), we need to allow the game to select this new ancillary. For reference, here is the code for the first ancillary in the file with some colors added. It seems the forum editor changed the tabs to spaces, so do not paste from here into the lua file.
Code:
events.CharacterRankUpNeedsAncillary[#events.CharacterRankUpNeedsAncillary+1] =
function (context)
if conditions.CharacterType("geisha", context) and not conditions.CharacterInHomeRegion(context) and conditions.FactionwideAncillaryTypeExists("s2anc_ainu_servant", context) == false then
if conditions.DateInRange(1500, 1900, context) then
effect.ancillary("s2anc_ainu_servant", 50, context)
end
return true
end
return false
end
Using notepad on the file in your temporary working folder, duplicate this section of code in the file. Now, make a few changes in your copy. In blue is the agent type; change this to "General". In red are some other conditions; delete this text. In magenta is the ID of the ancillary; change this to tut_barded_warhorse.
9. Save this version of the file in a temporary location. We will want this file again later, after testing is complete.
10. For testing, we need to temporarily make sure that no other ancillaries are available. Otherwise, it might be quite some time in gameplay before the game engine randomly selected your new ancillary. In the reference code above, the green color is the start date. Global search and replace in this file and change all the "1500" to "1600", except for the tut_barded_warhorse entry you just added. With this change, no other ancillaries will be available at all! So this is a temporary change, which is why you created the backup in step 9.
11. In PFM, open your pack file and replace the file (g) with the modified file from the previous step. Now is also a good time to double check your work. Make sure that the tables (a-e) have only one line each; make sure the strings are spelled correctly; make sure the updated lua file is showing and there is only one string "1500" in the file. Make sure the mod is "movie" type.
12. Test the mod! Copy your new packfile into the game's data area. Start a game. One quick way to test is to choose Chosokabe, normal difficulty, and auto-resolve two battles against the rebels; your general should level up. When you level up, you should see only one ancillary choice, which is the new barded warhorse.
13. After the initial test, replace the file (g) with the modified file you created in step 9. This way, the new ancillary will be chosen occasionally, instead of being the only ancillary in the game.
14. (Optional) Come back to this post and add to my reputation by clicking the little green "+" button under my name at the left. This will help my standing in the forum.