Giving Pawns Thoughts - examples?

Started by LWM, April 12, 2020, 10:05:29 AM

Previous topic - Next topic

LWM

Can anyone point me at a mod that gives pawns a simple thought?

And that has code available online, unlike selfish paranoid and/or thoughtless people?  :p  Seriously, why not share your code? [/rant]

K

Two of my mods do it but they're closed source. The code is really bad and possibly sourced in such a way that it would be illegal for me to license it, which is why I haven't released mine.

Though I don't have a (released) example here's how I do it. Just create the thought with the ThoughtMaker and add it to the target pawn:

thought = (Thought_Memory) ThoughtMaker.MakeThought(thoughtDef);
targetPawn.needs.mood.thoughts.memories.TryGainMemory(thought);


There's actually two types of thoughts in the game, memories and situational thoughts, but you can only add memories with this method. I'm not certain of how situational thoughts are handled, so you'd have to do some digging if you wanted to add one of those.


LWM

Thanks (and thank you for thinking about licensing) -

I am aiming for "I prayed in a really nice chapel +5" that lasts some hours.... is that "situational"?  Or is situational "I am praying in a really nice chapel" which goes away as soon as the pawn is done praying?

K

Any thought that lasts for some amount of time is a memory, so you definitely want a memory. Situational thoughts are purely transient - they're things like local beauty thoughts which do not stay for any amount of time, or thoughts which are dependent on other values, like the hunger or comfort thoughts.

LWM

Thank you for your help - it was useful, and people in nice chapels will soon have good thoughts  ;D