diff --git a/Lockpicking perk update.esp b/Lockpicking perk update.esp new file mode 100644 index 00000000..6d8ef287 Binary files /dev/null and b/Lockpicking perk update.esp differ diff --git a/scripts/PRKF__00E_LockpickingBonusPe_030020DA.pex b/scripts/PRKF__00E_LockpickingBonusPe_030020DA.pex new file mode 100644 index 00000000..d4b0db48 Binary files /dev/null and b/scripts/PRKF__00E_LockpickingBonusPe_030020DA.pex differ diff --git a/scripts/PRKF__00E_LockpickingReqPerk_030039BA.pex b/scripts/PRKF__00E_LockpickingReqPerk_030039BA.pex index 4c81683a..10120e6f 100644 Binary files a/scripts/PRKF__00E_LockpickingReqPerk_030039BA.pex and b/scripts/PRKF__00E_LockpickingReqPerk_030039BA.pex differ diff --git a/scripts/_00E_ContainerBonusControl.pex b/scripts/_00E_ContainerBonusControl.pex new file mode 100644 index 00000000..2c992bc9 Binary files /dev/null and b/scripts/_00E_ContainerBonusControl.pex differ diff --git a/scripts/_00E_ContainerController.pex b/scripts/_00E_ContainerController.pex deleted file mode 100644 index 11081968..00000000 Binary files a/scripts/_00E_ContainerController.pex and /dev/null differ diff --git a/scripts/_00E_HiddenSlotContainer.pex b/scripts/_00E_HiddenSlotContainer.pex new file mode 100644 index 00000000..cd9e302c Binary files /dev/null and b/scripts/_00E_HiddenSlotContainer.pex differ diff --git a/scripts/scriptarchiveorder.txt b/scripts/scriptarchiveorder.txt index f594c5ff..5d7f3377 100644 --- a/scripts/scriptarchiveorder.txt +++ b/scripts/scriptarchiveorder.txt @@ -413,7 +413,10 @@ scripts\_00e_complexscenetriggerscript.pex scripts\_00e_complexsermontriggerbox.pex scripts\_00e_complexsetstageonaliasdeath.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_cqc01_functions.pex scripts\_00e_cqc02_caliascuilasc.pex diff --git a/source/scripts/PRKF__00E_LockpickingBonusPe_030020DA.psc b/source/scripts/PRKF__00E_LockpickingBonusPe_030020DA.psc new file mode 100644 index 00000000..539a6521 --- /dev/null +++ b/source/scripts/PRKF__00E_LockpickingBonusPe_030020DA.psc @@ -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 diff --git a/source/scripts/PRKF__00E_LockpickingReqPerk_030039BA.psc b/source/scripts/PRKF__00E_LockpickingReqPerk_030039BA.psc index 2f4dafc8..17068b22 100644 --- a/source/scripts/PRKF__00E_LockpickingReqPerk_030039BA.psc +++ b/source/scripts/PRKF__00E_LockpickingReqPerk_030039BA.psc @@ -12,7 +12,11 @@ endif Key refKey = akTargetRef.GetKey() if refKey && akActor.GetItemCount(refKey) > 0 + bool bLocked = akTargetRef.IsLocked() akTargetRef.Activate(akActor, True) + if bLocked + ContainerBonusControl.OnOpenContainer(akTargetRef) + endif return endif @@ -31,11 +35,16 @@ Else bPlayerCanActivate = True EndIf -If bPlayerCanActivate - akTargetRef.Activate(akActor, True) -Else +if ! bPlayerCanActivate _00E_Game_UnlockNeedsSkill.Show() -EndIf + return +endif + +akTargetRef.Activate(akActor, True) + +if akTargetRef.GetBaseObject() as Container + ContainerBonusControl.OnOpenContainer(akTargetRef) +endif ;END CODE EndFunction ;END FRAGMENT @@ -54,4 +63,4 @@ Perk Property _00E_Class_Trickster_P09_MasterThief Auto Message Property _00E_Game_UnlockNeedsSkill Auto -Message Property _00E_sDoorLocked Auto +_00E_ContainerBonusControl Property ContainerBonusControl Auto diff --git a/source/scripts/_00E_ContainerController.psc b/source/scripts/_00E_ContainerBonusControl.psc similarity index 70% rename from source/scripts/_00E_ContainerController.psc rename to source/scripts/_00E_ContainerBonusControl.psc index fb0c92a4..716883ad 100644 --- a/source/scripts/_00E_ContainerController.psc +++ b/source/scripts/_00E_ContainerBonusControl.psc @@ -1,4 +1,4 @@ -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 int function _GetScriptVersion() Global @@ -6,140 +6,51 @@ int function _GetScriptVersion() Global endFunction ;===================================================================================== -; EVENTS +; FUNCTIONS ;===================================================================================== -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 +function OnOpenContainer(ObjectReference targetContainer) -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 + ; Lockpicking menu + while targetContainer.IsLocked() && Utility.IsInMenuMode() + Utility.WaitMenuMode(1.0) + endwhile -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 - + ; Game mode and still locked + if targetContainer.IsLocked() 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()) + ; Wait for it to open + int i + while i < 20 && targetContainer.GetOpenState() == 2 + Utility.WaitMenuMode(0.1) + i += 1 + endwhile - if ! bDoGold && ! bDoSlot - return - endif - - if IsProcessed(currentContainer) + ; Leave if we are not in the container menu yet + if SKSE.GetVersion() + if ! UI.IsMenuOpen("ContainerMenu") return endif - - if bDoGold - IncrementGold(currentContainer) - endif - - if bDoSlot - OpenHiddenSlot(currentContainer) - endif - + elseif ! Utility.IsInMenuMode() + return endif - -endevent -event OnMenuClose(String MenuName) - if MenuName == "LootMenu" - UnregisterForUpdate() - lastContainer = None - bLmHasGold = false - bLmHasSlot = false + if targetContainer.GetItemCount(_00E_HiddenSlotChecked) + return endif -endevent + targetContainer.AddItem(_00E_HiddenSlotChecked, 1, true) -;===================================================================================== -; FUNCTIONS -;===================================================================================== + if targetContainer.GetItemCount(Gold001) >= 5 + IncrementGold(targetContainer) + endif -bool function IsProcessed(ObjectReference targetContainer) - if targetContainer.GetItemCount(_00E_HiddenSlotChecked) - return true + if _00E_ChestsWithHiddenSlots.HasForm(targetContainer.GetBaseObject()) + OpenHiddenSlot(targetContainer) endif - targetContainer.AddItem(_00E_HiddenSlotChecked, 1, true) - return false endfunction Function IncrementGold(ObjectReference targetContainer) @@ -186,8 +97,8 @@ function OpenHiddenSlot(ObjectReference currentContainer, bool bLootMenu = false containerToFill.SetFactionOwner(none) Endif - lastContainer = currentContainer - containerToFill.Activate(PlayerREF, True) + containerToFill.lastContainer = currentContainer + containerToFill.Activate(PlayerREF, false) endif If containerToFill == _00E_FS_SleightOfHand_HiddenSlot_BigSlotREF @@ -215,17 +126,17 @@ bool function SetUpHiddenSlot(ObjectReference aContainer) 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 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 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 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 Message messageToShow -ObjectReference lastContainer -ObjectReference containerToFill - -bool bLmHasGold -bool bLmHasSlot +_00E_HiddenSlotContainer containerToFill Actor Property PlayerRef Auto ActorBase Property Player Auto @@ -396,5 +303,3 @@ FormList Property _00E_ChestsWithHiddenSlots Auto Faction Property SleightOfHandOwnerFaction Auto Message Property _00E_FS_LockpickingGoldBuffMSG Auto - -Perk Property _00E_LockpickingReqPerk Auto diff --git a/source/scripts/_00E_HiddenSlotContainer.psc b/source/scripts/_00E_HiddenSlotContainer.psc new file mode 100644 index 00000000..7b4c9faf --- /dev/null +++ b/source/scripts/_00E_HiddenSlotContainer.psc @@ -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