Movement script broke for inventory objects

Post » Wed Aug 07, 2013 10:19 pm

The script goes like this.

Scriptname ALectraLevitateScript extends ObjectReference{Object will drift up and down}Import UtilityImport GameBool Property bStartAtBottom = False Auto{Set True if drifting down would cause the object to clip through its starting point}Float Property fVel = 4.0 Auto{Base speed at which to drift}Float Property fDriftX = 0.0 Auto{Random drift along X axis}Float Property fDriftY = 0.0 Auto{Random drift along Y axis}Float Property fDriftZ = 2.0 Auto{How far to drift along Z axis}Float fPosX = 0.0Float fPosY = 0.0Float fPosZ = 0.0Float fAngX = 0.0Float fAngY = 0.0Float fAngZ = 0.0Float fTDriftZ = 0.0Event OnLoad()  ;Store object's starting position  fPosX = GetPositionX()  fPosY = GetPositionY()  fPosZ = GetPositionZ()  fAngX = GetAngleX()  fAngY = GetAngleY()  fAngZ = GetAngleZ()   If bStartAtBottom    ;Set the path center to above the starting point    fPosZ += fDriftZ / 2  EndIf  ; TranslateTo will fail if object's 3d is not completely loaded  While !Is3DLoaded()    Wait(0.01)  EndWhile   UpdateTranslation()EndEvent;Use this instead of OnTranslationComplete, otherwise there will be a pause before the object moves again.Event OnTranslationAlmostComplete()  UpdateTranslation()EndEventEvent OnCellDetach()  CleanUp()EndEventEvent OnUnload()  CleanUp()EndEventFunction UpdateTranslation()  Float fCPosZ = GetPositionZ()  If fCPosZ < fPosZ ;We are below the center point    If fDriftX || fDriftY ; We need to drift X and Y as well          TranslateTo(fPosX + RandomFloat(-fDriftX,fDriftX), fPosY + RandomFloat(-fDriftY,fDriftY), fPosZ + (fDriftZ / 2),fAngX,fAngY,fAngZ,fVel)    Else ; No X or Y drift, RandomFloat is slow so skip it if we don't need it          TranslateTo(fPosX, fPosY, fPosZ + (fDriftZ / 2),fAngX,fAngY,fAngZ,fVel)    EndIf  Else ;We are at or above the center point    If fDriftX || fDriftY ; We need to drift X and Y as well          TranslateTo(fPosX + RandomFloat(-fDriftX,fDriftX), fPosY + RandomFloat(-fDriftY,fDriftY), fPosZ - (fDriftZ / 2),fAngX,fAngY,fAngZ,fVel)    Else ; No X or Y drift, RandomFloat is slow so skip it if we don't need it          TranslateTo(fPosX, fPosY, fPosZ - (fDriftZ / 2),fAngX,fAngY,fAngZ,fVel)    EndIf  EndIfEndFunctionFunction CleanUp()  StopTranslation()  ; This should keep the object from getting progressively farther from its starting point if the cell is loaded repeatedly  MoveToMyEditorLocation()EndFunction

It works fine for static objects, but it doesn't work for objects that can be put into the players inventory. Strangely enough it worked before for several weeks in the past, but recently this script no longer functions for inventory objects.

The script itself is perfect, but why did it stop working on inventory objects? Was there some change to the game itself or something recently? Any ideas? I'd be very thankful for any help on this baffling issue.

User avatar
Code Affinity
 
Posts: 3325
Joined: Wed Jun 13, 2007 11:11 am

Post » Thu Aug 08, 2013 6:24 am

Hi,

I think the problem comes from Havok-enabled items. In your OnLoad() event handler add the following line:

SetMotionType(Motion_Keyframed, TRUE)

And, see also the vanilla defaultDisableHavokOnLoad.psc script in the Scripts\Source folder.

-docblacky

User avatar
Laura Mclean
 
Posts: 3471
Joined: Mon Oct 30, 2006 12:15 pm

Post » Wed Aug 07, 2013 8:12 pm

Thank you so much for sharing that, adding that to the event handler easily fixed the problem.

User avatar
brenden casey
 
Posts: 3400
Joined: Mon Sep 17, 2007 9:58 pm

Post » Wed Aug 07, 2013 10:44 pm

Always a pleasure :smile:

-docblacky

User avatar
celebrity
 
Posts: 3522
Joined: Mon Jul 02, 2007 12:53 pm


Return to V - Skyrim