Modding Tutorials/Weapons

From RimWorld Wiki
Jump to navigation Jump to search

Modding Tutorials

This page was originally created by Cala13er.

In this tutorial, we'll make a new weapon.


You should have read the Getting Started tutorial, which gets you up to speed with how mods are structured in RimWorld. You should also have a good understanding of where files are located (such as About.xml, def XML files, where you should put textures, and so on).

Making the folders[edit]

If you haven't already created a ThingDef folder as taught in the Getting Started tutorial, you will need to create a new folder in which will contain your new item xml. Inside your Defs folder create a new subfolder called ThingDefs. You're now done as far as creating folders go.

Creating the new weapon[edit]

In this example, we'll be making a gun called the Scar-H.

First of all, we need to get the outline code sorted. Below is what your xml should look like.

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


Next, we will need to make a new abstract ThingDef which will be the Base properties for the a gun.

	<ThingDef Name="BaseGun" Abstract="True">
			<description>Fire a bullet.</description>

Now that we have an abstract ThingDef we will need to make another one for the bullet the gun will use.

	<ThingDef Name="BaseBullet" Abstract="True">

Note that both of these do NOT need to be edited.

Now, we're going to be making the bullet our gun will use. Here is my bullet def for the Scar-H.

	<ThingDef ParentName="BaseBullet">
		<label>7.62×51mm NATO</label>

Now all we have left to do is make the Gun def!

	<ThingDef ParentName="BaseGun">

And there you go! Your very own gun :)

Hopefully, you’ll be able to understand what each property is once you read the page on ThingDef.

Note that the way the game processes shooting a weapon with the above variables is as follows: Start trying to shoot -> wait for warmup ticks -> fire shot -> wait ticksBetweenBurstShots -> fire shot -> wait ticksBetweenBurstShots -> wait for cooldownTicks -> back to warmup ticks.

Obviously the number of shots in the burst can change.


Let’s test our new mod! Fire up RimWorld, making sure to turn on Development mode in the options menu. Open the mods menu and make sure your mod is ticked (For active), and then press the tilde key (~) to check for any errors thrown on runtime. That’s right, no errors! Now start a new game and activate God mode, then attempt to spawn your gun into the game, make your colonist pick the weapon up and try firing with it at a wall!


You now know how to:

  • make your own gun
  • know most of the thingDef's global attributes and their functions with the optional choices

Tutorial brought to you by Cala13er, If you have any questions about this tutorial. Message either Cala13er or Tynan on the forums.

Next we'll learn how to make a flooring!