1

Merged ETR_CellStorageScript updates back to player aliases due to lower performance

This commit is contained in:
Eddoursul 2022-06-18 01:24:04 +02:00
parent 56c9fad726
commit 8bc8b1362d
8 changed files with 26 additions and 67 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,58 +1 @@
Scriptname ETR_CellStorageScript extends ObjectReference Scriptname ETR_CellStorageScript extends ObjectReference
FormList Property ETR_ItemsNew Auto
FormList Property ETR_ItemsFound Auto
FormList Property ETR_ItemsStored Auto
FormList Property ETR_PersistentStorageList Auto
event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
Debug.Notification("OnItemRemoved")
bool bStored = ETR_ItemsStored.HasForm(akBaseItem)
if GetItemCount(akBaseItem) > 0
if ! bStored
ETR_ItemsFound.RemoveAddedForm(akBaseItem)
ETR_ItemsNew.RemoveAddedForm(akBaseItem)
ETR_ItemsStored.AddForm(akBaseItem)
Debug.Notification("Added " + akBaseItem.GetName() + " to ETR_ItemsStored.")
endif
return
endif
if Eddoursul_Functions.GetItemCountInList(ETR_PersistentStorageList, akBaseItem)
Debug.Notification("ETR_PersistentStorageList")
; do nothing
if ! bStored
ETR_ItemsFound.RemoveAddedForm(akBaseItem)
ETR_ItemsNew.RemoveAddedForm(akBaseItem)
ETR_ItemsStored.AddForm(akBaseItem)
Debug.Notification("Added " + akBaseItem.GetName() + " to ETR_ItemsStored.")
endif
else
ETR_ItemsNew.RemoveAddedForm(akBaseItem)
ETR_ItemsStored.RemoveAddedForm(akBaseItem)
ETR_ItemsFound.AddForm(akBaseItem)
Debug.Notification("Added " + akBaseItem.GetName() + " to ETR_ItemsFound.")
endif
endevent
event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
if ETR_ItemsStored.HasForm(akBaseItem)
return
endif
ETR_ItemsFound.RemoveAddedForm(akBaseItem)
ETR_ItemsNew.RemoveAddedForm(akBaseItem)
ETR_ItemsStored.AddForm(akBaseItem)
;UI.Invoke("HUD Menu", "_root.AHZWidgetContainer.AHZWidget.RefreshWidgets")
Debug.Notification("Added " + akBaseItem.GetName() + " to cell storage and ETR_ItemsStored.")
endevent

View File

@ -27,8 +27,14 @@ 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()
@ -37,9 +43,12 @@ Event OnLocationChange(Location akOldLoc, Location akNewLoc)
i -= 1 i -= 1
if ! aFollowers[i].IsDead() && ! aFollowers[i].IsDisabled() if ! aFollowers[i].IsDead() && ! aFollowers[i].IsDisabled()
iCurrentFollowers += aFollowers[i].GetFormID() iCurrentFollowers += aFollowers[i].GetFormID()
;Debug.Notification("Follower ID: " + aFollowers[i].GetFormID())
endif endif
endwhile endwhile
;Debug.Notification("New follower index: " + iCurrentFollowers)
if iCurrentFollowers == iFollowerIndex if iCurrentFollowers == iFollowerIndex
return return
endif endif
@ -72,7 +81,7 @@ Event OnLocationChange(Location akOldLoc, Location akNewLoc)
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
endEvent EndEvent
event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer) event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
@ -85,14 +94,17 @@ event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemRefe
endif endif
elseif ETR_PersistentStorageList.HasForm(akDestContainer) elseif ETR_PersistentStorageList.HasForm(akDestContainer)
ETR_ItemsFound.RemoveAddedForm(akBaseItem) ETR_ItemsFound.RemoveAddedForm(akBaseItem)
ETR_ItemsNew.RemoveAddedForm(akBaseItem)
ETR_ItemsStored.AddForm(akBaseItem) ETR_ItemsStored.AddForm(akBaseItem)
Debug.Notification("Added " + akBaseItem.GetName() + " to ETR_ItemsStored") return
elseif bAtHome && akDestContainer.GetParentCell() != PlayerRef.GetParentCell()
return return
endif endif
endif endif
if bAtHome && (! akDestContainer || akDestContainer.GetParentCell() == PlayerRef.GetParentCell()) && Eddoursul_Functions.HasRefInCell(akBaseItem, None, true, ETR_PersistentStorageList) if bAtHome && (akDestContainer || Eddoursul_Functions.HasRefInCell(akBaseItem, None, true, ETR_PersistentStorageList))
ETR_ItemsFound.RemoveAddedForm(akBaseItem)
ETR_ItemsStored.AddForm(akBaseItem)
ObjectReference cellStorage = Eddoursul_Functions.GetOrCreateCellStorage(PlayerRef, ETR_PersistentStorageList, ETR_CellStorageContainer) ObjectReference cellStorage = Eddoursul_Functions.GetOrCreateCellStorage(PlayerRef, ETR_PersistentStorageList, ETR_CellStorageContainer)
@ -102,7 +114,6 @@ event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemRefe
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
Debug.Notification("Moving " + akBaseItem.GetName() + " to ETR_ItemsNew")
ETR_ItemsFound.RemoveAddedForm(akBaseItem) ETR_ItemsFound.RemoveAddedForm(akBaseItem)
ETR_ItemsStored.RemoveAddedForm(akBaseItem) ETR_ItemsStored.RemoveAddedForm(akBaseItem)
ETR_ItemsNew.AddForm(akBaseItem) ETR_ItemsNew.AddForm(akBaseItem)

View File

@ -48,11 +48,11 @@ event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemRefe
endif endif
if ! akDestContainer || akDestContainer.GetParentCell() == PlayerRef.GetParentCell() if ((akDestContainer && akDestContainer.GetParentCell() == PlayerRef.GetParentCell()) || (! akDestContainer && Eddoursul_Functions.HasRefInCell(akBaseItem, None, true, ETR_PersistentStorageList)))
ObjectReference cellStorage = Eddoursul_Functions.GetOrCreateCellStorage(PlayerRef, ETR_PersistentStorageList, ETR_CellStorageContainer) ObjectReference cellStorage = Eddoursul_Functions.GetOrCreateCellStorage(PlayerRef, ETR_PersistentStorageList, ETR_CellStorageContainer)
if cellStorage.GetItemCount(akBaseItem) == 0 && Eddoursul_Functions.HasRefInCell(akBaseItem, None, true, ETR_PersistentStorageList) if cellStorage.GetItemCount(akBaseItem) == 0
cellStorage.AddItem(akBaseItem, 1, true) cellStorage.AddItem(akBaseItem, 1, true)
endif endif
@ -66,17 +66,22 @@ event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemRefere
if akSourceContainer && !(akSourceContainer as Actor) && ETR_PersistentStorageList.HasForm(akSourceContainer) if akSourceContainer && !(akSourceContainer as Actor) && ETR_PersistentStorageList.HasForm(akSourceContainer)
if Eddoursul_Functions.GetItemCountInList(ETR_PersistentStorageList, akBaseItem) == 0 if Eddoursul_Functions.GetItemCountInList(ETR_PersistentStorageList, akBaseItem) == 0
Debug.Notification("Added " + akBaseItem.GetName() + " to ETR_ItemsFound")
ETR_ItemsStored.RemoveAddedForm(akBaseItem) ETR_ItemsStored.RemoveAddedForm(akBaseItem)
ETR_ItemsFound.AddForm(akBaseItem) ETR_ItemsFound.AddForm(akBaseItem)
ETR_ItemsNew.RemoveAddedForm(akBaseItem)
endif endif
elseif bAtHome elseif bAtHome
ObjectReference cellStorage = Eddoursul_Functions.GetOrCreateCellStorage(PlayerRef, ETR_PersistentStorageList, ETR_CellStorageContainer) ObjectReference cellStorage = Eddoursul_Functions.GetOrCreateCellStorage(PlayerRef, ETR_PersistentStorageList, ETR_CellStorageContainer)
int iCount = cellStorage.GetItemCount(akBaseItem) int iCount = cellStorage.GetItemCount(akBaseItem)
if iCount > 0 && ! Eddoursul_Functions.HasRefInCell(akBaseItem, None, true, ETR_PersistentStorageList) if iCount > 0 && ! Eddoursul_Functions.HasRefInCell(akBaseItem, None, true, ETR_PersistentStorageList)
cellStorage.RemoveItem(akBaseItem, iCount, true) cellStorage.RemoveItem(akBaseItem, iCount, true)
if Eddoursul_Functions.GetItemCountInList(ETR_PersistentStorageList, akBaseItem) == 0
ETR_ItemsStored.RemoveAddedForm(akBaseItem)
ETR_ItemsFound.AddForm(akBaseItem)
endif
endif endif
endif endif