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.
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.