73 lines
2.2 KiB
Plaintext
73 lines
2.2 KiB
Plaintext
Scriptname _00E_DeadBodyCleanupScript extends Actor
|
|
|
|
;This script cleans up dead actors, enables a container and moves all their inventory, after it Loads/unloads after a certain period of time.
|
|
;See WIDeadBodyCleanupScript for original code.
|
|
|
|
float Property DaysBeforeCleanUp = 0.5 Auto
|
|
{Default = 0.5: What's the minimum amount of time (in days) that the body should stick around before being cleaned up. (Clean up happens during while loop.)}
|
|
ObjectReference Property _00E_DeathContainer Auto
|
|
{Container to move all the items the actor has in his inventory when cleaned up.}
|
|
ObjectReference Property _00E_NPCDumpMarker Auto
|
|
{Marker where the dead actor will be stored when cleaned up.}
|
|
|
|
actor SelfRef ;used to keep me persistent so I get UnLoad events while I exist
|
|
|
|
state Dead
|
|
;do nothing
|
|
Event OnDeath(Actor akKiller)
|
|
EndEvent
|
|
|
|
EndState
|
|
|
|
Event OnDeath(Actor akKiller)
|
|
|
|
GoToState("Dead")
|
|
|
|
if _00E_DeathContainer
|
|
|
|
bool cleanedUp = false
|
|
|
|
while cleanedUp == false
|
|
; debug.trace("_00E_DeadBodyCleanupScript" + self + "OnDeath() In While Loop, will try cleaning up after waiting " + DaysBeforeCleanUp)
|
|
|
|
Utility.waitGameTime(DaysBeforeCleanUp * 24)
|
|
|
|
cleanedUp = checkForCleanup()
|
|
|
|
endWhile
|
|
|
|
else
|
|
; debug.trace("_00E_DeadBodyCleanupScript" + self + " WARNING: NO _00E_DeathContainer!", 2)
|
|
|
|
endif
|
|
|
|
EndEvent
|
|
|
|
|
|
bool function checkForCleanup()
|
|
|
|
if Is3DLoaded() == False
|
|
; debug.trace("_00E_DeadBodyCleanupScript" + self + "Cleaning up body.")
|
|
cleanUpBody()
|
|
return true
|
|
Else
|
|
; debug.trace("_00E_DeadBodyCleanupScript" + self + "Not cleaning up body, because my 3D is loaded.")
|
|
EndIf
|
|
|
|
return false
|
|
|
|
endfunction
|
|
|
|
function cleanUpBody()
|
|
; debug.trace("_00E_DeadBodyCleanupScript" + self + "cleanUpBody() moving to WIDeadBodyCleanupCellMarker in WIDeadBodyCleanupCell and Calling RemoveAllItems() to _00E_DeathContainer, and enabling it:" + _00E_DeathContainer)
|
|
|
|
;Disable()
|
|
;*** It has been decided it's safer to move them to a holding cell, for quests that might be filling allowing for dead actors but not allowing checking for disabled actors
|
|
|
|
MoveTo(_00E_NPCDumpMarker)
|
|
|
|
_00E_DeathContainer.SetActorOwner(GetActorBase())
|
|
_00E_DeathContainer.Enable()
|
|
RemoveAllItems(_00E_DeathContainer)
|
|
|
|
EndFunction |