r/xcom2mods • • Feb 08 '16

[Mod Tutorial][Mod Release] Unlock All Armor Customization Options

Hello!

I'd like to release my new mod here, which allows you to select any armor customization option with any armor. This includes civilian armor.

For all that are only interested in the mod itself, here is the workshop link:

http://steamcommunity.com/sharedfiles/filedetails/?id=619230980

For the modders that want to know how it is done, here the quick tutorial:

  1. We need to figure out what we want to change, my basic thought was that there has to be a function that checks which customization option is allowed for which armor type. I personally just used ctrl+f and searched for "IsVeteran" and eventually found the "X2SimpleBodyPartFilter.uc" file, which from a first look seemed to do exactly what I wanted.
  2. A quick look over the file reveals functions like "FilterByTorsoAndArmorMatch" and "FilterByGenderAndArmor", which both seem to check if the current ArmorTemplate is the same as the one from the function parameter, a good starting point
  3. Our plan now is to override the class and change the function in a way that it does no longer check for the current armor type: For this we create a new class in our mod directory (I called mine X2SimpleBodyPartFilter_Override.uc) and put in the content of the original X2SimpleBodyPartFilter.uc file.
  4. To make sure the class definition fits we have to change the top line from

    class X2SimpleBodyPartFilter extends X2BodyPartFilter; to class X2SimpleBodyPartFilter_Override extends X2SimpleBodyPartFilter config(AllArmorOptions); This tells the program to override the original file (by extending it) and we also want to allow the user to set some options later (thats why we added the config(AllArmorOptions) part).

  5. At the top of our new class we add 3 configuration parameters, which we later on assing through an .ini file. This allows the user to do quick changes to the mod manually.

    var config bool modIsActive; var config bool showVeteranOptions; var config bool ignoreCharacterTemplate;

  6. Change the functions we want to ignore the armor template, charactertemplate(soldier or civilian) and similar options. For this mod I changed the "FilterByGenderAndArmor" function to no longer check for the ArmorTemplate and the function FilterByTorsoAndArmorMatch to no longer check for the CharacterTemplate, VeteranStatus and ArmorTemplate. I also left in the original options in case someone wants to deactivate the mod through the ini file.
  7. We add a Configuration file to allow the user to change some options. to do this we create a new config file in the Config folder. The filename has to start with "XCom" and must be followed by the name you gave in the class declaration (seen in section 4). In our case this is "AllArmorOptions", which means the result config file must be called "XComAllArmorOptions.ini".
  8. The content of the ini file shall be: [AllArmorOptions.X2SimpleBodyPartFilter_Override] modIsActive=true showVeteranOptions=true ignoreCharacterTemplate=true The part in the []-brackets needs to be "<YourProjectName>.<YourClassName>". When I started my project I called it "AllArmorOption", and the class got named "X2SimpleBodyPartFilter_Override" (see section 3/4). The 3 lines below that declaration need to be called the same as the variables in section 5. These are the lines that the user can change and they will be directly used in the mod and affect the filtering.
  9. In the file XComEngine.ini we need to tell the engine to actually override the class by adding these two lines: [Engine.Engine] +ModClassOverrides=(BaseGameClass="X2SimpleBodyPartFilter", ModClass="X2SimpleBodyPartFilter_Override")
  10. Last but not least, from experience I can tell you that most civilian armor is only a torso and has no option for arms/legs. However, if you customize your soldier you are forced to select a arm/leg option. This is why we need to add a "no arm" and "no leg" option to avoid clipping. We do this by creating a new config file called "XComContent.ini" in the Config folder of our project. The content shall be as follows: [XComGame.X2BodyPartTemplateManager] +BodyPartTemplateConfig=(PartType="Arms", TemplateName="MOD_ALL_ARMOR_NoArms_Male", ArchetypeName="GameUnit_Civilian.ARC_Civilian_M", Gender=eGender_Male, bVeteran=false, ArmorTemplate="nonExistant", CharacterTemplate="Soldier") +BodyPartTemplateConfig=(PartType="Arms", TemplateName="MOD_ALL_ARMOR_NoArms_Female", ArchetypeName="GameUnit_Civilian.ARC_Civilian_F", Gender=eGender_Female, bVeteran=false, ArmorTemplate="nonExistant", CharacterTemplate="Soldier")

    +BodyPartTemplateConfig=(PartType="Legs", TemplateName="MOD_ALL_ARMOR_NoLegs_Male", ArchetypeName="GameUnit_Civilian.ARC_Civilian_M", Gender=eGender_Male, bVeteran=false, ArmorTemplate="nonExistant", CharacterTemplate="Soldier") +BodyPartTemplateConfig=(PartType="Legs", TemplateName="MOD_ALL_ARMOR_NoLegs_Female", ArchetypeName="GameUnit_Civilian.ARC_Civilian_F", Gender=eGender_Female, bVeteran=false, ArmorTemplate="nonExistant", CharacterTemplate="Soldier")

These 4 lines basically add a torso-model (the ArchetypeName part) as arms/legs for male/female. The game doesnt know how to render the torso at the place of the arm/leg and therefore doesnt render anything at all. I'm sure there is a better way to achieve this, but this is the easiest I found. Leaving the ArchetypeName field empty results in an error.

And that's it. If you build the solution and start the debugger you can see that you know have all the options for all armor types, including civilian armor:

Code: http://pastebin.com/WQfeZcQG Workshop: http://steamcommunity.com/sharedfiles/filedetails/?id=619230980 Proof: http://i.imgur.com/iqsY1u6.jpg

9 Upvotes

12 comments sorted by

View all comments

1

u/headshotmasta Feb 08 '16

Very nice! I shall put it in the wiki ;]

1

u/Iriiriiri Feb 08 '16

there's a wiki?

1

u/headshotmasta Feb 08 '16

There is now =) Since the development kit has been released we can start fleshing it out.