XML Stage

1) Create a mod folder.

RimWorld>Mods>PlagueGun

2) Inside PlagueGun, make an About folder.

RimWorld>Mods>PlagueGun>About

3) Inside the About folder, make a new text file and rename it About.xml.

RimWorld>Mods>PlagueGun>About>About.xml

<?xml version="1.0" encoding="utf-8"?>



<ModMetaData>

<name>Test Mod - Plague Gun</name>

<author>YourName</author>

<targetVersion>0.17.0</targetVersion>

<description>V1.0

This mod adds a plague gun, a weapon that has a chance to give your enemies the plague.

</description>

</ModMetaData>



4) Add a Preview.png or Preview.jpeg to your About folder.

RimWorld>Mods>PlagueGun>About>Preview.png

5) Make a Defs folder in your Mod's directory.

RimWorld>Mods>PlagueGun>Defs



What are Defs?

RimWorld uses something called Defs like blueprints for in-game objects. Instead of using hidden C# code, RimWorld will look up an XML Def and copy it to the game world. This makes things easier for us, the modders. Everything from characters, animals, floors, damages, buildings, and even diseases in RimWorld use Defs. We're going to make Defs for our Plague Gun and Plague Bullet.



6) Make a new ThingDefs folder in your Defs folder.

RimWorld>Mods>PlagueGun>Defs>ThingDefs

7) Make a new text file in your ThingDefs folder, and change it to RangedWeapon_PlagueGun.xml.

RimWorld>Mods>PlagueGun>Defs>ThingDefs>RangedWeapon_PlagueGun.xml

DO NOT USE THIS -- This is an incomplete preview.



<?xml version="1.0" encoding="utf-8"?>

<Defs>



<ThingDef ParentName="BaseBullet">

<defName>TST_PlagueGun_Bullet</defName>

<label>plague bullet</label>

...

</ThingDef>



<ThingDef ParentName="BaseHumanMakeableGun">

<defName>TST_PlagueGun_Weapon</defName>

<label>plague gun</label>

...

</ThingDef>



</Defs>



9a) First add our favorite line to the top.

<?xml version="1.0" encoding="utf-8"?>



9b) Add <Defs> opening and closing tags to the XML to hold our new code.

<?xml version="1.0" encoding="utf-8"?>

<Defs>





</Defs>



9c) Use your text editor. Use its "Find in Files" function to reference and copy Bullet_Revolver to your XML file.

10) Use your text editor. Use its "Find in Files" function to reference and copy Gun_Revolver to your XML file.

11) Change the defName, labels, and other stats of Bullet_Revolver and Revolver in your XML file to make them unique.

TIP

Change the <defaultProjectile> tag inside the PlagueGun's Verbs to use the defName of your bullet (TST_Bullet_PlagueGun). Failing to do this will result in a no errors, but your gun will shoot regular bullets and not give the plague effect.



Once again, under the verbs. Please make sure <defaultProjectile> references the bullet.

e.g.

<defaultProjectile>TST_Bullet_PlagueGun</defaultProjectile>

<?xml version="1.0" encoding="utf-8"?>



<Defs>



<ThingDef ParentName="BaseBullet">

<defName>TST_Bullet_PlagueGun</defName>

<label>plague bullet</label>

<graphicData>

<texPath>Things/Projectile/Bullet_Small</texPath>

<graphicClass>Graphic_Single</graphicClass>

</graphicData>

<projectile>

<flyOverhead>false</flyOverhead>

<damageDef>Bullet</damageDef>

<damageAmountBase>9</damageAmountBase>

<speed>55</speed>

</projectile>

</ThingDef>



<ThingDef ParentName="BaseHumanMakeableGun">

<defName>TST_Gun_PlagueGun</defName>

<label>plague gun</label>

<description>A curious weapon notable for its horrible health effects.</description>

<graphicData>

<texPath>Things/Item/Equipment/WeaponRanged/Revolver</texPath>

<graphicClass>Graphic_Single</graphicClass>

</graphicData>

<soundInteract>InteractRevolver</soundInteract>

<statBases>

<WorkToMake>15000</WorkToMake>

<Mass>1.4</Mass>

<AccuracyTouch>0.91</AccuracyTouch>

<AccuracyShort>0.71</AccuracyShort>

<AccuracyMedium>0.50</AccuracyMedium>

<AccuracyLong>0.32</AccuracyLong>

<RangedWeapon_Cooldown>1.26</RangedWeapon_Cooldown>

<Weapon_Bulk>0.5</Weapon_Bulk>

</statBases>

<weaponTags>

<li>SimpleGun</li>

</weaponTags>

<costList>

<Steel>30</Steel>

<Component>2</Component>

</costList>

<verbs>

<li>

<verbClass>Verb_Shoot</verbClass>

<hasStandardCommand>true</hasStandardCommand>

<defaultProjectile>TST_Bullet_PlagueGun</defaultProjectile>

<warmupTime>0.3</warmupTime>

<range>26</range>

<soundCast>ShotRevolver</soundCast>

<soundCastTail>GunTail_Light</soundCastTail>

<muzzleFlashScale>9</muzzleFlashScale>

</li>

</verbs>

<tools>

<li>

<label>grip</label>

<capacities>

<li>Blunt</li>

</capacities>

<power>8</power>

<cooldownTime>1.6</cooldownTime>

</li>

<li>

<label>barrel</label>

<capacities>

<li>Blunt</li>

<li>Poke</li>

</capacities>

<power>8</power>

<cooldownTime>1.6</cooldownTime>

</li>

</tools>

</ThingDef>



</Defs>

