Ludeon Forums

RimWorld => Mods => Help => Topic started by: LWM on April 12, 2020, 10:05:29 AM

Title: Giving Pawns Thoughts - examples?
Post by: LWM on April 12, 2020, 10:05:29 AM
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]
Title: Re: Giving Pawns Thoughts - examples?
Post by: K on April 12, 2020, 01:33:54 PM
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.

Title: Re: Giving Pawns Thoughts - examples?
Post by: LWM on April 12, 2020, 01:50:28 PM
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?
Title: Re: Giving Pawns Thoughts - examples?
Post by: K on April 12, 2020, 04:00:13 PM
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.
Title: Re: Giving Pawns Thoughts - examples?
Post by: LWM on April 29, 2020, 09:47:20 PM
Thank you for your help - it was useful, and people in nice chapels will soon have good thoughts  ;D