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

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

Previous topic - Next topic

Tynan

This is really great! But it might be even more useful on the wiki. The wiki is designed as a long-term info repository, while forums are for temporary discussion. If you put it on the wiki, others can also participate it and improve it, or add other tutorials alongside, and so on. Consider wiki-ing it!
Tynan Sylvester - @TynanSylvester - Tynan's Blog

jecrell

Quote from: Tynan on June 03, 2017, 11:17:03 PM
This is really great! But it might be even more useful on the wiki. The wiki is designed as a long-term info repository, while forums are for temporary discussion. If you put it on the wiki, others can also participate it and improve it, or add other tutorials alongside, and so on. Consider wiki-ing it!

*glows*

My good man. I'm working right now to convert this beast into Markdown and then I'll put it up on the wiki.

*gets back to work*
...Psst. Still there? If you'd like to support
me and my works, do check out my Patreon.
Someday, I could work for RimWorld full time!

https://www.patreon.com/jecrell

kaptain_kavern

#18
Markdown is more universal even, you know for like ... posterity.

After all of this, When you'll have a bit of free time Jecrell, reminds me to show you the beauty of static site generators like Jekyll. This baby is eating Markdown (or even plaintext) files and outputs you a valid website directly from a github repo for free hosting even ;D

I could also set this up for you. If it can be of any interest for you.

DrGenghis

Having some trouble with this, can't seem to figure out what the problem is and I've gone through the tutorial several times just in case I missed something.

Keep getting these errors.
Error CS1061 'ThingDef' does not contain a definition for 'AddHediffChance' and no extension method 'AddHediffChance' accepting a first argument of type 'ThingDef' could be found (are you missing a using directive or an assembly reference?) PlagueGun D:\SteamLibrary\SteamApps\common\RimWorld\Mods\PlagueGun\Source\PlagueGun\PlagueGun\Projectile_PlagueBullet.cs 36 Active
Error CS1061 'ThingDef' does not contain a definition for 'HediffToAdd' and no extension method 'HediffToAdd' accepting a first argument of type 'ThingDef' could be found (are you missing a using directive or an assembly reference?) PlagueGun D:\SteamLibrary\SteamApps\common\RimWorld\Mods\PlagueGun\Source\PlagueGun\PlagueGun\Projectile_PlagueBullet.cs 51 Active
Error CS1061 'ThingDef' does not contain a definition for 'HediffToAdd' and no extension method 'HediffToAdd' accepting a first argument of type 'ThingDef' could be found (are you missing a using directive or an assembly reference?) PlagueGun D:\SteamLibrary\SteamApps\common\RimWorld\Mods\PlagueGun\Source\PlagueGun\PlagueGun\Projectile_PlagueBullet.cs 63 Active
Error CS1061 'ThingDef' does not contain a definition for 'AddHediffChance' and no extension method 'AddHediffChance' accepting a first argument of type 'ThingDef' could be found (are you missing a using directive or an assembly reference?) PlagueGun D:\SteamLibrary\SteamApps\common\RimWorld\Mods\PlagueGun\Source\PlagueGun\PlagueGun\Projectile_PlagueBullet.cs 75 Active


Any help would be much appreciated. Just in case here is a gist with both .cs files and the xml. https://gist.github.com/anonymous/47f35abe717ce37aed28ae952983b3c1

UncleIROH

I'm attempting to go through this but the C# file refuses to compile.
The line Visual Studio has issues with is:
if (Def != null && hitThing != null && hitThing is Pawn hitPawn) //Fancy way to declare a variable inside an if statement. - Thanks Erdelf.

I've changed it to this to get it to compile:
Pawn hitPawn = hitThing as Pawn;
if (this.Def != null && hitPawn != null)


With this change I am able to load up the gun in game equip and fire it. But notarget ever gets the plague. I've even edited the XML and C# AddHediffChance to 0.98f;

UncleIROH

@DrGenghis

I was having the same issue. The forum post looks like it might have a mistake in it because it doesn't match the example C# file.

The post has this line:
public ThingDef Def
{
     get { return this.def as ThingDef_PlagueBullet; }
}


But it should be:
public ThingDef_PlagueBullet Def
{
       get { return this.def as ThingDef_PlagueBullet; }
}



DrGenghis

@UncleIROH

You rule! Thank you for fixing my problem! Not having any issues with compiling now.

Spdskatr

My mods

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

jecrell

Quote from: UncleIROH on June 04, 2017, 01:13:26 AM
@DrGenghis

I was having the same issue. The forum post looks like it might have a mistake in it because it doesn't match the example C# file.

The post has this line:
public ThingDef Def
{
     get { return this.def as ThingDef_PlagueBullet; }
}


But it should be:
public ThingDef_PlagueBullet Def
{
       get { return this.def as ThingDef_PlagueBullet; }
}


Bless you fellow RimWorlder and my apologies! I'm not sure how that slipped through.
I fixed it in the post.
...Psst. Still there? If you'd like to support
me and my works, do check out my Patreon.
Someday, I could work for RimWorld full time!

https://www.patreon.com/jecrell

mrofa

Some errors are becouse of the unneded dlls in your mods assembly, this is in regard to point 21 of the guide.
Here is my suggestion:
Leave output path as it was ( default "bin\Debug\") and instead use Build Events
In build events use Post-build with xcopy, post build will run its macro after you compile a build(press F7 on default settings)
xcopy "YourDllFile" "OutputDirectory" /i /y
-YourDllFile is a path and file name
-OutputDirectory full path where the file should end up
-/i if OutputDirectory dont exist it will be created
-/y dont show file override propmpt and auto accept it

Here is how my looks:
xcopy "C:\Users\Mrowa\Documents\Visual Studio 2013\Projects\ClutterFurniture\ClutterFurniture\bin\Debug\ClutterFurniture.dll"
"C:\Program Files (x86)\Steam\steamapps\common\RimWorld\Mods\Clutter Furniture\Assemblies" /i /y

All i do is clutter all around.

UncleIROH

Anyone get this gun to actually give someone the plague? I've killed bunches of pawns with it, no plague.

jecrell

#27
Quote from: UncleIROH on June 04, 2017, 11:14:16 AM
Anyone get this gun to actually give someone the plague? I've killed bunches of pawns with it, no plague.

You probably forgot to set your ProjectileDef inside the PlagueGun def to your new Bullet def.

Hope that helps you find what you're looking for.

Otherwise, set the hediffChance to 1.0 in XML for 100% chance of giving the plague.
...Psst. Still there? If you'd like to support
me and my works, do check out my Patreon.
Someday, I could work for RimWorld full time!

https://www.patreon.com/jecrell

steeveebr

Jecrell,

This is great ty! 

Out of curiosity:  Step 11 states to copy all of the ThingDef Parents and Bases to your XML...

Quote11) Repeat and copy all of the ThingDef Parents and Bases for Bullet_Pistol and Pistol to your XML file.

And then your code snippet also includes BaseHumanGun.  Is that inclusion necessary?  I don't see it as a parent in either the Pistol Bullet or the Pistol Gun.  If it is necessary how would I determine that while working on another say another "Thing"?


UncleIROH

#29
@Jecrell Thanks that was it!