Difference between revisions of "Modding"

From RimWorld Wiki
Jump to navigation Jump to search
m
(add templates section for further visibility)
(39 intermediate revisions by 23 users not shown)
Line 1: Line 1:
__NOTOC__
+
<!--Top Nav Box-->
 +
{| align=center
 +
| {{Basics_Nav}}
 +
|}
 +
<hr>
  
==MODs files are stored in:==
+
{{See also|List of mods}}
[[File:Folders-OS-Windows-8-Metro-icon.png|36px|link=]] [[File:Folders-OS-Linux-Metro-icon.png|36px|link=]] [[File:Folders-OS-Apple-Metro-icon.png|36px|link=]]
+
'''Mods''' (short for modifications) are small packages that add to or otherwise affect gameplay in RimWorld. They include art packs (for reskinning the game), more weapons, more incidents, furniture, and game-balancing mods.
  
<code>path to game folder/Mods</code>
+
This page is about making mods. For info about using mods, see [[Installing mods]].
  
== How to install mods ==
+
==Mod-making tutorials==  
Finding and Installing mods which is short for modification to your RimWorld is a very easy task to do if you want to add some new content to your game. First you need to look online and find a mod that you want to try out, the main source for finding mods is [[http://ludeon.com/forums/index.php?board=15.0 forum]] which is the mod release section on the main Ludeon site. Once you find a mod you like that is COMPATIBLE with the VERSION of RimWorld you have, or even a few mods you like you can download them from there page in the mod release forum. Once you have downloaded them and opened up your .rar files you just got, its a simple case of drag and dropping the mod folders inside the .rar files into you RimWorld mods folder, Starting up your game and activating the mods. Alot of the RimWorld mods require you to start a new game before the new content is available.
+
Mod-making tutorials are available at the [[Modding Tutorials]] page. If you can't find what you need, you should try looking in [[Modding/Random Bits of Information|Random Bits of Information]] to check if the information you're looking for has been found but just hasn't been organized into the correct article yet.
  
== Editing mods folder ==
+
===Mod-making Templates===
When editing your mods folder you should ALWAYS make a backup in an easy to find place (such as your desktop)in case you come across errors, this way you will always be able to undo a mistake that may occur. and it is also VERY IMPORTANT to never delete the ThingCatagories.XML file in your mod pack, doing this will result in a black screen when trying to start the game up.
+
*[https://ludeon.com/forums/index.php?topic=39038.0 Mod Development Cookiecutter (automatically build your mod development environment)]
  
== Mod Compatibility ==
+
==What you can mod==
Not all mods work with each other, you will know if you have mods that do not work if you are having serious gameplay issue, such as unplaceable items, graphical issue, colonists getting stuck etc.
+
You can mod defs, code, images, and sounds.
  
==General Modding Advice==
+
* '''Defs''': XML files containing lists of definitions for use by the game. There are a lot of these. They define every thing, skills, storyteller, and many other types of data. Find them in YourModName/Defs. More about this later.
*The tilde key (`) brings up the dev console, which will report any errors it encounters. This is the quickest way to see what, if any, errors exist in your mod.
+
* '''Code''': You can add .NET assemblies and the game will load them. Place your DLLs in YourModName/Assemblies. More about this later.
*Use Development Mode (Found in Options) to help debug your mod.
+
* '''Images''': You can add images.
 +
* '''Sounds''': You can add sound files.
  
==Getting started==
+
==The basics: Defs==
===Format of files===
+
The most basic kind of RimWorld modding is done by editing '''defs'''.
 +
 
 +
Definitions each define some piece of the game. Different kinds of definitions can define:
 +
 
 +
* '''Sound'''
 +
* '''Weapons'''
 +
* '''Buildings'''
 +
* '''Plants'''
 +
* '''Animals'''
 +
* '''More (To be determined)'''
 +
 
 +
When the game runs, it collects all the definitions into pools. It then semi-randomly draws from these pools in various circumstances. It will randomly draw guns of a certain category to arm a new enemy mercenary. Or, it will randomly spawn an animal type on the edge of the map. Modding the game means adding your definitions to these pools and watching the game use them in this way.
 +
 
 +
Definitions are organized into packages. Each package is saved as a single XML file.
 +
 
 +
Groups of packages are organized into mods. A mod is a unit of interlinked functionality and content. It could be a pack of new weapons, a new animal, or a total conversion of the game. A mod will usually contain several packages of various types, as well as content like images and sounds.
 +
 
 +
The base game is defined in a single mod called Core.
 +
 
 +
Players can choose which mods to activate. In some cases, several mods can be active at once. You could use a medieval mod to replace the core mod, and add on a weapons pack created by someone else. The game will run with the medieval mod content, and also randomly spawn in weapons from the extra weapons pack.
 +
 
 +
==Mod file structure==
 
For defining new game content, '''[[wikipedia:XML|XML]]''' files are used. Here is an example of the format, that applies to most of the definitions:
 
For defining new game content, '''[[wikipedia:XML|XML]]''' files are used. Here is an example of the format, that applies to most of the definitions:
 
<source lang="xml">
 
<source lang="xml">
Line 33: Line 59:
 
Remember, that the word '''Some''' must be replaced by the name of whatever are you defining. For thing it's '''&lt;ThingDef&gt;'''.
 
Remember, that the word '''Some''' must be replaced by the name of whatever are you defining. For thing it's '''&lt;ThingDef&gt;'''.
  
==Mod structure==
+
The RimWorld mods use the following directory structure:
The RimWorld mods use the following directory structure.
 
 
<pre>
 
<pre>
 
┌About  
 
┌About  
├╴About.xml (Contains info about the mod)
+
├─About.xml (Contains info about the mod)
├╴Preview.png (Image that appears above the mod info in game. Max width 600px.)
+
├─Preview.png (Image that appears above the mod info in game. Max width 600px.)
 
 
 
├Assemblies (If your mod uses any DLL files put them here)
 
├Assemblies (If your mod uses any DLL files put them here)
├╴MyMod.dll
+
├─MyMod.dll
 
 
 
├Defs (Contains xml definitions of the mod)
 
├Defs (Contains xml definitions of the mod)
 
├┬ThingDefs
 
├┬ThingDefs
│├╴Things.xml
+
│├─Things.xml
│└╴Buildings.xml
+
│└─Buildings.xml
 +
 
├┬ResearchProjectDefs
 
├┬ResearchProjectDefs
│└╴MyProjects.xml
+
│└─MyProjects.xml
 +
 
│the folder name must be specific here. Look in Core mod to see what are other names supposed to be
 
│the folder name must be specific here. Look in Core mod to see what are other names supposed to be
 
 
Line 54: Line 81:
 
 
 
├Source
 
├Source
├╴MyMod.cs (Optionally, put the source code of your mod here)
+
├─MyMod.cs (Optionally, put the source code of your mod here)
 +
 +
├Patches
 +
├─Patch.xml
 
 
├Strings
+
├Languages
 +
├┬English (Replace with the language name)
 +
│├┬Keyed
 +
││└─Keys.xml
 +
│├┬Strings
 +
││└┬Names
 +
││  └─PawnNames.xml
 +
│├┬DefInjected
 +
││└┬ThingDef
 +
││  └─Thing.xml
 +
│├─LanguageInfo.xml
 +
│└─LangIcon.png
 
 
 
├Textures (Put any image textures here, preferably in .png format.)
 
├Textures (Put any image textures here, preferably in .png format.)
└┬Things
+
├┬Things
├╴MyMod_ImageA.png
+
│├─MyMod_ImageA.png
└╴MyMod_ImageB.png
+
│└─MyMod_ImageB.png
 
</pre>
 
</pre>
  
===Mod Info:===
+
===Mod info===
This is found in <code>\MODNAME\About\</code>
+
This is found in <code>MODNAME/About</code>
 
*The contents of About.xml are plain text. HTML Markup tags cause NullRef's.
 
*The contents of About.xml are plain text. HTML Markup tags cause NullRef's.
 
*You can have an image for your mod. Restrict the image width to 600 pixels
 
*You can have an image for your mod. Restrict the image width to 600 pixels
  
===Textures:===
+
===Textures===
These are found in <code>\MODNAME\Textures\</code>
+
These are found in <code>MODNAME/Textures</code>
 
*You can have any path you want from this point on.
 
*You can have any path you want from this point on.
*When referencing textures in your mod, using <TexturePath>, have the complete path relative to your mod, including the filename (but not the file extension). Example for the RoyalBed Testmod: <code><TexturePath>Things/Building/RoyalBed</TexturePath></code>
+
*When referencing textures in your mod, using <graphicPath>, have the complete path relative to your mod, including the filename (but not the file extension). Example for the RoyalBed Testmod: <code><graphicPath>Things/Building/RoyalBed</graphicPath></code>
*You can randomize textures within a folder using a <textureFolderPath> pointing at a folder with multiple textures inside. Each Thing of the given def will have a random texture from the folder.
+
 
 +
For textures that have multiple faces, like animals and furniture which can be rotated; You can use the Graphic_multi class. Immediately following your <graphicPath></graphicPath>. Your Path should point to the folder containing the different textures: Texturename_side, Texturename_front, and Texturename_back.  
 +
<source lang="xml" >
 +
<graphicPath>Things/Buildings/RoyalCouch/RoyalCouch</graphicPath>
 +
<graphicClass>Graphic_multi</graphicClass>
 +
</source>
  
===New Interactable "Things":===
+
Inside your folder:
 +
<pre>
 +
┌Textures
 +
└┬Things
 +
└┬Buildings
 +
  └┬RoyalCouch
 +
  ├╴RoyalCouch_side
 +
  ├╴RoyalCouch_front
 +
  └╴RoyalCouch_back
 +
</pre>
 +
 
 +
 
 +
===Interactive "things"===
 
A thing is anything that exists in the game world. It includes resources, races (humanoid and animal), buildings, furniture, and many others.
 
A thing is anything that exists in the game world. It includes resources, races (humanoid and animal), buildings, furniture, and many others.
  
These are defined in <code>\MODNAME\Defs\ThingDefs</code>
+
These are defined in <code>MODNAME/Defs/ThingDefs</code>
 
If you make a new workbench, you'll need to define a recipe for it. This is a list, so you can have many new recipes listed.
 
If you make a new workbench, you'll need to define a recipe for it. This is a list, so you can have many new recipes listed.
  
The recipes themselves are defined in: <code>\MODNAME\Defs\RecipeDefs</code>
+
The recipes themselves are defined in: <code>MODNAME/Defs/RecipeDefs</code>
 
In here you can define what ingredients/resources are required, what can be used, and what the default recipe is.
 
In here you can define what ingredients/resources are required, what can be used, and what the default recipe is.
  
Any new resources will need to be defined in: <code>MODNAME\Defs\ThingDefs</code>
+
Any new resources will need to be defined in: <code>MODNAME/Defs/ThingDefs</code>
  
===New Turrets:===
+
===Turrets===
These are defined in two files in: <code>\MODNAME\Defs\ThingDefs</code>
+
These are defined in two files in: <code>MODNAME/Defs/ThingDefs/Buildings_Big.xml</code> and <code>Weapons_Guns.xml</code> (Remember, these can be named anything)
Buildings_Big.xml and Weapons_Guns.xml (Remember, these can be named anything)
 
  
Buildings_Big.xml defines the structure of the turret itself. IE:
+
Buildings_Big.xml defines the structure of the turret itself. For example:
<syntaxhighlight lang="xml" >
+
<source lang="xml" >
 
<building>
 
<building>
 
<turretGunDef>Gun_TurretImprovised</turretGunDef>
 
<turretGunDef>Gun_TurretImprovised</turretGunDef>
 
<burstCooldownTicks>300</burstCooldownTicks>
 
<burstCooldownTicks>300</burstCooldownTicks>
 
</building>
 
</building>
</syntaxhighlight>
+
</source>
 
Weapons_Gun.xml defines the weapon the turret uses. Anything can be used as a weapon for turrets, including grenades.
 
Weapons_Gun.xml defines the weapon the turret uses. Anything can be used as a weapon for turrets, including grenades.
  
===New Resources:===
+
===Resources===
These are defined in: <code>MODNAME\Defs\ThingDefs\Resources.xml</code>
+
These are defined in: <code>MODNAME/Defs/ThingDefs/Resources.xml</code>
  
===New Research Projects:===
+
===Research projects===
These are found in: <code>MODNAME\Defs\ResearchProjectDefs</code>
+
These are found in: <code>MODNAME/Defs/ResearchProjectDefs</code>
  
 
You can have research trees as well, where additional research projects get unlocked as you move through.
 
You can have research trees as well, where additional research projects get unlocked as you move through.
 
This is how to add prerequisites:
 
This is how to add prerequisites:
<syntaxhighlight lang="xml" >
+
<source lang="xml" >
 
<prerequisites>
 
<prerequisites>
 
<li>-this is the <defName> of the prerequisite-</li>
 
<li>-this is the <defName> of the prerequisite-</li>
 
</prerequisites>
 
</prerequisites>
</syntaxhighlight>
+
</source>
 
Because it's a list, you can have multiple prerequisites for a research project.
 
Because it's a list, you can have multiple prerequisites for a research project.
 +
 +
==Advice==
 +
*The tilde key (` or ~) brings up the development console, which will report any errors or warnings it encounters when a mod loads or during gameplay. This is the quickest way to see what, if any, errors exist in your mod. (You don't need to turn on development mode for this.)
 +
*Use development mode (found in the options menu) to help debug your mod, spawn items related to your mod, or fire incidents at will. (Or just mess around, if you'd like.)
 +
 +
==The other stuff: Code, Graphics, Sound==
 +
 +
You can find links to tutorials on the [[Modding Tutorials]] page. There's also more tutorials about the basics there, so don't miss out on that.
  
 
== References ==
 
== References ==
*[http://ludeon.com/forums/index.php?topic=1681.0 forum thread]
+
*[https://github.com/roxxploxx/RimWorldModGuide/wiki A good guide to assist people trying to mod RimWorld]
*[http://rimworldgame.com/publicArtSource/ThingGraphics.zip RimWorld core art source]
+
*[https://ludeon.com/forums/index.php?topic=39038.0 Mod Development Cookiecutter (automatically build your mod development environment)]
 +
*[http://ludeon.com/forums/index.php?topic=1681.0 Simple tutorial forum thread]
 +
*[https://ludeon.com/forums/index.php?topic=2325.0 RimWorld core art source thread]
 +
 
 +
== Notes ==
 +
*You can have as many mods as you like, however too many mods may affect performance.
 +
*If the game crashes due to a mod-related reason on startup, or mods conflict with each other, then the game will reset the mods.
 +
*Mods for previous versions may be usable, however most of the time they are not compatible.
 +
 
 +
[[Category:Modding]]

Revision as of 23:46, 14 February 2018

Basics Menus Game Creation Gameplay Pawns Plants Resources Gear Mods
Basics Menu Controls User Interface Save File Modding Version history

Mods (short for modifications) are small packages that add to or otherwise affect gameplay in RimWorld. They include art packs (for reskinning the game), more weapons, more incidents, furniture, and game-balancing mods.

This page is about making mods. For info about using mods, see Installing mods.

Mod-making tutorials

Mod-making tutorials are available at the Modding Tutorials page. If you can't find what you need, you should try looking in Random Bits of Information to check if the information you're looking for has been found but just hasn't been organized into the correct article yet.

Mod-making Templates

What you can mod

You can mod defs, code, images, and sounds.

  • Defs: XML files containing lists of definitions for use by the game. There are a lot of these. They define every thing, skills, storyteller, and many other types of data. Find them in YourModName/Defs. More about this later.
  • Code: You can add .NET assemblies and the game will load them. Place your DLLs in YourModName/Assemblies. More about this later.
  • Images: You can add images.
  • Sounds: You can add sound files.

The basics: Defs

The most basic kind of RimWorld modding is done by editing defs.

Definitions each define some piece of the game. Different kinds of definitions can define:

  • Sound
  • Weapons
  • Buildings
  • Plants
  • Animals
  • More (To be determined)

When the game runs, it collects all the definitions into pools. It then semi-randomly draws from these pools in various circumstances. It will randomly draw guns of a certain category to arm a new enemy mercenary. Or, it will randomly spawn an animal type on the edge of the map. Modding the game means adding your definitions to these pools and watching the game use them in this way.

Definitions are organized into packages. Each package is saved as a single XML file.

Groups of packages are organized into mods. A mod is a unit of interlinked functionality and content. It could be a pack of new weapons, a new animal, or a total conversion of the game. A mod will usually contain several packages of various types, as well as content like images and sounds.

The base game is defined in a single mod called Core.

Players can choose which mods to activate. In some cases, several mods can be active at once. You could use a medieval mod to replace the core mod, and add on a weapons pack created by someone else. The game will run with the medieval mod content, and also randomly spawn in weapons from the extra weapons pack.

Mod file structure

For defining new game content, XML files are used. Here is an example of the format, that applies to most of the definitions:

<?xml version="1.0" encoding="utf-8" ?>
<SomeDefs>
   <SomeDef>
      <defName>MyNewDefinitionOfContent</defName>
      <!-- more tags will appear depending on what are you defining -->
   </SomeDef>
</SomeDefs>

Remember, that the word Some must be replaced by the name of whatever are you defining. For thing it's <ThingDef>.

The RimWorld mods use the following directory structure:

┌About 
├─About.xml (Contains info about the mod)
├─Preview.png (Image that appears above the mod info in game. Max width 600px.)
│
├Assemblies (If your mod uses any DLL files put them here)
├─MyMod.dll
│
├Defs (Contains xml definitions of the mod)
├┬ThingDefs
│├─Things.xml
│└─Buildings.xml
│
├┬ResearchProjectDefs
│└─MyProjects.xml
│
│the folder name must be specific here. Look in Core mod to see what are other names supposed to be
│
├Sounds
│
├Source
├─MyMod.cs (Optionally, put the source code of your mod here)
│
├Patches
├─Patch.xml
│
├Languages
├┬English (Replace with the language name)
│├┬Keyed
││└─Keys.xml
│├┬Strings
││└┬Names
││  └─PawnNames.xml
│├┬DefInjected
││└┬ThingDef
││  └─Thing.xml
│├─LanguageInfo.xml
│└─LangIcon.png
│
├Textures (Put any image textures here, preferably in .png format.)
├┬Things
│├─MyMod_ImageA.png
│└─MyMod_ImageB.png

Mod info

This is found in MODNAME/About

  • The contents of About.xml are plain text. HTML Markup tags cause NullRef's.
  • You can have an image for your mod. Restrict the image width to 600 pixels

Textures

These are found in MODNAME/Textures

  • You can have any path you want from this point on.
  • When referencing textures in your mod, using <graphicPath>, have the complete path relative to your mod, including the filename (but not the file extension). Example for the RoyalBed Testmod: <graphicPath>Things/Building/RoyalBed</graphicPath>

For textures that have multiple faces, like animals and furniture which can be rotated; You can use the Graphic_multi class. Immediately following your <graphicPath></graphicPath>. Your Path should point to the folder containing the different textures: Texturename_side, Texturename_front, and Texturename_back.

<graphicPath>Things/Buildings/RoyalCouch/RoyalCouch</graphicPath>
<graphicClass>Graphic_multi</graphicClass>

Inside your folder:

┌Textures
└┬Things
 └┬Buildings
  └┬RoyalCouch
   ├╴RoyalCouch_side
   ├╴RoyalCouch_front
   └╴RoyalCouch_back


Interactive "things"

A thing is anything that exists in the game world. It includes resources, races (humanoid and animal), buildings, furniture, and many others.

These are defined in MODNAME/Defs/ThingDefs If you make a new workbench, you'll need to define a recipe for it. This is a list, so you can have many new recipes listed.

The recipes themselves are defined in: MODNAME/Defs/RecipeDefs In here you can define what ingredients/resources are required, what can be used, and what the default recipe is.

Any new resources will need to be defined in: MODNAME/Defs/ThingDefs

Turrets

These are defined in two files in: MODNAME/Defs/ThingDefs/Buildings_Big.xml and Weapons_Guns.xml (Remember, these can be named anything)

Buildings_Big.xml defines the structure of the turret itself. For example:

<building>
	<turretGunDef>Gun_TurretImprovised</turretGunDef>
	<burstCooldownTicks>300</burstCooldownTicks>
</building>

Weapons_Gun.xml defines the weapon the turret uses. Anything can be used as a weapon for turrets, including grenades.

Resources

These are defined in: MODNAME/Defs/ThingDefs/Resources.xml

Research projects

These are found in: MODNAME/Defs/ResearchProjectDefs

You can have research trees as well, where additional research projects get unlocked as you move through. This is how to add prerequisites:

<prerequisites>
	<li>-this is the <defName> of the prerequisite-</li>
</prerequisites>

Because it's a list, you can have multiple prerequisites for a research project.

Advice

  • The tilde key (` or ~) brings up the development console, which will report any errors or warnings it encounters when a mod loads or during gameplay. This is the quickest way to see what, if any, errors exist in your mod. (You don't need to turn on development mode for this.)
  • Use development mode (found in the options menu) to help debug your mod, spawn items related to your mod, or fire incidents at will. (Or just mess around, if you'd like.)

The other stuff: Code, Graphics, Sound

You can find links to tutorials on the Modding Tutorials page. There's also more tutorials about the basics there, so don't miss out on that.

References

Notes

  • You can have as many mods as you like, however too many mods may affect performance.
  • If the game crashes due to a mod-related reason on startup, or mods conflict with each other, then the game will reset the mods.
  • Mods for previous versions may be usable, however most of the time they are not compatible.