[Tutorial] How to Make a RimWorld Mod, Step by Step

Started by jecrell, June 03, 2017, 05:00:43 AM

Previous topic - Next topic

SpaceDorf

Maxim 1   : Pillage, then burn
Maxim 37 : There is no overkill. There is only open fire and reload.
Rule 34 of Rimworld :There is a mod for that.
Avatar Made by Chickenplucker

Cayprol

#46
Great guide! totally, good for newbies like me.

btw, the example file still hasn't been fixed, that missing "/".

Also, for this guide particularly, I did all this on a Mac.
Just to try out how the recently ported VS works.
Didn't encounter any problem so far, I even used the built-in decompiler to inspect assembly.
Visual Studio for Mac requires Mono 5.0 and higher, so no .NET3.5.

D Mars

#47
Hey so I followed your guide, I'm able to spawn the Plague gun in game but it doesn't work when I try shooting another colonist. I downloaded all 3 files so I can visually compare them and everything seems to match up. I get this error on load though(http://imgur.com/a/T7X7i), any ideas on where I went wrong? Thanks!

Wof

Quote from: D Mars on August 03, 2017, 05:59:31 PM
Hey so I followed your guide, I'm able to spawn the Plague gun in game but it doesn't work when I try shooting another colonist. I downloaded all 3 files so I can visually compare them and everything seems to match up. I get this error on load though(http://imgur.com/a/T7X7i), any ideas on where I went wrong? Thanks!

I had the same issue. The problem was that the .dll wasn't created in my Assemblies folder but instead in a new folder inside the Source folder. I just moved it and it was fine.

D Mars

Quote from: Wof on August 03, 2017, 08:36:42 PM

I had the same issue. The problem was that the .dll wasn't created in my Assemblies folder but instead in a new folder inside the Source folder. I just moved it and it was fine.

This was it! Plague gun works now with no issues! Thanks bro you're the best!

Wof


SpaceDorf

Thank you flying spaghetti monster for finally sending my to the right IDE

sometimes microsoft gets it right

it's fast, it's portable, it's beautiful ..
Maxim 1   : Pillage, then burn
Maxim 37 : There is no overkill. There is only open fire and reload.
Rule 34 of Rimworld :There is a mod for that.
Avatar Made by Chickenplucker

Eck

Awesome tutorial, but I think there are some unnecessary steps. You don't need to (and I don't think you should) include all the parent base items in your custom RangedWeapon_PlagueGun.xml file. Those entries will already included from the Core game files so the copied entries aren't necessary (and might cause conflicts). Basically skip step 11, and remove every ThingDef in the RangedWeapon_PlagueGun.xml file after the BASES comment.

I followed the tutorial through and got everything working even though I raised my eyebrow at the copy/pasted base classes. After that, I deleted all the base def entries, changed some other things like fire rate and range, and everything still worked.

@Tynan - Could you double check my post and make sure I'm giving good advice. I only just started messing with modding Rim World and even though I tested what I said, I wouldn't mind a sanity check. :)

- Eck

Spdskatr

#53
Quote from: Eck on August 06, 2017, 03:06:36 PM
Awesome tutorial, but I think there are some unnecessary steps. You don't need to (and I don't think you should) include all the parent base items in your custom RangedWeapon_PlagueGun.xml file. Those entries will already included from the Core game files so the copied entries aren't necessary (and might cause conflicts). Basically skip step 11, and remove every ThingDef in the RangedWeapon_PlagueGun.xml file after the BASES comment.

Always add the abstracts in. When I was developing my plastics mod (rip that mod) I had a weird conflict with Numbers (that I only discovered during casual play and probably wasn't the fault of the mod author) that meant the game wasn't recognizing the abstracts from other mod folders, causing errors like "ThingDef __ has null ThingClass". It disappeared only when I added the building and resource base abstracts.

The abstracts thing was supposedly meant to start inheriting from previous mods in A14, but I developed the mod in A16.

Moral of the story: Always add them in. You may get unexpected and obscure bugs.

P.S. If it works for you then you really don't need to read any of this. it's just a warning in case you encounter null ThingClass errors in the future :P
My mods

If 666 is evil, does that make 25.8069758011 the root of all evil?

BinkyThePirate

This is a very useful intro to modding basics, and for the most part I know enough xml and C# to get what's going on in it, but with the 'var plagueOnPawn' section I'm not really clear on what is happening, just retyping what's there in the tutorial without really understanding why. Could someone give a basic rundown of what's actually going on there?

Jibbles

New to visual studios..and it's late.  Just don't hate me for asking. I sort of get stuck at step 18 and I want to make sure I'm doing this right.

He mentions going into the application tab.  Is "project options" the same thing?
http://i.imgur.com/dmwUfrw.png
This window is the only place I see where I can change stuff like the namespace, framework etc. 


Quote20) Go to the Build tab in the project properties.

