Reworked lockpicking and pickpocketing bonuses to work without SKSE

This commit is contained in:
Eddoursul 2024-02-13 18:09:37 +01:00
parent b533356da8
commit 99503f69b7
11 changed files with 94 additions and 146 deletions

BIN
Lockpicking perk update.esp Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -413,7 +413,10 @@ scripts\_00e_complexscenetriggerscript.pex
scripts\_00e_complexsermontriggerbox.pex scripts\_00e_complexsermontriggerbox.pex
scripts\_00e_complexsetstageonaliasdeath.pex scripts\_00e_complexsetstageonaliasdeath.pex
scripts\_00e_complexstartscenescript.pex scripts\_00e_complexstartscenescript.pex
scripts\_00E_ContainerController.pex scripts\_00E_ContainerBonusControl.pex
scripts\_00E_HiddenSlotContainer.pex
scripts\PRKF__00E_LockpickingBonusPe_030020DA.pex
scripts\PRKF__00E_LockpickingReqPerk_030039BA.pex
scripts\_00e_cq_d_01_functions.pex scripts\_00e_cq_d_01_functions.pex
scripts\_00e_cqc01_functions.pex scripts\_00e_cqc01_functions.pex
scripts\_00e_cqc02_caliascuilasc.pex scripts\_00e_cqc02_caliascuilasc.pex

View File

@ -0,0 +1,15 @@
;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
;NEXT FRAGMENT INDEX 3
Scriptname PRKF__00E_LockpickingBonusPe_030020DA Extends Perk Hidden
;BEGIN FRAGMENT Fragment_0
Function Fragment_0(ObjectReference akTargetRef, Actor akActor)
;BEGIN CODE
ContainerBonusControl.OnOpenContainer(akTargetRef)
;END CODE
EndFunction
;END FRAGMENT
;END FRAGMENT CODE - Do not edit anything between this and the begin comment
_00E_ContainerBonusControl Property ContainerBonusControl Auto

View File

@ -12,7 +12,11 @@ endif
Key refKey = akTargetRef.GetKey() Key refKey = akTargetRef.GetKey()
if refKey && akActor.GetItemCount(refKey) > 0 if refKey && akActor.GetItemCount(refKey) > 0
bool bLocked = akTargetRef.IsLocked()
akTargetRef.Activate(akActor, True) akTargetRef.Activate(akActor, True)
if bLocked
ContainerBonusControl.OnOpenContainer(akTargetRef)
endif
return return
endif endif
@ -31,11 +35,16 @@ Else
bPlayerCanActivate = True bPlayerCanActivate = True
EndIf EndIf
If bPlayerCanActivate if ! bPlayerCanActivate
akTargetRef.Activate(akActor, True)
Else
_00E_Game_UnlockNeedsSkill.Show() _00E_Game_UnlockNeedsSkill.Show()
EndIf return
endif
akTargetRef.Activate(akActor, True)
if akTargetRef.GetBaseObject() as Container
ContainerBonusControl.OnOpenContainer(akTargetRef)
endif
;END CODE ;END CODE
EndFunction EndFunction
;END FRAGMENT ;END FRAGMENT
@ -54,4 +63,4 @@ Perk Property _00E_Class_Trickster_P09_MasterThief Auto
Message Property _00E_Game_UnlockNeedsSkill Auto Message Property _00E_Game_UnlockNeedsSkill Auto
Message Property _00E_sDoorLocked Auto _00E_ContainerBonusControl Property ContainerBonusControl Auto

View File

@ -1,145 +1,56 @@
Scriptname _00E_ContainerController extends ReferenceAlias Hidden Scriptname _00E_ContainerBonusControl extends Quest Hidden
; This script sets up the sleight of hand loot of a chest upon activating it ; This script sets up the sleight of hand loot of a chest upon activating it
int function _GetScriptVersion() Global int function _GetScriptVersion() Global
return 1 return 1
endFunction endFunction
;=====================================================================================
; EVENTS
;=====================================================================================
event OnInit()
RegisterForMenu("ContainerMenu")
RegisterForMenu("LootMenu")
PlayerREF.AddPerk(_00E_LockpickingReqPerk)
endevent
event OnPlayerLoadGame()
lastContainer = None
bLmHasGold = false
bLmHasSlot = false
RegisterForMenu("ContainerMenu")
RegisterForMenu("LootMenu")
if ! PlayerREF.HasPerk(_00E_LockpickingReqPerk)
PlayerREF.AddPerk(_00E_LockpickingReqPerk)
endif
endevent
event OnUpdate()
ObjectReference currentContainer = lastContainer
lastContainer = None
if ! currentContainer
return
endif
if UI.IsMenuOpen("LootMenu") && currentContainer == Game.GetCurrentCrosshairRef()
if bLmHasGold
IncrementGold(currentContainer)
endif
if bLmHasSlot
OpenHiddenSlot(currentContainer, true)
endif
endif
endevent
event OnMenuOpen(String MenuName)
if MenuName == "LootMenu"
; Even when QuickLoot RE does not show up, it still sends open and close menu events
; To determine if QuickLoot is open, we check it 0.1 seconds later
lastContainer = None
UnregisterForUpdate()
ObjectReference lootMenuRef = Game.GetCurrentCrosshairRef()
if ! lootMenuRef
return
endif
if ! ( lootMenuRef.GetBaseObject() as Container ) || lootMenuRef.IsLocked() || lootMenuRef.IsActivationBlocked() || lootMenuRef.GetActorOwner() == Player
return
endif
bLmHasGold = lootMenuRef.GetItemCount(Gold001) >= 5
bLmHasSlot = false
if bLmHasGold || _00E_ChestsWithHiddenSlots.HasForm(lootMenuRef.GetBaseObject())
if ! bLmHasGold
bLmHasSlot = true
endif
if ! IsProcessed(lootMenuRef)
lastContainer = lootMenuRef
; Clears previous request automatically
RegisterForSingleUpdate(0.1)
endif
endif
return
endif
if MenuName == "ContainerMenu"
ObjectReference currentContainer = EnderalFunctions.GetCurrentContainer()
if ! currentContainer || currentContainer as Actor || currentContainer.GetActorOwner() == Player || currentContainer.GetParentCell() != PlayerREF.GetParentCell()
return
endif
if currentContainer == containerToFill
; Opened hidden container
Utility.Wait(0.1)
; Move unclaimed items to the original container
containerToFill.RemoveAllItems(lastContainer, true, true)
lastContainer = None
containerToFill = None
return
endif
bool bDoGold = currentContainer.GetItemCount(Gold001) >= 5
bool bDoSlot = _00E_ChestsWithHiddenSlots.HasForm(currentContainer.GetBaseObject())
if ! bDoGold && ! bDoSlot
return
endif
if IsProcessed(currentContainer)
return
endif
if bDoGold
IncrementGold(currentContainer)
endif
if bDoSlot
OpenHiddenSlot(currentContainer)
endif
endif
endevent
event OnMenuClose(String MenuName)
if MenuName == "LootMenu"
UnregisterForUpdate()
lastContainer = None
bLmHasGold = false
bLmHasSlot = false
endif
endevent
;===================================================================================== ;=====================================================================================
; FUNCTIONS ; FUNCTIONS
;===================================================================================== ;=====================================================================================
bool function IsProcessed(ObjectReference targetContainer) function OnOpenContainer(ObjectReference targetContainer)
; Lockpicking menu
while targetContainer.IsLocked() && Utility.IsInMenuMode()
Utility.WaitMenuMode(1.0)
endwhile
; Game mode and still locked
if targetContainer.IsLocked()
return
endif
; Wait for it to open
int i
while i < 20 && targetContainer.GetOpenState() == 2
Utility.WaitMenuMode(0.1)
i += 1
endwhile
; Leave if we are not in the container menu yet
if SKSE.GetVersion()
if ! UI.IsMenuOpen("ContainerMenu")
return
endif
elseif ! Utility.IsInMenuMode()
return
endif
if targetContainer.GetItemCount(_00E_HiddenSlotChecked) if targetContainer.GetItemCount(_00E_HiddenSlotChecked)
return true return
endif endif
targetContainer.AddItem(_00E_HiddenSlotChecked, 1, true) targetContainer.AddItem(_00E_HiddenSlotChecked, 1, true)
return false
if targetContainer.GetItemCount(Gold001) >= 5
IncrementGold(targetContainer)
endif
if _00E_ChestsWithHiddenSlots.HasForm(targetContainer.GetBaseObject())
OpenHiddenSlot(targetContainer)
endif
endfunction endfunction
Function IncrementGold(ObjectReference targetContainer) Function IncrementGold(ObjectReference targetContainer)
@ -186,8 +97,8 @@ function OpenHiddenSlot(ObjectReference currentContainer, bool bLootMenu = false
containerToFill.SetFactionOwner(none) containerToFill.SetFactionOwner(none)
Endif Endif
lastContainer = currentContainer containerToFill.lastContainer = currentContainer
containerToFill.Activate(PlayerREF, True) containerToFill.Activate(PlayerREF, false)
endif endif
If containerToFill == _00E_FS_SleightOfHand_HiddenSlot_BigSlotREF If containerToFill == _00E_FS_SleightOfHand_HiddenSlot_BigSlotREF
@ -215,17 +126,17 @@ bool function SetUpHiddenSlot(ObjectReference aContainer)
if messageToShow == _00E_FS_SleightOfHand_HiddenSlot_sSmallSlotFound if messageToShow == _00E_FS_SleightOfHand_HiddenSlot_sSmallSlotFound
containerToFill = _00E_FS_SleightOfHand_HiddenSlot_SmallSlotREF containerToFill = _00E_FS_SleightOfHand_HiddenSlot_SmallSlotREF as _00E_HiddenSlotContainer
iFormlistIndex = Utility.RandomInt(0, 2) + iFormlistIndexOffset iFormlistIndex = Utility.RandomInt(0, 2) + iFormlistIndexOffset
Elseif messageToShow == _00E_FS_SleightOfHand_HiddenSlot_sMediumSlotFound Elseif messageToShow == _00E_FS_SleightOfHand_HiddenSlot_sMediumSlotFound
containerToFill = _00E_FS_SleightOfHand_HiddenSlot_MediumSlotREF containerToFill = _00E_FS_SleightOfHand_HiddenSlot_MediumSlotREF as _00E_HiddenSlotContainer
iFormlistIndex = Utility.RandomInt(3, 5) + iFormlistIndexOffset iFormlistIndex = Utility.RandomInt(3, 5) + iFormlistIndexOffset
Elseif messageToShow == _00E_FS_SleightOfHand_HiddenSlot_sBigSlotFound Elseif messageToShow == _00E_FS_SleightOfHand_HiddenSlot_sBigSlotFound
containerToFill = _00E_FS_SleightOfHand_HiddenSlot_BigSlotREF containerToFill = _00E_FS_SleightOfHand_HiddenSlot_BigSlotREF as _00E_HiddenSlotContainer
iFormlistIndex = Utility.RandomInt(6, 7) + iFormlistIndexOffset iFormlistIndex = Utility.RandomInt(6, 7) + iFormlistIndexOffset
EndIf EndIf
@ -356,11 +267,7 @@ int iBigSlotChance = 15
; This formlist will be filled with the formlist containing the items that will actually be added into the container ; This formlist will be filled with the formlist containing the items that will actually be added into the container
Message messageToShow Message messageToShow
ObjectReference lastContainer _00E_HiddenSlotContainer containerToFill
ObjectReference containerToFill
bool bLmHasGold
bool bLmHasSlot
Actor Property PlayerRef Auto Actor Property PlayerRef Auto
ActorBase Property Player Auto ActorBase Property Player Auto
@ -396,5 +303,3 @@ FormList Property _00E_ChestsWithHiddenSlots Auto
Faction Property SleightOfHandOwnerFaction Auto Faction Property SleightOfHandOwnerFaction Auto
Message Property _00E_FS_LockpickingGoldBuffMSG Auto Message Property _00E_FS_LockpickingGoldBuffMSG Auto
Perk Property _00E_LockpickingReqPerk Auto

View File

@ -0,0 +1,16 @@
Scriptname _00E_HiddenSlotContainer extends ObjectReference
Event OnActivate(ObjectReference akActionRef)
if ! lastContainer
return
endif
Utility.Wait(0.1)
RemoveAllItems(lastContainer, true, true)
lastContainer = None
EndEvent
ObjectReference Property lastContainer Auto