Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Scriptname DCS_Laundry_Script extends Quest
- { It just works. }
- ; DIAMOND CITY SWAT VERSION 2.0: https://www.nexusmods.com/fallout4/mods/10893/
- ; A FALLOUT 4 MOD BY @THORALDGM | THORALDGM.COM | SCRIPT UPDATED 20170926
- ;
- ; This script makes washers functional in Diamond City security office. Max compatibility with other mods.
- ;
- ; PERMISSIONS:
- ;
- ; - Do not repost my mod. If you want to tweak minor changes, send me the esp and I will post it in Files.
- ; - Language translations are allowed only on same platforms where I posted mod. Please mail link when done.
- ; - This mod may not be folded entirely into a larger work without my written permission and collaboration.
- ; - Please ask if you want to use parts of my code to improve other mods. Must be unique and credit source.
- ;
- ; - If you have any questions, or see a better way to do something, please let me know.
- ;
- ; SCRIPT SECTIONS:
- ;
- ; LINE 041: PROPERTIES
- ; LINE 062: ON INIT
- ; LINE 096: IS WASHER AVAILABLE
- ; LINE 123: ENABLE LAUNDRY
- ; LINE 133: DISABLE LAUNDRY
- ; LINE 149: ON ITEM ADDED
- ;
- ; WARNINGS:
- ;
- ; - ANYTHING PLACED IN WASHER WILL BE STRIPPED OF ARMOR/WEAPON MODS DURING TRANSFER TO DRYER!
- ; - WEAPONS PLACED IN WASHER WILL GENERATE SMALL AMOUNTS OF AMMO IN DRYER. THIS CAN BE FARMED/REPEATED.
- ;
- ; This does not create working washers/dryers in workshops. For that functionality, check out these mods:
- ; - Functional Washer: https://www.nexusmods.com/fallout4/mods/14402/
- ; - Laundry Day: https://www.nexusmods.com/fallout4/mods/9042/
- ;
- ; Other laundromats in game that could benefit from this method:
- ; - http://fallout.wikia.com/wiki/Charlestown_laundry
- ; - http://fallout.wikia.com/wiki/Faded_Glory_laundromat
- ; ------------------------------------------------------------------------------------------------------------
- ; PROPERTIES
- ; ------------------------------------------------------------------------------------------------------------
- FormList Property flCleanClothes Auto Const Mandatory ; FormList of clean clothes
- FormList Property flDirtyClothes Auto Const Mandatory ; FormList of dirty clothes
- ReferenceAlias Property raWasher1 Auto Const ; Left washer
- ReferenceAlias Property raWasher2 Auto Const ; Center washer
- ReferenceAlias Property raWasher3 Auto Const ; Right washer
- ReferenceAlias Property raDryer1 Auto Const ; Left dryer
- ReferenceAlias Property raDryer2 Auto Const ; Center dryer
- ReferenceAlias Property raDryer3 Auto Const ; Right dryer
- Sound Property pFXHumanCannibalGush Auto Const Mandatory ; Gurgling sound for washers
- Sound Property pDRSFacilityXBlastOpenEBuzzer Auto Const Mandatory ; Buzzer sound for dryers
- GlobalVariable Property gvDevTracking Auto Mandatory ; Are dev messages turned on
- GlobalVariable Property gvPlayerWantsLaundry Auto Mandatory ; Does player want working washers
- ; ------------------------------------------------------------------------------------------------------------
- ; EVENT: ON INIT
- ; ------------------------------------------------------------------------------------------------------------
- Event OnInit()
- If gvPlayerWantsLaundry.GetValue() == 1 ; If player wants working washers...
- If IsWasherAvailable(raWasher1) ; If left washer is available,
- EnableLaundry(raWasher1) ; enable left washer functionality.
- If gvDevTracking.GetValue() == 1 ; Inform dev tracker.
- Debug.Notification("DCS: Left washer enabled.")
- EndIf
- EndIf
- If IsWasherAvailable(raWasher2) ; If center washer is available,
- EnableLaundry(raWasher2) ; enable center washer functionality.
- If gvDevTracking.GetValue() == 1 ; Inform dev tracker.
- Debug.Notification("DCS: Center washer enabled.")
- EndIf
- EndIf
- If IsWasherAvailable(raWasher3) ; If right washer is available,
- EnableLaundry(raWasher3) ; enable right washer functionality.
- If gvDevTracking.GetValue() == 1 ; Inform dev tracker.
- Debug.Notification("DCS: Right washer enabled.")
- EndIf
- EndIf
- EndIf
- EndEvent
- ; ------------------------------------------------------------------------------------------------------------
- ; CUSTOM FUNCTION: IS WASHER AVAILABLE
- ; ------------------------------------------------------------------------------------------------------------
- Bool Function IsWasherAvailable(ReferenceAlias raMachine)
- ObjectReference obMachine ; Prepare to get objref of refalias
- If !raMachine ; If no refalias passed to function
- return False ; tell caller washer not available
- ElseIf raMachine != raWasher1 && raMachine != raWasher2 && raMachine != raWasher3
- return False ; If not security office washer, decline.
- Else
- obMachine = raMachine.GetReference() ; otherwise fill objref and continue
- EndIf
- ; ********************************************************************************************************
- ; FUNCTION ONLY PROCEEDS PAST THIS POINT IF CALLER IS ASKING ABOUT A SECURITY OFFICE WASHER!
- ; ********************************************************************************************************
- If !obMachine || obMachine.IsDisabled() || obMachine.IsDeleted() ; If washer is scrapped or wack
- return False ; tell caller washer not available
- Else
- return True ; otherwise washer is good to go!
- EndIf
- EndFunction
- ; ------------------------------------------------------------------------------------------------------------
- ; CUSTOM FUNCTION: ENABLE LAUNDRY
- ; ------------------------------------------------------------------------------------------------------------
- Function EnableLaundry(ReferenceAlias raMachine)
- AddInventoryEventFilter(None) ; Required filter for OnItemAdded
- Utility.Wait(0.1) ; Let stack apply filter before registrations
- RegisterForRemoteEvent(raMachine, "OnItemAdded") ; Listen for washer event on ref passed to function
- EndFunction
- ; ------------------------------------------------------------------------------------------------------------
- ; CUSTOM FUNCTION: DISABLE LAUNDRY
- ; ------------------------------------------------------------------------------------------------------------
- Function DisableLaundry()
- RemoveAllInventoryEventFilters() ; Remove the required OnItemAdded filter
- UnregisterForRemoteEvent(raWasher1, "OnItemAdded") ; Stop listening for left washer event
- UnregisterForRemoteEvent(raWasher2, "OnItemAdded") ; Stop listening for center washer event
- UnregisterForRemoteEvent(raWasher3, "OnItemAdded") ; Stop listening for right washer event
- If gvDevTracking.GetValue() == 1 ; Inform dev tracker.
- Debug.Notification("DCS: Laundry disabled.")
- EndIf
- EndFunction
- ; ------------------------------------------------------------------------------------------------------------
- ; EVENT: ON ITEM ADDED
- ; ------------------------------------------------------------------------------------------------------------
- Event ReferenceAlias.OnItemAdded(ReferenceAlias akSender, Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
- ; ********************************************************************************************************
- ; PAIR INCOMING WASHER WITH OUTGOING DRYER
- ; ********************************************************************************************************
- Form LaunderedItem = akBaseItem ; Store item for pending transfer
- ObjectReference obSender = akSender.GetReference() ; Get objref of the washer refalias
- ObjectReference ClothesDestination ; Prepare to assign a dryer
- String GoWhere ; String for assigned dryer
- If akSender == raWasher1
- ClothesDestination = raDryer1.GetReference() ; Left washer targets left dryer
- GoWhere = "left"
- ElseIf akSender == raWasher2
- ClothesDestination = raDryer2.GetReference() ; Center washer targets center dryer
- GoWhere = "center"
- Else
- ClothesDestination = raDryer3.GetReference() ; Right washer targets right dryer
- GoWhere = "right"
- EndIf
- If gvDevTracking.GetValue() == 1
- Debug.Notification("DCS: Destination is " + GoWhere + " dryer.") ; Inform dev tracker.
- EndIf
- ; ********************************************************************************************************
- ; SWAP OUTGOING ITEM WITH CLEAN ITEM IF AVAILABLE
- ; ********************************************************************************************************
- If flDirtyClothes.HasForm(akBaseItem) ; If item is on dirty clothes list
- Int index = flDirtyClothes.Find(akBaseItem) ; get exact position on the list
- LaunderedItem = flCleanClothes.GetAt(index) ; Replace transfer item with clean version
- EndIf
- ; ********************************************************************************************************
- ; REMOVE ITEM FROM WASHER, ADD OUTGOING ITEM TO DRYER, PLAY GURGLING & BUZZER SOUNDS
- ; ********************************************************************************************************
- ClothesDestination.AddItem(LaunderedItem, 1, true) ; Silently add item to dryer
- obSender.RemoveItem(akBaseItem, 1, true) ; Silently delete item from washer
- Bool bInstanceID = pFXHumanCannibalGush.PlayAndWait(akSourceContainer) ; Assign & play gurgling sound. When finished,
- Int iInstanceID = pDRSFacilityXBlastOpenEBuzzer.Play(akSourceContainer) ; assign & play buzzer sound
- EndEvent
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement