Optimized _00E_Theriantrophist_AlchemyControl, removed obsolete code
This commit is contained in:
parent
b5ef32f9a3
commit
4ab9c06e57
Binary file not shown.
@ -1,7 +1,5 @@
|
|||||||
Scriptname _00E_Theriantrophist_AlchemyControl extends ReferenceAlias
|
Scriptname _00E_Theriantrophist_AlchemyControl extends ReferenceAlias
|
||||||
|
|
||||||
import EnderalLib
|
|
||||||
|
|
||||||
;=====================================================================================
|
;=====================================================================================
|
||||||
; PROPERTIES
|
; PROPERTIES
|
||||||
;=====================================================================================
|
;=====================================================================================
|
||||||
@ -361,131 +359,126 @@ Function _SetNewStageNQ11(Int newStage)
|
|||||||
EndIf
|
EndIf
|
||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
|
Function _UpdateInventoryFilters()
|
||||||
|
|
||||||
|
Form[] aPotions = JFormMap.allKeysPArray(RenamedPotions)
|
||||||
|
int i = aPotions.length
|
||||||
|
while i > 0
|
||||||
|
i -= 1
|
||||||
|
AddInventoryEventFilter(aPotions[i])
|
||||||
|
endwhile
|
||||||
|
|
||||||
|
aPotions = JFormMap.allKeysPArray(ModelChangedPotions)
|
||||||
|
i = aPotions.length
|
||||||
|
while i > 0
|
||||||
|
i -= 1
|
||||||
|
AddInventoryEventFilter(aPotions[i])
|
||||||
|
endwhile
|
||||||
|
|
||||||
|
EndFunction
|
||||||
|
|
||||||
;=====================================================================================
|
;=====================================================================================
|
||||||
; EVENTS
|
; EVENTS
|
||||||
;=====================================================================================
|
;=====================================================================================
|
||||||
|
|
||||||
Event OnItemAdded(Form baseItem, int count, ObjectReference itemRef, ObjectReference source)
|
Event OnMenuOpen(String MenuName)
|
||||||
|
|
||||||
Potion item = baseItem as Potion
|
If menuName == "Crafting Menu"
|
||||||
If item
|
RemoveAllInventoryEventFilters()
|
||||||
Bool bIsInCraftingMode = UI.IsMenuOpen("Crafting Menu")
|
GoToState("InCrafting")
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
; Ignore not-custom potions (with FormID not starting with 0xFF) or already registered potions
|
GoToState("InInventory")
|
||||||
If (Math.LogicalAnd(item.GetFormID(), 0xFF000000) == 0xFF000000) && JFormMap.hasKey(RenamedPotions, item) == False
|
|
||||||
_UpdatePotion(item, count, bIsInCraftingMode)
|
EndEvent
|
||||||
|
|
||||||
|
Event OnMenuClose(String MenuName)
|
||||||
|
|
||||||
|
GoToState("")
|
||||||
|
|
||||||
|
If menuName == "Crafting Menu"
|
||||||
|
_UpdateInventoryFilters()
|
||||||
|
endif
|
||||||
|
|
||||||
|
EndEvent
|
||||||
|
|
||||||
|
State InCrafting
|
||||||
|
Event OnItemAdded(Form baseItem, int count, ObjectReference itemRef, ObjectReference source)
|
||||||
|
|
||||||
|
Potion item = baseItem as Potion
|
||||||
|
If item
|
||||||
|
; Ignore not-custom potions (with FormID not starting with 0xFF) or already registered potions
|
||||||
|
If (Math.LogicalAnd(item.GetFormID(), 0xFF000000) == 0xFF000000) && JFormMap.hasKey(RenamedPotions, item) == False
|
||||||
|
_UpdatePotion(item, count, true)
|
||||||
|
EndIf
|
||||||
EndIf
|
EndIf
|
||||||
EndIf
|
|
||||||
|
|
||||||
EndEvent
|
EndEvent
|
||||||
|
EndState
|
||||||
|
|
||||||
Event OnItemRemoved(Form baseItem, int count, ObjectReference itemRef, ObjectReference dest)
|
State InInventory
|
||||||
; Probably a potion is consumed
|
Event OnItemRemoved(Form baseItem, int count, ObjectReference itemRef, ObjectReference dest)
|
||||||
Potion item = baseItem as Potion
|
if dest != None
|
||||||
if item && dest == None
|
return
|
||||||
; we want to prevent that all potions that have been brewed are collected in this list
|
endif
|
||||||
; and cause performance issues. So we risk that we loose track of them by removing them
|
; Probably a potion is consumed
|
||||||
; from this list. In this case, the name will be the old vanilla skyrim one
|
Potion item = baseItem as Potion
|
||||||
if (PlayerREF.getItemCount(item) == 0)
|
if item
|
||||||
JFormMap.removeKey(RenamedPotions, item)
|
; we want to prevent that all potions that have been brewed are collected in this list
|
||||||
JFormMap.removeKey(ModelChangedPotions, item)
|
; 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)
|
||||||
|
Endif
|
||||||
Endif
|
Endif
|
||||||
Endif
|
EndEvent
|
||||||
EndEvent
|
EndState
|
||||||
|
|
||||||
|
|
||||||
Int curScriptVersion = 0
|
Int curScriptVersion = 0
|
||||||
Int Property LATEST_SCRIPT_VERSION = 3 AutoReadOnly
|
Int Property LATEST_SCRIPT_VERSION = 4 AutoReadOnly
|
||||||
|
|
||||||
Event OnInit()
|
Event OnInit()
|
||||||
curScriptVersion = LATEST_SCRIPT_VERSION
|
curScriptVersion = LATEST_SCRIPT_VERSION
|
||||||
|
RegisterForMenu("ContainerMenu")
|
||||||
|
RegisterForMenu("InventoryMenu")
|
||||||
|
RegisterForMenu("FavoritesMenu")
|
||||||
|
RegisterForMenu("Crafting Menu")
|
||||||
EndEvent
|
EndEvent
|
||||||
|
|
||||||
Function _UpdateToVersion3()
|
|
||||||
Potion p
|
|
||||||
Int i
|
|
||||||
|
|
||||||
Int potionArrayID = JFormMap.allKeys(RenamedPotions)
|
|
||||||
|
|
||||||
JFormMap.clear(RenamedPotions)
|
|
||||||
JFormMap.clear(ModelChangedPotions)
|
|
||||||
|
|
||||||
; Update already cached potions
|
|
||||||
Int nPotions = JArray.count(potionArrayID)
|
|
||||||
i = 0
|
|
||||||
While i < nPotions
|
|
||||||
p = JArray.getForm(potionArrayID, i, None) as Potion
|
|
||||||
If p && Math.LogicalAnd(p.GetFormID(), 0xFF000000) == 0xFF000000
|
|
||||||
_UpdatePotion(p, 1, False)
|
|
||||||
EndIf
|
|
||||||
i += 1
|
|
||||||
EndWhile
|
|
||||||
|
|
||||||
; Update potions in the player's inventory
|
|
||||||
Int nItems = PlayerREF.GetNumItems()
|
|
||||||
i = 0
|
|
||||||
While i < nItems
|
|
||||||
p = PlayerREF.GetNthForm(i) as Potion
|
|
||||||
If p && Math.LogicalAnd(p.GetFormID(), 0xFF000000) == 0xFF000000 && JFormMap.hasKey(RenamedPotions, p) == False
|
|
||||||
_UpdatePotion(p, 1, False)
|
|
||||||
EndIf
|
|
||||||
i += 1
|
|
||||||
EndWhile
|
|
||||||
|
|
||||||
Debug.Trace("_00E_Theriantrophist_AlchemyControl: _UpdateToVersion3 done")
|
|
||||||
EndFunction
|
|
||||||
|
|
||||||
Event OnPlayerLoadGame()
|
Event OnPlayerLoadGame()
|
||||||
Bool bRestoreNamesModels = True
|
GoToState("")
|
||||||
|
|
||||||
; Version update
|
; Version update
|
||||||
If curScriptVersion < LATEST_SCRIPT_VERSION
|
If curScriptVersion < LATEST_SCRIPT_VERSION
|
||||||
Int oldScriptVersion = curScriptVersion
|
Int oldScriptVersion = curScriptVersion
|
||||||
curScriptVersion = LATEST_SCRIPT_VERSION
|
curScriptVersion = LATEST_SCRIPT_VERSION
|
||||||
|
|
||||||
If oldScriptVersion < 3
|
If oldScriptVersion < 4
|
||||||
_UpdateToVersion3()
|
UnregisterForUpdate()
|
||||||
bRestoreNamesModels = False
|
RegisterForMenu("ContainerMenu")
|
||||||
|
RegisterForMenu("InventoryMenu")
|
||||||
|
RegisterForMenu("FavoritesMenu")
|
||||||
|
RegisterForMenu("Crafting Menu")
|
||||||
|
_UpdateInventoryFilters()
|
||||||
EndIf
|
EndIf
|
||||||
EndIf
|
EndIf
|
||||||
|
|
||||||
; Fix 1.5.3.0 _IsSelfBrewnPotion stuck in permanent Wait loop.
|
|
||||||
; It may take a looong time
|
|
||||||
If criticalSectionProcesses > 0
|
|
||||||
RegisterForSingleUpdate(0.1)
|
|
||||||
EndIf
|
|
||||||
|
|
||||||
; Restore names and models
|
; Restore names and models
|
||||||
If bRestoreNamesModels
|
Potion k
|
||||||
Potion k
|
|
||||||
|
|
||||||
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))
|
k.setName(JFormMap.getStr(potionNames, k))
|
||||||
k = JFormMap.nextKey(potionNames, k, endKey = None) as Potion
|
k = JFormMap.nextKey(potionNames, k, endKey = None) as Potion
|
||||||
endwhile
|
endwhile
|
||||||
|
|
||||||
Int potionModels = ModelChangedPotions
|
Int potionModels = ModelChangedPotions
|
||||||
k = JFormMap.nextKey(potionModels, previousKey = None, endKey = None) as Potion
|
k = JFormMap.nextKey(potionModels, previousKey = None, endKey = None) as Potion
|
||||||
while k != None
|
while k != None
|
||||||
k.SetWorldModelPath(JFormMap.getStr(potionModels, k))
|
k.SetWorldModelPath(JFormMap.getStr(potionModels, k))
|
||||||
k = JFormMap.nextKey(potionModels, k, endKey = None) as Potion
|
k = JFormMap.nextKey(potionModels, k, endKey = None) as Potion
|
||||||
endwhile
|
endwhile
|
||||||
EndIf
|
|
||||||
EndEvent
|
|
||||||
|
|
||||||
Event OnUpdate()
|
|
||||||
; Fix 1.5.3.0 _IsSelfBrewnPotion stuck in permanent Wait loop.
|
|
||||||
If criticalSectionProcesses <= 0
|
|
||||||
Utility.WaitMenuMode(0.1) ; Wait a bit more, just in case
|
|
||||||
If criticalSectionProcesses <= 0
|
|
||||||
;Debug.Notification("Unfucked _IsSelfBrewnPotion")
|
|
||||||
Return
|
|
||||||
EndIf
|
|
||||||
EndIf
|
|
||||||
|
|
||||||
PotionsMixedOnLastTest = Game.QueryStat("Potions Mixed") + Game.QueryStat("Poisons Mixed")
|
|
||||||
criticalSectionProcesses = 0
|
|
||||||
RegisterForSingleUpdate(0.1)
|
|
||||||
EndEvent
|
EndEvent
|
||||||
|
Loading…
Reference in New Issue
Block a user