[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

Quote from: SpaceDorf on August 06, 2017, 05:57:16 AM
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 ..

Or not .. VisualStudio it is then .. fascinating that the IDE has become the greatest obstacle to start programming...
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

CrazyMalk

Gosh... I'm getting my a** kicked from Visual Studio 2017... For some reasone there isn't any "build" tab in the Properties menu. Does anyone knows why?

CrazyMalk

Nevermind, got it to work! But now i'm having a problem when trying to build the project:
Severity Code Description Project File Line Suppression State
Error CS0117 'HediffDefOf' does not contain a definition for 'Petrification' BasiliskEye C:\Users\USUARIO\source\repos\BasiliskEye\BasiliskEye\BasiliskVision.cs 15 Active
Error CS1061 'Projectile_PetrifyBullet' does not contain a definition for 'def' and no extension method 'def' accepting a first argument of type 'Projectile_PetrifyBullet' could be found (are you missing a using directive or an assembly reference?) BasiliskEye C:\Users\USUARIO\source\repos\BasiliskEye\BasiliskEye\Petrify.cs 16 Active
Error CS1061 'Projectile_PetrifyBullet' does not contain a definition for 'launcher' and no extension method 'launcher' accepting a first argument of type 'Projectile_PetrifyBullet' could be found (are you missing a using directive or an assembly reference?) BasiliskEye C:\Users\USUARIO\source\repos\BasiliskEye\BasiliskEye\Petrify.cs 30 Active
Error CS0115 'Projectile_PetrifyBullet.Impact(Thing)': no suitable method found to override BasiliskEye C:\Users\USUARIO\source\repos\BasiliskEye\BasiliskEye\Petrify.cs 21 Active
Error CS1061 'string' does not contain a definition for 'Translate' and no extension method 'Translate' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) BasiliskEye C:\Users\USUARIO\source\repos\BasiliskEye\BasiliskEye\Petrify.cs 29 Active
Error CS0103 The name 'HediffMaker' does not exist in the current context BasiliskEye C:\Users\USUARIO\source\repos\BasiliskEye\BasiliskEye\Petrify.cs 40 Active
Error CS0103 The name 'Messages' does not exist in the current context BasiliskEye C:\Users\USUARIO\source\repos\BasiliskEye\BasiliskEye\Petrify.cs 29 Active
Error CS0103 The name 'MessageSound' does not exist in the current context BasiliskEye C:\Users\USUARIO\source\repos\BasiliskEye\BasiliskEye\Petrify.cs 31 Active
Error CS0103 The name 'Rand' does not exist in the current context BasiliskEye C:\Users\USUARIO\source\repos\BasiliskEye\BasiliskEye\Petrify.cs 26 Active
Error CS0103 The name 'Rand' does not exist in the current context BasiliskEye C:\Users\USUARIO\source\repos\BasiliskEye\BasiliskEye\Petrify.cs 33 Active
Error CS0246 The type or namespace name 'Bullet' could not be found (are you missing a using directive or an assembly reference?) BasiliskEye C:\Users\USUARIO\source\repos\BasiliskEye\BasiliskEye\Petrify.cs 8 Active
Error CS0246 The type or namespace name 'Hediff' could not be found (are you missing a using directive or an assembly reference?) BasiliskEye C:\Users\USUARIO\source\repos\BasiliskEye\BasiliskEye\Petrify.cs 40 Active
Error CS0246 The type or namespace name 'Pawn' could not be found (are you missing a using directive or an assembly reference?) BasiliskEye C:\Users\USUARIO\source\repos\BasiliskEye\BasiliskEye\Petrify.cs 24 Active
Error CS0234 The type or namespace name 'Tasks' does not exist in the namespace 'System.Threading' (are you missing an assembly reference?) BasiliskEye C:\Users\USUARIO\source\repos\BasiliskEye\BasiliskEye\BasiliskVision.cs 5 Active
Error CS0246 The type or namespace name 'Thing' could not be found (are you missing a using directive or an assembly reference?) BasiliskEye C:\Users\USUARIO\source\repos\BasiliskEye\BasiliskEye\Petrify.cs 21 Active


"Petrify" is the same as "Plague", on the tutorial :P Can anyone help me?

DJRockXD

