Advertisement
ThoraldGM

Scavver Trigger Volume

Jul 9th, 2016
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.80 KB | None | 0 0
  1. Scriptname ScavverTriggerVolume extends ObjectReference
  2. { It just works. }
  3.  
  4. ; SCAVVER MOD BY @THORALDGM | THORALDGM AT GMAIL.COM | SCRIPT UPDATED 20160708
  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. FormList Property pScavverArmorAllowed Auto Const Mandatory ; Outfits allowed to wear
  14.  
  15. GlobalVariable Property pgvScavverStatusSniffer Auto Mandatory ; Is dev tracking on?
  16.  
  17. GlobalVariable Property pgvScavverCircledBack Auto Mandatory ; Number of times repeating path
  18. GlobalVariable Property pgvScavverCircleTimer Auto Mandatory ; Timer for window range
  19. GlobalVariable Property pgvScavverStatTimesCircled Auto Mandatory ; Total incremented number of times
  20. GlobalVariable Property pgvScavverWasStuck Auto Mandatory ; Was stuck flag
  21.  
  22. GlobalVariable Property pgvScavverDoNotLootHere Auto Mandatory ; THE FIVE PACKAGE STACK CONDITIONS
  23. GlobalVariable Property pgvScavverIsHome Auto Mandatory ; 2nd
  24. GlobalVariable Property pgvScavverIsInLimbo Auto Mandatory ; 3rd
  25. GlobalVariable Property pgvScavverLootedArea Auto Mandatory ; 4th
  26. GlobalVariable Property pgvScavverStartRoute Auto Mandatory ; 5th
  27.  
  28. Keyword Property pObjectTypeAmmo Auto Const Mandatory ; Ammo keyword
  29. Keyword Property pObjectTypeArmor Auto Const Mandatory ; Armor keyword
  30. Keyword Property pObjectTypeFood Auto Const Mandatory ; Food keyword
  31. Keyword Property pObjectTypeWeapon Auto Const Mandatory ; Weapon keyword
  32.  
  33. Potion Property pRadAway Auto Const Mandatory ; RadAway
  34.  
  35. Quest Property pScavverUtilityQuest Auto Const Mandatory ; Utility quest
  36.  
  37. ; -----------------------------------------------------------------------------------------------------------
  38. ; EVENT: ON TRIGGER ENTER
  39. ; -----------------------------------------------------------------------------------------------------------
  40.  
  41. Event OnTriggerEnter(ObjectReference akActionRef)
  42. If akActionRef == pScavver
  43. String PluralOrNot = "times"
  44. Float NumTimes
  45.  
  46. If pgvScavverWasStuck.GetValue() == 0
  47. pgvScavverCircledBack.SetValue(0)
  48. NumTimes = 0
  49. CancelTimerGameTime(1)
  50. pgvScavverCircleTimer.SetValue(0)
  51.  
  52. ; If pgvScavverStatusSniffer.GetValue() == 1
  53. ; Debug.Notification("Scavver volume timer cancelled.")
  54. ; EndIf
  55. Else
  56. pgvScavverCircledBack.Mod(1)
  57. NumTimes += 1
  58. EndIf
  59.  
  60. If NumTimes == 0 ; If this is the first visit
  61. ; If pgvScavverStatusSniffer.GetValue() == 1
  62. ; Debug.Notification("Scavver volume timer started.")
  63. ; EndIf
  64.  
  65. StartTimerGameTime(1.65, 1) ; and start 5 RL minute window (100 gminutes)
  66. pgvScavverCircleTimer.SetValue(1) ; (0.0165 x 20 gminutes/RLmin x 5 = 1.65)
  67. EndIf
  68.  
  69. If NumTimes == 1
  70. PluralOrNot = "time" ; time instead of times
  71. EndIf
  72.  
  73. ; If pgvScavverStatusSniffer.GetValue() == 1
  74. ; Debug.Notification("Scavver triggered volume " + NumTimes + " " + PluralOrNot + ".")
  75. ; EndIf
  76.  
  77. Bool CanLootHere = false ; ADDED 20160708 TO STOP SANCTUARY LOOTING!
  78.  
  79. Utility.Wait(1)
  80.  
  81. If pgvScavverIsInLimbo.GetValue() == 0
  82. If (pgvScavverIsHome.GetValue() == 0) || (pgvScavverStartRoute.GetValue() == 1)
  83. If pgvScavverDoNotLootHere.GetValue() == 0
  84. If pgvScavverLootedArea.GetValue() == 0
  85. CanLootHere = true ; ADDED 20160708 TO STOP SANCTUARY LOOTING!
  86. EndIf
  87. EndIf
  88. EndIf
  89. EndIf
  90.  
  91. Utility.Wait(1)
  92.  
  93. If (NumTimes > 3) && (CanLootHere == true) ; If this is the 3rd visit AND CAN LOOT HERE!
  94. If pgvScavverCircleTimer.GetValue() == 1 ; within 5 RL minute window
  95. ; grab all items he could be trying to access
  96. ; then reevaluate package so his AI moves him away from this trouble spot
  97.  
  98. If pgvScavverStatusSniffer.GetValue() == 1
  99. Debug.Notification("SCAVVER IS WALKING IN CIRCLES... FIXING")
  100. EndIf
  101.  
  102. ObjectReference[] kAmmoArray = pScavver.FindAllReferencesWithKeyword(pObjectTypeAmmo, 1000)
  103. ObjectReference[] kArmorArray = pScavver.FindAllReferencesWithKeyword(pObjectTypeArmor, 1000)
  104. ObjectReference[] kFoodArray = pScavver.FindAllReferencesWithKeyword(pObjectTypeFood, 1000)
  105. ObjectReference[] kWeaponArray = pScavver.FindAllReferencesWithKeyword(pObjectTypeWeapon, 1000)
  106. ObjectReference[] kRadArray = pScavver.FindAllReferencesOfType(pRadAway, 1000)
  107. Int i
  108. Int ArraySize
  109.  
  110. i = 0
  111. ArraySize = kAmmoArray.Length
  112. While (i < ArraySize)
  113. If (kAmmoArray[i].GetContainer() != Game.GetPlayer()) && (kAmmoArray[i].GetContainer() != pScavver)
  114. If !pScavverActor.WouldBeStealing(kAmmoArray[i]) && !kAmmoArray[i].IsQuestItem() && kAmmoArray[i].IsEnabled()
  115. pScavver.AddItem(kAmmoArray[i], 1, true)
  116. EndIf
  117. EndIf
  118. i += 1
  119. EndWhile
  120.  
  121. i = 0
  122. ArraySize = kArmorArray.Length
  123. While (i < ArraySize)
  124. If (kArmorArray[i].GetContainer() != Game.GetPlayer()) && (kArmorArray[i].GetContainer() != pScavver)
  125. If !pScavverActor.WouldBeStealing(kArmorArray[i]) && !kArmorArray[i].IsQuestItem() && kArmorArray[i].IsEnabled()
  126. pScavver.AddItem(kArmorArray[i], 1, true)
  127. EndIf
  128. EndIf
  129. i += 1
  130. EndWhile
  131.  
  132. i = 0
  133. ArraySize = kFoodArray.Length
  134. While (i < ArraySize)
  135. If (kFoodArray[i].GetContainer() != Game.GetPlayer()) && (kFoodArray[i].GetContainer() != pScavver)
  136. If !pScavverActor.WouldBeStealing(kFoodArray[i]) && !kFoodArray[i].IsQuestItem() && kFoodArray[i].IsEnabled()
  137. pScavver.AddItem(kFoodArray[i], 1, true)
  138. EndIf
  139. EndIf
  140. i += 1
  141. EndWhile
  142.  
  143. i = 0
  144. ArraySize = kWeaponArray.Length
  145. While (i < ArraySize)
  146. If (kWeaponArray[i].GetContainer() != Game.GetPlayer()) && (kWeaponArray[i].GetContainer() != pScavver)
  147. If !pScavverActor.WouldBeStealing(kWeaponArray[i]) && !kWeaponArray[i].IsQuestItem() && kWeaponArray[i].IsEnabled()
  148. pScavver.AddItem(kWeaponArray[i], 1, true)
  149. EndIf
  150. EndIf
  151. i += 1
  152. EndWhile
  153.  
  154. i = 0
  155. ArraySize = kRadArray.Length
  156. While (i < ArraySize)
  157. If (kRadArray[i].GetContainer() != Game.GetPlayer()) && (kRadArray[i].GetContainer() != pScavver)
  158. If !pScavverActor.WouldBeStealing(kRadArray[i]) && !kRadArray[i].IsQuestItem() && kRadArray[i].IsEnabled()
  159. pScavver.AddItem(kRadArray[i], 1, true)
  160. EndIf
  161. EndIf
  162. i += 1
  163. EndWhile
  164.  
  165. CancelTimerGameTime(1)
  166. pgvScavverCircleTimer.SetValue(0)
  167. pgvScavverCircledBack.SetValue(0) ; Reset global variable. Important!
  168. pgvScavverStatTimesCircled.Mod(1)
  169. pScavverUtilityQuest.UpdateCurrentInstanceGlobal(pgvScavverStatTimesCircled)
  170. pScavverActor.EvaluatePackage()
  171. EndIf
  172. EndIf
  173. EndIf
  174. EndEvent
  175.  
  176. ; -----------------------------------------------------------------------------------------------------------
  177. ; EVENT: ON TIMER GAME TIME
  178. ; -----------------------------------------------------------------------------------------------------------
  179.  
  180. Event OnTimerGameTime(int aiTimerID) ; Cancel timer
  181. pgvScavverCircleTimer.SetValue(0)
  182. pgvScavverCircledBack.SetValue(0) ; Reset global variable. Important!
  183. ; Debug.Notification("Scavver volume timer ended.")
  184. EndEvent
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement