Advertisement
ThoraldGM

Scavver "moves, loots, & builds" in unloaded cell

Nov 19th, 2017
529
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.58 KB | None | 0 0
  1. Scriptname ScavverUnloadedAlgorithm extends Package
  2. { It just works. }
  3.  
  4. ; SCAVVER MOD BY @THORALDGM | [email protected] | SCRIPT UPDATED 20160706
  5.  
  6. ; -----------------------------------------------------------------------------------------------------------
  7. ; PROPERTIES
  8. ; -----------------------------------------------------------------------------------------------------------
  9.  
  10. ObjectReference Property pScavver Auto Const Mandatory ; Scavver ObjRef
  11. Actor Property pScavverActor Auto Const Mandatory ; Scavver ActorRef
  12.  
  13. GlobalVariable Property pgvScavverStatusSniffer Auto Mandatory ; Does player have Scavver dev tracking on?
  14. GlobalVariable Property pgvScavverIsInLimbo Auto Mandatory ; Is Scavver in an unloaded cell?
  15.  
  16. ObjectReference Property pScavverMarker Auto Const Mandatory ; Alert system for stuck NPCs
  17. ObjectReference Property pScavverTriggerVolume Auto Const Mandatory ; Trigger volume is stuck path failsafe
  18. ObjectReference Property pScavMarker000 Auto Const Mandatory ; Scavver's moving target for travel location
  19.  
  20. ObjectReference[] Property arScavMarkers Auto ; Array of ScavMarkers (0 = 100, 1 = 101 ...)
  21. GlobalVariable Property pgvScavverCurrentMarker Auto Mandatory ; Track route progress / location (0 to 22)
  22.  
  23. GlobalVariable Property pgvScavverLootedArea Auto Mandatory ; Condition for package stack. Important!
  24. GlobalVariable Property pgvScavverDoNotLootHere Auto Mandatory
  25. GlobalVariable Property pgvScavverIsHome Auto Mandatory
  26. GlobalVariable Property pgvScavverStartRoute Auto Mandatory
  27. GlobalVariable Property pgvScavverLapsCompleted Auto Mandatory
  28.  
  29. ScavverUtilityScript Property pScavverUtilityScript Auto Const Mandatory
  30. ObjectReference Property pTgmScavverUnloadedLoot Auto Const Mandatory
  31.  
  32. ; -----------------------------------------------------------------------------------------------------------
  33. ; EVENT: ON CELL LOAD (PLAYER HAS ARRIVED, RESUME SWEEP AND TRAVEL PACKAGES)
  34. ; -----------------------------------------------------------------------------------------------------------
  35.  
  36. Event ObjectReference.OnCellLoad(ObjectReference akSender)
  37. pgvScavverIsInLimbo.SetValue(0) ; Remove limbo flag
  38. pgvScavverLootedArea.SetValue(1) ; Flag area as looted
  39. pgvScavverDoNotLootHere.SetValue(0)
  40. pgvScavverIsHome.SetValue(0) ; No longer staying home
  41. pgvScavverStartRoute.SetValue(1) ; Ok to start route again
  42.  
  43. ; THESE ARE THE 5 CONDITION FLAGS FOR PACKAGE STACK. THIS MEANS SCAVVER WILL TRAVEL ON CELL LOAD!
  44.  
  45. UnregisterForRemoteEvent(pScavverActor, "OnCellLoad") ; Stop listening for event
  46.  
  47. CancelTimer(1) ; Cancel limbo timer
  48. CancelTimer(2) ; Cancel wait at home timer
  49. CancelTimer(3) ; Cancel loot container reset
  50.  
  51. If pgvScavverStatusSniffer.GetValue() == 1
  52. Debug.Notification("Scavver exited limbo as player arrived.") ; Notify Scavver is exiting limbo
  53. EndIf
  54.  
  55. pScavverActor.EvaluatePackage() ; Wake up and resume normal behavior
  56. EndEvent
  57.  
  58. ; -----------------------------------------------------------------------------------------------------------
  59. ; EVENT: ON START ("Called when the package starts.")
  60. ; -----------------------------------------------------------------------------------------------------------
  61.  
  62. Event OnStart(Actor akActor)
  63. int CurrentMarker = pgvScavverCurrentMarker.GetValue() as int ; Pkg only runs if Scavver is in limbo
  64.  
  65. pScavver.MoveTo(arScavMarkers[CurrentMarker]) ; Move Scavver to current marker
  66. pScavMarker000.MoveTo(pScavver) ; Move travel marker to Scavver
  67. pScavverMarker.MoveTo(pScavver) ; Place distance marker at Scavver
  68. pScavverTriggerVolume.MoveTo(pScavver) ; Place trigger volume at Scavver
  69.  
  70. ; Debug.Trace("SCAVVER UNLOADED ALGORITHM: ON START FIRED")
  71. CancelTimer(1)
  72. StartTimer(600, 1) ; Stand in limbo for 10 minutes
  73.  
  74. If pgvScavverStatusSniffer.GetValue() == 1
  75. Debug.Notification("Scavver started limbo at marker #" + CurrentMarker + ".")
  76. EndIf
  77.  
  78. RegisterForRemoteEvent(pScavverActor, "OnCellLoad")
  79. EndEvent
  80.  
  81. ; -----------------------------------------------------------------------------------------------------------
  82. ; EVENT: ON TIMER
  83. ; -----------------------------------------------------------------------------------------------------------
  84.  
  85. Event OnTimer(int aiTimerID) ; Cancel timer
  86. int CurrentMarker = pgvScavverCurrentMarker.GetValue() as int
  87. int NextMarker
  88.  
  89. If aiTimerID == 1
  90. pTgmScavverUnloadedLoot.RemoveAllItems(pScavver, false) ; Move loot from "unloaded" container
  91. StartTimer(60, 3) ; Reset "unloaded" loot for next time
  92.  
  93. If pgvScavverStatusSniffer.GetValue() == 1
  94. Debug.Notification("Scavver completed limbo at marker #" + CurrentMarker + ".")
  95. EndIf
  96.  
  97. NextMarker = CurrentMarker + 1
  98.  
  99. If NextMarker == arScavMarkers.Length
  100. NextMarker = 0 ; SCAVVER IS MOVING TO VAULT 111 EXT
  101. pgvScavverIsHome.SetValue(1) ; Flag that Scavver has arrived home
  102. pgvScavverStartRoute.SetValue(0) ; Scavver will pause at home for building
  103. pgvScavverLapsCompleted.Mod(1) ; Increment number of laps completed
  104.  
  105. pScavMarker000.MoveTo(arScavMarkers[NextMarker]) ; Move travel marker to next location
  106. pScavver.MoveTo(pScavMarker000) ; Move Scavver to travel marker
  107. pScavverMarker.MoveTo(pScavver) ; Place distance marker at Scavver
  108. pScavverTriggerVolume.MoveTo(pScavver) ; Place trigger volume at Scavver
  109. pgvScavverCurrentMarker.SetValue(NextMarker as float)
  110.  
  111. pScavverUtilityScript.BuildScavverSettlement() ; Build next stage of settlement
  112. StartTimer(4320, 2) ; Wait one game day (72 RL minutes)
  113.  
  114. Else ; ELSE NOT MOVING TO VAULT 111 EXT
  115.  
  116. pScavMarker000.MoveTo(arScavMarkers[NextMarker]) ; Move travel marker to next location
  117. pScavver.MoveTo(pScavMarker000) ; Move Scavver to travel marker
  118. pScavverMarker.MoveTo(pScavver) ; Place distance marker at Scavver
  119. pScavverTriggerVolume.MoveTo(pScavver) ; Place trigger volume at Scavver
  120. pgvScavverCurrentMarker.SetValue(NextMarker as float)
  121.  
  122. pScavverActor.EvaluatePackage() ; This pkg will repeat until limbo == 0
  123. EndIf
  124.  
  125. ElseIf aiTimerID == 2 ; Entire home stay was in limbo
  126. pgvScavverIsHome.SetValue(0) ; No longer staying home
  127. pgvScavverStartRoute.SetValue(1) ; Ok to start route again
  128. Utility.Wait(1)
  129. pScavverActor.EvaluatePackage() ; Move along
  130.  
  131. ElseIf aiTimerID == 3
  132. pTgmScavverUnloadedLoot.Reset() ; Reset "unloaded" loot for next time
  133.  
  134. Else
  135. ; Timer is not 1-3, do nothing
  136. EndIf
  137. EndEvent
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement