-
Notifications
You must be signed in to change notification settings - Fork 16
Description
Steps to produce...
- Create a pawn with no mood/joy/comfort etc (eg. with a gene)
- Give pawn might trait (using item)
- Give pawn might class (using item) eg. Monk, but I think the issue should occur with every class
What should happen...
Pawn gets a chi bar, no console errors, can meditate, etc
What actually happens...
Pawn doesnt get a chi bar, lots of console errors, meditating does nothing.
This is one of the errors...
Exception ticking Burban (at (217, 0, 167)): System.NullReferenceException: Object reference not set to an instance of an object
[Ref 741149BA]
at TorannMagic.CompAbilityUserMight.ResolveSustainedSkills () [0x008c5] in <fb59b96a7c5c447ea5217e8dbd7643c1>:0
at TorannMagic.CompAbilityUserMight.CompTick () [0x001a3] in <fb59b96a7c5c447ea5217e8dbd7643c1>:0
at Verse.ThingWithComps.Tick () [0x00024] in <2a40c3593b334f29ac3cb3d32d652351>:0
at Verse.Pawn.Tick () [0x0002c] in <2a40c3593b334f29ac3cb3d32d652351>:0
- POSTFIX Mlie.YayosCombat3: Void yayoCombat.HarmonyPatches.Pawn_TickRare:Postfix(Pawn __instance)
at Verse.TickList.Tick () [0x0015c] in <2a40c3593b334f29ac3cb3d32d652351>:0
UnityEngine.StackTraceUtility:ExtractStackTrace ()
(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.Log.Error_Patch1 (string)
Verse.TickList:Tick ()
(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.TickManager.DoSingleTick_Patch3 (Verse.TickManager)
Verse.TickManager:TickManagerUpdate ()
(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.Game.UpdatePlay_Patch4 (Verse.Game)
Verse.Root_Play:Update ()
I believe the errors are occurring because the code isn't checking if the pawn has a mood before going deeper or making adjustments to mood.
For example here...
if(this.Pawn.needs.mood.thoughts.memories.NumMemoriesOfDef(ThoughtDef.Named("RangerSoldBondedPet")) > 0)
Should probably be...
if(this.Pawn.needs?.mood?.thoughts.memories.NumMemoriesOfDef(ThoughtDef.Named("RangerSoldBondedPet")) > 0)
I think there are other situations too, for example in skills like Meditate, it makes a lot of assumptions that needs/mood exists.
This is the gene I used to create the pawn, which has nothing custom just disabling needs...
<GeneDef>
<defName>ES_Gene_Emotionless</defName>
<label>emotionless</label>
<description>This individual cannot feel emotions.</description>
<iconPath>UI/Genes/ES_Moodless</iconPath>
<displayCategory>Miscellaneous</displayCategory>
<biostatMet>-2</biostatMet>
<biostatCpx>1</biostatCpx>
<disablesNeeds>
<li>Mood</li>
<li>Joy</li>
<li>Beauty</li>
<li>Outdoors</li>
<li>Indoors</li>
<li>RoomSize</li>
<li>Comfort</li>
<li>DrugDesire</li>
</disablesNeeds>
<exclusionTags>
<li>Mood_Depressive</li>
<li>Mood_Pessimist</li>
<li>Mood_Optimist</li>
<li>Mood_Sanguine</li>
<li>Aggression_DeadCalm</li>
<li>Aggression_Aggressive</li>
<li>Aggression_HyperAggressive</li>
</exclusionTags>
</GeneDef>
If there was more checking, then mod compatibility would likely improve a lot.