Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;**************************************************************************
- ;FO4 Papyrus RefCollectionAlias scavenge timer
- ;Ensure no dead spawned NPCs hang around in a RefCollectionAlias due to missed
- ;OnDeath() alias script events which can happen during simultaneous events,
- ; or when NPC 3d is unloaded between uGridsToLoad and fLODFadeOutMultActors
- ;**************************************************************************
- GlobalVariable Property pGlobalName Auto Mandatory
- RefCollectionAlias Property Alias_Name Auto
- Int iScavengeTimer = 30
- Float fScavengeTimer = 60.0 ;Player sprint 500 NPC run 350, deltaT to 3D unload at 15K separation
- ;**************************************************************************
- Event OnTimer(int iTimer)
- If iTimer == iScavengeTimer
- Scavenge()
- Endif
- EndEvent
- ;**************************************************************************
- Function Scavenge()
- Bool bCleanup = FALSE
- Int iIndex = 0
- While iIndex < Alias_Name.GetCount()
- ObjectReference ThisREF = Alias_Name.GetAt(iIndex)
- If (ThisREF as Actor).IsDead() == TRUE ;This is normally done by ONDeath attached to RefAlias
- Alias_Name.RemoveRef(ThisREF) ;Remove persistent hold
- Elseif ThisREF.Is3DLoaded() == FALSE ;One or more live NPCs are stuck with 3D unloaded
- bCleanup = TRUE
- EndIf
- iIndex +=1
- EndWhile
- If Alias_Name.GetCount() == 0 || bCleanup == TRUE ;None left or stuck
- Cleanup()
- Else ;Keep going
- pGlobalName.SetValue(Alias_Name.GetCount()) ;Global is used in quest objective
- pQuestName.UpdateCurrentInstanceGlobal(pGlobalName) ;Global is used in quest objective
- StartTimer(fScavengeTimer, iScavengeTimer)
- Endif
- EndFunction
- ;**************************************************************************
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement