How to mod/replace functionality/code of a class?

Started by Ripshaft, March 10, 2017, 03:01:24 PM

Previous topic - Next topic

Ripshaft

Heya, I will likely figure this out on my own eventually, but I think regardless this is a critical bit of information for anyone interested in modding and has some manner of coding background.


If there's a class you want to modify in the main game dll, how do you mod such that it uses your iteration of the class rather than the game's?
This is assuming you have already identified the code and class by decompiling and set up a solution as per the excellent help in the wiki, what does it take to insert your own usage of the code into how the game normally runs?


The specific example I am trying to modify is the ApplyArmor (or its parent) class within the Verse namespace. I will eventually modify the calculations that determine how durability dmg to armor is calculated, but right now I am just trying to get a 'hello world' through the Log.Message() call to show up.

Hopefully that's somewhat clear.



Thanks to anyone who takes the time to read and perhaps reply - and if you want more clarity on anything let me know.

Thirite

It can be done easily via HugsLib or by using some code extracted from CCL. I wrote a tutorial on the latter here: https://ludeon.com/forums/index.php?topic=30404.msg309918#msg309918

Ripshaft

#2
Ooooh! that looks just like what I need, I did not think to use 'detour' as a search word when trying to find posts on it, figures =p

I'm just heading home from campus now, I'll not be able to take a good look at it until then but if all goes well I'll get back with stories of success or glorious failure, thanks!

edit:
Hmmm that is a bit more rough of a method than I'd hoped, snatching the method from memory lol, but it makes sense, and probably the best option at the moment. Will take a crack at it when I've some time later tonight if all goes well.

edit again:
cursed ambition! I decided to evaluate other options and approaches and while looking at other methods my concerns for game balance (especially the importance of scarce resources) and general desire to add awesomeness to the game have ground progress to a halt lol
Currently trying to figure out if I want to add a 'test instance' of power armor to the game that I can modify in great detail independently by having it point to a custom class instead of apparel, or just do a quick patchwork of modifying only the durability loss upon taking damage... dunno.
Currently the idea of adding a capacitor to the power armor so that it has enhanced ability when toggled (ie combat mode) and vastly decreased ability if it runs out of charge has alot of appeal to me as far as cool factor goes... maybe random short circuit and explosion when charged or overcharged to spice things up lol.. maybe increase chance of catastrophic failure while in the rain, proportional to durability... so that power armor that's all torn up may react poorly to water =)... ahh... possibilities damnit!