enderalse/scripts/source/defaultdisablehavokonload.psc

71 lines
2.1 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:46:41 +00:00
Bool Property beenPutInContainer auto hidden
2021-10-05 22:46:41 +00:00
Event OnCellAttach()
If Is3DLoaded() && beenSimmed == False && beenPutInContainer == False
SetMotionType(Motion_Keyframed, True)
; debug.trace("havok disabled on: " + self)
EndIf
EndEvent
2021-10-05 22:46:41 +00:00
Event OnLoad()
If beenSimmed == False && beenPutInContainer == False
SetMotionType(Motion_Keyframed, True)
; debug.trace("havok disabled on: " + self)
EndIf
EndEvent
2021-10-05 22:46:41 +00:00
Event OnActivate(ObjectReference triggerRef)
If havokonActivate && beenSimmed == False
ReleaseToHavok()
2021-10-05 22:46:41 +00:00
EndIf
EndEvent
2021-10-05 22:46:41 +00:00
Event OnHit(ObjectReference var1, Form var2, Projectile var3, bool var4, bool var5, bool var6, bool var7)
If havokOnHit && beenSimmed == False
ReleaseToHavok()
2021-10-05 22:46:41 +00:00
EndIf
EndEvent
2021-10-05 22:46:41 +00:00
Event OnGrab()
If havokOnZkey && beenSimmed == False
ReleaseToHavok()
2021-10-05 22:46:41 +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:46:41 +00:00
If beenSimmed == False
If akNewContainer != None
;Stops the OnLoad event from generating errors.
beenPutInContainer = True
Else
;No container, means it's being dropped in the open. Let it loose now.
ReleaseToHavok()
EndIf
EndIf
EndEvent
2021-10-05 22:46:41 +00:00
Function ReleaseToHavok()
beenSimmed = True
beenPutInContainer = False
defaultDisableHavokOnLoad myLink = GetLinkedRef(linkHavokPartner) as defaultDisableHavokOnLoad
If myLink && (myLink.beenSimmed == False)
myLink.ReleaseToHavok()
EndIf
SetMotionType(Motion_Dynamic, True)
Self.ApplyHavokImpulse(0, 0, 1, 5)
; Debug.Trace("Released Havok.")
EndFunction