SKKmods Posted July 14, 2023 Share Posted July 14, 2023 This papyrus error is thrown occasionally (maybe ~10% of triggers) on an ObjectReference attached script. Nothing is broken, but it's un-neat. Any ideas on how to strengthen this to avoid the error condition: Event OnLoad() If (Self.IsBoundGameObjectAvailable() == True) && (Self.IsDisabled() == false) && (Self.Is3dLoaded() == true) Self.SetMotionType(Motion_Keyframed, FALSE) EndIf EndEvent Link to comment Share on other sites More sharing options...
LarannKiar Posted July 15, 2023 Share Posted July 15, 2023 Physics-enabled objects such as cars, takeable items and dead actors (living ones don't) must have a weight ("Havok mass") so maybe Self.GetMass() > 0 does the trick? Link to comment Share on other sites More sharing options...
SKKmods Posted July 15, 2023 Author Share Posted July 15, 2023 Good thinking will add that test and throw a debug message if it trips ... ... BUT its the exact same object that works 90% and only generates the error 10% of the time. Link to comment Share on other sites More sharing options...
LarannKiar Posted July 15, 2023 Share Posted July 15, 2023 One possible cause of this error could be that 10% of the time, the engine fails to initialize the Havok physics for the object the script is attached to by the time OnLoad() is received. Event OnLoad() If (Self.IsBoundGameObjectAvailable() == True) && (Self.IsDisabled() == false) && (Self.Is3dLoaded() == true) Int Failsafe While Self.GetWeight() == 0 && Failsafe < 10 Utility.Wait(0.1) Failsafe = Failsafe + 1 EndWhile If Self.GetWeight() == 0 ; error, I guess Else Self.SetMotionType(Motion_Keyframed, FALSE) EndIf EndIf EndEvent By the way, the wiki mentions that this function (the Skyrim version, more specifically) has some bugs... maybe there's something to it, unfortunately I'm not sure. I tried to use SetMotionType() on some mod added dead actors earlier but for me, sometimes it just didn't work (~25% of the time). Finally, I copied over the ACHR >> XRGD and XRGB "ragdoll data" subrecords from preexisting dead actors to the mod added ones. That worked perfectly. If it works for you though, maybe waiting for the engine to load the Havok physics helps. Link to comment Share on other sites More sharing options...
SKKmods Posted July 15, 2023 Author Share Posted July 15, 2023 Looks like the (wait + bailout counter) is the way forward. The same object on different loads 5 minutes apart: SKK_476WorkshopSafetyScannerScript.OnLoad [SKK_476WorkshopSafetyScannerScript < (FF00BEA1)>] mass 9.990244 SKK_476WorkshopSafetyScannerScript.OnLoad [SKK_476WorkshopSafetyScannerScript < (FF00BEA1)>] ZERO MASS Link to comment Share on other sites More sharing options...
niston Posted July 16, 2023 Share Posted July 16, 2023 Bool Function WaitForHavokInit(ObjectReference refWaitFor, Int waitLimit = 30) If (refWaitFor == none || refWaitFor.GetFormID() == 0 || !refWaitFor.IsBoundGameObjectAvailable() || refWaitFor.IsDisabled() || refWaitFor.IsDeleted()) Return False EndIf Float weight = refWaitFor.GetWeight() While ((weight == 0.0) && (waitLimit > 0)) Utility.Wait(0.1) waitLimit -= 1 weight = refWaitFor.GetWeight() EndWhile Return (weight > 0.0) EndFunction Might be useful then Link to comment Share on other sites More sharing options...
Recommended Posts