You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
179 lines
5.1 KiB
179 lines
5.1 KiB
Scriptname ETR_TrackStoredItems extends ReferenceAlias
|
|
|
|
Actor Property PlayerRef Auto
|
|
|
|
FormList Property ETR_ItemsNew Auto
|
|
FormList Property ETR_ItemsFound Auto
|
|
FormList Property ETR_ItemsStored Auto
|
|
FormList Property ETR_PersistentStorageList Auto
|
|
|
|
Container Property ETR_CellStorageContainer Auto
|
|
|
|
Keyword Property LocTypePlayerHouse Auto
|
|
|
|
bool bBusy = false
|
|
bool bAtHome = false
|
|
bool bRescanHome = false
|
|
bool bRescanPersistent = false
|
|
ObjectReference lastDestContainer = None
|
|
bool lastDestIsPersistent = false
|
|
ObjectReference lastSourceContainer = None
|
|
bool lastSourceIsPersistent = false
|
|
int iUpdateCount
|
|
|
|
|
|
event OnInit()
|
|
OnPlayerLoadGame()
|
|
endevent
|
|
|
|
|
|
Event OnPlayerLoadGame()
|
|
AddInventoryEventFilter(ETR_ItemsStored)
|
|
|
|
if skse.GetPluginVersion("Ahzaab's moreHUD Plugin") >= 30800
|
|
ahzmorehud.RegisterIconFormList("dbmNew", ETR_ItemsNew)
|
|
ahzmorehud.RegisterIconFormList("dbmFound", ETR_ItemsFound)
|
|
ahzmorehud.RegisterIconFormList("dbmDisp", ETR_ItemsStored)
|
|
endif
|
|
|
|
if skse.GetPluginVersion("Ahzaab's moreHUD Inventory Plugin") >= 10017
|
|
ahzmorehudie.RegisterIconFormList("dbmNew", ETR_ItemsNew)
|
|
ahzmorehudie.RegisterIconFormList("dbmFound", ETR_ItemsFound)
|
|
ahzmorehudie.RegisterIconFormList("dbmDisp", ETR_ItemsStored)
|
|
endif
|
|
|
|
if SKSE.GetPluginVersion("QuickLootRE") >= 292
|
|
QuickLootRE.RegisterNewItemsList(ETR_ItemsNew)
|
|
QuickLootRE.RegisterDisplayedItemsList(ETR_ItemsStored)
|
|
QuickLootRE.RegisterFoundItemsList(ETR_ItemsFound)
|
|
endif
|
|
|
|
; Rebuild all lists to avoid discrepancies, stale data, and broken records
|
|
|
|
ETR_ItemsStored.Revert()
|
|
ETR_Functions.AddArtifactsToList(ETR_PersistentStorageList, ETR_ItemsStored)
|
|
|
|
ETR_ItemsFound.Revert()
|
|
ETR_Functions.AddArtifactsToList(PlayerRef, ETR_ItemsFound, ETR_ItemsStored)
|
|
ETR_Functions.AddArtifactsFromFollowersToList(ETR_ItemsFound, ETR_ItemsStored)
|
|
|
|
ETR_ItemsNew.Revert()
|
|
ETR_Functions.AddAllFormsToList(ETR_ItemsNew, 41, ETR_ItemsStored, ETR_ItemsFound)
|
|
ETR_Functions.AddAllFormsToList(ETR_ItemsNew, 32, ETR_ItemsStored, ETR_ItemsFound)
|
|
ETR_Functions.AddAllFormsToList(ETR_ItemsNew, 27, ETR_ItemsStored, ETR_ItemsFound)
|
|
ETR_Functions.AddAllFormsToList(ETR_ItemsNew, 26, ETR_ItemsStored, ETR_ItemsFound)
|
|
|
|
Location currentLocation = PlayerRef.GetCurrentLocation()
|
|
bAtHome = currentLocation && currentLocation.HasKeyword(LocTypePlayerHouse)
|
|
if bAtHome
|
|
GotoState("AtHome")
|
|
else
|
|
GotoState("")
|
|
endif
|
|
EndEvent
|
|
|
|
|
|
Event OnLocationChange(Location akOldLoc, Location akNewLoc)
|
|
bAtHome = akNewLoc && akNewLoc.HasKeyword(LocTypePlayerHouse)
|
|
if bAtHome
|
|
GotoState("AtHome")
|
|
else
|
|
GotoState("")
|
|
endif
|
|
endEvent
|
|
|
|
|
|
Event OnMenuClose(String MenuName)
|
|
UnregisterForUpdate()
|
|
OnUpdate()
|
|
EndEvent
|
|
|
|
|
|
Event OnUpdate()
|
|
|
|
if UI.IsMenuOpen("ContainerMenu")
|
|
RegisterForMenu("ContainerMenu")
|
|
return
|
|
endif
|
|
|
|
while bBusy
|
|
Debug.Notification("Stored OnUpdate is busy")
|
|
Utility.wait(0.5)
|
|
endwhile
|
|
|
|
bBusy = true
|
|
|
|
iUpdateCount += 1
|
|
Debug.Notification("Running Stored OnUpdate " + iUpdateCount)
|
|
|
|
if bRescanHome
|
|
if lastSourceContainer && lastSourceContainer as Actor && (lastSourceContainer as Actor).IsPlayerTeammate()
|
|
lastSourceContainer = None
|
|
return
|
|
endif
|
|
bRescanHome = false
|
|
|
|
ObjectReference bookShelf
|
|
if lastDestContainer
|
|
if lastDestContainer as PlayerBookShelfContainerScript
|
|
bookShelf = lastDestContainer
|
|
endif
|
|
elseif lastSourceContainer
|
|
if lastSourceContainer as PlayerBookShelfContainerScript
|
|
bookShelf = lastSourceContainer
|
|
endif
|
|
endif
|
|
|
|
if bookShelf
|
|
int iLimit = 10
|
|
while iLimit > 0 && (bookShelf as PlayerBookShelfContainerScript).GetState() == "PlacingBooks"
|
|
Debug.Notification("Waiting for shelf update")
|
|
iLimit -= 1
|
|
Utility.wait(0.5)
|
|
endwhile
|
|
endif
|
|
|
|
ObjectReference cellStorage = ETR_Functions.GetCellStorage(PlayerRef, ETR_PersistentStorageList, ETR_CellStorageContainer)
|
|
ETR_Functions.SyncCellStorage(cellStorage, ETR_PersistentStorageList)
|
|
endif
|
|
|
|
if bRescanPersistent
|
|
bRescanPersistent = false
|
|
|
|
ETR_ItemsStored.Revert()
|
|
Form[] aContainers = ETR_PersistentStorageList.ToArray()
|
|
|
|
int n = aContainers.length
|
|
while n > 0
|
|
n -= 1
|
|
ETR_Functions.AddArtifactsToList(aContainers[n], ETR_ItemsStored)
|
|
endwhile
|
|
|
|
ETR_ItemsFound.Revert()
|
|
ETR_Functions.AddArtifactsToList(PlayerRef, ETR_ItemsFound, ETR_ItemsStored)
|
|
ETR_Functions.AddArtifactsFromFollowersToList(ETR_ItemsFound, ETR_ItemsStored)
|
|
endif
|
|
|
|
bBusy = false
|
|
|
|
EndEvent
|
|
|
|
|
|
; We acquired a stored item, and we want to find out if we just have taken the last stored item of its kind
|
|
event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
|
|
|
|
if akSourceContainer
|
|
if lastSourceContainer != akSourceContainer
|
|
lastSourceContainer = akSourceContainer
|
|
lastSourceIsPersistent = ETR_PersistentStorageList.HasForm(akSourceContainer)
|
|
endif
|
|
if bAtHome || lastSourceIsPersistent
|
|
bRescanHome = bAtHome
|
|
bRescanPersistent = true
|
|
RegisterForSingleUpdate(0.5)
|
|
endif
|
|
elseif bAtHome
|
|
ETR_Functions.OnItemPickup(akBaseItem)
|
|
endif
|
|
|
|
endevent
|
|
|