Merged ETR_CellStorageScript updates back to player aliases due to lower performance
This commit is contained in:
parent
56c9fad726
commit
8bc8b1362d
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,58 +1 @@
|
||||
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
|
||||
|
@ -27,8 +27,14 @@ EndEvent
|
||||
|
||||
|
||||
Event OnLocationChange(Location akOldLoc, Location akNewLoc)
|
||||
|
||||
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;
|
||||
Actor[] aFollowers = Eddoursul_Functions.GetPlayerFollowers()
|
||||
@ -37,9 +43,12 @@ Event OnLocationChange(Location akOldLoc, Location akNewLoc)
|
||||
i -= 1
|
||||
if ! aFollowers[i].IsDead() && ! aFollowers[i].IsDisabled()
|
||||
iCurrentFollowers += aFollowers[i].GetFormID()
|
||||
;Debug.Notification("Follower ID: " + aFollowers[i].GetFormID())
|
||||
endif
|
||||
endwhile
|
||||
|
||||
;Debug.Notification("New follower index: " + iCurrentFollowers)
|
||||
|
||||
if iCurrentFollowers == iFollowerIndex
|
||||
return
|
||||
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, 32, None, ETR_ExcludeFromNew) ; misc items
|
||||
|
||||
endEvent
|
||||
EndEvent
|
||||
|
||||
|
||||
event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
|
||||
@ -85,14 +94,17 @@ event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemRefe
|
||||
endif
|
||||
elseif ETR_PersistentStorageList.HasForm(akDestContainer)
|
||||
ETR_ItemsFound.RemoveAddedForm(akBaseItem)
|
||||
ETR_ItemsNew.RemoveAddedForm(akBaseItem)
|
||||
ETR_ItemsStored.AddForm(akBaseItem)
|
||||
Debug.Notification("Added " + akBaseItem.GetName() + " to ETR_ItemsStored")
|
||||
return
|
||||
elseif bAtHome && akDestContainer.GetParentCell() != PlayerRef.GetParentCell()
|
||||
return
|
||||
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)
|
||||
|
||||
@ -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
|
||||
|
||||
Debug.Notification("Moving " + akBaseItem.GetName() + " to ETR_ItemsNew")
|
||||
ETR_ItemsFound.RemoveAddedForm(akBaseItem)
|
||||
ETR_ItemsStored.RemoveAddedForm(akBaseItem)
|
||||
ETR_ItemsNew.AddForm(akBaseItem)
|
||||
|
@ -48,11 +48,11 @@ event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemRefe
|
||||
|
||||
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)
|
||||
|
||||
if cellStorage.GetItemCount(akBaseItem) == 0 && Eddoursul_Functions.HasRefInCell(akBaseItem, None, true, ETR_PersistentStorageList)
|
||||
if cellStorage.GetItemCount(akBaseItem) == 0
|
||||
cellStorage.AddItem(akBaseItem, 1, true)
|
||||
endif
|
||||
|
||||
@ -66,17 +66,22 @@ event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemRefere
|
||||
|
||||
if akSourceContainer && !(akSourceContainer as Actor) && ETR_PersistentStorageList.HasForm(akSourceContainer)
|
||||
if Eddoursul_Functions.GetItemCountInList(ETR_PersistentStorageList, akBaseItem) == 0
|
||||
Debug.Notification("Added " + akBaseItem.GetName() + " to ETR_ItemsFound")
|
||||
ETR_ItemsStored.RemoveAddedForm(akBaseItem)
|
||||
ETR_ItemsFound.AddForm(akBaseItem)
|
||||
ETR_ItemsNew.RemoveAddedForm(akBaseItem)
|
||||
endif
|
||||
|
||||
elseif bAtHome
|
||||
ObjectReference cellStorage = Eddoursul_Functions.GetOrCreateCellStorage(PlayerRef, ETR_PersistentStorageList, ETR_CellStorageContainer)
|
||||
int iCount = cellStorage.GetItemCount(akBaseItem)
|
||||
|
||||
if iCount > 0 && ! Eddoursul_Functions.HasRefInCell(akBaseItem, None, true, ETR_PersistentStorageList)
|
||||
cellStorage.RemoveItem(akBaseItem, iCount, true)
|
||||
|
||||
if Eddoursul_Functions.GetItemCountInList(ETR_PersistentStorageList, akBaseItem) == 0
|
||||
ETR_ItemsStored.RemoveAddedForm(akBaseItem)
|
||||
ETR_ItemsFound.AddForm(akBaseItem)
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
endif
|
||||
|
Loading…
Reference in New Issue
Block a user