Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Scriptname ModdablePipboy:PipboyPreventUnequip extends Quest
- Actor Property PlayerREF Auto Const Mandatory
- Armor Property Pipboy Auto Const Mandatory
- bool bHasPipboy = false
- bool bUsingWorkbench = false
- bool bEquipLock = false
- Event OnInit()
- RegisterForRemoteEvent(PlayerREF, "OnItemEquipped")
- RegisterForRemoteEvent(PlayerREF, "OnPlayerLoadGame")
- RegisterForRemoteEvent(PlayerREF, "OnPlayerUseWorkBench")
- RegisterForMenuOpenCloseEvent("ExamineMenu")
- AddInventoryEventFilter(Pipboy)
- RegisterForRemoteEvent(PlayerREF, "OnItemRemoved")
- EndEvent
- ; We want to temporarily disable unequip prevention during workbench
- Event Actor.OnPlayerUseWorkBench(Actor akActor, ObjectReference akWorkBench)
- If akActor.IsEquipped(Pipboy)
- bEquipLock = true
- akActor.EquipItem(Pipboy, false, true) ; Turn off prevention until we end the workbench
- bEquipLock = false
- Endif
- bUsingWorkbench = true
- EndEvent
- Event ObjectReference.OnItemRemoved(ObjectReference akSource, Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
- If akBaseItem == Pipboy && akSource == PlayerREF && akDestContainer != PlayerREF ; We're giving away our Pipboy! NOOOOOOOO
- If akDestContainer
- akDestContainer.RemoveItem(Pipboy, 1, true, PlayerREF) ; Put it back!
- PlayerREF.EquipItem(Pipboy, true, true)
- Endif
- Endif
- EndEvent
- Event OnMenuOpenCloseEvent(string asMenuName, bool abOpening)
- If asMenuName == "ExamineMenu" && bUsingWorkbench && !abOpening
- bEquipLock = true
- PlayerREF.EquipItem(Pipboy, true, true) ; Force re-equip with removal prevention
- bEquipLock = false
- Endif
- EndEvent
- Event Actor.OnItemEquipped(Actor akActor, Form akBaseObject, ObjectReference akReference)
- If akBaseObject == Pipboy && !bEquipLock && !bUsingWorkbench ; Don't do this when we're already doing it, or we're working on the item
- bEquipLock = true
- akActor.EquipItem(Pipboy, true, true)
- bEquipLock = false
- Endif
- EndEvent
- Event Actor.OnPlayerLoadGame(actor akSender)
- If akSender.IsEquipped(Pipboy) ; Force prevent unequip
- akSender.EquipItem(Pipboy, true, true)
- Endif
- EndEvent
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement