Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; ------------------------------------------------------------------------------------------------------------
- ; EVENT: ON INIT
- ; ------------------------------------------------------------------------------------------------------------
- Event OnInit()
- ; ********************************************************************************************************
- ; ASSIGN PLAYER'S CHOICE (LOCKER, DESK, OR CABINET) AS GUARD GEAR CONTAINER
- ; ********************************************************************************************************
- Int PlayerChoice = gvGearContainerChoice.GetValue() as Int ; Did player choose 1, 2, or 3
- If PlayerChoice == 3
- raGearContainer.ForceRefTo(raCabinet.GetReference()) ; If 3, assign cabinet
- ElseIf PlayerChoice == 2
- raGearContainer.ForceRefTo(raDesk.GetReference()) ; If 2, assign desk
- Else
- raGearContainer.ForceRefTo(raLocker.GetReference()) ; Else assign locker (default)
- EndIf
- ; ********************************************************************************************************
- ; IF CHOICE HAS BEEN SCRAPPED BY PLAYER OR OTHERWISE MISSING, REASSIGN GUARD GEAR CONTAINER
- ; ********************************************************************************************************
- Int RedirectAttempts = 0 ; How many ref changes attempted?
- String strFoundRef = "NONE" ; Placeholder string for dev tracker
- While (raGearContainer.GetReference() == None) && RedirectAttempts < 3 ; Make 3 attempts if scrapped
- Debug.Notification("DCS: Container not found. Redirecting...") ; Notify player of error correction
- RedirectAttempts += 1 ; Increment number of attempts
- PlayerChoice += 1 ; Select the next available choice
- If PlayerChoice == 4 ; If choice is out of bounds,
- PlayerChoice = 1 ; next choice is the first option
- EndIf
- If PlayerChoice == 3
- raGearContainer.ForceRefTo(raCabinet.GetReference()) ; If 3, assign cabinet
- strFoundRef = "cabinet"
- ElseIf PlayerChoice == 2
- raGearContainer.ForceRefTo(raDesk.GetReference()) ; If 2, assign desk
- strFoundRef = "desk"
- Else
- raGearContainer.ForceRefTo(raLocker.GetReference()) ; Else assign locker (default)
- strFoundRef = "locker"
- EndIf
- If strFoundRef != "NONE"
- Debug.Notification("DCS: Reassigned to " + strFoundRef + ".") ; Notify player of change
- EndWhile
- ; ********************************************************************************************************
- ; ANNOUNCE RESULTS AND WARN IF ALL THREE OPTIONS WERE SCRAPPED BY PLAYER OR NOT FOUND
- ; ********************************************************************************************************
- ; Mod requires guard gear container to be accessible by player. If no accessible container, fail forward.
- ; Replace message box debug with message box show. Critical message should display on all platforms!
- If raGearContainer.GetReference() == None
- Debug.MessageBox("Diamond City SWAT: No containers found! Proceeding with default gear.")
- gvGearContainerChoice.SetValue(0) ; Flag script as using default gear instead of player container!
- Else
- If gvDevTracking.GetValue() == 1
- Debug.Notification("DCS: Guard gear is in " + strFoundRef + ".")
- EndIf
- EndIf
- ; ********************************************************************************************************
- ; SET OWNERSHIP OF GUARD GEAR CONTAINER SO PLAYER DOESN'T STEAL ITEMS AND GET ATTACKED
- ;
- ; NOTE THAT EVERYTHING FROM HERE TO THE END OF ONINIT ONLY HAPPENS IF PLAYER HAS CONTAINER ACCESS!
- ; ********************************************************************************************************
- If gvGearContainerChoice.GetValue() as Int != 0 ; If using locker, desk, or cabinet...
- obGearContainer = raGearContainer.GetReference() ; Grab ObjRef of the RefAlias
- Cell GearContainerCell = obGearContainer.GetParentCell() ; Grab parent cell of the ObjRef
- GearContainerCell.SetFactionOwner(pPlayerFaction) ; Remove stolen flag from cell/container
- ; This method makes everything in Security Office belong to the player, including the jail key.
- ; I would rather change flag on the container only, but obGearContainer.SetActorOwner(NONE) didn't work.
- ; I may also look into making player ownership of the Security Office a MCM option that can be toggled.
- ; Note that choosing Arturo's "All Others Pay Caps" cabinet changes Market, not Security Office!
- ; ****************************************************************************************************
- ; WARN PLAYER IF CONTAINER IS STILL DANGEROUS
- ; ****************************************************************************************************
- Bool bPlayerOwns = (GearContainerCell.GetFactionOwner() == pPlayerFaction)
- If !bPlayerOwns
- ; This first notification is a critical warning, so display even if player doesn't want dev messages.
- ; Criticals are rare. Dev messages are spammy. Dev messages default to off in final version.
- Debug.Notification("DCS: SET FACTION FAILED!") ; Show notice on top left screen corner
- Debug.Trace("DIAMOND CITY SWAT: SET FACTION FAILED!") ; Write warning in log file
- Else
- If gvDevTracking.GetValue() == 1 ; If player wants developer messages
- Debug.Notification("DCS: Player owns cell.") ; inform player that faction updated
- EndIf
- EndIf
- ; ****************************************************************************************************
- ; POPULATE LIST OF SLOT NAME STRINGS FOR DEV MESSAGES
- ; ****************************************************************************************************
- strSortedItems = new string[24]
- strSortedItems[0] = "headgear"
- strSortedItems[1] = "outfit"
- strSortedItems[2] = "gloves"
- strSortedItems[3] = "bracelet"
- strSortedItems[4] = "jacket"
- strSortedItems[5] = "top"
- strSortedItems[6] = "leg addon"
- strSortedItems[7] = "bottom"
- strSortedItems[8] = "chestplate"
- strSortedItems[9] = "left arm"
- strSortedItems[10] = "right arm"
- strSortedItems[11] = "left leg"
- strSortedItems[12] = "right leg"
- strSortedItems[13] = "full mask"
- strSortedItems[14] = "eyewear"
- strSortedItems[15] = "partial mask"
- strSortedItems[16] = "neckwear"
- strSortedItems[17] = "ring"
- strSortedItems[18] = "cloak or pack"
- strSortedItems[19] = "satchel"
- strSortedItems[20] = "bandolier"
- strSortedItems[21] = "cargo"
- strSortedItems[22] = "gun on back"
- strSortedItems[23] = "left hand item"
- If gvDevTracking.GetValue() == 1
- Debug.Notification("DCS: Strings filled.")
- EndIf
- ; ****************************************************************************************************
- ; IF PLAYER HAS AWKCR MOD INSTALLED, START INTER-MOD COMMUNICATION AND GRAB NECESSARY FORMS
- ; ****************************************************************************************************
- ArmorKywds = new keyword[24] ; There are 24 biped slots that are most relevant to armors.
- bModInstalled = Game.IsPluginInstalled("ArmorKeywords.esm")
- Utility.Wait(0.1) ; Give stack a moment to find mod before I start grabbing forms.
- If bModInstalled
- ; AWKCR keyword IDs for biped armor slots are from Gambit77's Armorsmith Extended tutorial:
- ; https://forums.nexusmods.com/index.php?showtopic=3687915
- ; See also:
- ; https://www.creationkit.com/fallout4/index.php?title=Biped_Slots
- ; https://www.creationkit.com/fallout4/index.php?title=Inter-mod_Communication
- ArmorKywds[0] = Game.GetFormFromFile(0x01000813, "ArmorKeywords.esm") as Keyword
- ArmorKywds[1] = Game.GetFormFromFile(0x0100081E, "ArmorKeywords.esm") as Keyword
- ArmorKywds[2] = Game.GetFormFromFile(0x0100081D, "ArmorKeywords.esm") as Keyword
- ArmorKywds[3] = Game.GetFormFromFile(0x01000831, "ArmorKeywords.esm") as Keyword
- ArmorKywds[4] = Game.GetFormFromFile(0x01000832, "ArmorKeywords.esm") as Keyword
- ArmorKywds[5] = Game.GetFormFromFile(0x0100081B, "ArmorKeywords.esm") as Keyword
- ArmorKywds[6] = Game.GetFormFromFile(0x01000833, "ArmorKeywords.esm") as Keyword
- ArmorKywds[7] = Game.GetFormFromFile(0x0100081C, "ArmorKeywords.esm") as Keyword
- ArmorKywds[8] = Game.GetFormFromFile(0x0100080E, "ArmorKeywords.esm") as Keyword
- ArmorKywds[9] = Game.GetFormFromFile(0x01000803, "ArmorKeywords.esm") as Keyword
- ArmorKywds[10] = Game.GetFormFromFile(0x01000804, "ArmorKeywords.esm") as Keyword
- ArmorKywds[11] = Game.GetFormFromFile(0x01000805, "ArmorKeywords.esm") as Keyword
- ArmorKywds[12] = Game.GetFormFromFile(0x01000806, "ArmorKeywords.esm") as Keyword
- ArmorKywds[13] = Game.GetFormFromFile(0x0100080F, "ArmorKeywords.esm") as Keyword
- ArmorKywds[14] = Game.GetFormFromFile(0x0100080C, "ArmorKeywords.esm") as Keyword
- ArmorKywds[15] = Game.GetFormFromFile(0x01000801, "ArmorKeywords.esm") as Keyword
- ArmorKywds[16] = Game.GetFormFromFile(0x01000810, "ArmorKeywords.esm") as Keyword
- ArmorKywds[17] = Game.GetFormFromFile(0x0100081F, "ArmorKeywords.esm") as Keyword
- ArmorKywds[18] = Game.GetFormFromFile(0x01000839, "ArmorKeywords.esm") as Keyword
- ArmorKywds[19] = Game.GetFormFromFile(0x01000834, "ArmorKeywords.esm") as Keyword
- ArmorKywds[20] = Game.GetFormFromFile(0x01000838, "ArmorKeywords.esm") as Keyword
- ArmorKywds[21] = Game.GetFormFromFile(0x01000836, "ArmorKeywords.esm") as Keyword
- ArmorKywds[22] = Game.GetFormFromFile(0x0100083E, "ArmorKeywords.esm") as Keyword
- ArmorKywds[23] = Game.GetFormFromFile(0x01000837, "ArmorKeywords.esm") as Keyword
- AK_Slot30_Hat = Game.GetFormFromFile(0x0100080D, "ArmorKeywords.esm") as Keyword
- AK_Slot36_Bracelet = Game.GetFormFromFile(0x01000811, "ArmorKeywords.esm") as Keyword
- AK_Slot46_Headband = Game.GetFormFromFile(0x0100083F, "ArmorKeywords.esm") as Keyword
- AK_Slot46_MaskFull = Game.GetFormFromFile(0x0100083A, "ArmorKeywords.esm") as Keyword
- AK_Slot49_Mouth = Game.GetFormFromFile(0x0100083B, "ArmorKeywords.esm") as Keyword
- AK_Slot50_Scarf = Game.GetFormFromFile(0x0100083D, "ArmorKeywords.esm") as Keyword
- AK_Slot54_Pack = Game.GetFormFromFile(0x01000824, "ArmorKeywords.esm") as Keyword
- AK_Slot55_GunOnHip = Game.GetFormFromFile(0x0100083C, "ArmorKeywords.esm") as Keyword
- AK_Slot55_Satchel = Game.GetFormFromFile(0x01000861, "ArmorKeywords.esm") as Keyword
- AK_Slot56_Harness = Game.GetFormFromFile(0x01000835, "ArmorKeywords.esm") as Keyword
- AK_Slot58_Piercing = Game.GetFormFromFile(0x01000812, "ArmorKeywords.esm") as Keyword
- If gvDevTracking.GetValue() == 1
- Debug.Notification("DCS: AWKCR handled.")
- EndIf
- EndIf
- ; ****************************************************************************************************
- ; REGISTER (START LISTENING) FOR REMOTE EVENTS, SO SCRIPT CAN REACT
- ; ****************************************************************************************************
- AddInventoryEventFilter(None) ; Required filter for OnItemAdded and OnItemRemoved
- Utility.Wait(0.1) ; Give stack a moment to set up required filter before I register events.
- RegisterForRemoteEvent(raGearContainer, "OnItemAdded") ; Do something when items added to gear container
- RegisterForRemoteEvent(raGearContainer, "OnItemRemoved") ; Do something when items removed from gear container
- Else
- ; Else player scrapped all containers and is using fail forward default, so no custom gear functionality.
- EndIf
- EndEvent
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement