1
Fork 0
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.
 
 
 

112 lines
4.2 KiB

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
Container Property ETR_CellStorageContainer Auto
Keyword Property LocTypePlayerHouse Auto
bool bAtHome = false
int iFollowerIndex = 0
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 = Eddoursul_Functions.GetPlayerFollowers()
int i = aFollowers.length
while i > 0
i -= 1
if ! aFollowers[i].IsDead() && ! aFollowers[i].IsDisabled()
iCurrentFollowers += aFollowers[i].GetFormID()
endif
endwhile
if iCurrentFollowers == iFollowerIndex
return
endif
; If the list of followers has changed, rebuild ETR_ItemsFound and ETR_ItemsNew
iFollowerIndex = iCurrentFollowers
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)
i = aFollowers.length
while i > 0
i -= 1
if ! aFollowers[i].IsDead() && ! aFollowers[i].IsDisabled()
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)
endif
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
endEvent
event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
if akDestContainer
if akDestContainer as Actor
if (akDestContainer as Actor).IsPlayerTeammate()
; Keep follower items marked as found
return
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
endif
endif
if bAtHome && (! akDestContainer || akDestContainer.GetParentCell() == PlayerRef.GetParentCell()) && Eddoursul_Functions.HasRefInCell(akBaseItem, None, true, ETR_PersistentStorageList)
ObjectReference cellStorage = Eddoursul_Functions.GetOrCreateCellStorage(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
Debug.Notification("Moving " + akBaseItem.GetName() + " to ETR_ItemsNew")
ETR_ItemsFound.RemoveAddedForm(akBaseItem)
ETR_ItemsStored.RemoveAddedForm(akBaseItem)
ETR_ItemsNew.AddForm(akBaseItem)
endif
endevent