Closed exuvo closed 6 years ago
Putting a try catch in that expensive function will slow things down too much. The other mod should simply be coded more defensive to prevent the NRE. Sorry.
Okay then ill try with the other mod creator and see if they can avoid creating the effect it the target is a zombie. What is the best way to detect if the target is a zombie?
If the class of the zombie is called Zombieland.Zombie. But personally, I would rather add ordinary null checks to cover any other slimmed down creatures of other mods too. So if you deal with property X.Y you always check if X is non-Null or else you bail out. No need to check if X is from a zombie.
The failing job is a default rimworld vomit job and after looking at the decompiled source at https://github.com/josh-m/RW-Decompile/blob/master/RimWorld/JobDriver_Vomit.cs it think the error is because the vomit job tries to make pawns more hungry each vomit and zombies don't have a hunger need?
So if the target pawn does not have a hunger need, don't add a vomit job. Does my understanding seem correct?
Sounds reasonable. Indeed, zombies have no hunger need and if the vomit job references that you better not assign it. Zombies don’t vomit anyway! :-)
Another mod I use caused a zombie to vomit, which is obviously not supported. Is there a way to handle this case without affecting performance too much? A try catch around line 277 "jobs?.JobTrackerTick();" in Zombie.cs and clearing the job list if an exception occurs maybe?
The offending mod is A RimWorld of Magic because of the hediff source Projectile_FogOfTorment.
Object reference not set to an instance of an object at RimWorld.JobDriver_Vomit/cIterator0.<>m1 () <0x000a9>
at (wrapper dynamic-method) Verse.AI.JobDriver.DriverTick_Patch1 (object) <0x002ba>
at Verse.AI.Pawn_JobTracker.JobTrackerTick () <0x00242>
at ZombieLand.Zombie.CustomTick () <0x00089>
at ZombieLand.TickManager.ZombieTicking () <0x000fd>
at ZombieLand.Patches/Verse_TickManager_TickManagerUpdate_Patch.ZombieTick () <0x00039>
at (wrapper dynamic-method) Verse.TickManager.TickManagerUpdate_Patch0 (object) <0x000d9>
at Verse.Game.UpdatePlay () <0x00015>
at Verse.Root_Play.Update () <0x0004c>
The save data for the offending zombie: