Difference between revisions of "Modding"

From RimWorld Wiki
Jump to navigation Jump to search
(Changing this page over to be a hub page for using mods and removing duplicate/obsolete information about modmaking in favor of a link to the Modding Tutorials hub instead.)
Line 4: Line 4:
 
|}
 
|}
 
----
 
----
{{About|making mods|info about using mods|Installing mods}}
 
  
'''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. RimWorld mods may make use of XML and C#.
+
'''Game modifications''' (or '''mods''') are a way of altering the way the game functions by adding, changing, or removing content such as items, textures, sounds, or more. RimWorld has built-in support for modding, including Steam Workshop support.
  
==Mod-making tutorials==
+
== Using Mods ==
Mod-making tutorials are available on the [[Modding Tutorials]] page. If you can't find what you need, you should try looking in [https://ludeon.com/forums/index.php?board=14.0 the forum's help section on modding] to check whether the information you're looking for has been asked previously before starting a new thread.
 
  
===Mod-making Templates===
+
If you own RimWorld on Steam, then the easiest way of finding and downloading mods is by using [https://steamcommunity.com/app/294100/workshop/ Steam Workshop]. Steam Workshop automates the process of downloading and installing mods, as well as keeping them up to date with new releases.
*[https://ludeon.com/forums/index.php?topic=39038.0 Mod Development Cookiecutter (automatically build your mod development environment)]
 
  
===Multi-version Mods===
+
Even if you do not own RimWorld on Steam, Workshop can still be used to discover new mods; while some mods are released on [https://www.nexusmods.com/rimworld Nexus Mods], no other mod site has close to the same amount of mods available. You can use tools such as [https://github.com/rimpy-custom/RimPy/releases RimPy] to download and install mods from Steam Workshop and GitHub instead.
You can make your mod work across several versions rather than breaking compatibility each time the game has a significant update. Here's Tynan's post & Google Doc explaining how to do it: https://store.steampowered.com/news/app/294100/view/5512953038607155444
 
  
==What you can mod==
+
=== Manual Installation ===
RimWorld does not limit what you can or can't do. The only limit is skills and motivation, or patience and willpower. You can mod everything, from Defs to code, images, and sounds. Some examples:
 
  
* '''Defs''': XML files containing lists of definitions for use by the game. There are a lot of these. They define every item/thing, skills, storyteller, and many other types of data. Find them in YourModName/Defs. More about this later.
+
You can install mods manually by unzipping them into subfolders within your local Mods folder. This location varies by operating system:
* '''Code''': You can add .NET assemblies, and the game will load them. Place your DLLs in YourModName/Assemblies. There is no API for RimWorld modding, but you can make full use of RimWorld's functions. You also have the full power of the .NET Framework 3.5 available. More about this later.
 
* '''Images''': You can add images.
 
* '''Sounds''': You can add sound files.
 
* '''Patches''': Using XPath, you can edit Defs with pinpoint precision to change only the values you need to change while staying as compatible as possible with other mods.
 
* '''Jobs''':  A useful link here https://github.com/Mehni/ExampleJob/wiki - covers JobGivers WorkGivers and Toils
 
** Higher level, explanation on how pawns think:  https://github.com/roxxploxx/RimWorldModGuide/wiki/SHORTTUTORIAL%3A-How-Pawns-Think
 
  
==The basics: Defs==
+
{| class="wikitable" style="margin-right:auto"
The most basic type of RimWorld modding is editing '''Defs'''.
+
|-
 +
! Operating System !! Default Folder Location
 +
|-
 +
| Windows || <code>C:\Program Files (x86)\Steam\steamapps\common\RimWorld\Mods</code>
 +
|-
 +
| Mac || <code>Library/Application/Support/Steam/steamapps/common/RimWorld</code>
 +
|-
 +
| Linux (standalone) || <code>~/.steam/steam/steamapps/common/RimWorld/Mods</code>
 +
|-
 +
| Linux (GoG) || <code>/home/<user>/GOG/Games/RimWorld/game/Mods/</code>
 +
|}
  
Definitions each define some piece of the game. Different kinds of definitions can define:
+
=== Activating Mods ===
  
* '''Weapons'''
+
Once you have installed mods, you can select the '''Mods''' option from the main menu of RimWorld to activate them. Activating or deactivating mods requires RimWorld to restart.
* '''Buildings'''
 
* '''Plants'''
 
* '''Animals'''
 
* '''Sound'''
 
* '''Research'''
 
* '''Biomes'''
 
* '''Much much more'''
 
  
When the game runs, it collects all the definitions into a database. It then draws from these pools when appropriate. It will randomly draw guns of a particular category to arm a new enemy mercenary. Or, it will randomly spawn an animal type on the edge of the map. Modding the game with Defs means adding your definitions to these pools and watching the game use them.
+
== Making Mods ==
  
A mod could be a pack of new weapons, a new animal, or a total conversion of the game. A mod will usually contain several Defs of various types and content like images and sounds.
+
Please check out the [[Modding_Tutorials|Modding Tutorials]] hub for tutorials and guides on how to create and publish your own mods.
 
 
The base game is defined in a single mod called Core.
 
 
 
Players can choose which mods to activate. Most players often have several mods active at once. You could use a medieval mod to replace the core mod and add it to a weapons pack created by someone else. The game will run with the medieval mod content while randomly spawning 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:
 
<source lang="xml">
 
<?xml version="1.0" encoding="utf-8" ?>
 
<Defs>
 
  <SomeDef>
 
      <defName>MyNewDefinitionOfContent</defName>
 
      <!-- more tags will appear depending on what are you defining -->
 
  </SomeDef>
 
</Defs>
 
</source>
 
All rootnodes for Defs start with '''&lt;Defs&gt;'''. Remember, that the word '''Some''' must be replaced by the name of whatever are you defining. For thing it's '''&lt;ThingDef&gt;'''.
 
 
 
The RimWorld mods use the following directory structure. Root folders have to follow the naming pattern (About, Assemblies, Defs, Sounds, Patches, Textures, Languages) to be read by RimWorld. Apart from the Languages Folder, subfolders can have any structure. For the sake of organisation, modders are encouraged to keep things categorised:
 
<pre>
 
┌About (Your mod MUST have an About folder containing an About.xml file. Case sensitive)
 
├─About.xml (Contains info about the mod)
 
├─Preview.png (Image that appears above the mod info in-game)
 
 
├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
 
 
 
├┬Sounds (Put any sound files here. Universally supported formats are .ogg and .wav. .mp3 files are not guaranteed to work)
 
├─MySound.wav
 
|
 
├Source
 
├─MyMod.cs (Optionally, put the source code of your mod here)
 
 
├Patches
 
├─MyPatch.xml
 
 
├Languages
 
├┬English (Replace with the language name)
 
│├┬Keyed
 
││└─Keys.xml
 
│├┬Strings
 
││└┬Names
 
││  └─PawnNames.xml
 
│├┬DefInjected (NOTE: the folder (and subfolder) names must be specific here and follow the XML structure of the mod)
 
││└┬ThingDef
 
││  └─Thing.xml
 
│├─LanguageInfo.xml
 
│└─LangIcon.png
 
 
├Textures (Put any image textures here, preferably in .png format.)
 
├┬Things
 
│├─MyMod_ImageA.png
 
│└─MyMod_ImageB.png
 
</pre>
 
 
 
===Mod info===
 
This is found in <code>MODNAME/About</code>
 
*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 size to 1 MB.
 
 
 
===Textures===
 
These are found in <code>MODNAME/Textures</code>
 
*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: <code><graphicPath>Things/Building/RoyalBed</graphicPath></code>
 
 
 
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_east (for both east- and west-facing), Texturename_south (front-facing), and Texturename_north (back-facing).
 
<source lang="xml" >
 
<graphicPath>Things/Buildings/RoyalCouch/RoyalCouch</graphicPath>
 
<graphicClass>Graphic_Multi</graphicClass>
 
</source>
 
 
 
Inside your folder:
 
<pre>
 
┌Textures
 
└┬Things
 
└┬Buildings
 
  └┬RoyalCouch
 
  ├╴RoyalCouch_east
 
  ├╴RoyalCouch_south
 
  └╴RoyalCouch_north
 
</pre>
 
 
 
For plant textures with multiple growth stages and/or utilize the Graphic_Random class, the different images for each stage must be in separate folders. These images within must also share the same filenames. For example, the [[corn plant]] has one immature form and two different mature forms that appear at random once the plant is fully grown. Similar to Graphic_Multi, when using the Graphic_Random class, you will always want to reference the folder containing the images rather than the images themselves. It should be noted that only harvestable plants can display an immature image.
 
 
 
An example of how retexturing a plant could work:
 
 
 
<source lang="xml" >
 
<graphicPath>Things/Plants/CornPlant</graphicPath>
 
<graphicClass>Graphic_Random</graphicClass>
 
</source>
 
 
 
Your folder structure:
 
<pre>
 
┌Textures
 
└┬Things
 
└┬Plants
 
  └┬CornPlant
 
  ├╴CornPlant_A
 
  └╴CornPlant_B
 
  └┬CornPlant_Immature
 
  ├╴CornPlant_A
 
  └╴CornPlant_B
 
</pre>
 
 
 
Even though there is only one image used for the immature corn plant, we must have two copies of it with the same filenames as the mature plant images to prevent broken textures in-game.
 
If you wanted to add a leafless variant to a plant (such as the leafless trees in winter), you would add another folder.
 
 
 
<pre>
 
┌Textures
 
└┬Things
 
└┬Plants
 
  └┬CornPlant
 
  ├╴CornPlant_A
 
  └╴CornPlant_B
 
  └┬CornPlant_Immature
 
  ├╴CornPlant_A
 
  └╴CornPlant_B
 
  └┬CornPlant_Leafless
 
  ├╴CornPlant_A
 
  └╴CornPlant_B
 
</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.
 
 
 
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 that you can have many new recipes listed. Note that new workbenches also need a WorkGiver tied to them; otherwise, pawns will ignore your new bench.
 
 
 
The recipes themselves are defined in: <code>MODNAME/Defs/RecipeDefs</code>
 
Here, you can define what ingredients/resources are required, what can be used, and the default recipe.
 
 
 
Any new resources will need to be defined in: <code>MODNAME/Defs/ThingDefs</code>
 
 
 
===Turrets===
 
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 defines the structure of the turret itself. For example:
 
<source lang="xml" >
 
<building>
 
<turretGunDef>Gun_MiniTurret</turretGunDef>
 
<turretBurstCooldownTime>4.8</turretBurstCooldownTime>
 
</building>
 
</source>
 
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: <code>MODNAME/Defs/ThingDefs/Resources.xml</code>
 
 
 
===Research projects===
 
These are found in: <code>MODNAME/Defs/ResearchProjectDefs</code>
 
 
 
You can also have research trees, where additional research projects get unlocked as you move through.
 
This is how to add prerequisites:
 
<source lang="xml" >
 
<prerequisites>
 
<li>-this is the <defName> of the prerequisite-</li>
 
</prerequisites>
 
</source>
 
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. The dev console 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.)
 
* Code injection is generally bad since it leads to mod conflicts. This was a previous practice for altering runtime code but is out of vogue as of version ~A17. Use [[Modding_Tutorials/Harmony|Harmony]] instead.
 
 
 
==I want to make a mod that can...==
 
'''Or, how do I make my mod do ''this''?'''
 
 
 
You can find links to tutorials on the [[Modding Tutorials]] page. There are also more tutorials about the basics there, so don't miss out on that.
 
 
 
* Save/Load information.  See a very useful guide at [https://spdskatr.github.io/RWModdingResources/saving-guide this page]
 
** For saving settings for your mod, either use a class that extends ModSettings or use HugsLib.
 
** For saving per-world data, make a [[Modding Tutorials/GameComponent|Game Component]] and override ExposeData
 
* Add a new value to a def
 
** See [[Modding Tutorials/ThingComp|ThingComp]]
 
** Also helpful: [[Modding Tutorials/DefModExtension|DefModExtension]]s
 
 
 
== References ==
 
*[https://github.com/roxxploxx/RimWorldModGuide/wiki A good guide to assist people trying to mod RimWorld]
 
*[https://spdskatr.github.io/RWModdingResources/ A good collection of guides for RimWorld modders]
 
*[https://ludeon.com/forums/index.php?topic=39038.0 Mod Development Cookiecutter (automatically build your mod development environment)]
 
**Note: Created project is set up for RimWorld 1.1 and requires updating .NET version to 4.72 to work with RimWorld 1.3.
 
*[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]]
 
[[Category:Modding]]

Revision as of 04:33, 13 June 2023

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

Game modifications (or mods) are a way of altering the way the game functions by adding, changing, or removing content such as items, textures, sounds, or more. RimWorld has built-in support for modding, including Steam Workshop support.

Using Mods

If you own RimWorld on Steam, then the easiest way of finding and downloading mods is by using Steam Workshop. Steam Workshop automates the process of downloading and installing mods, as well as keeping them up to date with new releases.

Even if you do not own RimWorld on Steam, Workshop can still be used to discover new mods; while some mods are released on Nexus Mods, no other mod site has close to the same amount of mods available. You can use tools such as RimPy to download and install mods from Steam Workshop and GitHub instead.

Manual Installation

You can install mods manually by unzipping them into subfolders within your local Mods folder. This location varies by operating system:

Operating System Default Folder Location
Windows C:\Program Files (x86)\Steam\steamapps\common\RimWorld\Mods
Mac Library/Application/Support/Steam/steamapps/common/RimWorld
Linux (standalone) ~/.steam/steam/steamapps/common/RimWorld/Mods
Linux (GoG) /home/<user>/GOG/Games/RimWorld/game/Mods/

Activating Mods

Once you have installed mods, you can select the Mods option from the main menu of RimWorld to activate them. Activating or deactivating mods requires RimWorld to restart.

Making Mods

Please check out the Modding Tutorials hub for tutorials and guides on how to create and publish your own mods.