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.
84 lines
2.5 KiB
84 lines
2.5 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 bAtHome = false
|
|
|
|
|
|
event OnInit()
|
|
OnPlayerLoadGame()
|
|
endevent
|
|
|
|
|
|
Event OnPlayerLoadGame()
|
|
AddInventoryEventFilter(ETR_ItemsStored)
|
|
EndEvent
|
|
|
|
|
|
Event OnLocationChange(Location akOldLoc, Location akNewLoc)
|
|
bAtHome = akNewLoc && akNewLoc.HasKeyword(LocTypePlayerHouse)
|
|
endEvent
|
|
|
|
|
|
; The item is already registered as stored, and we just stored more
|
|
event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
|
|
|
|
if ! bAtHome
|
|
return
|
|
endif
|
|
|
|
if akDestContainer
|
|
|
|
if !(akDestContainer as Actor)
|
|
if ETR_PersistentStorageList.HasForm(akDestContainer)
|
|
return
|
|
endif
|
|
elseif (akDestContainer as Actor).IsPlayerTeammate()
|
|
return
|
|
endif
|
|
|
|
endif
|
|
|
|
if ! akDestContainer || akDestContainer.GetParentCell() == PlayerRef.GetParentCell()
|
|
|
|
ObjectReference cellStorage = Eddoursul_Functions.GetOrCreateCellStorage(PlayerRef, ETR_PersistentStorageList, ETR_CellStorageContainer)
|
|
|
|
if cellStorage.GetItemCount(akBaseItem) == 0 && Eddoursul_Functions.HasRefInCell(akBaseItem, None, true, ETR_PersistentStorageList)
|
|
cellStorage.AddItem(akBaseItem, 1, true)
|
|
endif
|
|
|
|
endif
|
|
|
|
endevent
|
|
|
|
|
|
; We took a stored item, and we want to find out if it's the last stored item of its kind
|
|
event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
|
|
|
|
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)
|
|
endif
|
|
|
|
endif
|
|
|
|
endevent
|
|
|