Invaliduninstalled Script Classes - how to detect

Post » Mon Nov 19, 2012 3:48 pm

Hey guys,
How do we detect invalid Object Reference Script Classes from a 3rd party mod?

E.g.:
  • Install ModA that extended Actors to ModAActors.
  • My mod (ModB) then finds these ModAActors and adds them in Aliases.
  • I deactivate and uninstall modA.
  • ModB still has ModAActors in its Aliases.
  • However, in ModB Scripts, operations on ModAActors throw an error because the ModAActors Script Class has been removed.
How do we detect if ModAActors are invalid? Remember that ModB is oblivious of ModA or ModAActors. So, we can't do this:
If objRef as ModAActor;valid actorElse;invalid actorEndIf

And even if I re-class the now invalid ModAActor as Actor, it throws a Script error. E.g.:
Actor actorRef = objRef as Actor ;This should reclass objRef from ModAActor to ActorFloat distance = actorRef.GetDistance (Game.GetPlayer ());This throws the error becase actorRef is still ModAActor but has been removed.

The actual circumstance is that I uninstalled ASIS and my Fight or Fly mod threw errors like these:
9/30/2012 - 09:36:57AM] error: Method getDistance not found on NPCPotions. Aborting call and returning Nonestack:	[kuFOFQ (0C000801)].kufofqs.processActor() - "kuFOFQS.psc" Line 395	[kuFOFQ (0C000801)].kufofqs.processActors() - "kuFOFQS.psc" Line 366	[kuFOFQ (0C000801)].kufofqs.tick() - "kuFOFQS.psc" Line 333	[kuFOFQ (0C000801)].kufofqs.OnUpdate() - "kuFOFQS.psc" Line 75

NPCPotions is an ASIS Class that extends Actor. Even if I reclassed the reference with "As Actor" before I called "GetDistance" on the reference, it failed because NPCPotions no longer exists.

I need a method to detect that the actor with NPCPotions is invalid before I process it.
User avatar
Jesus Lopez
 
Posts: 3508
Joined: Thu Aug 16, 2007 10:16 pm

Post » Mon Nov 19, 2012 9:54 am

I don't know if they would be detectable. My suggestion would be to do a start-up check (using OnPlayerLoadGame() ) to look for the mod that you care about still being loaded, and if not, purge your usage of aliases that utilize extended types (if you are keeping track of them).
User avatar
Sophh
 
Posts: 3381
Joined: Tue Aug 08, 2006 11:58 pm

Post » Mon Nov 19, 2012 5:16 pm

Thanks, Chesko. I thought that would have been the case. Is there a "try/fail" in Papyrus? I couldn't find any.
And thanks for mentioning "OnPlayerLoadGame ()". I didn't know Bethesday's added that in. (And since 1.6!).
User avatar
Mario Alcantar
 
Posts: 3416
Joined: Sat Aug 18, 2007 8:26 am


Return to V - Skyrim