Advertisement
ThoraldGM

DCS Quest Script (OnInit fragment)

Sep 29th, 2017
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.96 KB | None | 0 0
  1. ; ------------------------------------------------------------------------------------------------------------
  2. ; EVENT: ON INIT
  3. ; ------------------------------------------------------------------------------------------------------------
  4.  
  5. Event OnInit()
  6.  
  7. ; ********************************************************************************************************
  8. ; ASSIGN PLAYER'S CHOICE (LOCKER, DESK, OR CABINET) AS GUARD GEAR CONTAINER
  9. ; ********************************************************************************************************
  10.  
  11. Int PlayerChoice = gvGearContainerChoice.GetValue() as Int ; Did player choose 1, 2, or 3
  12.  
  13. If PlayerChoice == 3
  14. raGearContainer.ForceRefTo(raCabinet.GetReference()) ; If 3, assign cabinet
  15. ElseIf PlayerChoice == 2
  16. raGearContainer.ForceRefTo(raDesk.GetReference()) ; If 2, assign desk
  17. Else
  18. raGearContainer.ForceRefTo(raLocker.GetReference()) ; Else assign locker (default)
  19. EndIf
  20.  
  21. ; ********************************************************************************************************
  22. ; IF CHOICE HAS BEEN SCRAPPED BY PLAYER OR OTHERWISE MISSING, REASSIGN GUARD GEAR CONTAINER
  23. ; ********************************************************************************************************
  24.  
  25. Int RedirectAttempts = 0 ; How many ref changes attempted?
  26. String strFoundRef = "NONE" ; Placeholder string for dev tracker
  27.  
  28. While (raGearContainer.GetReference() == None) && RedirectAttempts < 3 ; Make 3 attempts if scrapped
  29. RedirectAttempts += 1 ; Increment number of attempts
  30.  
  31. PlayerChoice += 1 ; Select the next available choice
  32.  
  33. If PlayerChoice == 4 ; If choice is out of bounds,
  34. PlayerChoice = 1 ; next choice is the first option
  35. EndIf
  36.  
  37. If PlayerChoice == 3
  38. raGearContainer.ForceRefTo(raCabinet.GetReference()) ; If 3, assign cabinet
  39. strFoundRef = "cabinet"
  40. ElseIf PlayerChoice == 2
  41. raGearContainer.ForceRefTo(raDesk.GetReference()) ; If 2, assign desk
  42. strFoundRef = "desk"
  43. Else
  44. raGearContainer.ForceRefTo(raLocker.GetReference()) ; Else assign locker (default)
  45. strFoundRef = "locker"
  46. EndIf
  47.  
  48. EndWhile
  49.  
  50. ; ********************************************************************************************************
  51. ; ANNOUNCE RESULTS AND WARN IF ALL THREE OPTIONS WERE SCRAPPED BY PLAYER OR NOT FOUND
  52. ; ********************************************************************************************************
  53.  
  54. ; Mod requires guard gear container to be accessible by player. If no accessible container, can't use mod.
  55.  
  56. ; Replace message box debug with message box show. Critical message should display on all platforms!
  57.  
  58. If raGearContainer.GetReference() == None
  59. Debug.MessageBox("Diamond City SWAT: No containers found! Uninstall mod and contact ThoraldGM asap.")
  60. Else
  61. If gvDevTracking.GetValue() == 1
  62. Debug.Notification("DCS: Guard gear is in " + strFoundRef + ".")
  63. EndIf
  64. EndIf
  65.  
  66. ; ********************************************************************************************************
  67. ; SET OWNERSHIP OF GUARD GEAR CONTAINER SO PLAYER DOESN'T STEAL ITEMS AND GET ATTACKED
  68. ; ********************************************************************************************************
  69.  
  70. obGearContainer = raGearContainer.GetReference() ; Grab ObjRef of the RefAlias
  71. Cell GearContainerCell = obGearContainer.GetParentCell() ; Grab parent cell of the ObjRef
  72. GearContainerCell.SetFactionOwner(pPlayerFaction) ; Remove stolen flag from cell/container
  73.  
  74. ; This method makes everything in Security Office belong to the player, including the jail key.
  75. ; I would rather change flag on the container only, but obGearContainer.SetActorOwner(NONE) didn't work.
  76. ; I may also look into making player ownership of the Security Office a MCM option that can be toggled.
  77.  
  78. ; Note that choosing Arturo's "All Others Pay Caps" cabinet changes Market, not Security Office!
  79.  
  80. ; ********************************************************************************************************
  81. ; WARN PLAYER IF CONTAINER IS STILL DANGEROUS
  82. ; ********************************************************************************************************
  83.  
  84. Bool bPlayerOwns = (GearContainerCell.GetFactionOwner() == pPlayerFaction)
  85.  
  86. If !bPlayerOwns
  87. ; This first notification is a critical warning, so display even if player doesn't want dev messages.
  88. ; Criticals are rare. Dev messages are spammy. Dev messages default to off in final version.
  89.  
  90. Debug.Notification("DCS: SET FACTION FAILED!") ; Show notice on top left screen corner
  91. Debug.Trace("DIAMOND CITY SWAT: SET FACTION FAILED!") ; Write warning in log file
  92. Else
  93. If gvDevTracking.GetValue() == 1 ; If player wants developer messages
  94. Debug.Notification("DCS: Player owns cell.") ; inform player that faction updated
  95. EndIf
  96. EndIf
  97.  
  98. [ .... THIS IS A FRAGMENT .... REST OF ONINIT FOLLOWS IN ORIGINAL FILE ... ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement