Need help understanding NeedsDef and interaction with HeDiffs

Started by BadDevilGrind, November 07, 2018, 08:23:24 AM

Previous topic - Next topic

BadDevilGrind

Hello everyone.

I've been experimenting a bit with modding with XML and C# but I can't seem to wrap my head around how modding Needs works.
Let's say I have a custom Need and then a Hediff that has the following line added

<causesNeed>CustomNeed</causesNeed>

I can see the CustomNeed ingame, and it ticks down as one might expect, but how can I connect that need with some custom ThingDef.

Here's an example:

I have a HeDiff called "Chocolate Mind" which gives a learning bonus. Besides giving a stat bonus the HeDiff is connected to a custom HeDiff_Class that I've written in C# that makes them fall asleep during day.
The Chocolate Mind HeDiff has the following added to it in the XML

<causesNeed>ChocolateNeed</causesNeed>

How do I make it so that the Need gets filled up whenever the Pawn eats, in this case, Chocolate.
And how would I make it so that if they don't get the chocolate, something happens.

I've looked into using <stages>, and I've setup two stages on my HeDiff, based off the LuciferiumAddiction HeDiff, with one stage being just an empty list, and the next stage being one with a <label>unmet</label> tag on it, but nothing happened when it went below the threshold that can be seen on the Need Bar on the Pawn.

AileTheAlien

Having it fill up a need seems pretty easy. For that, it looks like you just need a IngestionOutcomeDoer_OffsetNeed; Take a look at Flake, Yayo, or Smokeleaf, which all affect Rest. For the unmet-need...not sure about that one. Making a new chemical type which is addictive is pretty easy with XML, but I don't know about needs.