-
Notifications
You must be signed in to change notification settings - Fork 91
Creating an xpath patch
CE adds two new patch operations to make creation of compatibility patches easier.
<Operation Class="CombatExtended.PatchOperationFindMod">
<modName>YourModNameHere</modName>
</Operation>
This operation reports success if the given mod is currently loaded. The intended use is to use a PatchOperationSequence where the first operation is this, followed by all your compatibility patches.
modName: the name of the mod as defined in About.xml
<Operation Class="CombatExtended.PatchOperationMakeGunCECompatible">
<defName></defName>
<statBases></statBases>
<costList></costList>
<Properties></Properties>
<AmmoUser></AmmoUser>
<FireModes></FireModes>
<weaponTags></weaponTags>
<researchPrerequisite></researchPrerequisite>
</Operation>
This operation is intended as a shorthand to cut down on copy-paste when patching guns for CE compatibility by combining frequently used functions into one operation.
defName: your gun's defName. I.e. to patch the vanilla pistol you'd use Gun_Pistol.
statBases: these are the statBases of your gun. Any stats you specify here will be added to the gun's def. If the gun already has a particular stat defined it will override it with the new value. This will also automatically remove the AccuracyTouch/Short/etc. stats since those are not used by CE. If the def doesn't have a statBases node yet it will be added automatically.
costList: if this is specified it will override the gun's costList with this. Note that this will remove all ingredients in the def's cost list and only leave the ones specified in the PatchOperation. If the def has no costList node it will be added
Properties: this automatically removes all vanilla ranged verbs of the gun and replaces them with the one specified here. Does not affect Verb_MeleeAttack.
AmmoUser: this will add a CompAmmoUser with the given CompProperties to the def. Using <AmmoUser />
will create the comp with default settings. If you don't want your gun to have CompAmmoUser simply remove this entry from the patch. If the def has no comps node yet it will be added.
FireModes: same as AmmoUser but for CompFireModes.
weaponTags: this appends the listed tags to the gun's def. If the gun def doesn't have a weaponTags node yet it will add one. Does not affect existing tags.
researchPrerequisite: if this is specified it will override recipeMaker's research prerequisite. For post-WWII era firearms the prerequisite should be CE_AdvancedFirearms, unless your gun has its own prerequisite (such as charge shot) or is very simple in construction (e.g. a modern-day revolver).
Here is an example of what your patch should look like, using a hypothetical compatibility patch for the High Caliber mod:
<?xml version="1.0" encoding="utf-8" ?>
<Patch>
<Operation Class="PatchOperationSequence">
<success>Always</success>
<operations>
<li Class="CombatExtended.PatchOperationFindMod">
<modName>High Caliber</modName>
</li>
<!-- FN Five-Seven -->
<li Class="CombatExtended.PatchOperationMakeGunCECompatible">
<defName>Gun_Fiveseven_HC</defName>
<statBases>
<Mass>0.61</Mass>
<RangedWeapon_Cooldown>0.37</RangedWeapon_Cooldown>
<SightsEfficiency>0.35</SightsEfficiency>
<ShotSpread>0.17</ShotSpread>
<SwayFactor>0.9</SwayFactor>
<Bulk>2.08</Bulk>
<WorkToMake>5000</WorkToMake>
</statBases>
<costList>
<Steel>25</Steel>
<Component>2</Component>
</costList>
<Properties>
<verbClass>CombatExtended.Verb_ShootCE</verbClass>
<hasStandardCommand>true</hasStandardCommand>
<projectileDef>Bullet_FN57x28mm_FMJ</projectileDef>
<warmupTime>0.6</warmupTime>
<range>12</range>
<soundCast>ShotFiveseven</soundCast>
<soundCastTail>GunTail_Light</soundCastTail>
<muzzleFlashScale>9</muzzleFlashScale>
</Properties>
<AmmoUser>
<magazineSize>20</magazineSize>
<reloadTime>4</reloadTime>
<ammoSet>AmmoSet_FN57x28mm</ammoSet>
</AmmoUser>
<FireModes />
<weaponTags>
<li>CE_Sidearm</li>
<li>CE_AI_Pistol</li>
<li>CE_OneHandedWeapon</li>
</weaponTags>
</researchPrerequisite>CE_AdvancedFirearms</researchPrerequisite>
</li>
<!-- SVU -->
<li Class="CombatExtended.PatchOperationMakeGunCECompatible">
<defName>Gun_DragunovSVU_HC</defName>
<statBases>
<Mass>4.20</Mass>
<RangedWeapon_Cooldown>0.37</RangedWeapon_Cooldown>
<SightsEfficiency>1.24</SightsEfficiency>
<ShotSpread>0.06</ShotSpread>
<SwayFactor>1.33</SwayFactor>
<Bulk>8.7</Bulk>
<WorkToMake>18000</WorkToMake>
</statBases>
<costList>
<Steel>60</Steel>
<Component>3</Component>
</costList>
<Properties>
<verbClass>CombatExtended.Verb_ShootCE</verbClass>
<hasStandardCommand>true</hasStandardCommand>
<projectileDef>Bullet_762x54mmR_FMJ</projectileDef>
<warmupTime>1.5</warmupTime>
<range>75</range>
<soundCast>ShotSVU</soundCast>
</Properties>
<AmmoUser>
<magazineSize>10</magazineSize>
<reloadTime>4.5</reloadTime>
<ammoSet>AmmoSet_762x54mmR</ammoSet>
</AmmoUser>
<FireModes>
<aiAimMode>AimedShot</aiAimMode>
</FireModes>
<weaponTags>
<li>CE_AI_Rifle</li>
</weaponTags>
</researchPrerequisite>CE_AdvancedFirearms</researchPrerequisite>
</li>
<!-- etc.. -->
</operations>
</Operation>
</Patch>