I couldn't find the "defName" file or the "Bullet_Pistol" document using that "find in file" thing. Plus I could only find that function in Notepad++, not in Atom...
I found a "Bullet_Pistol" reference manually in the "Weapons_Guns" XML document, but not a stand alone version of it...
And I am probably an idiot for not being able to make the "Find in Files" function work even in Notepad++, as it couldn't find anything on my computer when I tested it out multiple times... Help please ):

CrazyMalk

Try selecting only the "Core">"Defs" folder inside "Mods" on that browsing place. You need to set up a location to it search.

DrMrEd

Quote from: DJRockXD on October 12, 2017, 06:48:33 AM
I couldn't find the "defName" file or the "Bullet_Pistol" document using that "find in file" thing. Plus I could only find that function in Notepad++, not in Atom...
I found a "Bullet_Pistol" reference manually in the "Weapons_Guns" XML document, but not a stand alone version of it...
And I am probably an idiot for not being able to make the "Find in Files" function work even in Notepad++, as it couldn't find anything on my computer when I tested it out multiple times... Help please ):
Kudos to the tutorial maker and suggesting folks learn to search the Defs -- you'll be doing a ton of this when you start down your own path. But for this one, no need to search blindly for strings in files. All the weapons stuff is in Defs\ThingDefs_Misc\Weapons_Guns.xml. There Bullet_Pistol def is at line 65. There is no standalone version - although each ThingDef could probably be spread out in its own file, but that would be a nightmare in other ways.

CrazyMalk

Ok... I was able to build the mod into a single dll, but now i'm having in-game console errors. And i think they are caused because i used a custom hediff in the C# code... What should i do to perfectly insert my custom heddiff into the Visual Studio project?

StoneWolf

To begin with must I compliment you on having made this excellent tutorial! This is the sixth time I've tried modding and it is for sure the easiest start I've ever had. All thanks to you and Tynan of course! ;)

I'm just a bit curious though. In your tutorial you advise on setting a prefix for the defName variable in order to increase mod compatability. Should I do the same for the file name? Or does it really not matter what its called?

jamaicancastle

One correction to update this for B18: the message syntax has changed. Where you have
                    }), MessageSound.Standard);
in the huge block of code for the projectile class, it should be
                    }), MessageTypeDefOf.NeutralEvent);
(or any of the other MessageTypeDef options, that just seemed the most like what it was doing before). I can verify that the rest of it works as advertised.

kaptain_kavern

Quote from: StoneWolf on November 06, 2017, 01:51:24 PM
In your tutorial you advise on setting a prefix for the defName variable in order to increase mod compatability. Should I do the same for the file name? Or does it really not matter what its called?

Nope, for the file name, there is no problems, you can call them as you want. You could even have all your xml code in one file if you wanted ^^ - I don't see why doing this, but my point being: you can do anyhow you prefer

DrunkRussianBear

I'm lost right now, what is the reason behind the C# code? is it necessary? I read through the tutorial but fail to understand the purpose of the code(what each line actually does).
Guns for everyone.

kaptain_kavern

For simple mods, you don't need C# at all. I've done lots of mods and still don't know C# yet.

Most of the time, you'll need C# if your mod needs to "something" that is not a vanilla "normal" mechanics. But you don't need C# at all to make new plants, animals, buildings, benches, etc... as long as they behave like vanilla do

DrunkRussianBear

#72
So for a simple weapon/clothing mod all I need is XML? if so that's pretty neat, I'm currently working on a weapon/clothing mod that adds the full arsenal of my fictional nation(can be found here: https://www.nationstates.net/nation=velariya) including uniforms and all. Just gotta wait for CE to update so I can make a compatibility patch once I know my guns work in vanilla.

By the way any chance you could take a peek through my mod once I'm done? I'm not sure what has changed in B18(code syntax wise) so I'm a bit scared it won't work in B18.
Guns for everyone.

kaptain_kavern

Oh right, I sure can have a look.

But most of the time the (red) error message will tell you explicitly what is going wrong. My updating/debugging mods process is: launch the mod, copy paste the wall of errors (starting by the red ones only, yellow error are often less harmful) in my text editor, then for each error I searched for the exact location and do what the error message is saying... Doing that for each errors, relaunch and repeat the process.

But if I can help you, I'll do, no problems

Son_Of_Diablo

Thanks for this tutorial!
Really explains everything well! :)


I got the test mod working, but I do have an issue where it won't add Plague to the attacked pawn (I do get the success message though).