XCOM 2
45 ratings
[WOTC] Iridar's Template Master Mod Documentation
By Iridar
This guide contains detailed documentation and instructions on how to use the Iridar's Template Master mod.
   
Award
Favorite
Favorited
Unfavorite
ABOUT
What are templates?

Templates are "blueprints" which are used by XCOM 2 to create objects, such as units, items, weapons and even abilities. For example, all of the standard conventional XCOM Assault Rifles are objects of the "AssaultRifle_CV" template.

Once created, these objects continue to refer to their templates to determine many of their characteristics. For example, you can rename and recolor individual standard conventional Assault Rifles, but all of them will draw their base damage value from the same "AssaultRifle_CV" template.

Templates are created by game's and mods' code every time the game starts, while objects using these templates are created over the course of the campaign.

Once templates are created, mods get a chance to edit practically any aspect of created templates. This feature is used by many mods out there to change how the game works. Some mods, like More Effective Blast Padding change just one ability, while others, like (WOTC) Cosmetic Lasers and Coilguns use complicated logic to create cosmetic copies of the base game weapons.

What is Template Master?

Template Master is a mod that lets you create and edit templates yourself by providing it with commands through configuration files. You can create new items, set up their appearance and description, and then use them in your campaigns.
INSTALLATION
To install Template Master, subscribe to these mods:

[WOTC] Iridar's Template Master - Core

[WOTC] Iridar's Template Master - Configuration

You will also any version of the X2 WOTC Community Highlander.
CREATING TEMPLATES
Commands that instruct the Template Master to create new templates should be added to this file:
..\steamapps\workshop\content\268500\2363084976\Config\XComTemplateCreator.ini

At the moment Template Master can create Templates of the following types:
    Create_X2ItemTemplate command is used to create:
  • X2ItemTemplate and all of its subclasses, including but not limited to:
  • X2EquipmentTemplate
  • X2SchematicTemplate
  • X2WeaponTemplate
  • X2WeaponUpgradeTemplate

Create_X2StrategyElementTemplate command is used to create:

  • X2StrategyElementTemplate and all of its subclasses, including:
  • X2TechTemplate

Commands to create templates have the following parameters:

name T - (Template) - Template Name of the Template that will be created. It must be unique and must not be in use by the base game or other mods.

name C - (Class) - Template Class (Template Type), e.g. X2ItemTemplate or one of the other values from the list above. X2ItemTemplate is used by default if a different template class is not specified.

array<name> RDLC - (Required DLC) - optional array of DLC Identifiers of required mods for this command to execute. In other words, if any RDLCs are specified, the command will execute only if the mods with specified DLC names are currently active.

You can also add a "NOT_" prefix to the DLC name, and then the command will be executed only if that mod is NOT loaded.

bDiffVariants - optional bool setting that will determine whether the Template Master needs to create difficulty variants of this template. Typically this should be set to true for schematic and tech templates.

Examples:
[WOTCIridarTemplateMaster.X2Item_TemplateCreator] ; Create an X2ItemTemplate +Create_X2ItemTemplate = (T = "Test_ItemTemplate") ; Create an X2WeaponTemplate +Create_X2ItemTemplate = (T = "Test_WeaponTemplate", C = "X2WeaponTemplate") ; Create an X2SchematicTemplate, but only if RPGO is active: +Create_X2ItemTemplate = (T = "Test_SchematicTemplate", C = "X2SchematicTemplate", RDLC = ("XCOM2RPGOverhaul"), bDiffVariants = true) ; Same command written differently: +Create_X2ItemTemplate = (T = "Test_SchematicTemplate", C = "X2SchematicTemplate", RDLC[0] = "XCOM2RPGOverhaul", bDiffVariants = true) ; Create an X2EquipmentTemplate, but only if these three mods are active: +Create_X2ItemTemplate = (T = "Test_EquipmentTemplate", C = "X2EquipmentTemplate", RDLC[0] = "XCOM2RPGOverhaul", RDLC[1] = "WOTCClausImmolators", RLD[2] = "WOTCDefensiveItemOverhaul2") ; Same command written differently: +Create_X2ItemTemplate = (T = "Test_EquipmentTemplate", C = "X2EquipmentTemplate", RDLC = ("XCOM2RPGOverhaul", "WOTCClausImmolators", "WOTCDefensiveItemOverhaul2")) ; Create a new Tech Template: +Create_X2StrategyElementTemplate = (T = "SomeTech", C = "X2TechTemplate", bDiffVariants = true)

Templates created by the Template Master will have all of their parameters initialized to their default values. Typically if you wish for the new templates to be used for anything, you will then have to configure them with the Template Master using the Edit Template commands.
LOCALIZATION
Localization (in-game textual description) for templates created by the Template Master can be added using this file:
..\steamapps\workshop\content\268500\2363084976\Config\Localization\XComGame.int
Localization files can be opened by most popular text editors, including Notepad++[notepad-plus-plus.org] and Windows Notepad.

If you need to change localization of other existing templates, then you should either edit original localization files for those templates yourself, or use the Edit Template commands.

The general syntax for adding localization for a template is as follows:
[TemplateName TemplateType] LocalizedProperty = "Textual value" AnotherLocalizedProperty = "Another textual value" +LocalizedArrayProperty = "Textual value 1" +LocalizedArrayProperty = "Textual value 2" +LocalizedArrayProperty = "Textual value 3" +AnotherLocalizedArrayProperty[0] = "Textual value 1" +AnotherLocalizedArrayProperty[1] = "Textual value 2" +AnotherLocalizedArrayProperty[2] = "Textual value 3"
For example, here's base game localization for the conventional SPARK Autocannon:
[SparkRifle_CV X2WeaponTemplate] FriendlyName="Heavy Autocannon" FriendlyNamePlural="Heavy Autocannon" BriefSummary="A powerful but physically-heavy cannon designed specifically for use by SPARK units." TacticalText="<Bullet/> Firing the primary weapon ends the soldier's turn, in the absence of special training." AbilityDescName="heavy autocannon"
You can learn more about XCOM 2 Localization System here.

Keep in mind all of this is done by the game itself. The Template Master simply provides a localization file for you to use.
EDITING TEMPLATES
Template Master can be instructed to edit existing or newly created templates using this file:
..\steamapps\workshop\content\268500\2363084976\Config\XComTemplateEditor.ini

The command to edit a template used the Edit_TemplateType tag. Currently valid commands are:
Edit_X2ItemTemplate Edit_X2EquipmentTemplate Edit_X2ArmorTemplate Edit_X2SchematicTemplate Edit_X2WeaponTemplate Edit_X2PairedWeaponTemplate Edit_X2GrenadeTemplate Edit_X2GrenadeLauncherTemplate Edit_X2GremlinTemplate Edit_X2WeaponUpgradeTemplate Edit_X2TechTemplate Edit_X2SoldierUnlockTemplate Edit_X2SoldierAbilityUnlockTemplate

You can add as many edit template commands as you need. The rule is that one command can change one template property at a time.

Edit Template commands should be placed under one of these three config headers, depending on when you wish the command to run relative to other mods that could also be editing templates.

[WOTCIridarTemplateMaster.X2DLCInfo_First]
Commands placed under this header will run as early as possible, making sure Template Editor gets to them first. This is generally done so that other mods that edit templates would access this template *after* Template Editor.

For example, if you create a weapon template, you might want to assign its core properties, like WeaponCat as early as possible, so that a mod that makes sweeping changes based on weapon category will read your weapon correctly.

[WOTCIridarTemplateMaster.X2DLCInfo_Standard]
Commands placed under this header will run after the first header, but before the third header.

[WOTCIridarTemplateMaster.X2DLCInfo_Last]
Commands under this header will run as late as possible, making sure Template Editor gets the last word. This header should be used if you wish the command to be as reliable as possible.

PARAMETERS

Edit template commands have the following mandatory parameters:

name T - (Template) - Template Name of the Template that needs to be edited. How to find template names.

name P - (Property) - Name of the property that needs to be changed.

You can find all properties that exist in classes that can be edited by Template Master by looking at their source code, which is shipped alongside Template Master Configuration mod in the form of .txt files.

And the following optional parameters:

string V - (Value) - Directly specify the new value for the property. The value will be converted from "string" to the another type automatically, if necessary.

name DT - (Donor Template) - Take the new value for the property from another Template's property. By default the Template Master will look at the same property in the Donor Template.

name DP - (Donor Property) - when using a Donor Template, you can specify a different property name.

int DP_Index (Donor Property Index) - If the Donor Property is an array, then the Template Master will look at the specified member as the Donor.

name OP - (Operation) - Operation type: Append, AppendNoDup, Replace, Swap, Insert, Remove, Calculate.

Most of these are relevant only for array properties. The default operation for arrays is "Append", i.e. add a new member to the end of the array.

"AppendNoDup" will add a member to an array, but only if that array does not already contain it. It doesn't work with some of the struct type properties.

"Replace" is meant to be used together with "Index", replacing any existing array members by that index.

"Insert", similarly, inserts the specified value into the specified position of an array property.

"Remove" is a flexible command. If used without a V value and without an index, it will remove all members of the specified array property.

If used with a V value, it will remove only array members that match the specified value.

If used with an Index, it will remove the array member with a specified index.

If used with both, it will remove the specified array member only if it matches the specified value.

"Swap" is used together with DT - donor template, then Template Master will swap the values of specified P property between T and DT templates.

"Calculate" is used with global values and strategy costs, explained in detail below.

int Diff - (Difficulty index) - If specified, only template of that difficulty will be patched. 0 - Rookie,1 - Veteran, 2 - Commander, 3 - Legend.

int Index - if "P" is an array property, you can specify an Index of where a new value needs to be inserted or otherwise interacted with, depending on the Operation Type (OP).

array<name> RDLC - (Required DLC) - Same as for creating templates, this command will be executed only when all of the mods with specified DLC Identifiers are active.

You can also add a "NOT_" prefix to the DLC name, and then the command will be executed only if that mod is NOT loaded.

The following optional parameters are used only when editing templates of specific types:

X2ItemTemplate and its subclasses:

StrategyRequirement Requirements - strategic requirements that must be fulfilled before this template can be built in Engineering.

StrategyCost Cost - strategic cost that the player must pay to build one item of this template in Engineering.

X2EquipmentTemplate and its subclasses:

UIStatMarkup UIStatMarkup - stat markup. It will visually change soldier's stats in the armory when an item of this template is equipped. Note that this is a purely UI feature and will not have an effect in actual gameplay. Typically the stat changes displayed by stat markups are mirrored by passive abilities that actually change soldier's stats in tactical.

X2WeaponTemplate and its subclasses:

WeaponDamageValue Damage

WeaponAttachment WeaponAttachment - information about a wepon's visual weapon attachment.

PrecomputedPathData WeaponPrecomputedPathData - information about weapon's trajectory. Used by grenade-like weapons that fire in an arc. These parameters will have an effect on the curvature of the arc and how many bounces the projectile is allowed to perform.

AbilityIconOverride AbilityIconOverride - allows specified abilities to use different icons when they are attached to this weapon.

AbilityAnimationOverride AbilitySpecificAnimation - allows specified abilities to use different activation animations when they are attached to this weapon.
EXAMPLES
; Make the specified weapon available at the start of the campaign. +Edit_X2WeaponTemplate = (T = "IRI_TestTemplate_2", P = "StartingItem", V = "true") ; Swap the values of the "StartingItem" property for the specified Template and Donor Template. ; This will make the magnetic rifle available at the start of the campaign, and the conventional rifle will stop being available at the start of the campaign. +Edit_X2ItemTemplate = (T = "AssaultRifle_CV", P = "StartingItem", DT = "AssaultRifle_MG", OP = "Swap") ; Set a new value of the specified localized property. This will rename all magnetic rifles to "HIJACKED!" in-game. +Edit_X2ItemTemplate = (T = "AssaultRifle_MG", P = "FriendlyName", V = "HIJACKED!") ; This block of commands will swap everything that has to do with weapon appearance between Magnetic Rifle and conventional Assault Rifle. +Edit_X2WeaponTemplate = (T = "AssaultRifle_CV", DT = "AssaultRifle_MG", OP = "Swap", P = "GameArchetype") +Edit_X2WeaponTemplate = (T = "AssaultRifle_CV", DT = "AssaultRifle_MG", OP = "Swap", P = "EquipSound") +Edit_X2WeaponTemplate = (T = "AssaultRifle_CV", DT = "AssaultRifle_MG", OP = "Swap", P = "WeaponPanelImage") +Edit_X2WeaponTemplate = (T = "AssaultRifle_CV", DT = "AssaultRifle_MG", OP = "Swap", P = "DefaultAttachments") +Edit_X2WeaponTemplate = (T = "AssaultRifle_CV", DT = "AssaultRifle_MG", OP = "Swap", P = "AbilityIconOverrides") +Edit_X2WeaponTemplate = (T = "AssaultRifle_CV", DT = "AssaultRifle_MG", OP = "Swap", P = "AbilitySpecificAnimations") +Edit_X2WeaponTemplate = (T = "AssaultRifle_CV", DT = "AssaultRifle_MG", OP = "Swap", P = "FriendlyName") +Edit_X2WeaponTemplate = (T = "AssaultRifle_CV", DT = "AssaultRifle_MG", OP = "Swap", P = "FriendlyNamePlural") +Edit_X2WeaponTemplate = (T = "AssaultRifle_CV", DT = "AssaultRifle_MG", OP = "Swap", P = "BriefSummary") +Edit_X2WeaponTemplate = (T = "AssaultRifle_CV", DT = "AssaultRifle_MG", OP = "Swap", P = "TacticalText") +Edit_X2WeaponTemplate = (T = "AssaultRifle_CV", DT = "AssaultRifle_MG", OP = "Swap", P = "AbilityDescName") +Edit_X2WeaponTemplate = (T = "AssaultRifle_CV", DT = "AssaultRifle_MG", OP = "Swap", P = "UnknownUtilityCategory") +Edit_X2WeaponTemplate = (T = "AssaultRifle_CV", DT = "AssaultRifle_MG", OP = "Swap", P = "BlackMarketTexts") +Edit_X2WeaponTemplate = (T = "AssaultRifle_CV", DT = "AssaultRifle_MG", OP = "Swap", P = "LootTooltip") +Edit_X2WeaponTemplate = (T = "AssaultRifle_CV", DT = "AssaultRifle_MG", OP = "Swap", P = "strImage") +Edit_X2WeaponTemplate = (T = "AssaultRifle_CV", DT = "AssaultRifle_MG", OP = "Swap", P = "strInventoryImage") +Edit_X2WeaponTemplate = (T = "AssaultRifle_CV", DT = "AssaultRifle_MG", OP = "Swap", P = "strBackpackIcon") +Edit_X2WeaponTemplate = (T = "AssaultRifle_CV", DT = "AssaultRifle_MG", OP = "Swap", P = "LootStaticMesh") +Edit_X2WeaponTemplate = (T = "AssaultRifle_CV", DT = "AssaultRifle_MG", OP = "Swap", P = "LootParticleSystem") +Edit_X2WeaponTemplate = (T = "AssaultRifle_CV", DT = "AssaultRifle_MG", OP = "Swap", P = "LootParticleSystemEnding") ; Give conventional AR three upgrade slots. +Edit_X2WeaponTemplate = (T = "AssaultRifle_CV", P = "NumUpgradeSlots", V = "3") ; Remove visual weapon upgrade for the Extended Mags on the conventional Assault Rifle when there is no Auto Loader upgrade attached. ; Note that for editing weapon upgrade templates the "V" parameter is used to specify the name of the AttachFn delegate. +Edit_X2WeaponUpgradeTemplate = (T = "ClipSizeUpgrade_Bsc", V = "NoReloadUpgradePresent", P = "UpgradeAttachments", OP = "Remove",\\ WeaponAttachment = (AttachSocket = "Mag", UIArmoryCameraPointTag = "UIPawnLocation_WeaponUpgrade_AssaultRifle_Mag", AttachMeshName = "ConvAssaultRifle.Meshes.SM_ConvAssaultRifle_MagB", AttachIconName = "img:///UILibrary_Common.ConvAssaultRifle.ConvAssault_MagB", InventoryIconName = "img:///UILibrary_StrategyImages.X2InventoryIcons.ConvAssault_MagB_inv", InventoryCategoryIcon = "img:///UILibrary_StrategyImages.X2InventoryIcons.Inv_weaponIcon_clip", AttachProjectileName = "", ApplyToWeaponTemplate = "AssaultRifle_CV", AttachToPawn = false)) ; Set up a new melee weapon and make it buildable. +Edit_X2WeaponTemplate = (T = "WP_VorpalBlade", P = "WeaponCat", V = "sword") +Edit_X2WeaponTemplate = (T = "WP_VorpalBlade", P = "WeaponTech", V = "beam") +Edit_X2WeaponTemplate = (T = "WP_VorpalBlade", P = "InventorySlot", V = "eInvSlot_SecondaryWeapon") +Edit_X2WeaponTemplate = (T = "WP_VorpalBlade", P = "StowedLocation", V = "eSlot_RightBack") +Edit_X2WeaponTemplate = (T = "WP_VorpalBlade", P = "Tier", V = "4") +Edit_X2WeaponTemplate = (T = "WP_VorpalBlade", P = "WeaponPanelImage", V = "_Sword") +Edit_X2WeaponTemplate = (T = "WP_VorpalBlade", P = "strImage", V = "img:///ViperBlade.UI.INV_ViperBlade") +Edit_X2WeaponTemplate = (T = "WP_VorpalBlade", P = "GameArchetype", V = "ViperBlade.Archetype.WP_XCom_ViperBlade") +Edit_X2WeaponTemplate = (T = "WP_VorpalBlade", P = "EquipSound", V = "Sword_Equip_Beam") +Edit_X2WeaponTemplate = (T = "WP_VorpalBlade", P = "UIArmoryCameraPointTag", V = "UIPawnLocation_WeaponUpgrade_Shotgun") +Edit_X2WeaponTemplate = (T = "WP_VorpalBlade", P = "NumUpgradeSlots", V = "2") +Edit_X2WeaponTemplate = (T = "WP_VorpalBlade", P = "CanBeBuilt", V = "true") +Edit_X2WeaponTemplate = (T = "WP_VorpalBlade", P = "StartingItem", V = "false") +Edit_X2WeaponTemplate = (T = "WP_VorpalBlade", P = "bInfiniteItem", V = "false") +Edit_X2WeaponTemplate = (T = "WP_VorpalBlade", P = "iRadius", V = "1") +Edit_X2WeaponTemplate = (T = "WP_VorpalBlade", P = "iRange", V = "0") +Edit_X2WeaponTemplate = (T = "WP_VorpalBlade", P = "InfiniteAmmo", V = "true") +Edit_X2WeaponTemplate = (T = "WP_VorpalBlade", P = "iPhysicsImpulse", V = "5") +Edit_X2WeaponTemplate = (T = "WP_VorpalBlade", P = "Aim", V = "20") +Edit_X2WeaponTemplate = (T = "WP_VorpalBlade", P = "CritChance", V = "10") +Edit_X2WeaponTemplate = (T = "WP_VorpalBlade", P = "iSoundRange", V = "8") +Edit_X2WeaponTemplate = (T = "WP_VorpalBlade", P = "iEnvironmentDamage", V = "5") +Edit_X2WeaponTemplate = (T = "WP_VorpalBlade", P = "DamageTypeTemplateName", V = "Electrical") +Edit_X2WeaponTemplate = (T = "WP_VorpalBlade", P = "BaseDamage", \\ Damage = (Damage = 7, Spread = 1, PlusOne = 0 , Crit = 3, Pierce = 999, Shred = 0, Tag="", DamageType = "Electrical")) +Edit_X2WeaponTemplate = (T = "WP_VorpalBlade", P = "Requirements",\\ Requirements = (RequiredTechs[0] = "PlasmaRifle")) +Edit_X2WeaponTemplate = (T = "WP_VorpalBlade", P = "TradingPostValue", V = "35") +Edit_X2WeaponTemplate = (T = "WP_VorpalBlade", P = "Cost",\\ Cost = (ResourceCosts[0] = (ItemTemplateName = "Supplies", Quantity = 70),\\ ResourceCosts[1] = (ItemTemplateName = "AlienAlloy", Quantity = 5),\\ ArtifactCosts[0] = (ItemTemplateName = "EleriumCore", Quantity = 1))) ; Add "MagnetizedWeapons" tech requirement to a tech template. +Edit_X2TechTemplate = (T = "DismantleAdventPistol", P = "Requirements", Requirements = (RequiredTechs = ("MagnetizedWeapons"))) ; Add a bonus weapon effect to a specified weapon. Effect's class' name must be specified without script package. +Edit_X2WeaponTemplate = (RDLC = ("WOTC_LW2SecondaryWeapons"), T = "CombatKnife_CG", P = "BonusWeaponEffects", V = "X2Effect_StickBladeEffect")
SPECIAL CASES
Some of the template properties that can be edited by Edit Template commands have certain special handling for extra functionality.

Edit_X2ItemTemplate

When using this command to edit the OnBuiltFn property of an item template, you can use the V value to specify either "GiveItems" or "UpgradeItems", and the delegate will be assigned to the corresponding function from X2Item_DefaultSchematics.uc.

Edit_X2TechTemplate

Similarly to above, the ResearchCompletedFn property can be set to one of the delegates from the X2StrategyElement_DefaultTechs.uc or X2StrategyElement_XpackTechs.uc.
Example:
+Edit_X2TechTemplate = (T = "AcidBombProject", P = "ResearchCompletedFn", V = "UpgradeItems")

Edit_X2WeaponUpgradeTemplate

This command has this extra functionality: when this command includes a "WeaponAttachment" property, the "WeaponAttachment.ValidateAttachmentFn" can be set to one of the typical delegates using the "V" value part of the Edit Template command.

For example:
+Edit_X2WeaponUpgradeTemplate = (T = "ReloadUpgrade_Bsc", P = "UpgradeAttachments", WeaponAttachment = (AttachSocket = "Mag", UIArmoryCameraPointTag = "UIPawnLocation_WeaponUpgrade_AssaultRifle_Mag", AttachMeshName = "IRI_VektorRifle_CG.Meshes.SM_Vektor_CG_ExtendedMag_AL", InventoryIconName = "img:///UILibrary_LW_Coilguns.Inv_CoilRifleSMG_MagC", InventoryCategoryIcon = "img:///UILibrary_StrategyImages.X2InventoryIcons.Inv_weaponIcon_clip", ApplyToWeaponTemplate = "VektorRifle_CG"), V = "ClipSizeUpgradePresent")
This command adds visual weapon attachment configuration for the basic Auto Loader on the Coil Vektor rifle.
Notice the V = "ClipSizeUpgradePresent" part. This will tell the Template Master to do this:
WeaponAttachment.ValidateAttachmentFn = class'X2Item_DefaultUpgrades'.static.ClipSizeUpgradePresent;
Valid values for the "V" part of the command include all the standard weapon upgrade ValidateAttachmentFn delegates:
NoReloadUpgradePresent ReloadUpgradePresent NoClipSizeUpgradePresent ClipSizeUpgradePresent NoFreeFireUpgradePresent FreeFireUpgradePresent

Edit_X2EquipmentTemplate

This command has a special handling for editing UIStatMarkup property of equipment templates. Instead of specifying the value for the StatLabel part of the stat markup right in the edit template command, you can specify the name of a localized string in XLocalizedData.uc as the V value, and template master will use that localized string instead.

This is better than specifying the value directly if you care about players of non-english locale using your mod.

Example:
+Edit_X2WeaponTemplate = (T = "Sword_ MG", P = "UIStatMarkups", OP = "AppendNoDup", UIStatMarkup = (StatModifier = 25, StatUnit = "%"), V = "StunChanceLabel")
This will make Template Master assign class'XLocalizedData'.default.StunChanceLabel to StatLabel part of the markup.

You can use localized strings from AimLabel and up to XpSquadSharesLabel.

Edit_X2WeaponTemplate

This command has extra functionality: when editing the "RangeAccuracy" property, you can set the OP = "Replace", and use the "V" value of the command to specify the name of one of the standard Range Accuracy arrays used by base game weapons, such as "SHORT_CONVENTIONAL_RANGE".

+Edit_X2WeaponTemplate = (T = "Sidearm_CV", P = "RangeAccuracy", OP = "Replace", V = "MEDIUM_CONVENTIONAL_RANGE")
This command will make the Template Master do:
Template.RangeAccuracy = class'X2Item_DefaultWeapons'.default.MEDIUM_CONVENTIONAL_RANGE;

This is easier and quicker than filling up the array one by one. Valid array names are:
SHORT_CONVENTIONAL_RANGE SHORT_MAGNETIC_RANGE SHORT_BEAM_RANGE MEDIUM_CONVENTIONAL_RANGE MEDIUM_MAGNETIC_RANGE MEDIUM_BEAM_RANGE LONG_CONVENTIONAL_RANGE LONG_MAGNETIC_RANGE LONG_BEAM_RANGE VEKTOR_CONVENTIONAL_RANGE VEKTOR_MAGNETIC_RANGE VEKTOR_BEAM_RANGE FLAT_CONVENTIONAL_RANGE FLAT_MAGNETIC_RANGE FLAT_BEAM_RANGE
WEAPON INITIALIZED HOOK
Weapon Initialized is a Highlander hook that allows changing how a particular weapon visualizes on a particular soldier. Typically it is used to make the weapon use different attack animations, for example, when dual wielding, or using a secondary weapon as a primary, or in combination with a ballistic shield.

Normally using Weapon Initialized would require writing Unreal Script, but now you can access its functionality through Template Master's WeaponInits commands.

Each WeaponInits has the following parameters:

Conditions
A set of conditions that will determine which weapons should be affected by this command. You must specify at least one condition, or the command will never be executed.

Commands
A set of actions that template master should perform when all conditions are met.

RDLC
Optional. A set of mod names that must be currently active for this command to ever run.

Conditions

Each condition has the following parameters:
string CO - (Condition Object) - the object to which this condition will be applied to.

name CP - (Condition Property) - the property of the condition object to which this condition will be applied to.

array<string> CV - (Condition Values) - one or several condition values that the CP should have for this condition to be met.

There are only a few valid COs you can use, and each of them has its own valid CPs:

ItemState - XComGameState_Item of the weapon being initialized. Valid CPs for ItemState are:
  • TemplateName
  • ItemLocation - stowed location. Not sure it has any real use in XCOM 2.
  • InventorySlot
  • WeaponCat - weapon category. Applicable only to weapons, non weapons will have an empty weapon category.
  • WeaponUpgradeTemplateName - with this CO and CP, you can enter weapon upgrade template names as CVs, and the condition will be met if this weapon has the specified upgrades installed. E.g. you can use this to alter weapon animations if the weapon has a specific weapon upgrade, like a bipod.
UnitState - XComGameState_Unit of the Unit that has this weapon equipped.
  • TemplateName - character template name of the unit.
LoadedAmmo - XComGameState_Item of the ammo loaded into the weapon that is being initialized.
  • Same as ItemState
XComWeapon - The Game Archetype of the weapon that is being initialized.
  • Path - UPK path to the Game Archetype.
EInventorySlot - You can enter an Inventory Slot value as a Condition Object, and template master will attempt to retrieve an Item State in that slot and then use it as a Condition Object.
  • Same as ItemState
EXAMPLES #2
+WeaponInits = (\\ Conditions = (\\ (CO = "XComWeapon", CP = "Path", CV = ("IRI_Sword_CG.Archetypes.WP_Sword_CG_Whip")),\\ (CO = "ItemState", CP = "InventorySlot", CV = ("eInvSlot_PrimaryWeapon"))),\\ Commands = (\\ (P = "CustomUnitPawnAnimsets", V = "IRI_Sword_CG.Anims.AS_Sword_CG_Primary"),\\ (P = "WeaponFireAnimSequenceName", V = "FF_WhipAttackA"),\\ (P = "WeaponFireKillAnimSequenceName", V = "FF_WhipAttackA")))
This command has two conditions:

1) The Path to the Game Archetype of the weapon that is being initialized must be "IRI_Sword_CG.Archetypes.WP_Sword_CG_Whip". This means the command will run for any weapon using the coil whip sword archetype. This check is superior to looking at weapon template name, as it is more universal.

2) The weapon that is being initialized must be equipped in the primary weapon slot.

If both conditions are met, the following actions will be executed:

1) "IRI_Sword_CG.Anims.AS_Sword_CG_Primary" AnimSet will be added to the list of weapon's CustomUnitPawnAnimsets, automatically replacing animations with the same names in any AnimSet that were already located there.

2) Set value "FF_WhipAttackA" to the "WeaponFireAnimSequenceName" property.

3) Set value "FF_WhipAttackA" to the "WeaponFireKillAnimSequenceName" property.

This WeaponInits commands is intended to let the coil whip sword use a different attack animation when it is equipped as a primary weapon.


+WeaponInits = (\\ Conditions = (\\ (CO = "ItemState", CP = "TemplateName", CV = ("IRI_MechMachinegun_T1")),\\ (CO = "ItemState", CP = "InventorySlot", CV = ("eInvSlot_TertiaryWeapon")),\\ (CO = "UnitState", CP = "TemplateName", CV = ("IRI_PilotableMechChar"))),\\ Commands = (\\ (P = "DefaultSocket", V = "L_Hand")))

This command will change the default socket for a specific weapon equipped into a specific slot by a specific unit.
ALIAS PAIRS
Since Template Master's Edit Template commands typically edit only one template property per command, often you have to create multiple commands for the same template name.

The Alias System allows you to easily change that template name.

Alias Pairs are specified in a XComTemplateEditor.ini config file like this:
[WOTCIridarTemplateMaster.Help] +AliasPairs = (T = "Sidearm_CV", A = "Autopistol_T1") +AliasPairs = (T = "Sidearm_MG", A = "Autopistol_T2")

Where A is the alias name, and T is the real template name.

