Advertisement
expired6978

Prevent Unequip

Jan 16th, 2017
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. Scriptname ModdablePipboy:PipboyPreventUnequip extends Quest
  2.  
  3. Actor Property PlayerREF Auto Const Mandatory
  4. Armor Property Pipboy Auto Const Mandatory
  5.  
  6. bool bHasPipboy = false
  7. bool bUsingWorkbench = false
  8. bool bEquipLock = false
  9.  
  10. Event OnInit()
  11. RegisterForRemoteEvent(PlayerREF, "OnItemEquipped")
  12. RegisterForRemoteEvent(PlayerREF, "OnPlayerLoadGame")
  13. RegisterForRemoteEvent(PlayerREF, "OnPlayerUseWorkBench")
  14. RegisterForMenuOpenCloseEvent("ExamineMenu")
  15. AddInventoryEventFilter(Pipboy)
  16. RegisterForRemoteEvent(PlayerREF, "OnItemRemoved")
  17. EndEvent
  18.  
  19. ; We want to temporarily disable unequip prevention during workbench
  20. Event Actor.OnPlayerUseWorkBench(Actor akActor, ObjectReference akWorkBench)
  21. If akActor.IsEquipped(Pipboy)
  22. bEquipLock = true
  23. akActor.EquipItem(Pipboy, false, true) ; Turn off prevention until we end the workbench
  24. bEquipLock = false
  25. Endif
  26.  
  27. bUsingWorkbench = true
  28. EndEvent
  29.  
  30. Event ObjectReference.OnItemRemoved(ObjectReference akSource, Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
  31. If akBaseItem == Pipboy && akSource == PlayerREF && akDestContainer != PlayerREF ; We're giving away our Pipboy! NOOOOOOOO
  32. If akDestContainer
  33. akDestContainer.RemoveItem(Pipboy, 1, true, PlayerREF) ; Put it back!
  34. PlayerREF.EquipItem(Pipboy, true, true)
  35. Endif
  36. Endif
  37. EndEvent
  38.  
  39. Event OnMenuOpenCloseEvent(string asMenuName, bool abOpening)
  40. If asMenuName == "ExamineMenu" && bUsingWorkbench && !abOpening
  41. bEquipLock = true
  42. PlayerREF.EquipItem(Pipboy, true, true) ; Force re-equip with removal prevention
  43. bEquipLock = false
  44. Endif
  45. EndEvent
  46.  
  47. Event Actor.OnItemEquipped(Actor akActor, Form akBaseObject, ObjectReference akReference)
  48. If akBaseObject == Pipboy && !bEquipLock && !bUsingWorkbench ; Don't do this when we're already doing it, or we're working on the item
  49. bEquipLock = true
  50. akActor.EquipItem(Pipboy, true, true)
  51. bEquipLock = false
  52. Endif
  53. EndEvent
  54.  
  55. Event Actor.OnPlayerLoadGame(actor akSender)
  56. If akSender.IsEquipped(Pipboy) ; Force prevent unequip
  57. akSender.EquipItem(Pipboy, true, true)
  58. Endif
  59. EndEvent
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement