2021-10-05 22:15:58 +00:00
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)
2024-01-10 13:29:46 +00:00
if !bDone && (Self.GetBaseObject().GetType() == 28) ; check if it's a container otherwise the script tries to call this stuff on doors
2021-10-05 22:15:58 +00:00
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
Int Property LOCK_LEVEL_NOVICE = 1 AutoReadOnly
Int Property LOCK_LEVEL_APPRENTICE = 25 AutoReadOnly
Int Property LOCK_LEVEL_ADEPT = 50 AutoReadOnly
Int Property LOCK_LEVEL_EXPERT = 75 AutoReadOnly
Int Property LOCK_LEVEL_MASTER = 254 AutoReadOnly
Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
If akAggressor != PlayerREF || IsLocked() == False
Return
EndIf
Int projectileLevel = 0
If akProjectile == _00E_UnlockProjectile_Novice
projectileLevel = LOCK_LEVEL_NOVICE
ElseIf akProjectile == _00E_UnlockProjectile_Apprentice
projectileLevel = LOCK_LEVEL_APPRENTICE
ElseIf akProjectile == _00E_UnlockProjectile_Adept
projectileLevel = LOCK_LEVEL_ADEPT
ElseIf akProjectile == _00E_UnlockProjectile_Expert
projectileLevel = LOCK_LEVEL_EXPERT
ElseIf akProjectile == _00E_UnlockProjectile_Master
projectileLevel = LOCK_LEVEL_MASTER
ElseIf akSource
Formlist unlockSpells = Game.GetFormFromFile(0x00044EE4, "Skyrim.esm") as Formlist
If unlockSpells.HasForm(akSource)
If akSource == unlockSpells.GetAt(0) as Explosion
projectileLevel = LOCK_LEVEL_APPRENTICE
ElseIf akSource == unlockSpells.GetAt(1) as Explosion
projectileLevel = LOCK_LEVEL_ADEPT
ElseIf akSource == unlockSpells.GetAt(2) as Explosion
projectileLevel = LOCK_LEVEL_EXPERT
ElseIf akSource == unlockSpells.GetAt(3) as Explosion
projectileLevel = LOCK_LEVEL_MASTER
EndIf
EndIf
EndIf
If projectileLevel > 0
Int lockLevel = self.GetLockLevel()
If lockLevel > LOCK_LEVEL_MASTER
_00E_sDoorLocked.Show()
WPNTG06ControlStaffShootFailM.Play(Self)
ElseIf projectileLevel >= lockLevel
UnlockLock()
EndIf
EndIf
EndEvent
Bool Function _IsInSuntemple()
If _00E_SuntempleLocations
Location curLoc = GetCurrentLocation()
If curLoc && _00E_SuntempleLocations.HasForm(curLoc)
Return True
EndIf
EndIf
Return False
EndFunction
Bool Function _IsInSiege()
Quest qSiegeQuest = Game.GetForm(0x0002EBAD) as Quest
Int siegeStage = qSiegeQuest.GetStage()
Return (siegeStage >= 5 && siegeStage <= 125)
EndFunction
Bool Function _PlayerHasKey()
Key myKey = GetKey()
Return (myKey && PlayerREF.GetItemCount(myKey) > 0)
EndFunction
Event OnActivate(ObjectReference akActionRef)
If akActionRef == PlayerREF
If _IsInSiege() && (Self.GetBaseObject().GetType() != 29 || _IsInSuntemple() == False)
_00E_sDoorLocked.Show()
ElseIf IsActivationBlocked()
If IsLocked() && _PlayerHasKey() == False
Bool bPlayerCanActivate = False
Int iLockLevel = GetLockLevel()
If iLockLevel <= LOCK_LEVEL_APPRENTICE
bPlayerCanActivate = True
ElseIf iLockLevel <= LOCK_LEVEL_ADEPT
2023-12-08 02:45:53 +00:00
bPlayerCanActivate = (PlayerREF.HasPerk(_00E_Class_Trickery_P04b_) || PlayerREF.GetActorValue("Lockpicking") >= 25)
2021-10-05 22:15:58 +00:00
ElseIf iLockLevel <= LOCK_LEVEL_EXPERT
2023-12-08 02:45:53 +00:00
bPlayerCanActivate = (PlayerREF.HasPerk(_00E_Class_Trickery_P07_) || PlayerREF.GetActorValue("Lockpicking") >= 50)
2021-10-05 22:15:58 +00:00
ElseIf iLockLevel <= LOCK_LEVEL_MASTER
2023-12-08 02:45:53 +00:00
bPlayerCanActivate = (PlayerREF.HasPerk(_00E_Class_Trickery_P10_) || PlayerREF.GetActorValue("Lockpicking") >= 75)
2021-10-05 22:15:58 +00:00
Else
bPlayerCanActivate = True
EndIf
If bPlayerCanActivate
Activate(PlayerREF, True)
Else
_00E_Game_UnlockNeedsSkill.Show()
EndIf
Else
BlockActivation(False)
Activate(PlayerREF, True)
EndIf
EndIf
Else
Activate(akActionRef, True)
EndIf
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
Projectile Property _00E_UnlockProjectile_Apprentice Auto
Projectile Property _00E_UnlockProjectile_Adept Auto
Projectile Property _00E_UnlockProjectile_Expert Auto
Projectile Property _00E_UnlockProjectile_Master Auto
Message Property _00E_sDoorLocked Auto
Perk Property _00E_Class_Trickery_P04b_ Auto ; Unlock adept locks perk
Perk Property _00E_Class_Trickery_P07_ Auto ; Unlock expert locks
Perk Property _00E_Class_Trickery_P10_ Auto ; Unlock master locks
Sound Property _00E_UILockpickingUnlockM Auto
Sound Property WPNTG06ControlStaffShootFailM Auto
EffectShader Property _00E_Ability_Antimagic_FXSShader Auto
Explosion Property _00E_UnlockLockExplosion Auto
Actor Property PlayerREF Auto
Message Property _00E_Game_UnlockNeedsSkill Auto