Each template name can have multiple aliases, but you cannot specify the same alias for multiple template names.

Once alias pairs are set up, they can be used in commands like this:
[WOTCIridarTemplateMaster.X2DLCInfo_First] +Edit_X2WeaponTemplate = (T = "Autopistol_T1", P = "iEnvironmentDamage", V = "1") +Edit_X2WeaponTemplate = (T = "Autopistol_T2", P = "iEnvironmentDamage", V = "5") +Edit_X2WeaponTemplate = (T = "Autopistol_T1", P = "Tier", V = "0") +Edit_X2WeaponTemplate = (T = "Autopistol_T2", P = "Tier", V = "2")

When processing these commands, Template Master will automatically replace Autopistol_T1 with Sidearm_CV in all of these commands.

Alias Pairs work for T, DT and V parts of Edit Template commands, as well as for all names in StrategyRequirement structs.
GLOBAL VALUES
Template Master allows you to specify "global" values, which can then be split up among different properties of different templates based on provided coefficients.

Global values are specified in a XComTemplateEditor.ini config file like this:
[WOTCIridarTemplateMaster.Help] +GlobalValues = (ValueName = "ExampleGlobalValue", V = "30000") +GlobalValues = (ValueName = "ExampleGlobalValue", V = "60000", Diff = 3)

ValueName - name of the global value. It will be used to reference this particular global value in Edit Template commands.

V - the value itself. It can be of any primitive type, but naturally int and float make the most sense.

Diff - difficulty index. If specified, this global value will be used only be Edit Template commands with a matching difficulty index.

Once set up, you can use global values in Edit Template commands like this:

[WOTCIridarTemplateMaster.X2DLCInfo_First] +Edit_X2TechTemplate = (T = "MagnetizedWeapons", P = "PointsToComplete", OP = "Calculate", DP = "ExampleGlobalValue", V = "1") +Edit_X2TechTemplate = (T = "GaussWeapons", P = "PointsToComplete", OP = "Calculate", DP = "ExampleGlobalValue", V = "2") +Edit_X2TechTemplate = (T = "MagnetizedWeapons", P = "PointsToComplete", OP = "Calculate", DP = "ExampleGlobalValue", V = "1", Diff = 3) +Edit_X2TechTemplate = (T = "GaussWeapons", P = "PointsToComplete", OP = "Calculate", DP = "ExampleGlobalValue", V = "2", Diff = 3)

To use a global value, you have to specify OP = "Calculate", and then set the DP - donor property parameter to the name of the global value. Set the V - value to the desired coefficient - the relative size of the part of the global value that will be assigned to the specified P property of the specified T template.

In this example above, the commands specify that MagnetizedWeapons and GaussWeapons tech templates must have a combined research time of 30 000 points, and that GaussWeapons must take twice as long to research as MagnetizedWeapons. So the Template Master will assign 10 000 points of research time to MagnetizedWeapons and 20 000 points to GaussWeapons.

Notice that Diff = 3 (Legendary Difficulty) has a separate set of commands that use a different global value with the same value name, but a different difficulty index.
GLOBAL STRATEGY COSTS
Global strategy costs work nearly the same as global values explained above, but they are used for StrategyCost property types.

[WOTCIridarTemplateMaster.Help] +CombinedGlobalCosts = (CostName = "IRIWTOV_UpgradeCosts_T5",\\ Cost = (ResourceCosts[0]=(ItemTemplateName="Supplies", Quantity=805),\\ ResourceCosts[1]=(ItemTemplateName="AlienAlloy", Quantity=115),\\ ResourceCosts[2]=(ItemTemplateName="EleriumDust", Quantity=78))) +CombinedGlobalCosts = (CostName = "IRIWTOV_UpgradeCosts_T5", Diff = 3,\\ Cost = (ResourceCosts[0]=(ItemTemplateName="Supplies", Quantity=1355),\\ ResourceCosts[1]=(ItemTemplateName="AlienAlloy", Quantity=238),\\ ResourceCosts[2]=(ItemTemplateName="EleriumDust", Quantity=228))) [WOTCIridarTemplateMaster.X2DLCInfo_First] +Edit_X2SchematicTemplate = (T = "SniperRifle_T5_Schematic", P = "Cost", OP = "Calculate", DP = "IRIWTOV_UpgradeCosts_T5", V = "220") +Edit_X2SchematicTemplate = (T = "AssaultRifle_T5_Schematic", P = "Cost", OP = "Calculate", DP = "IRIWTOV_UpgradeCosts_T5", V = "185")
X2EFFECTS
When editing a template property of the type X2Effect, you can use Template Master to create new X2Effect objects using the V value and Params parts of the edit template command.

The V value can be used to specify the class name of an effect, and then Template Master will create that effect and assign it to the specified template property, for example:

; Add a bonus weapon effect to a specified weapon. +Edit_X2WeaponTemplate = (RDLC = ("WOTC_LW2SecondaryWeapons"), T = "CombatKnife_CG", P = "BonusWeaponEffects", V = "X2Effect_StickBladeEffect")

Note that the effect's class' name must be specified without script package prefix.

Alternatively, V value can be used to specify the following:

CreateStunnedStatusEffect - then Template Master will call class'X2StatusEffects'.static.CreateStunnedStatusEffect. You must use the Params array to specify parameters for that function.

CreateBurningStatusEffect corresponds to class'X2StatusEffects'.static.CreateBurningStatusEffect.

Examples:
; Params are: Duration (Actions), Chance (Percent), bIsMentalDamage +Edit_X2WeaponTemplate = (T = "Sword_T2", P = "BonusWeaponEffects", OP = "AppendNoDup", V = "CreateStunnedStatusEffect", Params = ("2", "25", "false")) ; Params are: Damage Per Tick, Damage Per Tick Spread +Edit_X2WeaponTemplate = (T = "Sword_T4", P = "BonusWeaponEffects", OP = "AppendNoDup", V = "CreateBurningStatusEffect", Params = ("2", "0"))
SOLDIER CLASSES
Template Master can be used to edit or set up ability trees for soldier classes. This is something that can be done through config even without Template Master, as covered on the modmaking wiki. However, the SoldierRanks array can be very complicated to set up and edit, and one stray comma or parenthesis can ruin the entire thing. It is inconvenient, confusing, and annoying.

Template Master makes it simpler by separating soldier abilities and stat progression into separate lists for each rank. Config for each rank must be set up separately.

Editing and creating ranks uses identical syntax, and in both cases you will use XComClassData.ini config file.

First, specify class and rank you wish to edit:

[WOTCIridarTemplateMaster.X2SoldierClassBuilder] +TemplateNames = "<ClassName>_<RankNumber>"

For example, to edit the squaddie rank of the Reaper class, you would do:
+TemplateNames = "Reaper_0"

Then you create a new config header:
[<ClassName>_<RankNumber> X2SoldierClassBuilderTemplate]
And then fill the AbilitySlots and StatProgression arrays using the base game syntax.

For example, to set up the squaddie rank of the Reaper class, you would do:
[Reaper_0 X2SoldierClassBuilderTemplate] +AbilitySlots = (AbilityName = "Shadow", ApplyToWeaponSlot = eInvSlot_Unknown) +AbilitySlots = (AbilityName = "ThrowClaymore", ApplyToWeaponSlot = eInvSlot_Unknown) +StatProgression = (StatType = eStat_Offense, StatAmount = 10) +StatProgression = (StatType = eStat_HP, StatAmount = 1) +StatProgression = (StatType = eStat_Strength, StatAmount = 0) +StatProgression = (StatType = eStat_Hacking, StatAmount = 0) +StatProgression = (StatType = eStat_CombatSims, StatAmount = 1) +StatProgression = (StatType = eStat_Will, StatAmount = 5)
Random decks use the following syntax:
+AbilitySlots = (RandomDeckName = "YourRandomDeckName")

Random decks themselves must be set up in XComClassData.ini for that particular class, using base game's syntax.

Template Master is used only to set up abilities and stat progression.

If you're creating a whole new class, you still have to set up the rest of the class using the base game syntax, as explained on the wiki linked above.

If you're editing an existing soldier class, you can edit Ability Slots and Stat Progression separately. Meaning that you specify only Ability Slots config, soldier's Stat Progression for that rank will not be affected in any way, and vice versa.
EXAMPLES #3
Here's an example of editing ability tree for the Templar class. Stat Progression is not affected.
[Templar X2SoldierClassTemplate] +RandomAbilityDecks = (DeckName = "IRI_TemplarXComAbilities",\\ Abilities=(\\ (AbilityName = "Sustain", ApplyToWeaponSlot = eInvSlot_Unknown), \\ (AbilityName = "Fortress", ApplyToWeaponSlot = eInvSlot_PrimaryWeapon), \\ (AbilityName = "Faceoff", ApplyToWeaponSlot = eInvSlot_SecondaryWeapon), \\ (AbilityName = "Shadowstep", ApplyToWeaponSlot = eInvSlot_Unknown), \\ (AbilityName = "Quickdraw", ApplyToWeaponSlot = eInvSlot_SecondaryWeapon), \\ (AbilityName = "LightningHands", ApplyToWeaponSlot = eInvSlot_SecondaryWeapon), \\ (AbilityName = "BlastPadding", ApplyToWeaponSlot = eInvSlot_Unknown), \\ (AbilityName = "VolatileMix", ApplyToWeaponSlot = eInvSlot_Unknown), \\ (AbilityName = "TotalCombat", ApplyToWeaponSlot = eInvSlot_Unknown), \\ (AbilityName = "TacticalRigging", ApplyToWeaponSlot = eInvSlot_Unknown), \\ (AbilityName = "FanFire", ApplyToWeaponSlot = eInvSlot_SecondaryWeapon), \\ (AbilityName = "ReturnFire", ApplyToWeaponSlot = eInvSlot_SecondaryWeapon), \\ (AbilityName = "DeepCover", ApplyToWeaponSlot = eInvSlot_Unknown), \\ (AbilityName = "CoveringFire", ApplyToWeaponSlot = eInvSlot_SecondaryWeapon), \\ (AbilityName = "EverVigilant", ApplyToWeaponSlot = eInvSlot_SecondaryWeapon), \\ (AbilityName = "Sentinel", ApplyToWeaponSlot = eInvSlot_SecondaryWeapon), \\ (AbilityName = "FieldMedic", ApplyToWeaponSlot = eInvSlot_Unknown), \\ (AbilityName = "IRI_AWC_MedicinePouch", ApplyToWeaponSlot = eInvSlot_Unknown), \\ (AbilityName = "DeathFromAbove", ApplyToWeaponSlot = eInvSlot_SecondaryWeapon))) [WOTCIridarTemplateMaster.X2SoldierClassBuilder] +TemplateNames = "Templar_0" +TemplateNames = "Templar_1" +TemplateNames = "Templar_2" +TemplateNames = "Templar_3" +TemplateNames = "Templar_4" +TemplateNames = "Templar_5" +TemplateNames = "Templar_6" [Templar_0 X2SoldierClassBuilderTemplate] +AbilitySlots = (AbilityName = "Rend", ApplyToWeaponSlot = eInvSlot_PrimaryWeapon) +AbilitySlots = (AbilityName = "Volt", ApplyToWeaponSlot = eInvSlot_PrimaryWeapon) +AbilitySlots = (AbilityName = "TemplarFocus", ApplyToWeaponSlot = eInvSlot_PrimaryWeapon) +AbilitySlots = (AbilityName = "Momentum", ApplyToWeaponSlot = eInvSlot_Unknown) [Templar_1 X2SoldierClassBuilderTemplate] +AbilitySlots = (AbilityName = "Parry", ApplyToWeaponSlot = eInvSlot_PrimaryWeapon) +AbilitySlots = (AbilityName = "Reverberation", ApplyToWeaponSlot = eInvSlot_Unknown) +AbilitySlots = (AbilityName = "Amplify", ApplyToWeaponSlot = eInvSlot_PrimaryWeapon) +AbilitySlots = (RandomDeckName = "IRI_TemplarXComAbilities") [Templar_2 X2SoldierClassBuilderTemplate] +AbilitySlots = (AbilityName = "Overcharge", ApplyToWeaponSlot = eInvSlot_Unknown) +AbilitySlots = (AbilityName = "Channel", ApplyToWeaponSlot = eInvSlot_Unknown) +AbilitySlots = (AbilityName = "DeepFocus", ApplyToWeaponSlot = eInvSlot_Unknown) +AbilitySlots = (RandomDeckName = "IRI_TemplarXComAbilities") [Templar_3 X2SoldierClassBuilderTemplate] +AbilitySlots = (AbilityName = "Deflect", ApplyToWeaponSlot = eInvSlot_Unknown) +AbilitySlots = (AbilityName = "TemplarExchange", ApplyToWeaponSlot = eInvSlot_Unknown) +AbilitySlots = (AbilityName = "Pillar", ApplyToWeaponSlot = eInvSlot_Unknown) +AbilitySlots = (RandomDeckName = "IRI_TemplarXComAbilities") [Templar_4 X2SoldierClassBuilderTemplate] +AbilitySlots = (AbilityName = "Reflect", ApplyToWeaponSlot = eInvSlot_Unknown) +AbilitySlots = (AbilityName = "TemplarInvert", ApplyToWeaponSlot = eInvSlot_Unknown) +AbilitySlots = (AbilityName = "Stunstrike", ApplyToWeaponSlot = eInvSlot_PrimaryWeapon) +AbilitySlots = (RandomDeckName = "IRI_TemplarXComAbilities") [Templar_5 X2SoldierClassBuilderTemplate] +AbilitySlots = (AbilityName = "TemplarBladestorm", ApplyToWeaponSlot = eInvSlot_PrimaryWeapon) +AbilitySlots = (AbilityName = "ArcWavePassive", ApplyToWeaponSlot = eInvSlot_PrimaryWeapon) +AbilitySlots = (AbilityName = "VoidConduit", ApplyToWeaponSlot = eInvSlot_PrimaryWeapon) +AbilitySlots = (RandomDeckName = "IRI_TemplarXComAbilities") [Templar_6 X2SoldierClassBuilderTemplate] +AbilitySlots = (AbilityName = "Reaper", ApplyToWeaponSlot = eInvSlot_PrimaryWeapon) +AbilitySlots = (AbilityName = "IonicStorm", ApplyToWeaponSlot = eInvSlot_PrimaryWeapon) +AbilitySlots = (AbilityName = "Ghost", ApplyToWeaponSlot = eInvSlot_Unknown) +AbilitySlots = (RandomDeckName = "IRI_TemplarXComAbilities")
30 Comments
Iridar  [author] 13 Apr @ 12:43pm 
I don't think there's such a property in base game code, so no.
Imperius 13 Apr @ 12:39pm 
Can weight of items be modified with the template editor?
Ironmonk 27 Jan @ 7:16pm 
So, I'm trying to create a Predator Class that works like a Hero Faction Soldier with specific Predator skin model and its primary weapon is the vektor-rifle, and I saw that there is a Predator Crossbow model from AVP and it got me thinking... is there a way to automatically swap "Vektor Rifles" skin to this "Predator Crossbow" only when equipped by this Class?

