Addiction HediffDef

Started by larSyn, November 10, 2017, 12:34:16 AM

Previous topic - Next topic

larSyn

So, I've been meaning to ask about this for a bit now.  What is the purpose of the empty list in the <stages> of the addiction HediffDef?

Here's what I mean:


If it gets removed, when a pawns dependency hits zero they freeze and no information is available in the Needs or Health tabs.  I made this mistake with my mod and am now curious as to what it does.  Is it meant to be like that? 

CannibarRechter

The first position is reserved for any modifications that happens to the pawn when they are addicted, but not in withdrawal.

public class Hediff_Addiction : HediffWithComps
{
private const int DefaultStageIndex = 0;

private const int WithdrawalStageIndex = 1;


I can't tell in looking at the code if it's actually used, though.
CR All Mods and Tools Download Link
CR Total Texture Overhaul : Gives RimWorld a Natural Feel
CR Moddable: make RimWorld more moddable.
CR CompFX: display dynamic effects over RimWorld objects

larSyn

Quote from: CannibarRechter on November 10, 2017, 07:06:23 AM
The first position is reserved for any modifications that happens to the pawn when they are addicted, but not in withdrawal.

...

I can't tell in looking at the code if it's actually used, though.

It definitely does something.  I had a few reports about freezing pawns that were addicted to some of the drugs in my mod and adding the empty list fixed it.  I had removed it, wondering why there would be something like that, and everything was fine at first.  Then a Steam user had the bug and figured it out the fix(luckily for me...). 

Thanks for looking into the code, Cannibar.  I'm just starting to learn C# and I wouldn't have figured that out.

CannibarRechter

What I meant was I couldn't tell if you put some real values in there, instead of leaving it blank, that those would do something. I'm surprised that if you don't have at least two items in the list that you don't get red errors / exceptions, actually, but I didn't look at that part of the code to get an explanation for that.
CR All Mods and Tools Download Link
CR Total Texture Overhaul : Gives RimWorld a Natural Feel
CR Moddable: make RimWorld more moddable.
CR CompFX: display dynamic effects over RimWorld objects

larSyn

Oh I see.  Yeah , I never tried to put anything in there, since checking them against all the vanilla drugs shows it set the same way.  Maybe it has to do eliminating/resetting a pawns dependency, since that's when the bug occurs if it is removed.  It just seemed odd to me when I first started the mod (I made the drugs first).  I'm new to all of this and it seemed strange that there would be something like an empty list.