(Obsolete) TUTORIAL - Modding Guide

Started by AcDie, January 21, 2014, 05:15:36 AM

Previous topic - Next topic

AcDie

How mod data is structured

RimWorld modding is done by editing definitions. 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.

Definition editing

When you open up the package editor, you'll be able to choose a mod to edit. Once that�s done, you�ll choose a definition to edit (or create a new one). This will open the definition editor. The definition editor displays a hierarchical tree of editable properties in the selected definition. Some of them are expandable into lists; elements can be added and removed from these lists. Some of them have sub-properties.
* Mouse over the names of properties in the definition editor to get more info about them.

(source)

AcDie

Texture/Sound Modding (author - Rhodes)

Interested in creating new textures for RimWorld?  This post is here to get you started!
The process may seem complicated, but is actually quite simple!

Things you will need:

To Begin, Follow These Simple Steps:
Move UnityAssetsExplorer.exe to your Desktop
Open UnityAssetsExplorer.exe.
Click the Open Assets-file button.
Browse to your RimWorld Game Directory.
Open the RimWorld###Win_Data folder.
Highlight the assets file, resources.assets, and then Click the Open button.
Make sure the Covert TEX to DDS box is Checked
Click the Extract All button.

Excellent!  You've just extracted all the goodies and textures used to create RimWorld.

To Continue:
Minimize UnityAssetsExplorer.exe.
Go to your Desktop and open the newly created folder named resources.

You will see lots of files - most of these aren't important. However, some are very important! 
The important ones are the DDS files.  If you installed the required plugins for Photoshop or Gimp, you can open these DDS files to see what textures they contain!

Using Photoshop, open the DDS file you want to modify.  For example, I opened Bed.tex.dds.
In Photoshop, I changed the color of the sheets.  I wanted a Pink bed with my name written on the blanket - so I painted it in!
After I was satisfied with my changes, I clicked Save.

Photoshop then asked me all these weird questions about dds Formats and stuff!
It was simple though.. I only had to change one selection!

If the image is a UI element: Select DXT1 from the Drop-Down List and make sure No MIP maps is selected in the MIP Map Generation box. Then click Save.

If the image is a texture: Select DXT1 from the Drop-Down List and make sure Generate MIP maps is selected in the MIP Map Generation box. Then click Save.

Note: Be sure to keep a list of which files you modified!

Once you have modified all the files you want to change, we're ready to pack them all back into the Resources.assets file and load them into our game!

Open/Focus UnityAssetsExplorer.exe.
You should still have the Resources.assets file open. If not, re-open it using the above instructions.

Depending on how many DDS files you modified, this part may take a little while. I hope you kept that list handy!

Browse through the list in UnityAssetsExplorer and highlight each file you modified. In my case, I highlighted Bed.tex.
Right-Click the Selected Item and choose Import This File from DDS.
Do this for each file you modified.
Once you have finished Importing each file, click the Save as Assets-file button.
Browse back to your RimWorld Game Directory and save the new assets file as something original.  I saved mine as resources.IheartPinkBeds.assets.

I then created a copy of my Original resources.assets file so that I wouldn't lose it.
Then, I renamed my resources.IheartPinkBeds.assets file to resources.assets

The next time I played RimWorld - All my beds were pink!  I didn't even have to start a new game!

After you modify a file (be it DDS or XML or OGG) make sure the file size remains the same as the original.  Otherwise, you could run into issues with your RimWorld loading.  You have been warned.

[EDIT]

How did I go from being all serious to the goofy ending?  This is what happens when I focus on something for more than 5 minutes...

ItchyFlea

#2
I figure we should start writing this up, since there might be some confusion out there about how to do certain things. I know I certainly had trouble.  :)
I'm just going to write things in no particular order. When it comes to releasing Alpha 2, we can organise the information into a readable format. Please correct me if I'm wrong at any point. If I'm unsure of a point, I'll ask in Red

General Modding Advice:

� 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.
� Use Developement Mode (Found in Options) to help debug your mod.

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 <TexturePath>, have the complete path relative to your mod, including the filename (but not the file extension) Example for the RoyalBed Testmod: <TexturePath>Things/Building/RoyalBed</TexturePath>
� 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.

Mod Folder Structure:

While you can name all .xml files whatever you want. You cannot rename the folders; the game looks in folders with specific names to find specific data.

New Interactable '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

New 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. IE:
<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.

New Resources:

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

New 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.
All my mods are licensed under a Attribution-NonCommercial-ShareAlike 4.0 International
Ask for permission before using in ModPacks

Click here for a list of the mods I've created

Tynan

Looks like a great start.

We should get this info on the wiki for release.
Tynan Sylvester - @TynanSylvester - Tynan's Blog

palandus

How does one go about extracting existing textures (I want to make my Bunker Wall look slightly different in color to the current Metal Wall)

Tynan

I'll probably end up just posting all the art assets separately. For now, here's the wall: http://puu.sh/77O5K.psd
Tynan Sylvester - @TynanSylvester - Tynan's Blog

ItchyFlea

Grab UnityAssetsExplorer which Rhodes linked in this article: http://ludeon.com/forums/index.php?topic=1150.0
With that, click 'Open Assets-file' navigate to the game folder, and click on resources.asset (in RimWorld362WinDev_Data) once you've opened that, make sure 'convert TEX to DDS' is ticked, then hit 'extract'.

The software will create a folder called resources, and will fill it with the contents of resources.asset.
From there you can modify the textures. (I use paint.net)
All my mods are licensed under a Attribution-NonCommercial-ShareAlike 4.0 International
Ask for permission before using in ModPacks

Click here for a list of the mods I've created

Haplo

#7
Thanks for the detailled description.

I've built myself a small blacksmith workplace, which works similiar to the stonecutter, only it takes the slag and gives you a bit metal for it.
It works perfectly so far. My biggest problem with it was making a new table picture (I'm no designer :) )

Thanks Tynan for making modding so easy ;D

[attachment deleted by admin: too old]

Tynan

Quote from: Haplo on February 23, 2014, 03:09:06 PM
Thanks for the detailled description.

I've built myself a small blacksmith workplace, which works similiar to the stonecutter, only it takes the slag and gives you a bit metal for it.
It works perfectly so far. My biggest problem with it was making a new table picture (I'm no designer :) )

Thanks Tynan for making modding so easy ;D

You're welcome! That sounds like a sensible workshop to have.
Tynan Sylvester - @TynanSylvester - Tynan's Blog

Haplo

That's what I thought too. :)
You are free to implement it as it's only a play around for me.
Even if I think you can make better tables than me ;D

Architect

#10
I appear to be struggling with my texture sizes. Every time I make a texture, it forces the texture to be a 3*3 square of whatever it is. For instance, my 1*1 sleeping pod occupies one tile but graphically is three times as big?

Edit:
I have found that overdraw makes the image larger than the texture size is? I know not why, but setting overdraw to False seems to have resolved my issue, just in case anyone was having a similar one.
Check out BetterPower+ and all its derivatives by clicking the picture below.

It adds many new methods of power generation and uses for it, as well as other things such as incidents.


Evul

What size are you using? When I do textures I make them 64x64 and scale it up and min 64.

Tynan

Your texture will draw as large as the Thing is, unless you have overdraw on, in which case it will draw one square larger on each side (so you can make it stick off the edge if you wish).
Tynan Sylvester - @TynanSylvester - Tynan's Blog

Nasikabatrachus

#13
Total modding newbie questions: What's the minimum software I need to develop a mod, besides RimWorld itself and image software for textures? How do I edit XML files? Textedit works. My Mac was trying to open XML files with "Big Bang Board Games," which was confusing.

Evul

Pictures can be a transparent png :)
Photoshop gimp or similar software :)