21) Change the output path to be RimWorld\Mods\PlagueGun\Assemblies
- All .dll files will go into this directory when we "build" our code library.

22) In that same window, click the Advanced... button.

23) Change Debugging information to none.
- This prevents a simple error that occurs when RimWorld doesn't know what to do with the debug .pdb files.

This is what makes me think I'm in the wrong place. I don't see an advanced button, or overlooking where I can change the debug information to none.

BinkyThePirate

Mac layout of Visual Studio seems slightly different. For Windows, clicking on 'Build' from the menu tree on your left would bring up the Build properties tab, where you can set the options mentioned. Check under the 'Output' sub-menu, that might let you change the output path and give you the No Debugging Info option. But that's just a guess. Maybe someone with VS for Mac can offer more help. It's probably inside one of those sub-menus under Build, though.

janospalfi

#57
Thanks for the tutorial, easy to follow and actually goes into coding.  After putting it all together, I get the gun to spawn and everything works as intended, however, upon loading the mod I receive a bunch of XML errors:
XML error: Duplicate XML node name #text in this XML block: <ThingDef Name="BaseMakeableGun" ParentName="BaseGun" Abstract="True">
I've been through the xml file looking for a missing /
Tried removing the Bases
And haven't been able to figure out what the problem is

Jibbles

Find it strange that there isn't a completed version to download so we can test and see how everything is supposed to look and work. Can someone share? I'm grateful for this tutorial but I'm not able to get it to work.

still missing the / in xml file.

I come across errors even though I've copied things word for word. Guess I'm doing something wrong when it comes building the project.

Could not find type named Plague.ThingDef_PlagueBullet from node
Could not find a type named Plague.Projectile_PlagueBullet
XML error: <AddHediffChance>0.05</AddHediffChance> doesn't correspond to any field in type ThingDef.
XML error: <HediffToAdd>Plague</HediffToAdd> doesn't correspond to any field in type ThingDef.
Config error in TST_Bullet_PlagueGun: TST_Bullet_PlagueGun has null thingClass.

Veridian

#59
Quote from: Jibbles on August 23, 2017, 02:11:00 AM
Find it strange that there isn't a completed version to download so we can test and see how everything is supposed to look and work. Can someone share? I'm grateful for this tutorial but I'm not able to get it to work.

still missing the / in xml file.

I come across errors even though I've copied things word for word. Guess I'm doing something wrong when it comes building the project.

Could not find type named Plague.ThingDef_PlagueBullet from node
Could not find a type named Plague.Projectile_PlagueBullet
XML error: <AddHediffChance>0.05</AddHediffChance> doesn't correspond to any field in type ThingDef.
XML error: <HediffToAdd>Plague</HediffToAdd> doesn't correspond to any field in type ThingDef.
Config error in TST_Bullet_PlagueGun: TST_Bullet_PlagueGun has null thingClass.

Hey, I found the solution to this problem after running into it myself.

For whatever reason, this tutorial has the wrong information regarding the file hierarchy of the mods folder. You can see the correct hierarchy here: http://rimworldwiki.com/wiki/Modding_Tutorials/Mod_folder_structure

I would recommend downloading a mod that adds guns, looking over their file format, and then restructuring the plague gun folder to look like theirs. I did that, and it fixed the issue.

Unfortunately, now that the gun can be spawned in the game, it doesn't appear to be causing the plague. Even though I get the text telling me that it was a successful plague inflict, the pawn does not have the plague. Will look into it more.

Otherwise, this is a wonderful resource when getting into modding. But, if you are new to modding and are looking to use this guide, I have to recommend looking over the modding wiki a few times first. This step by step tutorial has a few bumps that will be really difficult to overcome unless you use the resources on the wiki.

Edit: So as it turns out, the gun does work! Due to how the plague works, the gun will inflict a 'hidden' plague on the victim. This plague will develop overtime until it reaches a threshold upon which it will notify you that that pawn has the plague! Alternatively, you can just keep shooting the victim, and assuming they don't die first, you'll eventually be notified that they have the plague. This is because the C# code adds the severity to a pawn who already has the plague rather than resetting the severity. Neat!