Or do I have to create a new Template for this?

To make it clear what I have in mind, it would be something like this:
Vektor Rifle equipped by Reapers use default skin
Vektor Rifle equipped by Predators use alternate skin
Iridar  [author] 20 Dec, 2024 @ 10:36am 
Hi.
1. Yes.
2. Not sure what you mean by reward deck, but class decks are set up via class data, yes.
3. Yes.
4. This is all done via class data. There's a guide on the /r/xcom2mods wiki on how it's done.

The Template Master here is used just to set up abilities and stat growth per rank, as the game's own way of doing it is a terrible overcomplicated mess that entirely breaks if you look at it wrong.
Dęąth Viper 20 Dec, 2024 @ 9:52am 
Hello, I have a few questions regarding the class creation using this new method.

1. Do I still need to create an XComClassData file to "add" the new classes to the game?

2. How do we add the class to a reward / forced deck? Or do I have to, again, use the classdata.ini

3. If the above question requires classdata.ini, then I assume I have to assign usable weapons as well?

4. How do you add ability point per level? Or is that also included int he stat syntax?
Iridar  [author] 12 Oct, 2024 @ 11:05am 
You got it a bit backwards. Abilities can't be bound to a slot. They can be bound to an item. Soldier class abilities can be set up to point towards a specific inventory slot, but the purpose of doing that is so that in the end the ability gets bound to an item in that happens to be in that inventory slot.

If the ability is already attached to an item, then it's not necessary.
Stukov81-T.TV 12 Oct, 2024 @ 10:44am 
this did definetly work for me. It may be Rapid fire needs to be bound to the weapon slot which you can't really do with WSR or template master. You can try using Ability to Slot Reassignment to get around it

+GIVE_ABILITIES=(WEAPON_CAT=smg, ABILITY=Suppression)
OtoshiGami 12 Oct, 2024 @ 7:47am 
I have the 5 tier overhaul set to schematics and no single build but when I start the game I get magnetic & beam Hunter Rifles from the Pathfinder mod.
As well as Plasma,shredstorm, & elerium rockets from iridar's rocket launcher mod. And BSG Gauss/Laser spark weapons from a spark mod I have to find.

All of them instant buys with no cost in engineering at the start of a new game. The Hunter rifles do have the proper costs.

What template config would I need to make them only visible after research.

I am also trying to give smgs the rapid fire ability but it is only visible in the armory and not usable in tactical.
I have tried WSR and template editor with these commands:

+GIVE_ABILITIES=(WEAPON_CAT=smg, ABILITY=RapidFire)
+GIVE_ABILITIES=(WEAPON_CAT=smg, ABILITY=RapidFire2)

+Edit_X2WeaponTemplate = (RDLC = ("ValhallaRifles"), T = "ARES_MJ_CV", P = "Abilities", OP = "AppendNoDup", V = "RapidFire")
Iridar  [author] 3 Oct, 2024 @ 12:55pm 
Not at the moment.
DukeBurger 3 Oct, 2024 @ 12:50pm 
Are you able to add other status effects to weapons such as bleeding or Disorientation?