enderalse/scripts/source/defaultdisablehavokonload.psc

70 lines
2.3 KiB
Plaintext
Raw Normal View History

scriptName defaultDisableHavokOnLoad extends ObjectReference
bool property havokOnHit = TRUE auto
{Start Havok Sim when hit? DEFAULT: TRUE}
bool property havokOnActivate auto
{Start Havok Sim when activated? DEFAULT: FALSE}
bool property havokOnZKey auto
{Start Havok Sim when grabbed by player? DEFAULT: FALSE}
keyword property linkHavokPartner auto
{Link with this keyword and that ref will also sim with myself}
bool property beenSimmed auto hidden
{prevent an object that has been havok'd in-game from going static}
2021-10-05 22:22:24 +00:00
EVENT onCellAttach()
if (beenSimmed == FALSE && Self.Is3DLoaded())
setMotionType(Motion_Keyframed, TRUE)
; ;debug.trace("havok disabled on: " + self)
endif
endEVENT
2021-10-05 22:22:24 +00:00
EVENT onLoad()
if (beenSimmed == FALSE && Self.Is3DLoaded())
setMotionType(Motion_Keyframed, TRUE)
; ;debug.trace("havok disabled on: " + self)
endif
endEVENT
2021-10-05 22:22:24 +00:00
EVENT onActivate(ObjectReference triggerRef)
if havokonActivate == TRUE && beenSimmed == FALSE && Self.Is3DLoaded() ;USSEP 4.1.8 Bug #26371 - Added Is3DLoaded check to prevent a race condition with the OnContainerChanged event when picking up an object
ReleaseToHavok()
2021-10-05 22:22:24 +00:00
endif
endEVENT
2021-10-05 22:22:24 +00:00
EVENT onHit(ObjectReference var1, Form var2, Projectile var3, bool var4, bool var5, bool var6, bool var7)
if havokOnHit == TRUE && beenSimmed == FALSE
ReleaseToHavok()
2021-10-05 22:22:24 +00:00
endif
endEVENT
2021-10-05 22:22:24 +00:00
EVENT onGrab()
if havokOnZkey == TRUE && beenSimmed == FALSE
ReleaseToHavok()
2021-10-05 22:22:24 +00:00
endif
endEVENT
;USKP 2.0.1 - Added event to deal with Papyrus spam caused by the player picking these things up since the game cannot process that properly.
Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
2021-10-05 22:22:24 +00:00
if( akNewContainer != None )
;Stops the OnLoad event from generating errors.
beenSimmed = True
Else
;No container, means it's being dropped in the open. Let it loose now.
ReleaseToHavok()
EndIf
EndEvent
2021-10-05 22:22:24 +00:00
FUNCTION ReleaseToHavok()
beenSimmed = TRUE
objectReference myLink = getLinkedRef(linkHavokPartner)
if myLink != NONE
defaultDisableHavokOnLoad linkScript = myLink as defaultDisableHavokOnLoad
if (linkScript) && (linkScript.beenSimmed == FALSE)
linkScript.ReleaseToHavok()
endif
endif
setMotionType(Motion_Dynamic, TRUE)
Self.ApplyHavokImpulse(0, 0, 1, 5)
; Debug.Trace("Released Havok.")
endFUNCTION