4
Fork 0

Moved lockpicking gold bonus to ContainerController

development
Eddoursul 4 months ago
parent 5dc76239c8
commit 6e1bf5a6e9
  1. BIN
      SleightOfHand quest.esp
  2. BIN
      scripts/_00E_ContainerController.pex
  3. BIN
      scripts/_00E_SleightOfHandAlias.pex
  4. BIN
      scripts/_00e_chestanddoorlockscript.pex
  5. 148
      source/scripts/_00E_ContainerController.psc
  6. 67
      source/scripts/_00e_chestanddoorlockscript.psc

Binary file not shown.

@ -1,4 +1,4 @@
Scriptname _00E_SleightOfHandAlias extends ReferenceAlias Hidden
Scriptname _00E_ContainerController extends ReferenceAlias Hidden
; This script sets up the sleight of hand loot of a chest upon activating it
;=====================================================================================
@ -11,37 +11,63 @@ event OnInit()
endevent
event OnPlayerLoadGame()
lastContainer = None
bLmHasGold = false
bLmHasSlot = false
RegisterForMenu("ContainerMenu")
RegisterForMenu("LootMenu")
endevent
event OnUpdate()
if lastContainer && UI.IsMenuOpen("LootMenu") && lastContainer == Game.GetCurrentCrosshairRef()
OpenHiddenSlot(lastContainer, true)
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"
UnregisterForUpdate()
; 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
Container baseContainer = lootMenuRef.GetBaseObject() as Container
if ! baseContainer || lootMenuRef.IsActivationBlocked() || _00E_ChestsWithHiddenSlots.Find(baseContainer) == -1
if ! ( lootMenuRef.GetBaseObject() as Container ) || lootMenuRef.IsActivationBlocked()
return
endif
bLmHasGold = lootMenuRef.GetItemCount(Gold001) >= 5
bLmHasSlot = false
if bLmHasGold || _00E_ChestsWithHiddenSlots.Find(lootMenuRef.GetBaseObject()) > -1
if ! bLmHasGold
bLmHasSlot = true
endif
if ! IsProcessed(lootMenuRef)
lastContainer = lootMenuRef
; Clears previous request automatically
RegisterForSingleUpdate(0.1)
endif
endif
lastContainer = lootMenuRef
; Clears previous request automatically
RegisterForSingleUpdate(0.1)
return
endif
@ -52,21 +78,35 @@ event OnMenuOpen(String MenuName)
return
endif
if currentContainer == containterToFill
if currentContainer == containerToFill
; Opened hidden container
Utility.Wait(0.1)
; Move unclaimed items to the original container
containterToFill.RemoveAllItems(lastContainer, true, true)
containerToFill.RemoveAllItems(lastContainer, true, true)
lastContainer = None
containterToFill = None
containerToFill = None
return
endif
bool bDoGold = currentContainer.GetItemCount(Gold001) >= 5
bool bDoSlot = _00E_ChestsWithHiddenSlots.Find(currentContainer.GetBaseObject()) > -1
if ! bDoGold && ! bDoSlot
return
endif
if _00E_ChestsWithHiddenSlots.Find(currentContainer.GetBaseObject()) == -1
if IsProcessed(currentContainer)
return
endif
OpenHiddenSlot(currentContainer)
if bDoGold
IncrementGold(currentContainer)
endif
if bDoSlot
OpenHiddenSlot(currentContainer)
endif
endif
endevent
@ -75,6 +115,8 @@ event OnMenuClose(String MenuName)
if MenuName == "LootMenu"
UnregisterForUpdate()
lastContainer = None
bLmHasGold = false
bLmHasSlot = false
endif
endevent
@ -83,6 +125,39 @@ endevent
; FUNCTIONS
;=====================================================================================
bool function IsProcessed(ObjectReference targetContainer)
if targetContainer.GetItemCount(_00E_HiddenSlotChecked)
return true
endif
targetContainer.AddItem(_00E_HiddenSlotChecked, 1, true)
return false
endfunction
Function IncrementGold(ObjectReference targetContainer)
int iGoldMultiplicator = _00E_GoldMult.GetValue() as int
if iGoldMultiplicator == 0
; Prevent division by zero
iGoldMultiplicator = 5
endif
float fIncrementPercentage = ( PlayerREF.GetActorValue("Lockpicking") / iGoldMultiplicator ) / 100
int iGoldBuffAmount = ( targetContainer.GetItemCount(Gold001) * fIncrementPercentage ) as Int
if iGoldBuffAmount == 0
return
endif
targetContainer.AddItem(Gold001, iGoldBuffAmount)
if iGoldBuffAmount > 1
_00E_FS_LockpickingGoldBuffMSG.Show(iGoldBuffAmount as Int)
EndIf
EndFunction
function OpenHiddenSlot(ObjectReference currentContainer, bool bLootMenu = false)
if ! SetUpHiddenSlot(currentContainer)
@ -93,22 +168,22 @@ function OpenHiddenSlot(ObjectReference currentContainer, bool bLootMenu = false
messageToShow.Show()
if bLootMenu
containterToFill.RemoveAllItems(currentContainer, true, true)
containerToFill.RemoveAllItems(currentContainer, true, true)
else
; Open hidden container after the original one closes
Utility.Wait(0.1)
If IsOwned(currentContainer)
containterToFill.SetFactionOwner(SleightOfHandOwnerFaction)
containerToFill.SetFactionOwner(SleightOfHandOwnerFaction)
Else
containterToFill.SetFactionOwner(none)
containerToFill.SetFactionOwner(none)
Endif
lastContainer = currentContainer
containterToFill.Activate(PlayerREF, True)
containerToFill.Activate(PlayerREF, True)
endif
If containterToFill == _00E_FS_SleightOfHand_HiddenSlot_BigSlotREF
If containerToFill == _00E_FS_SleightOfHand_HiddenSlot_BigSlotREF
_00E_EPHandler.GiveEP(_00E_BigHiddenSlotExpReward.GetValue() as int)
If _00E_HiddenSlotAchievementUnlocked.GetValueInt() == 0
UIEnchantingLearnEffectM.Play(PlayerREF)
@ -121,12 +196,6 @@ endfunction
bool function SetUpHiddenSlot(ObjectReference aContainer)
if aContainer.GetItemCount(_00E_HiddenSlotChecked)
return false
endif
aContainer.AddItem(_00E_HiddenSlotChecked, 1, true)
if ! DoesContainerHaveHiddenSlot()
return false
EndIf
@ -139,17 +208,17 @@ bool function SetUpHiddenSlot(ObjectReference aContainer)
if messageToShow == _00E_FS_SleightOfHand_HiddenSlot_sSmallSlotFound
containterToFill = _00E_FS_SleightOfHand_HiddenSlot_SmallSlotREF
containerToFill = _00E_FS_SleightOfHand_HiddenSlot_SmallSlotREF
iFormlistIndex = Utility.RandomInt(0, 2) + iFormlistIndexOffset
Elseif messageToShow == _00E_FS_SleightOfHand_HiddenSlot_sMediumSlotFound
containterToFill = _00E_FS_SleightOfHand_HiddenSlot_MediumSlotREF
containerToFill = _00E_FS_SleightOfHand_HiddenSlot_MediumSlotREF
iFormlistIndex = Utility.RandomInt(3, 5) + iFormlistIndexOffset
Elseif messageToShow == _00E_FS_SleightOfHand_HiddenSlot_sBigSlotFound
containterToFill = _00E_FS_SleightOfHand_HiddenSlot_BigSlotREF
containerToFill = _00E_FS_SleightOfHand_HiddenSlot_BigSlotREF
iFormlistIndex = Utility.RandomInt(6, 7) + iFormlistIndexOffset
EndIf
@ -163,9 +232,9 @@ EndFunction
Function AddItemsToContainer(Formlist itemsToAdd, int iFormlistIndexOffset, int iHiddenSlotTier)
containterToFill.RemoveAllItems()
containerToFill.RemoveAllItems()
if containterToFill == _00E_FS_SleightOfHand_HiddenSlot_BigSlotREF
if containerToFill == _00E_FS_SleightOfHand_HiddenSlot_BigSlotREF
if ! itemsToAdd.HasForm(_00E_FS_SleightOfHand_HiddenSlotUsedMarker)
itemsToAdd.AddForm(_00E_FS_SleightOfHand_HiddenSlotUsedMarker)
@ -184,9 +253,9 @@ Function AddItemsToContainer(Formlist itemsToAdd, int iFormlistIndexOffset, int
Form formToAdd = itemsToAdd.GetAt(iIndex)
if formToAdd == Gold001
containterToFill.AddItem(itemsToAdd.GetAt(iIndex), iHiddenSlotTier*5)
containerToFill.AddItem(itemsToAdd.GetAt(iIndex), iHiddenSlotTier*5)
Else
containterToFill.AddItem(itemsToAdd.GetAt(iIndex), 1)
containerToFill.AddItem(itemsToAdd.GetAt(iIndex), 1)
EndIf
iIndex -= 1
@ -281,7 +350,10 @@ 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 containterToFill
ObjectReference containerToFill
bool bLmHasGold
bool bLmHasSlot
Actor Property PlayerRef Auto
@ -289,6 +361,10 @@ GlobalVariable Property PlayerLevel Auto
GlobalVariable Property _00E_HiddenSlotAchievementUnlocked Auto
GlobalVariable Property _00E_BigHiddenSlotExpReward Auto
; Use this to control how much the lockpicking skill increments the gold found in chest. When changing, remember to change in _00E_LootContainer.psc as well!
; Current calculation: Gold in chest*((Lockpicking/iGoldMultiplicator)/100)
GlobalVariable Property _00E_GoldMult Auto
; These REFs simply provide the containers that will be filled when finding a secret slot
ObjectReference Property _00E_FS_SleightOfHand_HiddenSlot_SmallSlotREF Auto
ObjectReference Property _00E_FS_SleightOfHand_HiddenSlot_MediumSlotREF Auto
@ -310,3 +386,5 @@ FormList Property _00E_FS_HiddenSlotRewardFormlists Auto
FormList Property _00E_ChestsWithHiddenSlots Auto
Faction Property SleightOfHandOwnerFaction Auto
Message Property _00E_FS_LockpickingGoldBuffMSG Auto

@ -1,57 +1,5 @@
Scriptname _00E_ChestAndDoorLockScript extends ObjectReference
;=====================================================================================
; GOLDBUFF
;=====================================================================================
; Use this to control how much the lockpicking skill increments the gold found in chest. When changing, remember to change in _00E_LootContainer.psc as well!
; Current calculation: Gold in chest*((Lockpicking/iGoldMultiplicator)/100)
int iGoldMultiplicator = 5
int iCurrentGoldCount
float fPlayerLockpicking
bool bDone
Message Property _00E_FS_LockpickingGoldBuffMSG Auto
MiscObject Property Gold001 Auto
Event OnOpen(ObjectReference akActionRef)
if !bDone && (Self.GetBaseObject().GetType() == 28) ; check if it's a container otherwise the script tries to call this stuff on doors
bDone = True
iCurrentGoldCount = Self.GetItemCount(Gold001)
fPlayerLockpicking = PlayerREF.GetActorValue("Lockpicking")
if iCurrentGoldCount >= 5 && fPlayerLockpicking >= 15
IncrementGold()
EndIf
EndIf
EndEvent
;=====================================================================================
; FUNCTIONS
;=====================================================================================
Function IncrementGold()
float fIncrementPercentage = (fPlayerLockpicking/iGoldMultiplicator)/100
int iGoldBuffAmount = (iCurrentGoldCount*fIncrementPercentage) as Int
Self.AddItem(Gold001, iGoldBuffAmount)
if iGoldBuffAmount > 1
_00E_FS_LockpickingGoldBuffMSG.Show(iGoldBuffAmount as Int)
EndIf
EndFunction
;=====================================================================================
; ORIGINAL SCRIPT
;=====================================================================================
Event OnLoad()
BlockActivation(True)
EndEvent
@ -101,7 +49,11 @@ Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile,
_00E_sDoorLocked.Show()
WPNTG06ControlStaffShootFailM.Play(Self)
ElseIf projectileLevel >= lockLevel
UnlockLock()
; Unlock
Self.Lock(False)
_00E_UILockpickingUnlockM.Play(Self)
_00E_Ability_Antimagic_FXSShader.Play(Self)
self.PlaceAtMe(_00E_UnlockLockExplosion, 1)
EndIf
EndIf
@ -166,15 +118,6 @@ Event OnActivate(ObjectReference akActionRef)
EndEvent
Function UnlockLock()
Self.Lock(False)
_00E_UILockpickingUnlockM.Play(Self)
_00E_Ability_Antimagic_FXSShader.Play(Self)
self.PlaceAtMe(_00E_UnlockLockExplosion, 1)
EndFunction
Formlist Property _00E_SuntempleLocations Auto
Projectile Property _00E_UnlockProjectile_Novice Auto

Loading…
Cancel
Save