Advertisement
ThoraldGM

DCS Laundry Script

Sep 23rd, 2017
567
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.19 KB | None | 0 0
  1. Scriptname DCS_Laundry_Script extends Quest
  2. { It just works. }
  3.  
  4. ; DIAMOND CITY SWAT VERSION 2.0: https://www.nexusmods.com/fallout4/mods/10893/
  5. ; A FALLOUT 4 MOD BY @THORALDGM | THORALDGM.COM | SCRIPT UPDATED 20170923
  6. ;
  7. ; This script makes washers functional in Diamond City security office. Max compatibility with other mods.
  8. ;
  9. ; PERMISSIONS:
  10. ;
  11. ; - Do not repost my mod. If you want to tweak minor changes, send me the esp and I will post it in Files.
  12. ; - Language translations are allowed only on same platforms where I posted mod. Please mail link when done.
  13. ; - This mod may not be folded entirely into a larger work without my written permission and collaboration.
  14. ; - Please ask if you want to use parts of my code to improve other mods. Must be unique and credit source.
  15. ;
  16. ; - If you have any questions, or see a better way to do something, please let me know.
  17. ;
  18. ; SCRIPT SECTIONS:
  19. ;
  20. ; LINE 039: PROPERTIES
  21. ; LINE 059: ON INIT
  22. ; LINE 078: ON ITEM ADDED
  23. ;
  24. ; WARNINGS:
  25. ;
  26. ; - ANYTHING PLACED IN WASHER WILL BE STRIPPED OF ARMOR/WEAPON MODS DURING TRANSFER TO DRYER!
  27. ; - WEAPONS PLACED IN WASHER WILL GENERATE SMALL AMOUNTS OF AMMO IN DRYER. THIS CAN BE FARMED/REPEATED.
  28. ; - THIS SCRIPT DOES NOT CURRENTLY CHECK TO SEE IF WASHERS HAVE BEEN SCRAPPED BY PLACE WORKBENCH/SCRAP MODS.
  29. ;
  30. ; This does not create working washers/dryers in workshops. For that functionality, check out these mods:
  31. ; - Functional Washer: https://www.nexusmods.com/fallout4/mods/14402/
  32. ; - Laundry Day: https://www.nexusmods.com/fallout4/mods/9042/
  33. ;
  34. ; Other laundromats in game that could benefit from this method:
  35. ; - http://fallout.wikia.com/wiki/Charlestown_laundry
  36. ; - http://fallout.wikia.com/wiki/Faded_Glory_laundromat
  37.  
  38. ; ------------------------------------------------------------------------------------------------------------
  39. ; PROPERTIES
  40. ; ------------------------------------------------------------------------------------------------------------
  41.  
  42. FormList Property flCleanClothes Auto Const Mandatory ; FormList of clean clothes
  43. FormList Property flDirtyClothes Auto Const Mandatory ; FormList of dirty clothes
  44.  
  45. ReferenceAlias Property raWasher1 Auto Const ; Left washer
  46. ReferenceAlias Property raWasher2 Auto Const ; Center washer
  47. ReferenceAlias Property raWasher3 Auto Const ; Right washer
  48.  
  49. ReferenceAlias Property raDryer1 Auto Const ; Left dryer
  50. ReferenceAlias Property raDryer2 Auto Const ; Center dryer
  51. ReferenceAlias Property raDryer3 Auto Const ; Right dryer
  52.  
  53. Sound Property pFXHumanCannibalGush Auto Const Mandatory ; Gurgling sound for washers
  54. Sound Property pDRSFacilityXBlastOpenEBuzzer Auto Const Mandatory ; Buzzer sound for dryers
  55.  
  56. GlobalVariable Property gvDevTracking Auto Mandatory ; Are dev messages turned on
  57.  
  58. ; ------------------------------------------------------------------------------------------------------------
  59. ; EVENT: ON INIT
  60. ; ------------------------------------------------------------------------------------------------------------
  61.  
  62. Event OnInit()
  63.  
  64. ; ********************************************************************************************************
  65. ; REGISTER (START LISTENING) FOR REMOTE EVENTS, SO SCRIPT CAN REACT
  66. ; ********************************************************************************************************
  67.  
  68. AddInventoryEventFilter(None) ; Required filter for OnItemAdded
  69. Utility.Wait(0.1) ; Let stack apply filter before registrations
  70.  
  71. RegisterForRemoteEvent(raWasher1, "OnItemAdded") ; Listen for left washer event
  72. RegisterForRemoteEvent(raWasher2, "OnItemAdded") ; Listen for center washer event
  73. RegisterForRemoteEvent(raWasher3, "OnItemAdded") ; Listen for right washer event
  74.  
  75. EndEvent
  76.  
  77. ; ------------------------------------------------------------------------------------------------------------
  78. ; EVENT: ON ITEM ADDED
  79. ; ------------------------------------------------------------------------------------------------------------
  80.  
  81. Event ReferenceAlias.OnItemAdded(ReferenceAlias akSender, Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
  82.  
  83. ; ********************************************************************************************************
  84. ; PAIR INCOMING WASHER WITH OUTGOING DRYER
  85. ; ********************************************************************************************************
  86.  
  87. Form LaunderedItem = akBaseItem ; Store item for pending transfer
  88. ObjectReference obSender = akSender.GetReference() ; Get objref of the washer refalias
  89. ObjectReference ClothesDestination ; Prepare to assign a dryer
  90. String GoWhere ; String for assigned dryer
  91.  
  92. If akSender == raWasher1
  93. ClothesDestination = raDryer1.GetReference() ; Left washer targets left dryer
  94. GoWhere = "1"
  95. ElseIf akSender == raWasher2
  96. ClothesDestination = raDryer2.GetReference() ; Center washer targets center dryer
  97. GoWhere = "2"
  98. Else
  99. ClothesDestination = raDryer3.GetReference() ; Right washer targets right dryer
  100. GoWhere = "3"
  101. EndIf
  102.  
  103. If gvDevTracking.GetValue() == 1
  104. Debug.Notification("DCS: Destination is dryer " + GoWhere + ".") ; Inform optional dev tracker
  105. EndIf
  106.  
  107. ; ********************************************************************************************************
  108. ; REMOVE ITEM FROM WASHER, ADD CLEAN ITEM TO DRYER, PLAY GURGLING & BUZZER SOUNDS
  109. ; ********************************************************************************************************
  110.  
  111. If flDirtyClothes.HasForm(akBaseItem) ; If item is on dirty clothes list
  112. Int index = flDirtyClothes.Find(akBaseItem) ; get exact position on the list
  113. LaunderedItem = flCleanClothes.GetAt(index) ; Replace transfer item with clean version
  114. EndIf
  115.  
  116. ClothesDestination.AddItem(LaunderedItem, 1, true) ; Silently add item to dryer
  117. obSender.RemoveItem(akBaseItem, 1, true) ; Silently delete item from washer
  118.  
  119. Bool bInstanceID = pFXHumanCannibalGush.PlayAndWait(akSourceContainer) ; Assign & play gurgling sound. When finished,
  120. Int iInstanceID = pDRSFacilityXBlastOpenEBuzzer.Play(akSourceContainer) ; assign & play buzzer sound
  121.  
  122. EndEvent
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement