|
|
|
Scriptname ETR_TrackFoundItems 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
|
|
|
|
FormList Property ETR_ExcludeFromNew Auto
|
|
|
|
FormList Property ETR_ExcludeFromCellItems Auto
|
|
|
|
|
|
|
|
Container Property ETR_CellStorageContainer Auto
|
|
|
|
|
|
|
|
Keyword Property LocTypePlayerHouse Auto
|
|
|
|
|
|
|
|
bool bAtHome = false
|
|
|
|
int iFollowerIndex = 0
|
|
|
|
bool bUpdateFollowers = false
|
|
|
|
bool bSyncStorage = false
|
|
|
|
bool bUpdateLists = false
|
|
|
|
|
|
|
|
|
|
|
|
event OnInit()
|
|
|
|
OnPlayerLoadGame()
|
|
|
|
endevent
|
|
|
|
|
|
|
|
|
|
|
|
Event OnPlayerLoadGame()
|
|
|
|
AddInventoryEventFilter(ETR_ItemsFound)
|
|
|
|
EndEvent
|
|
|
|
|
|
|
|
|
|
|
|
Event OnLocationChange(Location akOldLoc, Location akNewLoc)
|
|
|
|
|
|
|
|
bAtHome = akNewLoc && akNewLoc.HasKeyword(LocTypePlayerHouse)
|
|
|
|
|
|
|
|
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
|
|
|
|
; If the list of followers has changed, rebuild ETR_ItemsFound and ETR_ItemsNew
|
|
|
|
iFollowerIndex = iCurrentFollowers
|
|
|
|
bUpdateFollowers = true
|
|
|
|
RegisterForSingleUpdate(3.0) ; wait until followers load into the location
|
|
|
|
endif
|
|
|
|
|
|
|
|
endEvent
|
|
|
|
|
|
|
|
|
|
|
|
Event OnUpdate()
|
|
|
|
|
|
|
|
Actor[] aFollowers
|
|
|
|
int i
|
|
|
|
|
|
|
|
if bUpdateLists
|
|
|
|
|
|
|
|
if Utility.IsInMenuMode()
|
|
|
|
RegisterForSingleUpdate(1.0)
|
|
|
|
return
|
|
|
|
endif
|
|
|
|
|
|
|
|
bUpdateLists = false
|
|
|
|
bUpdateFollowers = false
|
|
|
|
|
|
|
|
if bSyncStorage
|
|
|
|
bSyncStorage = false
|
|
|
|
ObjectReference cellStorage = ETR_Functions.GetCellStorage(PlayerRef, ETR_PersistentStorageList, ETR_CellStorageContainer)
|
|
|
|
ETR_Functions.SyncCellStorage(cellStorage, ETR_ExcludeFromCellItems)
|
|
|
|
endif
|
|
|
|
|
|
|
|
ETR_Functions.AddItemsOfTypeAndKeywordToList(ETR_PersistentStorageList, ETR_ItemsStored, 26, None, ETR_ExcludeFromCellItems)
|
|
|
|
ETR_Functions.AddItemsOfTypeAndKeywordToList(ETR_PersistentStorageList, ETR_ItemsStored, 41, None, ETR_ExcludeFromCellItems)
|
|
|
|
ETR_Functions.AddItemsOfTypeAndKeywordToList(ETR_PersistentStorageList, ETR_ItemsStored, 27, None, ETR_ExcludeFromCellItems)
|
|
|
|
ETR_Functions.AddItemsOfTypeAndKeywordToList(ETR_PersistentStorageList, ETR_ItemsStored, 32, None, ETR_ExcludeFromCellItems)
|
|
|
|
|
|
|
|
ETR_ItemsFound.Revert()
|
|
|
|
ETR_Functions.AddItemsOfTypeAndKeywordToList(PlayerRef, ETR_ItemsFound, 26, None, ETR_ExcludeFromNew, false, false, false)
|
|
|
|
ETR_Functions.AddItemsOfTypeAndKeywordToList(PlayerRef, ETR_ItemsFound, 41, None, ETR_ExcludeFromNew, false, false, false)
|
|
|
|
ETR_Functions.AddItemsOfTypeAndKeywordToList(PlayerRef, ETR_ItemsFound, 27, None, ETR_ExcludeFromNew, false, false, false)
|
|
|
|
ETR_Functions.AddItemsOfTypeAndKeywordToList(PlayerRef, ETR_ItemsFound, 32, None, ETR_ExcludeFromNew, false, false, false)
|
|
|
|
|
|
|
|
aFollowers = ETR_Functions.GetPlayerFollowers()
|
|
|
|
i = aFollowers.length
|
|
|
|
while i > 0
|
|
|
|
i -= 1
|
|
|
|
ETR_Functions.AddItemsOfTypeAndKeywordToList(aFollowers[i], ETR_ItemsFound, 26, None, ETR_ExcludeFromNew, false, false, false)
|
|
|
|
ETR_Functions.AddItemsOfTypeAndKeywordToList(aFollowers[i], ETR_ItemsFound, 41, None, ETR_ExcludeFromNew, false, false, false)
|
|
|
|
ETR_Functions.AddItemsOfTypeAndKeywordToList(aFollowers[i], ETR_ItemsFound, 27, None, ETR_ExcludeFromNew, false, false, false)
|
|
|
|
ETR_Functions.AddItemsOfTypeAndKeywordToList(aFollowers[i], ETR_ItemsFound, 32, None, ETR_ExcludeFromNew, false, false, false)
|
|
|
|
endwhile
|
|
|
|
|
|
|
|
ETR_ItemsNew.Revert()
|
|
|
|
ETR_Functions.AddAllFormsToList(ETR_ItemsNew, 26, None, ETR_ExcludeFromNew) ; armor
|
|
|
|
ETR_Functions.AddAllFormsToList(ETR_ItemsNew, 41, None, ETR_ExcludeFromNew) ; weapons
|
|
|
|
ETR_Functions.AddAllFormsToList(ETR_ItemsNew, 27, None, ETR_ExcludeFromNew) ; books
|
|
|
|
ETR_Functions.AddAllFormsToList(ETR_ItemsNew, 32, None, ETR_ExcludeFromNew) ; misc items
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
if bUpdateFollowers
|
|
|
|
bUpdateFollowers = false
|
|
|
|
|
|
|
|
Debug.Notification("Team changed, updating lists")
|
|
|
|
|
|
|
|
ETR_ItemsFound.Revert()
|
|
|
|
ETR_Functions.AddItemsOfTypeAndKeywordToList(PlayerRef, ETR_ItemsFound, 26, None, ETR_ExcludeFromNew, false, false, false)
|
|
|
|
ETR_Functions.AddItemsOfTypeAndKeywordToList(PlayerRef, ETR_ItemsFound, 41, None, ETR_ExcludeFromNew, false, false, false)
|
|
|
|
ETR_Functions.AddItemsOfTypeAndKeywordToList(PlayerRef, ETR_ItemsFound, 27, None, ETR_ExcludeFromNew, false, false, false)
|
|
|
|
ETR_Functions.AddItemsOfTypeAndKeywordToList(PlayerRef, ETR_ItemsFound, 32, None, ETR_ExcludeFromNew, false, false, false)
|
|
|
|
|
|
|
|
aFollowers = ETR_Functions.GetPlayerFollowers()
|
|
|
|
i = aFollowers.length
|
|
|
|
while i > 0
|
|
|
|
i -= 1
|
|
|
|
ETR_Functions.AddItemsOfTypeAndKeywordToList(aFollowers[i], ETR_ItemsFound, 26, None, ETR_ExcludeFromNew, false, false, false)
|
|
|
|
ETR_Functions.AddItemsOfTypeAndKeywordToList(aFollowers[i], ETR_ItemsFound, 41, None, ETR_ExcludeFromNew, false, false, false)
|
|
|
|
ETR_Functions.AddItemsOfTypeAndKeywordToList(aFollowers[i], ETR_ItemsFound, 27, None, ETR_ExcludeFromNew, false, false, false)
|
|
|
|
ETR_Functions.AddItemsOfTypeAndKeywordToList(aFollowers[i], ETR_ItemsFound, 32, None, ETR_ExcludeFromNew, false, false, false)
|
|
|
|
endwhile
|
|
|
|
|
|
|
|
ETR_ItemsNew.Revert()
|
|
|
|
ETR_Functions.AddAllFormsToList(ETR_ItemsNew, 26, None, ETR_ExcludeFromNew) ; armor
|
|
|
|
ETR_Functions.AddAllFormsToList(ETR_ItemsNew, 41, None, ETR_ExcludeFromNew) ; weapons
|
|
|
|
ETR_Functions.AddAllFormsToList(ETR_ItemsNew, 27, None, ETR_ExcludeFromNew) ; books
|
|
|
|
ETR_Functions.AddAllFormsToList(ETR_ItemsNew, 32, None, ETR_ExcludeFromNew) ; misc items
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
EndEvent
|
|
|
|
|
|
|
|
|
|
|
|
event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
|
|
|
|
|
|
|
|
if akDestContainer
|
|
|
|
bSyncStorage = bAtHome
|
|
|
|
bUpdateLists = true
|
|
|
|
RegisterForSingleUpdate(1.0)
|
|
|
|
elseif bAtHome && akItemReference
|
|
|
|
ETR_ItemsFound.RemoveAddedForm(akBaseItem)
|
|
|
|
ETR_ItemsStored.AddForm(akBaseItem)
|
|
|
|
ETR_Functions.GetCellStorage(PlayerRef, ETR_PersistentStorageList, ETR_CellStorageContainer).AddItem(akBaseItem, 1, true)
|
|
|
|
elseif PlayerRef.GetItemCount(akBaseItem) == 0 && ETR_Functions.GetItemCountInActors(ETR_Functions.GetPlayerFollowers(), akBaseItem) == 0
|
|
|
|
ETR_ItemsFound.RemoveAddedForm(akBaseItem)
|
|
|
|
ETR_ItemsNew.AddForm(akBaseItem)
|
|
|
|
endif
|
|
|
|
|
|
|
|
endevent
|