2022-06-30 10:31:01 +00:00
|
|
|
Scriptname ArtifactTrackerPlayer extends ReferenceAlias
|
|
|
|
|
|
|
|
FormList Property ETR_ItemsNew Auto
|
|
|
|
FormList Property ETR_ItemsFound Auto
|
|
|
|
FormList Property ETR_ItemsStored Auto
|
|
|
|
|
|
|
|
Keyword Property LocTypePlayerHouse Auto
|
|
|
|
|
2022-07-01 20:15:55 +00:00
|
|
|
Perk Property ETR_PickupPerk Auto
|
|
|
|
|
2022-06-30 10:31:01 +00:00
|
|
|
bool bAtHome = false
|
2022-06-30 13:08:16 +00:00
|
|
|
ObjectReference bookShelf = None
|
2022-07-03 13:12:14 +00:00
|
|
|
int iFollowerIndex = 0
|
|
|
|
int iArtifactCount = 0
|
2022-06-30 10:31:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
event OnInit()
|
|
|
|
OnPlayerLoadGame()
|
|
|
|
endevent
|
|
|
|
|
|
|
|
|
|
|
|
Event OnPlayerLoadGame()
|
|
|
|
|
|
|
|
if ! IsLoaded()
|
|
|
|
ETR_ItemsNew.Revert()
|
|
|
|
ETR_ItemsFound.Revert()
|
|
|
|
ETR_ItemsStored.Revert()
|
|
|
|
UnregisterForUpdate()
|
|
|
|
Debug.Notification("Failed to initialize ArtifactTracker.dll")
|
|
|
|
return
|
|
|
|
endif
|
|
|
|
|
2022-07-01 20:15:55 +00:00
|
|
|
if ! (GetReference() as Actor).HasPerk(ETR_PickupPerk)
|
|
|
|
(GetReference() as Actor).AddPerk(ETR_PickupPerk)
|
|
|
|
endif
|
|
|
|
|
2022-06-30 10:31:01 +00:00
|
|
|
if skse.GetPluginVersion("Ahzaab's moreHUD Plugin") >= 30800
|
|
|
|
ahzmorehud.RegisterIconFormList("dbmNew", ETR_ItemsNew)
|
|
|
|
ahzmorehud.RegisterIconFormList("dbmFound", ETR_ItemsFound)
|
|
|
|
ahzmorehud.RegisterIconFormList("dbmDisp", ETR_ItemsStored)
|
|
|
|
endif
|
|
|
|
|
|
|
|
if skse.GetPluginVersion("Ahzaab's moreHUD Inventory Plugin") >= 10017
|
|
|
|
ahzmorehudie.RegisterIconFormList("dbmNew", ETR_ItemsNew)
|
|
|
|
ahzmorehudie.RegisterIconFormList("dbmFound", ETR_ItemsFound)
|
|
|
|
ahzmorehudie.RegisterIconFormList("dbmDisp", ETR_ItemsStored)
|
|
|
|
endif
|
|
|
|
|
2022-07-02 14:01:42 +00:00
|
|
|
if SKSE.GetPluginVersion("QuickLootEE") >= 0
|
|
|
|
QuickLootEE.RegisterNewItemsList(ETR_ItemsNew)
|
|
|
|
QuickLootEE.RegisterDisplayedItemsList(ETR_ItemsStored)
|
|
|
|
QuickLootEE.RegisterFoundItemsList(ETR_ItemsFound)
|
2022-06-30 10:31:01 +00:00
|
|
|
endif
|
|
|
|
|
2022-07-03 13:12:14 +00:00
|
|
|
int iNewArtifactCount = GetArtifactCount()
|
|
|
|
if iNewArtifactCount != iArtifactCount
|
|
|
|
iArtifactCount = iNewArtifactCount
|
|
|
|
Debug.Notification("Artifact list changed, rebuilding the list")
|
|
|
|
ETR_ItemsNew.Revert() ; rebuild the list
|
|
|
|
endif
|
|
|
|
|
2022-06-30 10:31:01 +00:00
|
|
|
; Rebuild all lists to avoid discrepancies, stale data, and broken records
|
|
|
|
RescanStoredArtifacts()
|
|
|
|
RescanFoundArtifacts()
|
|
|
|
RescanNewArtifacts()
|
|
|
|
|
|
|
|
Location currentLocation = (GetReference() as ObjectReference).GetCurrentLocation()
|
|
|
|
bAtHome = currentLocation && currentLocation.HasKeyword(LocTypePlayerHouse)
|
|
|
|
|
|
|
|
if bAtHome
|
|
|
|
RegisterForModEvent("AT_HomeInventoryUpdate", "OnHomeInventoryUpdate")
|
2022-06-30 13:08:16 +00:00
|
|
|
RegisterForMenu("ContainerMenu")
|
|
|
|
GotoState("AtHome")
|
2022-06-30 10:31:01 +00:00
|
|
|
else
|
|
|
|
UnregisterForModEvent("AT_HomeInventoryUpdate")
|
2022-06-30 13:08:16 +00:00
|
|
|
UnregisterForMenu("ContainerMenu")
|
|
|
|
GotoState("")
|
2022-06-30 10:31:01 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
EndEvent
|
|
|
|
|
|
|
|
|
|
|
|
Event OnLocationChange(Location akOldLoc, Location akNewLoc)
|
|
|
|
|
|
|
|
bAtHome = akNewLoc && akNewLoc.HasKeyword(LocTypePlayerHouse)
|
|
|
|
|
|
|
|
if bAtHome
|
|
|
|
RegisterForModEvent("AT_HomeInventoryUpdate", "OnHomeInventoryUpdate")
|
2022-06-30 13:08:16 +00:00
|
|
|
GotoState("AtHome")
|
2022-06-30 10:31:01 +00:00
|
|
|
elseif akOldLoc && akOldLoc.HasKeyword(LocTypePlayerHouse)
|
|
|
|
UnregisterForModEvent("AT_HomeInventoryUpdate")
|
2022-06-30 13:08:16 +00:00
|
|
|
GotoState("")
|
2022-06-30 10:31:01 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
int iCurrentFollowers = 0;
|
|
|
|
Actor[] aFollowers = GetPlayerFollowers()
|
|
|
|
int i = aFollowers.length
|
|
|
|
while i > 0
|
|
|
|
i -= 1
|
|
|
|
iCurrentFollowers += aFollowers[i].GetFormID()
|
|
|
|
endwhile
|
|
|
|
|
|
|
|
if iCurrentFollowers != iFollowerIndex
|
|
|
|
iFollowerIndex = iCurrentFollowers
|
|
|
|
RegisterForSingleUpdate(5.0) ; wait until followers load into the location
|
|
|
|
endif
|
|
|
|
|
|
|
|
endEvent
|
|
|
|
|
|
|
|
|
|
|
|
Event OnUpdate()
|
|
|
|
|
|
|
|
Debug.Notification("Team changed, updating ETR_ItemsFound")
|
|
|
|
RescanFoundArtifacts()
|
|
|
|
|
|
|
|
EndEvent
|
|
|
|
|
|
|
|
|
2022-06-30 10:52:03 +00:00
|
|
|
event OnHomeInventoryUpdate(string eventName, string strArg, float numArg, Form sender)
|
2022-06-30 10:31:01 +00:00
|
|
|
if bAtHome
|
|
|
|
SyncCellStorage()
|
|
|
|
endif
|
|
|
|
endevent
|
|
|
|
|
|
|
|
|
2022-06-30 13:08:16 +00:00
|
|
|
state AtHome
|
|
|
|
|
|
|
|
event OnBeginState()
|
|
|
|
RegisterForMenu("ContainerMenu")
|
|
|
|
endevent
|
|
|
|
|
|
|
|
event OnEndState()
|
|
|
|
UnregisterForMenu("ContainerMenu")
|
|
|
|
endevent
|
|
|
|
|
|
|
|
event OnMenuOpen(String MenuName)
|
|
|
|
if ! bAtHome
|
|
|
|
GotoState("")
|
|
|
|
return
|
|
|
|
endif
|
|
|
|
ObjectReference currentContainer = GetCurrentContainer()
|
|
|
|
if currentContainer as PlayerBookShelfContainerScript
|
|
|
|
bookShelf = currentContainer
|
|
|
|
endif
|
|
|
|
endevent
|
|
|
|
|
|
|
|
event OnMenuClose(String MenuName)
|
|
|
|
|
|
|
|
if bookShelf
|
|
|
|
ObjectReference ref = bookShelf
|
|
|
|
bookShelf = None
|
2022-07-03 13:19:11 +00:00
|
|
|
Utility.wait(1.0)
|
2022-06-30 13:08:16 +00:00
|
|
|
int iLimit = 10
|
|
|
|
while iLimit > 0 && (ref as PlayerBookShelfContainerScript).GetState() == "PlacingBooks"
|
|
|
|
iLimit -= 1
|
|
|
|
Utility.wait(0.5)
|
|
|
|
endwhile
|
2022-07-01 20:15:55 +00:00
|
|
|
SyncCellStorage()
|
2022-06-30 13:08:16 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
endevent
|
|
|
|
|
|
|
|
endstate
|
|
|
|
|
|
|
|
|
2022-06-30 10:31:01 +00:00
|
|
|
; NATIVE FUNCTIONS
|
|
|
|
|
|
|
|
bool function IsLoaded() native global
|
|
|
|
|
2022-07-03 13:12:14 +00:00
|
|
|
int function GetArtifactCount() native global
|
|
|
|
|
2022-06-30 10:31:01 +00:00
|
|
|
function RescanStoredArtifacts() native global
|
|
|
|
|
|
|
|
function RescanFoundArtifacts() native global
|
|
|
|
|
|
|
|
function RescanNewArtifacts() native global
|
|
|
|
|
|
|
|
ObjectReference function GetCellStorage() native global
|
|
|
|
|
2022-06-30 13:08:16 +00:00
|
|
|
ObjectReference function GetCurrentContainer() native global
|
|
|
|
|
2022-07-01 20:15:55 +00:00
|
|
|
function SyncCellStorage() native global
|
2022-06-30 10:31:01 +00:00
|
|
|
|
|
|
|
Actor[] function GetPlayerFollowers() native global
|