4
Fork 0
Browse Source

Optimized _00E_Theriantrophist_AlchemyControl, removed obsolete code (2)

crafting-refactoring
Eddoursul 6 months ago
parent
commit
0af11ce0de
  1. BIN
      OnItemAdded Optimization.esp
  2. BIN
      scripts/_00e_theriantrophist_alchemycontrol.pex
  3. 38
      source/scripts/_00e_theriantrophist_alchemycontrol.psc

BIN
OnItemAdded Optimization.esp

Binary file not shown.

BIN
scripts/_00e_theriantrophist_alchemycontrol.pex

Binary file not shown.

38
source/scripts/_00e_theriantrophist_alchemycontrol.psc

@ -101,12 +101,14 @@ bool bDoneChymikum = false @@ -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) @@ -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) @@ -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 @@ -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 @@ -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) @@ -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 @@ -431,6 +424,7 @@ State InInventory
if (PlayerREF.getItemCount(item) == 0)
JFormMap.removeKey(RenamedPotions, item)
JFormMap.removeKey(ModelChangedPotions, item)
RemoveInventoryEventFilter(baseItem)
Endif
Endif
EndEvent

Loading…
Cancel
Save