Optimized _00E_Theriantrophist_AlchemyControl, removed obsolete code (2)

This commit is contained in:
Eddoursul 2021-12-20 06:15:44 +01:00
parent 4ab9c06e57
commit 0af11ce0de
3 changed files with 16 additions and 22 deletions

Binary file not shown.

View File

@ -101,12 +101,14 @@ bool bDoneChymikum = false
int PotionsMixedOnLastTest = 0 ; OBSOLETE AFTER 1.5.3.0. Needed for version update
int criticalSectionProcesses = 0 ; OBSOLETE AFTER 1.5.3.0. Needed for version update
FormList Property _00E_EmptyFormlist Auto
;=====================================================================================
; FUNCTIONS
;=====================================================================================
Function _UpdatePotion(Potion item, Int count, Bool bIsInCraftingMode)
Function _UpdatePotion(Potion item, Int count)
Int i
MagicEffect[] potionEffects = item.GetMagicEffects()
@ -114,7 +116,7 @@ Function _UpdatePotion(Potion item, Int count, Bool bIsInCraftingMode)
Bool bIsTheriantrophistPotion = item.HasKeyword(_00E_Theriantrophist_Effect)
MagicEffect firstTheriantrophistEffect = None
If bIsTheriantrophistPotion && bIsInCraftingMode ; FRESHLY BREWN THERIANTROPHIST POTION
If bIsTheriantrophistPotion ; FRESHLY BREWN THERIANTROPHIST POTION
PlayerREF.removeItem(item, count, abSilent = true)
Bool bRemoveTheriantrophistEffects = False
@ -198,20 +200,6 @@ Function _UpdatePotion(Potion item, Int count, Bool bIsInCraftingMode)
_UpdateNQ11(newPotion)
EndIf
ElseIf bIsTheriantrophistPotion && bIsInCraftingMode == False ; OLD THERIANTROPHIST POTION
i = 0
While i < nPotionEffects && !firstTheriantrophistEffect
If potionEffects[i].HasKeyword(_00E_Theriantrophist_Effect)
firstTheriantrophistEffect = potionEffects[i]
EndIf
i += 1
EndWhile
_RenamePotion(item, potionEffects, nPotionEffects, False)
_SetPotionModel(item, firstTheriantrophistEffect, potionEffects[0])
_UpdateNQ11(item)
Else ; COMMON POTION
_RenamePotion(item, potionEffects, nPotionEffects, True)
@ -361,6 +349,8 @@ EndFunction
Function _UpdateInventoryFilters()
AddInventoryEventFilter(_00E_EmptyFormlist)
Form[] aPotions = JFormMap.allKeysPArray(RenamedPotions)
int i = aPotions.length
while i > 0
@ -384,7 +374,6 @@ EndFunction
Event OnMenuOpen(String MenuName)
If menuName == "Crafting Menu"
RemoveAllInventoryEventFilters()
GoToState("InCrafting")
return
endif
@ -397,24 +386,28 @@ Event OnMenuClose(String MenuName)
GoToState("")
If menuName == "Crafting Menu"
_UpdateInventoryFilters()
endif
EndEvent
State InCrafting
Event OnBeginState()
RemoveAllInventoryEventFilters()
EndEvent
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)
_UpdatePotion(item, count)
EndIf
EndIf
EndEvent
Event OnEndState()
_UpdateInventoryFilters()
EndEvent
EndState
State InInventory
@ -431,6 +424,7 @@ State InInventory
if (PlayerREF.getItemCount(item) == 0)
JFormMap.removeKey(RenamedPotions, item)
JFormMap.removeKey(ModelChangedPotions, item)
RemoveInventoryEventFilter(baseItem)
Endif
Endif
EndEvent