Delayed processing of items moved to a container (WIP)
This commit is contained in:
parent
fcc0924c1f
commit
7330fca50a
Binary file not shown.
Binary file not shown.
@ -7,6 +7,7 @@ FormList Property ETR_ItemsFound Auto
|
|||||||
FormList Property ETR_ItemsStored Auto
|
FormList Property ETR_ItemsStored Auto
|
||||||
FormList Property ETR_PersistentStorageList Auto
|
FormList Property ETR_PersistentStorageList Auto
|
||||||
FormList Property ETR_ExcludeFromNew Auto
|
FormList Property ETR_ExcludeFromNew Auto
|
||||||
|
FormList Property ETR_ExcludeFromCellItems Auto
|
||||||
|
|
||||||
Container Property ETR_CellStorageContainer Auto
|
Container Property ETR_CellStorageContainer Auto
|
||||||
|
|
||||||
@ -14,6 +15,9 @@ Keyword Property LocTypePlayerHouse Auto
|
|||||||
|
|
||||||
bool bAtHome = false
|
bool bAtHome = false
|
||||||
int iFollowerIndex = 0
|
int iFollowerIndex = 0
|
||||||
|
bool bUpdateFollowers = false
|
||||||
|
bool bSyncStorage = false
|
||||||
|
bool bUpdateLists = false
|
||||||
|
|
||||||
|
|
||||||
event OnInit()
|
event OnInit()
|
||||||
@ -27,59 +31,107 @@ EndEvent
|
|||||||
|
|
||||||
|
|
||||||
Event OnLocationChange(Location akOldLoc, Location akNewLoc)
|
Event OnLocationChange(Location akOldLoc, Location akNewLoc)
|
||||||
|
|
||||||
bAtHome = akNewLoc && akNewLoc.HasKeyword(LocTypePlayerHouse)
|
bAtHome = akNewLoc && akNewLoc.HasKeyword(LocTypePlayerHouse)
|
||||||
RegisterForSingleUpdate(3.0) ; wait until followers load into the location
|
|
||||||
endEvent
|
|
||||||
|
|
||||||
|
|
||||||
Event OnUpdate()
|
|
||||||
|
|
||||||
;Debug.Notification("Follower index: " + iFollowerIndex)
|
|
||||||
|
|
||||||
int iCurrentFollowers = 0;
|
int iCurrentFollowers = 0;
|
||||||
Actor[] aFollowers = Eddoursul_Functions.GetPlayerFollowers()
|
Actor[] aFollowers = Eddoursul_Functions.GetPlayerFollowers()
|
||||||
int i = aFollowers.length
|
int i = aFollowers.length
|
||||||
while i > 0
|
while i > 0
|
||||||
i -= 1
|
i -= 1
|
||||||
if ! aFollowers[i].IsDead() && ! aFollowers[i].IsDisabled()
|
iCurrentFollowers += aFollowers[i].GetFormID()
|
||||||
iCurrentFollowers += aFollowers[i].GetFormID()
|
|
||||||
;Debug.Notification("Follower ID: " + aFollowers[i].GetFormID())
|
|
||||||
endif
|
|
||||||
endwhile
|
endwhile
|
||||||
|
|
||||||
;Debug.Notification("New follower index: " + iCurrentFollowers)
|
if iCurrentFollowers != iFollowerIndex
|
||||||
|
; If the list of followers has changed, rebuild ETR_ItemsFound and ETR_ItemsNew
|
||||||
if iCurrentFollowers == iFollowerIndex
|
iFollowerIndex = iCurrentFollowers
|
||||||
return
|
bUpdateFollowers = true
|
||||||
|
RegisterForSingleUpdate(3.0) ; wait until followers load into the location
|
||||||
endif
|
endif
|
||||||
|
|
||||||
; If the list of followers has changed, rebuild ETR_ItemsFound and ETR_ItemsNew
|
endEvent
|
||||||
iFollowerIndex = iCurrentFollowers
|
|
||||||
|
|
||||||
Debug.Notification("Team changed, updating lists")
|
|
||||||
|
|
||||||
ETR_ItemsFound.Revert()
|
Event OnUpdate()
|
||||||
Eddoursul_Functions.AddItemsOfTypeAndKeywordToList(PlayerRef, ETR_ItemsFound, 26, None, ETR_ExcludeFromNew, false, false, false)
|
|
||||||
Eddoursul_Functions.AddItemsOfTypeAndKeywordToList(PlayerRef, ETR_ItemsFound, 41, None, ETR_ExcludeFromNew, false, false, false)
|
|
||||||
Eddoursul_Functions.AddItemsOfTypeAndKeywordToList(PlayerRef, ETR_ItemsFound, 27, None, ETR_ExcludeFromNew, false, false, false)
|
|
||||||
Eddoursul_Functions.AddItemsOfTypeAndKeywordToList(PlayerRef, ETR_ItemsFound, 32, None, ETR_ExcludeFromNew, false, false, false)
|
|
||||||
|
|
||||||
i = aFollowers.length
|
Actor[] aFollowers
|
||||||
while i > 0
|
int i
|
||||||
i -= 1
|
|
||||||
if ! aFollowers[i].IsDead() && ! aFollowers[i].IsDisabled()
|
if bUpdateLists
|
||||||
|
|
||||||
|
if Utility.IsInMenuMode()
|
||||||
|
RegisterForSingleUpdate(1.0)
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
bUpdateLists = false
|
||||||
|
bUpdateFollowers = false
|
||||||
|
|
||||||
|
if bSyncStorage
|
||||||
|
bSyncStorage = false
|
||||||
|
ObjectReference cellStorage = Eddoursul_Functions.GetCellStorage(PlayerRef, ETR_PersistentStorageList, ETR_CellStorageContainer)
|
||||||
|
Eddoursul_Functions.SyncCellStorage(cellStorage, ETR_ExcludeFromCellItems)
|
||||||
|
endif
|
||||||
|
|
||||||
|
Eddoursul_Functions.AddItemsOfTypeAndKeywordToList(ETR_PersistentStorageList, ETR_ItemsStored, 26, None, ETR_ExcludeFromCellItems)
|
||||||
|
Eddoursul_Functions.AddItemsOfTypeAndKeywordToList(ETR_PersistentStorageList, ETR_ItemsStored, 41, None, ETR_ExcludeFromCellItems)
|
||||||
|
Eddoursul_Functions.AddItemsOfTypeAndKeywordToList(ETR_PersistentStorageList, ETR_ItemsStored, 27, None, ETR_ExcludeFromCellItems)
|
||||||
|
Eddoursul_Functions.AddItemsOfTypeAndKeywordToList(ETR_PersistentStorageList, ETR_ItemsStored, 32, None, ETR_ExcludeFromCellItems)
|
||||||
|
|
||||||
|
ETR_ItemsFound.Revert()
|
||||||
|
Eddoursul_Functions.AddItemsOfTypeAndKeywordToList(PlayerRef, ETR_ItemsFound, 26, None, ETR_ExcludeFromNew, false, false, false)
|
||||||
|
Eddoursul_Functions.AddItemsOfTypeAndKeywordToList(PlayerRef, ETR_ItemsFound, 41, None, ETR_ExcludeFromNew, false, false, false)
|
||||||
|
Eddoursul_Functions.AddItemsOfTypeAndKeywordToList(PlayerRef, ETR_ItemsFound, 27, None, ETR_ExcludeFromNew, false, false, false)
|
||||||
|
Eddoursul_Functions.AddItemsOfTypeAndKeywordToList(PlayerRef, ETR_ItemsFound, 32, None, ETR_ExcludeFromNew, false, false, false)
|
||||||
|
|
||||||
|
aFollowers = Eddoursul_Functions.GetPlayerFollowers()
|
||||||
|
i = aFollowers.length
|
||||||
|
while i > 0
|
||||||
|
i -= 1
|
||||||
Eddoursul_Functions.AddItemsOfTypeAndKeywordToList(aFollowers[i], ETR_ItemsFound, 26, None, ETR_ExcludeFromNew, false, false, false)
|
Eddoursul_Functions.AddItemsOfTypeAndKeywordToList(aFollowers[i], ETR_ItemsFound, 26, None, ETR_ExcludeFromNew, false, false, false)
|
||||||
Eddoursul_Functions.AddItemsOfTypeAndKeywordToList(aFollowers[i], ETR_ItemsFound, 41, None, ETR_ExcludeFromNew, false, false, false)
|
Eddoursul_Functions.AddItemsOfTypeAndKeywordToList(aFollowers[i], ETR_ItemsFound, 41, None, ETR_ExcludeFromNew, false, false, false)
|
||||||
Eddoursul_Functions.AddItemsOfTypeAndKeywordToList(aFollowers[i], ETR_ItemsFound, 27, None, ETR_ExcludeFromNew, false, false, false)
|
Eddoursul_Functions.AddItemsOfTypeAndKeywordToList(aFollowers[i], ETR_ItemsFound, 27, None, ETR_ExcludeFromNew, false, false, false)
|
||||||
Eddoursul_Functions.AddItemsOfTypeAndKeywordToList(aFollowers[i], ETR_ItemsFound, 32, None, ETR_ExcludeFromNew, false, false, false)
|
Eddoursul_Functions.AddItemsOfTypeAndKeywordToList(aFollowers[i], ETR_ItemsFound, 32, None, ETR_ExcludeFromNew, false, false, false)
|
||||||
endif
|
endwhile
|
||||||
endwhile
|
|
||||||
|
|
||||||
ETR_ItemsNew.Revert()
|
ETR_ItemsNew.Revert()
|
||||||
Eddoursul_Functions.AddAllFormsToList(ETR_ItemsNew, 26, None, ETR_ExcludeFromNew) ; armor
|
Eddoursul_Functions.AddAllFormsToList(ETR_ItemsNew, 26, None, ETR_ExcludeFromNew) ; armor
|
||||||
Eddoursul_Functions.AddAllFormsToList(ETR_ItemsNew, 41, None, ETR_ExcludeFromNew) ; weapons
|
Eddoursul_Functions.AddAllFormsToList(ETR_ItemsNew, 41, None, ETR_ExcludeFromNew) ; weapons
|
||||||
Eddoursul_Functions.AddAllFormsToList(ETR_ItemsNew, 27, None, ETR_ExcludeFromNew) ; books
|
Eddoursul_Functions.AddAllFormsToList(ETR_ItemsNew, 27, None, ETR_ExcludeFromNew) ; books
|
||||||
Eddoursul_Functions.AddAllFormsToList(ETR_ItemsNew, 32, None, ETR_ExcludeFromNew) ; misc items
|
Eddoursul_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()
|
||||||
|
Eddoursul_Functions.AddItemsOfTypeAndKeywordToList(PlayerRef, ETR_ItemsFound, 26, None, ETR_ExcludeFromNew, false, false, false)
|
||||||
|
Eddoursul_Functions.AddItemsOfTypeAndKeywordToList(PlayerRef, ETR_ItemsFound, 41, None, ETR_ExcludeFromNew, false, false, false)
|
||||||
|
Eddoursul_Functions.AddItemsOfTypeAndKeywordToList(PlayerRef, ETR_ItemsFound, 27, None, ETR_ExcludeFromNew, false, false, false)
|
||||||
|
Eddoursul_Functions.AddItemsOfTypeAndKeywordToList(PlayerRef, ETR_ItemsFound, 32, None, ETR_ExcludeFromNew, false, false, false)
|
||||||
|
|
||||||
|
aFollowers = Eddoursul_Functions.GetPlayerFollowers()
|
||||||
|
i = aFollowers.length
|
||||||
|
while i > 0
|
||||||
|
i -= 1
|
||||||
|
Eddoursul_Functions.AddItemsOfTypeAndKeywordToList(aFollowers[i], ETR_ItemsFound, 26, None, ETR_ExcludeFromNew, false, false, false)
|
||||||
|
Eddoursul_Functions.AddItemsOfTypeAndKeywordToList(aFollowers[i], ETR_ItemsFound, 41, None, ETR_ExcludeFromNew, false, false, false)
|
||||||
|
Eddoursul_Functions.AddItemsOfTypeAndKeywordToList(aFollowers[i], ETR_ItemsFound, 27, None, ETR_ExcludeFromNew, false, false, false)
|
||||||
|
Eddoursul_Functions.AddItemsOfTypeAndKeywordToList(aFollowers[i], ETR_ItemsFound, 32, None, ETR_ExcludeFromNew, false, false, false)
|
||||||
|
endwhile
|
||||||
|
|
||||||
|
ETR_ItemsNew.Revert()
|
||||||
|
Eddoursul_Functions.AddAllFormsToList(ETR_ItemsNew, 26, None, ETR_ExcludeFromNew) ; armor
|
||||||
|
Eddoursul_Functions.AddAllFormsToList(ETR_ItemsNew, 41, None, ETR_ExcludeFromNew) ; weapons
|
||||||
|
Eddoursul_Functions.AddAllFormsToList(ETR_ItemsNew, 27, None, ETR_ExcludeFromNew) ; books
|
||||||
|
Eddoursul_Functions.AddAllFormsToList(ETR_ItemsNew, 32, None, ETR_ExcludeFromNew) ; misc items
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
EndEvent
|
EndEvent
|
||||||
|
|
||||||
@ -87,37 +139,16 @@ EndEvent
|
|||||||
event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
|
event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
|
||||||
|
|
||||||
if akDestContainer
|
if akDestContainer
|
||||||
if akDestContainer as Actor
|
bSyncStorage = bAtHome
|
||||||
if (akDestContainer as Actor).IsPlayerTeammate()
|
bUpdateLists = true
|
||||||
; Keep follower items marked as found
|
RegisterForSingleUpdate(1.0)
|
||||||
return
|
elseif bAtHome && akItemReference
|
||||||
endif
|
|
||||||
elseif ETR_PersistentStorageList.HasForm(akDestContainer)
|
|
||||||
ETR_ItemsFound.RemoveAddedForm(akBaseItem)
|
|
||||||
ETR_ItemsStored.AddForm(akBaseItem)
|
|
||||||
return
|
|
||||||
elseif bAtHome && akDestContainer.GetParentCell() != PlayerRef.GetParentCell()
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
if bAtHome && (akDestContainer || Eddoursul_Functions.HasRefInCell(akBaseItem, None, true, ETR_PersistentStorageList))
|
|
||||||
|
|
||||||
ETR_ItemsFound.RemoveAddedForm(akBaseItem)
|
ETR_ItemsFound.RemoveAddedForm(akBaseItem)
|
||||||
ETR_ItemsStored.AddForm(akBaseItem)
|
ETR_ItemsStored.AddForm(akBaseItem)
|
||||||
|
Eddoursul_Functions.GetCellStorage(PlayerRef, ETR_PersistentStorageList, ETR_CellStorageContainer).AddItem(akBaseItem, 1, true)
|
||||||
ObjectReference cellStorage = Eddoursul_Functions.GetCellStorage(PlayerRef, ETR_PersistentStorageList, ETR_CellStorageContainer)
|
|
||||||
|
|
||||||
if cellStorage.GetItemCount(akBaseItem) == 0
|
|
||||||
cellStorage.AddItem(akBaseItem, 1, true)
|
|
||||||
endif
|
|
||||||
|
|
||||||
elseif PlayerRef.GetItemCount(akBaseItem) == 0 && Eddoursul_Functions.GetItemCountInActors(Eddoursul_Functions.GetPlayerFollowers(), akBaseItem) == 0
|
elseif PlayerRef.GetItemCount(akBaseItem) == 0 && Eddoursul_Functions.GetItemCountInActors(Eddoursul_Functions.GetPlayerFollowers(), akBaseItem) == 0
|
||||||
|
|
||||||
ETR_ItemsFound.RemoveAddedForm(akBaseItem)
|
ETR_ItemsFound.RemoveAddedForm(akBaseItem)
|
||||||
ETR_ItemsStored.RemoveAddedForm(akBaseItem)
|
|
||||||
ETR_ItemsNew.AddForm(akBaseItem)
|
ETR_ItemsNew.AddForm(akBaseItem)
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
endevent
|
endevent
|
||||||
|
Loading…
Reference in New Issue
Block a user