Skip to content
XeoNovaDan edited this page Jul 23, 2019 · 5 revisions

Making weapons work with Proper Shotguns:
If you want to make shotguns from your mod behave like the pump and chain shotgun when Proper Shotguns is active, you'll naturally need to make a patch so that Proper Shotguns' functionality is used. In order to do this, you will need to take advantage of ProperShotguns.ShotgunExtension and ProperShotguns.Verb_ShootShotgun.

The following XML can be used as a template for patching shotguns, which you would of course put in your mod's 'Patches' folder and replace all occurrences of YourShotgunProjectile and YourShotgun with the appropriate defNames:

<Patch>

    <Operation Class="PatchOperationFindMod">
        <mods>
            <li>[XND] Proper Shotguns</li>
        </mods>
        <match Class="PatchOperationSequence">
            <success>Always</success>
            <operations>
                <!-- Defines how many total pellets are launched for the shotgun's projectile -->
                <!-- You also don't need to change damage amount; the mod will take care of that automatically -->
                <li Class="PatchOperationAddModExtension">
                    <xpath>/Defs/ThingDef[defName="YourShotgunProjectile"]</xpath>
                    <value>
                        <li Class="ProperShotguns.ShotgunExtension">
                            <pelletCount>6</pelletCount>
                        </li>
                    </value>
                </li>

                <!-- Changes the shotgun projectile's texture so that it appears to be a single pellet -->
                <li Class="PatchOperationReplace">
                    <xpath>/Defs/ThingDef[defName="YourShotgunProjectile"]/graphicData/texPath</xpath>
                    <value>
                        <texPath>Things/Projectile/Bullet_Small</texPath>
                    </value>
                </li>

                <!-- Effectively tells the game that the shotgun should fire buckshots according to its projectile's pelletCount -->
                <li Class="PatchOperationReplace">
                    <xpath>/Defs/ThingDef[defName="YourShotgun"]/verbs//li[verbClass="Verb_Shoot" and defaultProjectile="YourShotgunProjectile"]/verbClass</xpath>
                    <value>
                        <verbClass>ProperShotguns.Verb_ShootShotgun</verbClass>
                    </value>
                </li>
            </operations>
        </match>
    </Operation>

</Patch>

Alternatively, if you want to patch another mod to use Proper Shotguns' functionality, you can use this XML as a template, replacing Super Duper Shotguns, SuperDuperShotgunProjectile and TheSuperestShotgun with the mod's name (as defined in its About.xml file) and appropriate defNames respectively:

<Patch>

    <Operation Class="PatchOperationFindMod">
        <mods>
            <li>[XND] Proper Shotguns</li>
        </mods>
        <match Class="PatchOperationFindMod">
            <mods>
                <li>Super Duper Shotguns</li>
            </mods>
            <match Class="PatchOperationSequence">
                <success>Always</success>
                <operations>
                    <!-- Defines how many total pellets are launched for the shotgun's projectile -->
                    <!-- You also don't need to change damage amount; the mod will take care of that automatically -->
                    <li Class="PatchOperationAddModExtension">
                        <xpath>/Defs/ThingDef[defName="SuperDuperShotgunProjectile"]</xpath>
                        <value>
                            <li Class="ProperShotguns.ShotgunExtension">
                                <pelletCount>6</pelletCount>
                            </li>
                        </value>
                    </li>

                    <!-- Changes the shotgun projectile's texture so that it appears to be a single pellet -->
                    <li Class="PatchOperationReplace">
                        <xpath>/Defs/ThingDef[defName="SuperDuperShotgunProjectile"]/graphicData/texPath</xpath>
                        <value>
                            <texPath>Things/Projectile/Bullet_Small</texPath>
                        </value>
                    </li>

                    <!-- Effectively tells the game that the shotgun should fire buckshots according to its projectile's pelletCount -->
                    <li Class="PatchOperationReplace">
                        <xpath>/Defs/ThingDef[defName="TheSuperestShotgun"]/verbs//li[verbClass="Verb_Shoot" and defaultProjectile="YourShotgunProjectile"]/verbClass</xpath>
                        <value>
                            <verbClass>ProperShotguns.Verb_ShootShotgun</verbClass>
                        </value>
                    </li>
                </operations>
            </match>
        </match>
    </Operation>

</Patch>
Clone this wiki locally