4
Fork 0

Optimized _00E_Theriantrophist_AlchemyControl, removed obsolete code (2)

english-generic-dialogue
Eddoursul 2 years ago
parent 4ab9c06e57
commit 0af11ce0de
  1. BIN
      OnItemAdded Optimization.esp
  2. BIN
      scripts/_00e_theriantrophist_alchemycontrol.pex
  3. 38
      source/scripts/_00e_theriantrophist_alchemycontrol.psc

Binary file not shown.

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

Loading…
Cancel
Save