1

Delayed follower rescanning

This commit is contained in:
Eddoursul 2022-06-22 20:03:51 +02:00
parent 3b78c86e79
commit 6eb5841745
2 changed files with 24 additions and 15 deletions

Binary file not shown.

View File

@ -16,6 +16,7 @@ int iFollowerIndex = 0
bool bAtHome = false
bool bRescanHome = false
bool bRescanPersistent = false
bool bRescanFollowers = false
ObjectReference lastDestContainer = None
bool lastDestIsPersistent = false
int iUpdateCount
@ -39,20 +40,8 @@ Event OnLocationChange(Location akOldLoc, Location akNewLoc)
bAtHome = akNewLoc && akNewLoc.HasKeyword(LocTypePlayerHouse)
lastDestContainer = None
int iCurrentFollowers = 0;
Actor[] aFollowers = ETR_Functions.GetPlayerFollowers()
int i = aFollowers.length
while i > 0
i -= 1
iCurrentFollowers += aFollowers[i].GetFormID()
endwhile
if iCurrentFollowers != iFollowerIndex
iFollowerIndex = iCurrentFollowers
bRescanHome = false
bRescanPersistent = false
RegisterForSingleUpdate(5.0) ; wait until followers load into the location
endif
bRescanFollowers = true
RegisterForSingleUpdate(3.0)
endEvent
@ -65,6 +54,25 @@ EndEvent
Event OnUpdate()
if bRescanFollowers
bRescanFollowers = false
int iCurrentFollowers = 0;
Actor[] aFollowers = ETR_Functions.GetPlayerFollowers()
int i = aFollowers.length
while i > 0
i -= 1
iCurrentFollowers += aFollowers[i].GetFormID()
endwhile
if iCurrentFollowers == iFollowerIndex
return
endif
iFollowerIndex = iCurrentFollowers
Debug.Notification("Team changed, rescanning")
endif
if UI.IsMenuOpen("ContainerMenu")
RegisterForMenu("ContainerMenu")
return
@ -81,11 +89,12 @@ Event OnUpdate()
Debug.Notification("Running Found OnUpdate " + iUpdateCount)
if bRescanHome
bRescanHome = false
if lastDestContainer && lastDestContainer as Actor && (lastDestContainer as Actor).IsPlayerTeammate()
lastDestContainer = None
return
endif
bRescanHome = false
if lastDestContainer && lastDestContainer as PlayerBookShelfContainerScript
int iLimit = 10