Moved torch reequipping to a separate script

This commit is contained in:
Eddoursul 2024-02-05 02:29:37 +01:00
parent 1e76ddf587
commit 16f10be14a
15 changed files with 51 additions and 55 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -2268,6 +2268,7 @@ scripts\ski_questbase.pex
scripts\ski_settingsmanager.pex
scripts\ski_widgetbase.pex
scripts\ski_widgetmanager.pex
scripts\_00e_torchcontrol.pex
scripts\_00e_digcontrol.pex
scripts\tif__000a5ebd.pex
scripts\tif__000a5ebe.pex

Binary file not shown.

View File

@ -36,7 +36,7 @@ bool function Dig()
Game.ForceThirdPerson()
Form[] equippedTorches = New Form[2]
Bool torchesUnequipping = (PlayerREF as _00E_PlayerFunctions).UnequipTorches(equippedTorches)
Bool torchesUnequipping = _00E_TorchControl.UnequipTorches(equippedTorches)
If PlayerREF.IsWeaponDrawn() ; Sheathe the weapon
PlayerREF.PlayIdle(DefaultSheathe)
@ -53,7 +53,7 @@ bool function Dig()
; Stop digging
Debug.SendAnimationEvent(PlayerREF, "IdleForceDefaultState")
(PlayerREF as _00E_PlayerFunctions).ReequipTorches(equippedTorches)
_00E_TorchControl.ReequipTorches(equippedTorches)
Wait(1)
Game.SetPlayerAIDriven(false)

View File

@ -0,0 +1,43 @@
Scriptname _00E_TorchControl Hidden
Int Function _GetHandSlotEx(int iHand) global
; By default, iHand = 0 for left hand, 1 for right hand
; In SKSE's "Equip Ex" functions though: iHand = 2 for left hand, 1 for right hand
Return 2 - iHand
EndFunction
Bool Function UnequipTorches(Form[] equippedTorches) global
Actor PlayerREF = Game.GetForm(0x14) as Actor
Bool unequipping = False
Int iHand = 0
While iHand < equippedTorches.Length
If PlayerREF.GetEquippedItemType(iHand) == 11 ; A torch is in the hand?
Form torch = PlayerREF.GetEquippedObject(iHand)
If torch
PlayerREF.UnequipItemEx(torch, _GetHandSlotEx(iHand))
equippedTorches[iHand] = torch
unequipping = True
EndIf
EndIf
iHand += 1
EndWhile
Return unequipping
EndFunction
Function ReequipTorches(Form[] equippedTorches) global
Actor PlayerREF = Game.GetForm(0x14) as Actor
Int iHand = 0
While iHand < equippedTorches.Length
Form torch = equippedTorches[iHand]
If torch
If PlayerREF.GetItemCount(torch) > 0
PlayerREF.EquipItemEx(torch, _GetHandSlotEx(iHand), False, True)
EndIf
; "Forget" about the form to not keep it persistent if equippedTorches is a script's property or variable
equippedTorches[iHand] = None
EndIf
iHand += 1
EndWhile
EndFunction

View File

@ -71,7 +71,7 @@ Function EnterClassMenu()
EndIf
Form[] equippedTorches = New Form[2]
(PlayerREF as _00E_PlayerFunctions).UnequipTorches(equippedTorches)
_00E_TorchControl.UnequipTorches(equippedTorches)
_00E_RealWorldOrigin.MoveTo(playerREF)
_00E_Class_MenuMeditationSound.Play(PlayerREF)

View File

@ -156,7 +156,7 @@ Function _TryStartSmoking()
RegisterCancelKeys()
EquippedTorches = New Form[2]
Bool bTorchesUnequipping = (PlayerRef as _00E_PlayerFunctions).UnequipTorches(EquippedTorches)
Bool bTorchesUnequipping = _00E_TorchControl.UnequipTorches(EquippedTorches)
If PlayerRef.IsWeaponDrawn()
_UnlockSmokingStage()
@ -294,7 +294,7 @@ Function StopSmoking()
StoredEquippedShield = None
EndIf
(PlayerRef as _00E_PlayerFunctions).ReequipTorches(EquippedTorches)
_00E_TorchControl.ReequipTorches(EquippedTorches)
If StoredCameraState == 0
Game.ForceFirstPerson()

View File

@ -82,48 +82,3 @@ Function ResumeRandomHeadTracking()
Game.SetGameSettingFloat("fAIHoldDefaultHeadTrackTimer", fDefaultHeadTrackTimerOldValue)
Game.SetGameSettingFloat("fAIStayonScriptHeadtrack", fStayHeadTrackTimerOldValue)
EndFunction
;=====================================================================================
; Equip/unequip torches
;=====================================================================================
Int Function _GetHandSlotEx(int iHand)
; By default, iHand = 0 for left hand, 1 for right hand
; In SKSE's "Equip Ex" functions though: iHand = 2 for left hand, 1 for right hand
Return 2 - iHand
EndFunction
Bool Function UnequipTorches(Form[] equippedTorches)
Bool unequipping = False
Int iHand = 0
While iHand < equippedTorches.Length
If GetEquippedItemType(iHand) == 11 ; A torch is in the hand?
Form torch = GetEquippedObject(iHand)
If torch
UnequipItemEx(torch, _GetHandSlotEx(iHand))
equippedTorches[iHand] = torch
unequipping = True
EndIf
EndIf
iHand += 1
EndWhile
Return unequipping
EndFunction
Function ReequipTorches(Form[] equippedTorches)
Int iHand = 0
While iHand < equippedTorches.Length
Form torch = equippedTorches[iHand]
If torch
If GetItemCount(torch) > 0
EquipItemEx(torch, _GetHandSlotEx(iHand), False, True)
EndIf
; "Forget" about the form to not keep it persistent if equippedTorches is a script's property or variable
equippedTorches[iHand] = None
EndIf
iHand += 1
EndWhile
EndFunction

View File

@ -117,7 +117,7 @@ Function TryPlayerActivate(ObjectReference myLinkedRef)
;USKP 1.3.0 FixEnd
EquippedTorches = New Form[2]
If (PlayerREF as _00E_PlayerFunctions).UnequipTorches(EquippedTorches)
If _00E_TorchControl.UnequipTorches(EquippedTorches)
Utility.Wait(0.25) ; Give some time for torch unequip animations to settle
EndIf
@ -193,7 +193,6 @@ Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile,
endif
endif
endEvent
event onReset()
@ -220,7 +219,7 @@ Function OnFurnitureExit()
; Debug.Trace(self + ": OnFurnitureExit")
If PlayerIsInFurniture
PlayerIsInFurniture = False
(PlayerREF as _00E_PlayerFunctions).ReequipTorches(EquippedTorches)
_00E_TorchControl.ReequipTorches(EquippedTorches)
EndIf
EndFunction

View File

@ -153,8 +153,6 @@ bool bFX = FALSE
Shade02 = selfRef.placeAtMe(EncWispShade) as Actor
EndIf
;Set AV06 to 1 as a flag for being in this state (used in Frostmere Crypt)
selfRef.SetActorValue("Variable06", 1)
;/ selfRef.setActorValue("Variable07",1)
selfRef.damageActorValue("Magicka", -(selfRef.getActorValue("Magicka")))
selfRef.SetActorValue("Magicka", 0.0)