How do thoughts work?

Started by The-Eroks, May 06, 2017, 10:29:40 AM

Previous topic - Next topic

The-Eroks

I've performed a number of searches and dug through the .xml... but I still can't find/figure out how thoughts are defined/triggered.

For example, how do I add a new thought? It seems to be related to the <workerclass> in some cases.... but not in others (ex: AteWithoutTable (Thoughts_Memory_Misc.xml) vs. Joywire (Thoughts_Exotic.xml)).

In the case of the Joywire, there doesn't seem to be an .xml association between the <ThingDef> Joywire and the <Thoughtdef> Joywire... this suggests that it might be coding?

Any insight or suggestions?

Zhentar

As a basic guideline, thoughts that are a reaction to an event (e.g. AteWithoutTable) are triggered when the event occurs; like AteWithoutTable gets added in Toils_Ingest.FinalizeIngest when the ingesting was done without a table. Thoughts that are related to a state the pawn is in are controlled by thoughtworkers that determine when they are in the state the thought applies to. In the case of the Joywire thought, it uses a thoughtworker that applies it when the pawn has the Joywire hediff; the Joywire hediff gets added by the InstallJoywire RecipeDef, which requires the Joywire ThingDef.

The-Eroks

To confirm, there is not an .xml accessible way to create new <ThoughtWorker>'s?

I did stumble across the ThoughtWorker hediff associated with Joywire and the ThoughtWorker associated with ingestion (ex: Lavish Meal), are there any other obvious examples that are easily modifiable?

Zhentar

No, creating a ThoughtWorker inherently requires C# code to back it.

ThoughtWorker_Hediff seems to be the only really flexible general purpose thought worker. But let's see the other places you can plug in new thoughts through XML...


  • IngestibleProperties (tasteThought, specialThoughtDirect, specialThoughtAsIngrediate)
  • InteractionDef (initiatorThought, recipientThought)
  • MentalStateDef (moodRecoveryThought)
  • PawnRelationDef (diedThought, soldThought, killedThought)