[Request] DLL Modding not covered by Power Generation Tutorial?

Started by deadlydullahan, May 26, 2015, 10:45:48 AM

Previous topic - Next topic

Adamiks

Quote from: mrofa on May 26, 2015, 01:51:26 PM
Quote from: Adamiks on May 26, 2015, 01:06:55 PM
Quote from: mrofa on May 26, 2015, 12:55:59 PM
You need a compiler, in this case look in power generator tourtial or just install visual c# since its a free compiler.

And there is a problem. I can't really download visual C# without removing some of my games/files from hardware. I'm looking for lightweight compiler program.

This

Oh, it looks that this is lightweight program. I thought you're talking about "Microsoft Visual Studio Express".

Rikiki

Quote- Weapon/Damage Coding (Say you want to create a freeze ray using frostbite damage def, how to go about that? [If this weapon hasn't been made yet, I'm already planning on it])
M&Co. Weapons mod is more focused on the "firing effects" but you can add your custom code upon impact to modify things on a pawn (for the freezing, maybe have a look at the StunHandler class in the Assembly-CSharp).

Quote- Pawn Coding (Creating unique creatures rather than your typical Mechs and Tribals)
Pawn is a veeery hard complex and complete part of Rimworld. Ask Haplo about his MAI... ;)
Creating your own creature is not hard (create XML bodydef, race, ...) but creating an associated AI will be very hard.
You may have a look at minami's events mod. There was an event with a massive carnivorous wild white gorilla.

Quote- Weather Coding (Tips on how to just mess around with this would be cool, who wouldn't want to make a hailstorm or tornado?)
The Mechanoid terraformer mod plays a little bit with the weather (start a custom thunderstorm, cast lighting strikes, ...).
There was also a tornado event in minami's events mod.

Quote- Storytellers/Events (Why not this? I see numerous people with awesome Ideas about an event but no idea how to make it. Drop some tips)
See Mechanoid terraformer or Fish Industry mod. You should definitely look at the IncidentWorker classes (IncidentWorker_CropBlight, IncidentWorker_RefugeePodCrash, ...).

In general, just look into others' mods source to learn and then try something on your own.
There will be more answers for precise questions (what's the goal, show a piece of code, the error message).

Happy modding! ;D

deadlydullahan


Marrin87

Thank you so much dear for giving references and guidelines. This is very helpful post for me. Well, I am going to buy honda 2000 generator from an online megastore. Actually they are providing heavy discounts on honda products.

Link removed. User was banned for this post. Reason: Spam, advertising. Spam bots will be incinerated. Fwoosh.

mipen

Quote from: Marrin87 on June 23, 2015, 07:25:59 AM
Thank you so much dear for giving references and guidelines. This is very helpful post for me. Well, I am going to buy honda 2000 generator from an online megastore. Actually they are providing heavy discounts on honda products.
Erm...? *reported for advertising*

SSS

Quote from: mrofa on May 26, 2015, 12:41:13 PM
This are in game classes, you generally dont want to touch them so in 99% ppl just write thier own classes based on the ingame ones.
And you can test yourself, if you copy place the ingame class and load it in dll, it will replace the orignal class ingame or atleast it should.

Can someone confirm this? I'm playing around with modding a bit, and I'm trying to modify a PlaceWorker class. The game isn't working any differently than before, so I want to make sure the problem is with the code rather than the game not using the modified class in the first place.

mipen

Quote from: SSS on July 09, 2015, 10:55:27 PM
Quote from: mrofa on May 26, 2015, 12:41:13 PM
This are in game classes, you generally dont want to touch them so in 99% ppl just write thier own classes based on the ingame ones.
And you can test yourself, if you copy place the ingame class and load it in dll, it will replace the orignal class ingame or atleast it should.

Can someone confirm this? I'm playing around with modding a bit, and I'm trying to modify a PlaceWorker class. The game isn't working any differently than before, so I want to make sure the problem is with the code rather than the game not using the modified class in the first place.
You can't edit the game classes, only Tynan can do that. To make your own place worker, create a new class and inherit from the base PlaceWorker class. Then go into ilspy or dotPeek and look at the PlaceWorker class to see what methods are available to you. Any that are abstract MUST be overwritten while any that are virtual are optional to override. I think there is only one method you need to worry about, 'AllowPlacing' or something along those lines. Once you have finished the class, just add it to the list of PlaceWorkers in your Def (or replace the one you want to change). Remember that you also have to include the namespace when referencing your place worker, so it'll look something like this :
<li>MyNameSpace.MyPlaceWorker<\li>
And that's all you need to do :)

SSS

Quote from: mipen on July 11, 2015, 01:10:44 AM
Quote from: SSS on July 09, 2015, 10:55:27 PM
Quote from: mrofa on May 26, 2015, 12:41:13 PM
This are in game classes, you generally dont want to touch them so in 99% ppl just write thier own classes based on the ingame ones.
And you can test yourself, if you copy place the ingame class and load it in dll, it will replace the orignal class ingame or atleast it should.

Can someone confirm this? I'm playing around with modding a bit, and I'm trying to modify a PlaceWorker class. The game isn't working any differently than before, so I want to make sure the problem is with the code rather than the game not using the modified class in the first place.
You can't edit the game classes, only Tynan can do that. To make your own place worker, create a new class and inherit from the base PlaceWorker class. Then go into ilspy or dotPeek and look at the PlaceWorker class to see what methods are available to you. Any that are abstract MUST be overwritten while any that are virtual are optional to override. I think there is only one method you need to worry about, 'AllowPlacing' or something along those lines. Once you have finished the class, just add it to the list of PlaceWorkers in your Def (or replace the one you want to change). Remember that you also have to include the namespace when referencing your place worker, so it'll look something like this :
<li>MyNameSpace.MyPlaceWorker<\li>
And that's all you need to do :)

Huzzah!

I actually had a different class name to start with, but after reading this thread I got the idea that I might need to somehow overwrite the original core class it was based on for whatever reason. I was under the impression that I could modify core classes, but I meant it differently: I'm replacing the original PlaceWorker with the modded one in the xml. It turns out my original assembly worked perfectly fine- I just wasn't referencing it in the xml correctly. I didn't realize the namespace needed to be included in the reference.

It works as intended now. Thank you! (Doubly thank you, actually. Looking at your RecipeUnlocker tutorial taught me how to reference modded-in defs, which is useful for a lot more than just adding recipes to tables.) ^-^

Edit: Wording