_00E_Theriantrophist_AlchemyControl: unregister potions on game load instead of in OnItemAdded, do not unregister potions in the secure chest
This commit is contained in:
parent
3b5bc3fffe
commit
4737d589a2
Binary file not shown.
Binary file not shown.
@ -66,6 +66,8 @@ MagicEffect Property AlchRestoreStamina Auto
|
|||||||
|
|
||||||
FormList Property _00E_EmptyFormlist Auto
|
FormList Property _00E_EmptyFormlist Auto
|
||||||
|
|
||||||
|
ObjectReference Property _00E_SecureChest_HostChestREF Auto
|
||||||
|
|
||||||
Int Property GreyAlchemist2PotionDurationLimitInSeconds = 180 Autoreadonly Hidden
|
Int Property GreyAlchemist2PotionDurationLimitInSeconds = 180 Autoreadonly Hidden
|
||||||
{The potion duration of all werewolf potions is limited to this amount if the player has the first and second perk grey alchemist}
|
{The potion duration of all werewolf potions is limited to this amount if the player has the first and second perk grey alchemist}
|
||||||
Int Property GreyAlchemist1PotionDurationLimitInSeconds = 120 Autoreadonly Hidden
|
Int Property GreyAlchemist1PotionDurationLimitInSeconds = 120 Autoreadonly Hidden
|
||||||
@ -101,7 +103,7 @@ bool bDoneDarkBlood = false
|
|||||||
bool bDoneChymikum = false
|
bool bDoneChymikum = false
|
||||||
|
|
||||||
Int curScriptVersion = 0
|
Int curScriptVersion = 0
|
||||||
Int Property LATEST_SCRIPT_VERSION = 4 AutoReadOnly
|
Int Property LATEST_SCRIPT_VERSION = 5 AutoReadOnly
|
||||||
|
|
||||||
bool bHasJContainers = false
|
bool bHasJContainers = false
|
||||||
|
|
||||||
@ -120,8 +122,6 @@ Function _UpdatePotion(Potion item, Int count)
|
|||||||
|
|
||||||
If bIsTheriantrophistPotion && EnderalLib.IsDLLLoaded() ; FRESHLY BREWN THERIANTROPHIST POTION
|
If bIsTheriantrophistPotion && EnderalLib.IsDLLLoaded() ; FRESHLY BREWN THERIANTROPHIST POTION
|
||||||
|
|
||||||
Debug.Notification("Replacing theriantrophist potion")
|
|
||||||
|
|
||||||
PlayerREF.removeItem(item, count, abSilent = true)
|
PlayerREF.removeItem(item, count, abSilent = true)
|
||||||
|
|
||||||
Bool bRemoveTheriantrophistEffects = False
|
Bool bRemoveTheriantrophistEffects = False
|
||||||
@ -156,7 +156,7 @@ Function _UpdatePotion(Potion item, Int count)
|
|||||||
EndIf
|
EndIf
|
||||||
Else
|
Else
|
||||||
Int maxDuration = NoAlchemistPotionDurationLimitInSeconds
|
Int maxDuration = NoAlchemistPotionDurationLimitInSeconds
|
||||||
Int durationBonus = PlayerREF.GetAV("Variable02") as Int
|
Int durationBonus = PlayerREF.GetActorValue("Variable02") as Int
|
||||||
|
|
||||||
If PlayerREF.hasPerk(_00E_Class_Theriantrophist_P03_GreyAlchemist_03)
|
If PlayerREF.hasPerk(_00E_Class_Theriantrophist_P03_GreyAlchemist_03)
|
||||||
maxDuration = -1 ; no duration mali are required
|
maxDuration = -1 ; no duration mali are required
|
||||||
@ -225,7 +225,6 @@ Function _UpdatePotion(Potion item, Int count)
|
|||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
Function _RenamePotion(Potion p, MagicEffect[] potionEffects, Int nPotionEffects, Bool bCommonPotion)
|
Function _RenamePotion(Potion p, MagicEffect[] potionEffects, Int nPotionEffects, Bool bCommonPotion)
|
||||||
Debug.Notification("Renaming potion")
|
|
||||||
String name = ""
|
String name = ""
|
||||||
|
|
||||||
If bCommonPotion
|
If bCommonPotion
|
||||||
@ -335,16 +334,16 @@ Function _UpdateNQ11(Potion newPotion)
|
|||||||
|
|
||||||
Bool bUpdateNQ11 = False
|
Bool bUpdateNQ11 = False
|
||||||
|
|
||||||
If newPotion.HasKeyword(_00E_Theriantrophist_ChymikumLife) && FS_NQ11.GetStage() >= 10 && !bDoneChymikum
|
If newPotion.HasKeyword(_00E_Theriantrophist_ChymikumLife) && FS_NQ11.GetCurrentStageID() >= 10 && !bDoneChymikum
|
||||||
bDoneChymikum = True
|
bDoneChymikum = True
|
||||||
bUpdateNQ11 = True
|
bUpdateNQ11 = True
|
||||||
EndIf
|
EndIf
|
||||||
If newPotion.HasKeyword(_00E_Theriantrophist_DarkBloodEffect) && FS_NQ11.GetStage() >= 10 && !bDoneDarkBlood
|
If newPotion.HasKeyword(_00E_Theriantrophist_DarkBloodEffect) && FS_NQ11.GetCurrentStageID() >= 10 && !bDoneDarkBlood
|
||||||
bDoneDarkBlood = True
|
bDoneDarkBlood = True
|
||||||
bUpdateNQ11 = True
|
bUpdateNQ11 = True
|
||||||
EndIf
|
EndIf
|
||||||
|
|
||||||
If bUpdateNQ11 && FS_NQ11.GetStage() < 17
|
If bUpdateNQ11 && FS_NQ11.GetCurrentStageID() < 17
|
||||||
FS_NQ11.ShowTutorial(2)
|
FS_NQ11.ShowTutorial(2)
|
||||||
|
|
||||||
If bDoneChymikum && bDoneDarkBlood
|
If bDoneChymikum && bDoneDarkBlood
|
||||||
@ -358,36 +357,71 @@ Function _UpdateNQ11(Potion newPotion)
|
|||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
Function _SetNewStageNQ11(Int newStage)
|
Function _SetNewStageNQ11(Int newStage)
|
||||||
If newStage > FS_NQ11.GetStage()
|
If newStage > FS_NQ11.GetCurrentStageID()
|
||||||
FS_NQ11.SetStage(newStage)
|
FS_NQ11.SetCurrentStageID(newStage)
|
||||||
EndIf
|
EndIf
|
||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
Function _UpdateInventoryFilters()
|
Function _InitAchemyControl()
|
||||||
|
|
||||||
RemoveAllInventoryEventFilters()
|
GoToState("")
|
||||||
|
|
||||||
AddInventoryEventFilter(_00E_EmptyFormlist)
|
int iSKSEVer = SKSE.GetVersion()
|
||||||
|
|
||||||
Int potionNames = RenamedPotions
|
if iSKSEVer < 2
|
||||||
Form k = JFormMap.nextKey(potionNames, previousKey = None, endKey = None)
|
bHasJContainers = false
|
||||||
while k != None
|
Debug.Trace("SKSE is not loaded, _00E_Theriantrophist_AlchemyControl is disabled")
|
||||||
AddInventoryEventFilter(k)
|
return
|
||||||
k = JFormMap.nextKey(potionNames, k, endKey = None)
|
endif
|
||||||
endwhile
|
|
||||||
|
bHasJContainers = ( (SKSE.GetPluginVersion("JContainers64") != -1) || (SKSE.GetPluginVersion("JContainersVR") != -1) ) && JContainers.isInstalled()
|
||||||
|
|
||||||
|
if ! bHasJContainers && ! EnderalLib.IsDLLLoaded()
|
||||||
|
; Both required components are missing, do not update version and disable everything
|
||||||
|
UnregisterForAllMenus()
|
||||||
|
Debug.Trace("JContainers and fs.dll are not loaded, _00E_Theriantrophist_AlchemyControl is disabled.")
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
; Version update
|
||||||
|
If curScriptVersion < LATEST_SCRIPT_VERSION
|
||||||
|
Int oldScriptVersion = curScriptVersion
|
||||||
|
curScriptVersion = LATEST_SCRIPT_VERSION
|
||||||
|
|
||||||
|
If oldScriptVersion < 5
|
||||||
|
RemoveAllInventoryEventFilters()
|
||||||
|
UnregisterForAllMenus()
|
||||||
|
UnregisterForUpdate()
|
||||||
|
EndIf
|
||||||
|
EndIf
|
||||||
|
|
||||||
|
if ! bHasJContainers
|
||||||
|
Debug.Trace("JContainers is not loaded, renaming and changing potion models is disabled")
|
||||||
|
endif
|
||||||
|
|
||||||
|
; Re-register menu listener to stay resilient to co-save deletion or corruption
|
||||||
|
RegisterForMenu("Crafting Menu")
|
||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
Function _RestorePotionAttributes()
|
Function _OnGameLoadJContainers()
|
||||||
Debug.Notification("Restoring potion names")
|
|
||||||
|
|
||||||
Potion k
|
Potion k
|
||||||
|
Potion previousKey
|
||||||
|
|
||||||
Int potionNames = RenamedPotions
|
Int potionNames = RenamedPotions
|
||||||
k = JFormMap.nextKey(potionNames, previousKey = None, endKey = None) as Potion
|
k = JFormMap.nextKey(potionNames, previousKey = None, endKey = None) as Potion
|
||||||
while k != None
|
while k != None
|
||||||
k.setName(JFormMap.getStr(potionNames, k))
|
; Forget items that are no longer in the inventory
|
||||||
k = JFormMap.nextKey(potionNames, k, endKey = None) as Potion
|
if PlayerREF.GetItemCount(k) == 0 && _00E_SecureChest_HostChestREF.GetItemCount(k) == 0
|
||||||
|
JFormMap.removeKey(RenamedPotions, k)
|
||||||
|
JFormMap.removeKey(ModelChangedPotions, k)
|
||||||
|
k = JFormMap.nextKey(potionNames, previousKey, endKey = None) as Potion
|
||||||
|
else
|
||||||
|
previousKey = k
|
||||||
|
k.setName(JFormMap.getStr(potionNames, k))
|
||||||
|
k = JFormMap.nextKey(potionNames, k, endKey = None) as Potion
|
||||||
|
endif
|
||||||
endwhile
|
endwhile
|
||||||
|
|
||||||
Int potionModels = ModelChangedPotions
|
Int potionModels = ModelChangedPotions
|
||||||
@ -399,96 +433,21 @@ Function _RestorePotionAttributes()
|
|||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
Function _InitAchemyControl()
|
|
||||||
|
|
||||||
;Debug.Notification("AchemyControl init")
|
|
||||||
|
|
||||||
GoToState("")
|
|
||||||
|
|
||||||
int iSKSEVer = SKSE.GetVersion()
|
|
||||||
|
|
||||||
if iSKSEVer < 2
|
|
||||||
RemoveAllInventoryEventFilters()
|
|
||||||
bHasJContainers = false
|
|
||||||
;Debug.Notification("SKSE is not loaded")
|
|
||||||
Debug.Trace("SKSE is not loaded, _00E_Theriantrophist_AlchemyControl is disabled")
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
bHasJContainers = ( (SKSE.GetPluginVersion("JContainers64") != -1) || (SKSE.GetPluginVersion("JContainersVR") != -1) )
|
|
||||||
|
|
||||||
if ! bHasJContainers && ! EnderalLib.IsDLLLoaded()
|
|
||||||
; Both required components are missing, do not update version and disable everything
|
|
||||||
RemoveAllInventoryEventFilters()
|
|
||||||
UnregisterForAllMenus()
|
|
||||||
Debug.Trace("JContainers and fs.dll are not loaded, _00E_Theriantrophist_AlchemyControl is disabled.")
|
|
||||||
;Debug.Notification("JContainers and fs.dll are not loaded")
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
; Version update
|
|
||||||
If curScriptVersion < LATEST_SCRIPT_VERSION
|
|
||||||
Int oldScriptVersion = curScriptVersion
|
|
||||||
curScriptVersion = LATEST_SCRIPT_VERSION
|
|
||||||
|
|
||||||
If oldScriptVersion < 4
|
|
||||||
;Debug.Notification("Updating AlchemyControl")
|
|
||||||
UnregisterForUpdate()
|
|
||||||
EndIf
|
|
||||||
EndIf
|
|
||||||
|
|
||||||
; Re-initialize everything to stay resilient to co-save deletion or corruption
|
|
||||||
|
|
||||||
if bHasJContainers
|
|
||||||
RegisterForMenu("ContainerMenu")
|
|
||||||
RegisterForMenu("InventoryMenu")
|
|
||||||
RegisterForMenu("FavoritesMenu")
|
|
||||||
;Debug.Trace("JContainers is loaded, hooking to menus")
|
|
||||||
else
|
|
||||||
RemoveAllInventoryEventFilters()
|
|
||||||
UnregisterForAllMenus()
|
|
||||||
Debug.Notification("JContainers is not loaded")
|
|
||||||
Debug.Trace("JContainers is not loaded, renaming and changing potion models is disabled")
|
|
||||||
endif
|
|
||||||
|
|
||||||
RegisterForMenu("Crafting Menu")
|
|
||||||
|
|
||||||
EndFunction
|
|
||||||
|
|
||||||
;=====================================================================================
|
;=====================================================================================
|
||||||
; EVENTS
|
; EVENTS
|
||||||
;=====================================================================================
|
;=====================================================================================
|
||||||
|
|
||||||
Event OnMenuOpen(String MenuName)
|
Event OnMenuOpen(String MenuName)
|
||||||
|
GoToState("InCrafting")
|
||||||
If menuName == "Crafting Menu"
|
|
||||||
GoToState("InCrafting")
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
if bHasJContainers
|
|
||||||
Debug.Notification("InInventory")
|
|
||||||
GoToState("InInventory")
|
|
||||||
endif
|
|
||||||
|
|
||||||
EndEvent
|
EndEvent
|
||||||
|
|
||||||
Event OnMenuClose(String MenuName)
|
Event OnMenuClose(String MenuName)
|
||||||
|
|
||||||
GoToState("")
|
GoToState("")
|
||||||
|
|
||||||
EndEvent
|
EndEvent
|
||||||
|
|
||||||
State InCrafting
|
State InCrafting
|
||||||
Event OnBeginState()
|
|
||||||
;Debug.Notification("RemoveAllInventoryEventFilters")
|
|
||||||
RemoveAllInventoryEventFilters()
|
|
||||||
EndEvent
|
|
||||||
|
|
||||||
Event OnItemAdded(Form baseItem, int count, ObjectReference itemRef, ObjectReference source)
|
Event OnItemAdded(Form baseItem, int count, ObjectReference itemRef, ObjectReference source)
|
||||||
|
|
||||||
Debug.Notification("Added " + baseItem.GetName())
|
|
||||||
|
|
||||||
Potion item = baseItem as Potion
|
Potion item = baseItem as Potion
|
||||||
If item
|
If item
|
||||||
; Ignore not-custom potions (with FormID not starting with 0xFF) or already registered potions
|
; Ignore not-custom potions (with FormID not starting with 0xFF) or already registered potions
|
||||||
@ -496,35 +455,6 @@ State InCrafting
|
|||||||
_UpdatePotion(item, count)
|
_UpdatePotion(item, count)
|
||||||
EndIf
|
EndIf
|
||||||
EndIf
|
EndIf
|
||||||
|
|
||||||
EndEvent
|
|
||||||
|
|
||||||
Event OnEndState()
|
|
||||||
if bHasJContainers && UI.IsMenuOpen("Crafting Menu") == false
|
|
||||||
Debug.Notification("_UpdateInventoryFilters")
|
|
||||||
_UpdateInventoryFilters()
|
|
||||||
endif
|
|
||||||
EndEvent
|
|
||||||
EndState
|
|
||||||
|
|
||||||
State InInventory
|
|
||||||
Event OnItemRemoved(Form baseItem, int count, ObjectReference itemRef, ObjectReference dest)
|
|
||||||
if dest != None
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
Debug.Notification("Removed " + baseItem.GetName())
|
|
||||||
; Probably a potion is consumed
|
|
||||||
Potion item = baseItem as Potion
|
|
||||||
if item
|
|
||||||
; we want to prevent that all potions that have been brewed are collected in this list
|
|
||||||
; and cause performance issues. So we risk that we loose track of them by removing them
|
|
||||||
; from this list. In this case, the name will be the old vanilla skyrim one
|
|
||||||
if (PlayerREF.getItemCount(item) == 0)
|
|
||||||
JFormMap.removeKey(RenamedPotions, item)
|
|
||||||
JFormMap.removeKey(ModelChangedPotions, item)
|
|
||||||
RemoveInventoryEventFilter(baseItem)
|
|
||||||
Endif
|
|
||||||
Endif
|
|
||||||
EndEvent
|
EndEvent
|
||||||
EndState
|
EndState
|
||||||
|
|
||||||
@ -535,9 +465,7 @@ EndEvent
|
|||||||
|
|
||||||
Event OnPlayerLoadGame()
|
Event OnPlayerLoadGame()
|
||||||
_InitAchemyControl()
|
_InitAchemyControl()
|
||||||
|
|
||||||
if bHasJContainers
|
if bHasJContainers
|
||||||
_RestorePotionAttributes()
|
_OnGameLoadJContainers()
|
||||||
_UpdateInventoryFilters()
|
|
||||||
endif
|
endif
|
||||||
EndEvent
|
EndEvent
|
||||||
|
Loading…
Reference in New Issue
Block a user