Advertisement
ThoraldGM

HH Quest Script 20171227

Dec 27th, 2017
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.56 KB | None | 0 0
  1. Scriptname HH_QuestScript extends Quest
  2. { It just works. }
  3.  
  4. ;/
  5.  
  6. Fallout 4 Papyrus script by ThoraldGM | http://thoraldgm.com | Updated 20171227
  7. Hitchhiker mod: (url pending)
  8.  
  9. SCRIPT SECTIONS:
  10.  
  11. LINE 0030: PROPERTIES
  12. LINE 0168: ON INIT
  13. LINE 0212: HH START HITCHING
  14. LINE ####: (OPTIONAL AUTO TIME CHANGE)
  15. LINE ####: (OPTIONAL AUTO WEATHER CHANGE)
  16. LINE ####: HH SPIN CAMERA
  17. LINE ####: ON TIMER
  18. LINE ####: HH STOP SPINNING
  19. LINE ####: HH SET RANDOM DESTINATION
  20. LINE ####: HH IS IN FAR HARBOR
  21. LINE ####: HH IS IN NUKA WORLD
  22. LINE ####: IS FURNITURE
  23. LINE ####: HH TRY TO USE FURNITURE
  24. LINE ####: HH FORCE TIME
  25. LINE ####: HH FORCE WEATHER
  26.  
  27. /;
  28.  
  29. ; ------------------------------------------------------------------------------------------------------------
  30. ; PROPERTIES
  31. ; ------------------------------------------------------------------------------------------------------------
  32.  
  33. ; ************************************************************************************************************
  34. ; Player menu options (21 here. Plus Force Time Now, Force Weather Now, Spin Idle Camera Now, & Restore Defaults):
  35. ; ************************************************************************************************************
  36. GlobalVariable Property HH_OptionCamMaxDistance Auto Mandatory
  37. { Max camera distance (default: 200, vanilla: 150) }
  38. GlobalVariable Property HH_OptionCamMinDistance Auto Mandatory
  39. { Min camera distance (default: 100, vanilla: 0) }
  40. GlobalVariable Property HH_OptionDevTracking Auto Mandatory
  41. { Does player want dev messages? (default: no) }
  42. GlobalVariable Property HH_OptionExcludeDLC Auto Mandatory
  43. { Turn all DLC on/off in available destinations (default: on if installed) }
  44. GlobalVariable Property HH_OptionExcludeFH Auto Mandatory
  45. { Turn Far Harbor DLC on/off in destinations (default: on if installed) }
  46. GlobalVariable Property HH_OptionExcludeNW Auto Mandatory
  47. { Turn Nuka-World DLC on/off in destinations (default: on if installed) }
  48. GlobalVariable Property HH_OptionExcludeVT Auto Mandatory
  49. { Turn Vault-Tec DLC on/off in destinations (default: on if installed) }
  50. GlobalVariable Property HH_OptionFastTravel Auto Mandatory
  51. { Does player want loading screens? (default: yes) }
  52. GlobalVariable Property HH_OptionHeal Auto Mandatory
  53. { Does player want to heal after teleport? (default: no) }
  54. GlobalVariable Property HH_OptionOffsetX Auto Mandatory
  55. { Player can choose X offset (default: 250) }
  56. GlobalVariable Property HH_OptionOffsetY Auto Mandatory
  57. { Player can choose Y offset (default: 250) }
  58. GlobalVariable Property HH_OptionOffsetZ Auto Mandatory
  59. { Player can choose Z offset (default: 500) }
  60. GlobalVariable Property HH_OptionSetTime Auto Mandatory
  61. { Change time after teleport? (default: no) }
  62. GlobalVariable Property HH_OptionSetTimePreference Auto Mandatory
  63. { Preferred game hour (player sets in menu) }
  64. GlobalVariable Property HH_OptionSetWeather Auto Mandatory
  65. { Change weather after teleport? (default: no) }
  66. GlobalVariable Property HH_OptionSetWeatherPreference Auto Mandatory
  67. { Preferred game weather (player sets in menu) }
  68. GlobalVariable Property HH_OptionSitFurniture Auto Mandatory
  69. { If destination is furniture, choose whether to use it (default: yes) }
  70. GlobalVariable Property HH_OptionSpinCamera Auto Mandatory
  71. { Does player want teleport to spin camera? (default: yes) }
  72. GlobalVariable Property HH_OptionSpinDuration Auto Mandatory
  73. { How long should camera spin? (default: 20 seconds) }
  74. GlobalVariable Property HH_OptionSpinGhost Auto Mandatory
  75. { Does player want invulnerable spin? (default: yes) }
  76. GlobalVariable Property HH_OptionTeleportSound Auto Mandatory
  77. { Does player want teleport sound? (default: yes) }
  78.  
  79. ; ************************************************************************************************************
  80. ; Weather:
  81. ; ************************************************************************************************************
  82. Weather Property DefaultWeather Auto Const Mandatory
  83. { Default weather (outdoors) }
  84. Weather Property CommonwealthClear Auto Const Mandatory
  85. { Clear }
  86. Weather Property CommonwealthDusty Auto Const Mandatory
  87. { Dusty }
  88. Weather Property CommonwealthFoggy Auto Const Mandatory
  89. { Foggy }
  90. Weather Property CommonwealthMisty Auto Const Mandatory
  91. { Misty }
  92. Weather Property CommonwealthMistyRainy Auto Const Mandatory
  93. { Misty Rainy }
  94. Weather Property CommonwealthOvercast Auto Const Mandatory
  95. { Overcast }
  96. Weather Property CommonwealthGSRadstorm Auto Const Mandatory
  97. { Radstorm }
  98. Weather Property CommonwealthRain Auto Const Mandatory
  99. { Rain }
  100.  
  101. ; ************************************************************************************************************
  102. ; Everything else:
  103. ; ************************************************************************************************************
  104. Book Property HH_Map Auto Const Mandatory
  105. { Hitchhiker map }
  106. FormList Property HH_IsFurniture Auto Const Mandatory
  107. { Formlist of formlists of furnitures }
  108. GlobalVariable Property HH_IsSpinning Auto Mandatory
  109. { Is the camera currently spinning? }
  110. GlobalVariable Property HH_PlayerHasFH Auto Mandatory
  111. { Does player have Far Harbor DLC? }
  112. GlobalVariable Property HH_PlayerHasNW Auto Mandatory
  113. { Does player have Nuka-World DLC? }
  114. GlobalVariable Property HH_PlayerHasVT Auto Mandatory
  115. { Does player have Vault-Tec DLC? }
  116. GlobalVariable Property HH_Category Auto Mandatory
  117. { Which category did player select? }
  118. GlobalVariable Property HH_TargetID Auto Mandatory
  119. { Which location did player select? }
  120. GlobalVariable Property HH_ShowMenu Auto Mandatory
  121. { Don't show menu when map placed in inventory }
  122. GlobalVariable Property pGameHour Auto Mandatory
  123. { Current game hour (from vanilla CK) }
  124. Perk Property HH_TeleportNoFallDamage Auto Const Mandatory
  125. { Temp perk so teleport falls don't kill player }
  126. Sound Property DRSVertibirdFlightLoadOpen Auto Const Mandatory
  127. { Teleport start sound effect }
  128. Sound Property OBJHijackerTeleportOut2DA Auto Const Mandatory
  129. { Teleport end sound effect }
  130. STATIC Property pXMarker Auto Const Mandatory
  131. { Xmarker (from vanilla CK) }
  132. STATIC Property pXMarkerHeading Auto Const Mandatory
  133. { Xmarker heading (from vanilla CK) }
  134. STATIC Property pCOCMarkerHeading Auto Const Mandatory
  135. { COC Xmarker heading (from vanilla CK) }
  136.  
  137. Actor Player ; Player actor
  138.  
  139. String GO_FILE = "Fallout4.esm" ; Vanilla or DLC target destination?
  140.  
  141. Int BUS_SHELTERS = 1 ; Category ints (makes code easier to read)
  142. Int DINERS = 2
  143. Int DIVES = 3
  144. Int DRIVE_INS = 4
  145. Int FACTORIES = 5
  146. Int FARMS = 6
  147. Int JUNKYARDS = 7
  148. Int MILITARY_BASES = 8
  149. Int MONUMENTS = 9
  150. Int POWER_LIFTS = 10
  151. Int RED_ROCKETS = 11
  152. Int VAULTS = 12
  153.  
  154. Int[] Go_Dive ; Array of Dives (hex refIDs converted to decimal)
  155. Int[] Go_Bus
  156. Int[] Go_Diner
  157. Int[] Go_Drive
  158. Int[] Go_Factory
  159. Int[] Go_Farm
  160. Int[] Go_Junkyard
  161. Int[] Go_Military
  162. Int[] Go_Monument
  163. Int[] Go_Power
  164. Int[] Go_Red
  165. Int[] Go_Vault
  166.  
  167. ; ------------------------------------------------------------------------------------------------------------
  168. ; EVENT: ON INIT
  169. ; ------------------------------------------------------------------------------------------------------------
  170.  
  171. Event OnInit()
  172. Player = Game.GetPlayer() ; Player actor
  173. Utility.Wait(0.1) ; Wait a moment before using actor
  174.  
  175. If Player.GetItemCount(HH_Map) == 0 ; If player doesn't have hitchhiker map,
  176. HH_ShowMenu.SetValue(0) ; don't show menu when map placed in inventory
  177. Utility.Wait(5) ; wait 5 seconds
  178. Player.AddItem(HH_Map) ; spawn hitchhiker map in player inventory
  179. EndIf
  180.  
  181. Go_Dive = New Int[13] ; Array of Dives (hex refIDs converted to decimal)
  182. Go_Dive[0] = 101019 ; Colonial Taphouse
  183. Go_Dive[1] = 146480 ; Concord Speakeasy
  184. Go_Dive[2] = 280352 ; Doc Phosphate's Saloon (NUKA-WORLD DLC)
  185. Go_Dive[3] = 406929 ; Dugout Inn
  186. Go_Dive[4] = 2240517 ; Forest Grove Pub Buffet
  187. Go_Dive[5] = 313396 ; Gwinnett Restaurant
  188. Go_Dive[6] = 857986 ; Nahant Bar Restaurant
  189. Go_Dive[7] = 1534528 ; Prost Bar
  190. Go_Dive[8] = 1730482 ; Quincy Liquors
  191. Go_Dive[9] = 993894 ; Shamrock Taphouse
  192. Go_Dive[10] = 13532 ; The Last Plank (FAR HARBOR DLC)
  193. Go_Dive[11] = 1094147 ; The Third Rail
  194. Go_Dive[12] = 1835650 ; Ticker Tape Lounge
  195.  
  196. ; IF HEX CONVERSION METHOD WORKS FOR ALL 13 DIVE BARS, ADD REMAINING 196 DESTINATIONS HERE
  197. Go_Bus = New Int[10]
  198. Go_Diner = New Int[30]
  199. Go_Drive = New Int[12]
  200. Go_Factory = New Int[12]
  201. Go_Farm = New Int[12]
  202. Go_Junkyard = New Int[20]
  203. Go_Military = New Int[20]
  204. Go_Monument = New Int[30]
  205. Go_Power = New Int[15]
  206. Go_Red = New Int[25]
  207. Go_Vault = New Int[10]
  208.  
  209. EndEvent
  210.  
  211. ; ------------------------------------------------------------------------------------------------------------
  212. ; CUSTOM FUNCTION: HH START HITCHING
  213. ; ------------------------------------------------------------------------------------------------------------
  214.  
  215. Function HH_StartHitching()
  216. If HH_OptionDevTracking.GetValue() as Int == 1
  217. Debug.TraceAndBox("Hitchhiker: Started hitching...")
  218. EndIf
  219.  
  220. If HH_OptionTeleportSound.GetValue() as Int == 1 ; If player wants teleport sound,
  221. Int iInstanceID = DRSVertibirdFlightLoadOpen.Play(Player) ; play teleport start sound at player
  222. EndIf
  223.  
  224. Int Category = HH_Category.GetValue() as Int ; Retrieve Category from global
  225. Int TargetID = HH_TargetID.GetValue() as Int ; Retrieve TargetID from global
  226.  
  227. Player.AddPerk(HH_TeleportNoFallDamage) ; IMPORTANT: Temp perk so teleport falls don't kill player!
  228.  
  229. If HH_OptionSpinGhost.GetValue() as Int == 1 ; If player wants no spin damage (default)
  230. If HH_OptionSpinCamera.GetValue() as Int == 1 ; If player wants spincam after teleport,
  231. Player.SetGhost() ; IMPORTANT: Player immune to all damage!
  232. EndIf ; *** Set ghost now BEFORE the spin! ***
  233.  
  234. If HH_OptionDevTracking.GetValue() as Int == 1 ; If player wants dev messages...
  235. If Player.IsGhost() ; If player is a ghost,
  236. Debug.Notification("Hitchhiker: Player is a ghost!") ; display dev message
  237. EndIf
  238. EndIf
  239. EndIf ; NOTE: Unghosting happens in HH_SpinCamera()
  240.  
  241. If HH_OptionTeleportSound.GetValue() as Int == 1 ; If player wants teleport sound,
  242. Int iInstanceID = OBJHijackerTeleportOut2DA.Play(Player) ; play teleport end sound at player
  243. EndIf
  244.  
  245. ObjectReference DestinationMarker = Player.PlaceAtMe(pXMarker) ; Dynamically spawn xmarker at player
  246.  
  247. If HH_IsInFarHarbor(Category, TargetID) == 1
  248. Go_File = "DLCCoast.esm"
  249. ElseIf HH_IsInNukaWorld(Category, TargetID) == 1
  250. Go_File = "DLCNukaWorld.esm"
  251. ElseIf Category == VAULTS && TargetID == 5
  252. Go_File = "DLCworkshop03.esm"
  253. Else
  254. Go_File = "Fallout4.esm"
  255. EndIf
  256.  
  257. ObjectReference TargetObject ; Destination target as ObjectReference
  258.  
  259. ; Next block looks redundant but the alternative is to create 12 nested formlists and 209 destination globals in CK
  260.  
  261. If Category == BUS_SHELTERS
  262. DestinationMarker.MoveTo(Game.GetFormFromFile(Go_Bus[TargetID], Go_File) as ObjectReference) ; MoveTo LOADS destination
  263. TargetObject = Game.GetFormFromFile(Go_Bus[TargetID], Go_File) as ObjectReference ; THEN destination can be saved to variable
  264. ElseIf Category == DINERS
  265. DestinationMarker.MoveTo(Game.GetFormFromFile(Go_Diner[TargetID], Go_File) as ObjectReference)
  266. TargetObject = Game.GetFormFromFile(Go_Diner[TargetID], Go_File) as ObjectReference
  267. ElseIf Category == DIVES
  268. DestinationMarker.MoveTo(Game.GetFormFromFile(Go_Dive[TargetID], Go_File) as ObjectReference)
  269. TargetObject = Game.GetFormFromFile(Go_Dive[TargetID], Go_File) as ObjectReference
  270. ElseIf Category == DRIVE_INS
  271. DestinationMarker.MoveTo(Game.GetFormFromFile(Go_Drive[TargetID], Go_File) as ObjectReference)
  272. TargetObject = Game.GetFormFromFile(Go_Drive[TargetID], Go_File) as ObjectReference
  273. ElseIf Category == FACTORIES
  274. DestinationMarker.MoveTo(Game.GetFormFromFile(Go_Factory[TargetID], Go_File) as ObjectReference)
  275. TargetObject = Game.GetFormFromFile(Go_Factory[TargetID], Go_File) as ObjectReference
  276. ElseIf Category == FARMS
  277. DestinationMarker.MoveTo(Game.GetFormFromFile(Go_Farm[TargetID], Go_File) as ObjectReference)
  278. TargetObject = Game.GetFormFromFile(Go_Farm[TargetID], Go_File) as ObjectReference
  279. ElseIf Category == JUNKYARDS
  280. DestinationMarker.MoveTo(Game.GetFormFromFile(Go_Junkyard[TargetID], Go_File) as ObjectReference)
  281. TargetObject = Game.GetFormFromFile(Go_Junkyard[TargetID], Go_File) as ObjectReference
  282. ElseIf Category == MILITARY_BASES
  283. DestinationMarker.MoveTo(Game.GetFormFromFile(Go_Military[TargetID], Go_File) as ObjectReference)
  284. TargetObject = Game.GetFormFromFile(Go_Military[TargetID], Go_File) as ObjectReference
  285. ElseIf Category == MONUMENTS
  286. DestinationMarker.MoveTo(Game.GetFormFromFile(Go_Monument[TargetID], Go_File) as ObjectReference)
  287. TargetObject = Game.GetFormFromFile(Go_Monument[TargetID], Go_File) as ObjectReference
  288. ElseIf Category == POWER_LIFTS
  289. DestinationMarker.MoveTo(Game.GetFormFromFile(Go_Power[TargetID], Go_File) as ObjectReference)
  290. TargetObject = Game.GetFormFromFile(Go_Power[TargetID], Go_File) as ObjectReference
  291. ElseIf Category == RED_ROCKETS
  292. DestinationMarker.MoveTo(Game.GetFormFromFile(Go_Red[TargetID], Go_File) as ObjectReference)
  293. TargetObject = Game.GetFormFromFile(Go_Red[TargetID], Go_File) as ObjectReference
  294. Else
  295. Category = VAULTS
  296. DestinationMarker.MoveTo(Game.GetFormFromFile(Go_Vault[TargetID], Go_File) as ObjectReference)
  297. TargetObject = Game.GetFormFromFile(Go_Vault[TargetID], Go_File) as ObjectReference
  298. EndIf
  299.  
  300. STATIC TargetBase = TargetObject.GetBaseObject() as STATIC ; Check if target base object is an X/COC marker/header
  301.  
  302. If TargetBase == pXMarker || TargetBase == pXMarkerHeading || TargetBase == pCOCMarkerHeading
  303. ; Do not use XYZ offsets if destination is a marker, because teleport placed player directly on the X
  304. Else ; else move marker to static ref with XYZ offsets
  305. Float OffsetX = HH_OptionOffsetX.GetValue() ; Player sets X (default 250)
  306. Float OffsetY = HH_OptionOffsetY.GetValue() ; Player sets Y (default 250)
  307. Float OffsetZ = HH_OptionOffsetZ.GetValue() ; Player sets Z (default 500)
  308. Utility.Wait(0.1)
  309. DestinationMarker.MoveTo(DestinationMarker, OffsetX, OffsetY, OffsetZ) ; Move marker with XYZ offsets
  310. DestinationMarker.MoveToNearestNavmeshLocation() ; Then move marker to nearest navmesh
  311. EndIf
  312.  
  313. If HH_OptionFastTravel.GetValue() as Int == 1 ; If player wants loading screens,
  314. Game.FastTravel(DestinationMarker) ; move player to marker (with load screens?)
  315. Else
  316. Player.MoveTo(DestinationMarker) ; else move player (with black screen)
  317. EndIf
  318.  
  319. Utility.Wait(0.1)
  320.  
  321. ; "If TargetObject Is Furniture" caused illegal typecast compiler error, so I wrote a custom function
  322. HH_TryToUseFurniture(Player, TargetObject)
  323.  
  324. ; ********************************************************************************************************
  325. ; Optional automatic time change on teleport
  326. ; ********************************************************************************************************
  327. If HH_OptionSetTime.GetValue() as Int == 1 ; If player wants automatic time change (default is NO)
  328. Int PrefTime = HH_OptionSetTimePreference.GetValue() as Int ; get preferred time
  329. HH_ForceTime(PrefTime) ; and set it
  330. EndIf
  331.  
  332. ; ********************************************************************************************************
  333. ; Optional automatic weather change on teleport
  334. ; ********************************************************************************************************
  335. If !Player.IsInInterior() ; If destination is NOT indoors...
  336. If HH_OptionSetWeather.GetValue() as Int == 1 ; If player wants automatic weather change (default is NO)
  337. Int PrefWeather = HH_OptionSetWeatherPreference.GetValue() as Int ; get preferred weather
  338. HH_ForceWeather(PrefWeather) ; and set it
  339. EndIf
  340. EndIf
  341.  
  342. If HH_OptionSpinCamera.GetValue() as Int == 1 ; If player wants spincam after teleport,
  343. HH_SpinCamera() ; call the custom spin camera function
  344. EndIf
  345.  
  346. StartTimer(10, 2) ; Remove HH_TeleportNoFallDamage perk in 10 seconds
  347. EndFunction
  348.  
  349. ; ------------------------------------------------------------------------------------------------------------
  350. ; CUSTOM FUNCTION: HH SPIN CAMERA
  351. ; ------------------------------------------------------------------------------------------------------------
  352.  
  353. Function HH_SpinCamera()
  354. Int SpinSeconds
  355. Game.ForceFirstPerson() ; IMPORTANT: Must start/run spin in first person!
  356.  
  357. ; Thx steve40 for distance & setini code
  358. Float CamMinDistance = HH_OptionCamMinDistance.GetValue() ; Player chooses min distance (default: 100, vanilla: 0)
  359. Float CamMaxDistance = HH_OptionCamMaxDistance.GetValue() ; Player chooses max distance (default: 200, vanilla: 150)
  360. Utility.SetIniFloat("fVanityModeMinDist:Camera", CamMinDistance) ; Set min
  361. Utility.SetIniFloat("fVanityModeMaxDist:Camera", CamMaxDistance) ; Set max
  362.  
  363. Utility.Wait(1) ; Wait a moment
  364. Utility.SetINIBool("bForceAutoVanityMode:Camera", true) ; Spin the idle camera around player
  365.  
  366. HH_IsSpinning.SetValue(1) ; Flag player / camera as spinning
  367.  
  368. SpinSeconds = HH_OptionSpinDuration.GetValue() as Int ; Player chooses how long to spin (default: 20 seconds)
  369. StartTimer(SpinSeconds, 1) ; Wait SpinSeconds then call StopSpinning from OnTimer event
  370. EndFunction
  371.  
  372. ; -----------------------------------------------------------------------------------------------------------
  373. ; EVENT: ON TIMER
  374. ; -----------------------------------------------------------------------------------------------------------
  375.  
  376. Event OnTimer(int aiTimerID) ; Cancel timer
  377. If aiTimerID == 1
  378. HH_StopSpinning() ; Call StopSpinning function
  379. ElseIf aiTimerID == 2
  380. Player.RemovePerk(HH_TeleportNoFallDamage) ; Temp perk removed after teleport is safely completed
  381.  
  382. If HH_OptionHeal.GetValue() as Int == 1 ; If player wants healed after teleport,
  383. Player.ResetHealthAndLimbs() ; reset health and limbs
  384. EndIf
  385.  
  386. Else
  387. ; Placeholder for additional timers
  388. EndIf
  389. EndEvent
  390.  
  391. ; ------------------------------------------------------------------------------------------------------------
  392. ; CUSTOM FUNCTION: HH STOP SPINNING
  393. ; ------------------------------------------------------------------------------------------------------------
  394.  
  395. Function HH_StopSpinning()
  396. CancelTimer(1) ; Cancel any lingering StopSpinning timers
  397.  
  398. If Player.IsGhost() ; If player is a ghost,
  399. Player.SetGhost(false) ; IMPORTANT: Undo player's temporary invulnerability
  400.  
  401. If HH_OptionDevTracking.GetValue() as Int == 1 ; If player wants dev messages
  402. If Player.IsGhost() == false ; If player is no longer a ghost,
  403. Debug.Notification("Hitchhiker: Player is not a ghost.") ; display dev message
  404. EndIf
  405. EndIf
  406. EndIf
  407.  
  408. If HH_IsSpinning.GetValue() as Int == 1 ; If player is spinning,
  409. Utility.SetINIBool("bForceAutoVanityMode:Camera", false) ; stop spinning
  410.  
  411. Game.ForceFirstPerson() ; IMPORTANT: Call this or spin will last forever!
  412.  
  413. HH_IsSpinning.SetValue(0) ; Flag player / camera as no longer spinning
  414.  
  415. EndIf ; Done with optional spincam effect
  416. EndFunction
  417.  
  418. ; ------------------------------------------------------------------------------------------------------------
  419. ; CUSTOM FUNCTION: HH SET RANDOM DESTINATION
  420. ; ------------------------------------------------------------------------------------------------------------
  421.  
  422. Function HH_SetRandomDestination(Int Category)
  423. Int TargetCount
  424. Int TargetID
  425. Int ReRoll
  426. Int ExcludeDLC = HH_OptionExcludeDLC.GetValue() as Int
  427. Int ExcludeFH = HH_OptionExcludeFH.GetValue() as Int
  428. Int ExcludeNW = HH_OptionExcludeNW.GetValue() as Int
  429. Int ExcludeVT = HH_OptionExcludeVT.GetValue() as Int
  430.  
  431. If HH_PlayerHasFH.GetValue() as Int == 0
  432. ExcludeFH = 1
  433. EndIf
  434.  
  435. If HH_PlayerHasNW.GetValue() as Int == 0
  436. ExcludeNW = 1
  437. EndIf
  438.  
  439. If HH_PlayerHasVT.GetValue() as Int == 0
  440. ExcludeVT = 1
  441. EndIf
  442.  
  443. If Category == BUS_SHELTERS
  444. TargetCount = Go_Bus.Length
  445. ElseIf Category == DINERS
  446. TargetCount = Go_Diner.Length
  447. ElseIf Category == DIVES
  448. TargetCount = Go_Dive.Length
  449. ElseIf Category == DRIVE_INS
  450. TargetCount = Go_Drive.Length
  451. ElseIf Category == FACTORIES
  452. TargetCount = Go_Factory.Length
  453. ElseIf Category == FARMS
  454. TargetCount = Go_Farm.Length
  455. ElseIf Category == JUNKYARDS
  456. TargetCount = Go_Junkyard.Length
  457. ElseIf Category == MILITARY_BASES
  458. TargetCount = Go_Military.Length
  459. ElseIf Category == MONUMENTS
  460. TargetCount = Go_Monument.Length
  461. ElseIf Category == POWER_LIFTS
  462. TargetCount = Go_Power.Length
  463. ElseIf Category == RED_ROCKETS
  464. TargetCount = Go_Red.Length
  465. Else
  466. Category = VAULTS
  467. TargetCount = Go_Vault.Length
  468. EndIf
  469.  
  470. If HH_OptionDevTracking.GetValue() as Int == 1
  471. Debug.TraceAndBox("Hitchhiker: Category is " + Category + ".")
  472. Debug.TraceAndBox("Hitchhiker: TargetCount is " + TargetCount +".")
  473. EndIf
  474.  
  475. ; ********************************************************************************************************
  476. ; Do-while functionality. Only loops if rolled destination is unwanted DLC.
  477. ; ********************************************************************************************************
  478.  
  479. ReRoll = 1
  480.  
  481. While ReRoll == 1
  482. ReRoll = 0
  483. TargetID = Utility.RandomInt(0, (TargetCount - 1)) ; Roll random 0 through (count - 1)
  484.  
  485. If ExcludeDLC == 1 || ExcludeFH == 1
  486. If HH_IsInFarHarbor(Category, TargetID) == 1
  487. ReRoll = 1
  488. If HH_OptionDevTracking.GetValue() as Int == 1
  489. Debug.TraceAndBox("Hitchhiker: FH ReRoll.")
  490. EndIf
  491. EndIf
  492. EndIf
  493.  
  494. If !ReRoll
  495. If ExcludeDLC == 1 || ExcludeNW == 1
  496. If HH_IsInNukaWorld(Category, TargetID) == 1
  497. ReRoll = 1
  498. If HH_OptionDevTracking.GetValue() as Int == 1
  499. Debug.TraceAndBox("Hitchhiker: NW ReRoll.")
  500. EndIf
  501. EndIf
  502. EndIf
  503. EndIf
  504.  
  505. If !ReRoll
  506. If ExcludeDLC == 1 || ExcludeVT == 1
  507. If Category == VAULTS && TargetID == 5
  508. ReRoll = 1
  509. If HH_OptionDevTracking.GetValue() as Int == 1
  510. Debug.TraceAndBox("Hitchhiker: VT ReRoll.")
  511. EndIf
  512. EndIf
  513. EndIf
  514. EndIf
  515. EndWhile
  516.  
  517. HH_Category.SetValue(Category)
  518. HH_TargetID.SetValue(TargetID)
  519.  
  520. If HH_OptionDevTracking.GetValue() as Int == 1
  521. Debug.TraceAndBox("Hitchhiker: Category is " + Category + ".")
  522. Debug.TraceAndBox("Hitchhiker: TargetID is " + TargetID +".")
  523. EndIf
  524. EndFunction
  525.  
  526. ; ------------------------------------------------------------------------------------------------------------
  527. ; CUSTOM FUNCTION: HH IS IN FAR HARBOR
  528. ; ------------------------------------------------------------------------------------------------------------
  529.  
  530. Int Function HH_IsInFarHarbor(Int Category, Int TargetID)
  531. Int Located = 0
  532.  
  533. If HH_OptionDevTracking.GetValue() as Int == 1
  534. Debug.TraceAndBox("Hitchhiker: Checking IsInFarHarbor.")
  535. EndIf
  536.  
  537. If Category == BUS_SHELTERS
  538. ; No FH bus shelters
  539. ElseIf Category == DINERS
  540. If TargetID == 3
  541. Located = 1
  542. EndIf
  543. ElseIf Category == DIVES
  544. If TargetID == 10
  545. Located = 1
  546. EndIf
  547. ElseIf Category == DRIVE_INS
  548. If TargetID == 5
  549. Located = 1
  550. EndIf
  551. ElseIf Category == FACTORIES
  552. If TargetID == 7 || TargetID == 10
  553. Located = 1
  554. EndIf
  555. ElseIf Category == FARMS
  556. ; No FH farms
  557. ElseIf Category == JUNKYARDS
  558. Int[] MyArray
  559. MyArray.Add(1)
  560. MyArray.Add(3)
  561. MyArray.Add(4)
  562. MyArray.Add(6)
  563. MyArray.Add(8)
  564. MyArray.Add(10)
  565. MyArray.Add(12)
  566. MyArray.Add(17)
  567. If MyArray.Find(TargetID) >= 0
  568. Located = 1
  569. EndIf
  570. ElseIf Category == MILITARY_BASES
  571. If TargetID == 0 || TargetID == 18
  572. Located = 1
  573. EndIf
  574. ElseIf Category == MONUMENTS
  575. If TargetID == 2 || TargetID == 21 || TargetID == 26
  576. Located = 1
  577. EndIf
  578. ElseIf Category == POWER_LIFTS
  579. ; No FH power lifts
  580. ElseIf Category == RED_ROCKETS
  581. If TargetID == 20 || TargetID == 21 || TargetID == 22
  582. Located = 1
  583. EndIf
  584. ElseIf Category == VAULTS
  585. If TargetID == 9
  586. Located = 1
  587. EndIf
  588. Else
  589. Debug.TraceAndBox("HITCHHIKER: NULL IN FH CHECK!")
  590. EndIf
  591.  
  592. Return Located
  593. EndFunction
  594.  
  595. ; ------------------------------------------------------------------------------------------------------------
  596. ; CUSTOM FUNCTION: HH IS IN NUKA WORLD
  597. ; ------------------------------------------------------------------------------------------------------------
  598.  
  599. Int Function HH_IsInNukaWorld(Int Category, Int TargetID)
  600. Int Located = 0
  601.  
  602. If HH_OptionDevTracking.GetValue() as Int == 1
  603. Debug.TraceAndBox("Hitchhiker: Checking IsInNukaWorld.")
  604. EndIf
  605.  
  606. If Category == BUS_SHELTERS
  607. ; No NW bus shelters
  608. ElseIf Category == DINERS
  609. If TargetID == 2 || TargetID == 13
  610. Located = 1
  611. EndIf
  612. ElseIf Category == DIVES
  613. If TargetID == 2
  614. Located = 1
  615. EndIf
  616. ElseIf Category == DRIVE_INS
  617. If TargetID == 0 || TargetID == 3 || TargetID == 9 || TargetID == 10
  618. Located = 1
  619. EndIf
  620. ElseIf Category == FACTORIES
  621. If TargetID == 11
  622. Located = 1
  623. EndIf
  624. ElseIf Category == FARMS
  625. ; No NW farms
  626. ElseIf Category == JUNKYARDS
  627. If TargetID == 9
  628. Located = 1
  629. EndIf
  630. ElseIf Category == MILITARY_BASES
  631. If TargetID == 11 || TargetID == 12
  632. Located = 1
  633. EndIf
  634. ElseIf Category == MONUMENTS
  635. If TargetID == 4 || TargetID == 9 || TargetID == 23 || TargetID == 24
  636. Located = 1
  637. EndIf
  638. ElseIf Category == POWER_LIFTS
  639. If TargetID == 13 || TargetID == 14
  640. Located = 1
  641. EndIf
  642. ElseIf Category == RED_ROCKETS
  643. If TargetID == 23 || TargetID == 24
  644. Located = 1
  645. EndIf
  646. ElseIf Category == VAULTS
  647. ; No NW vaults
  648. Else
  649. Debug.TraceAndBox("HITCHHIKER: NULL IN NW CHECK!")
  650. EndIf
  651.  
  652. Return Located
  653. EndFunction
  654.  
  655. ; ------------------------------------------------------------------------------------------------------------
  656. ; CUSTOM FUNCTION: IS FURNITURE
  657. ; ------------------------------------------------------------------------------------------------------------
  658.  
  659. ; Declared in properties: FormList Property HH_IsFurniture Auto Const Mandatory
  660. ; NESTED: Property is a formlist of formlists of furnitures. (Total = 302 NPC/Player furniture actions)
  661. ; [0] IsFurnitureBed 34
  662. ; [1] IsFurnitureBedWorkshop 20
  663. ; [2] IsFurnitureBench 19
  664. ; [3] IsFurnitureChair 57
  665. ; [4] IsFurnitureCouch 24
  666. ; [5] IsFurnitureInstitute 11
  667. ; [6] IsFurnitureInv 6
  668. ; [7] IsFurnitureKneel 6
  669. ; [8] IsFurnitureMisc 104
  670. ; [9] IsFurnitureStand 8
  671. ; [10] IsFurnitureStool 13
  672.  
  673. Int Function IsFurniture(ObjectReference TargetToCheck)
  674. Form TargetBaseObject = TargetToCheck.GetBaseObject()
  675. FormList FurnList = HH_IsFurniture ; FormList declared in properties
  676. FormList NestedList
  677. Int FurnSize = FurnList.GetSize()
  678. Int i = 0
  679. Int Found = 0
  680.  
  681. While i < FurnSize && !Found ; Stop loop if form found in furniture
  682. NestedList = FurnList.GetAt(i) as FormList ; Loop grabs next unchecked formlist
  683.  
  684. If NestedList.HasForm(TargetBaseObject) ; If found,
  685. Found = 1 ; mark as found and break loop
  686. Else
  687. i += 1 ; else iterate and keep looking
  688. EndIf
  689. EndWhile
  690.  
  691. Return Found ; return found (1) or not found (0) to caller
  692. EndFunction
  693.  
  694. ; ------------------------------------------------------------------------------------------------------------
  695. ; CUSTOM FUNCTION: HH TRY TO USE FURNITURE
  696. ; ------------------------------------------------------------------------------------------------------------
  697.  
  698. Int Function HH_TryToUseFurniture(Actor Person, ObjectReference TargetRef)
  699. Int DidItWork = 0
  700.  
  701. If IsFurniture(TargetRef) == 1 ; If target can be used (chair, wall lean, etc)
  702. If TargetRef.IsFurnitureInUse(True) == False ; and target is not in use right now (ignores reserved)
  703. If Person.SnapIntoInteraction(TargetRef) ; then attempt to use the furniture
  704. DidItWork = 1
  705. If HH_OptionSpinCamera.GetValue() as Int == 0
  706. Game.ForceFirstPerson() ; IMPORTANT: Prevents getting stuck in furniture if no spincam
  707. EndIf
  708. EndIf
  709. EndIf
  710. EndIf
  711.  
  712. Return DidItWork
  713. EndFunction
  714.  
  715. ; ------------------------------------------------------------------------------------------------------------
  716. ; CUSTOM FUNCTION: HH FORCE TIME
  717. ; ------------------------------------------------------------------------------------------------------------
  718.  
  719. Function HH_ForceTime(Int TargetHour)
  720. Int CurrentHour = pGameHour.GetValue() as Int ; Get current game hour
  721. Int MyDuration ; and determine how long to wait
  722.  
  723. If TargetHour < 0 || TargetHour > 24
  724. TargetHour = 9
  725. EndIf
  726.  
  727. If CurrentHour < TargetHour ; If target is later in same day,
  728. MyDuration = TargetHour - CurrentHour ; waiting period is easy to calculate
  729. Else
  730. Int Difference = CurrentHour - TargetHour
  731. MyDuration = 24 - Difference ; else duration is difference subtracted from midnight
  732. EndIf
  733.  
  734. If MyDuration > 0 && MyDuration < 24 ; If duration will result in a time change,
  735. Game.PassTime(MyDuration) ; wait that duration
  736. EndIf
  737. EndFunction
  738.  
  739. ; ------------------------------------------------------------------------------------------------------------
  740. ; CUSTOM FUNCTION: HH FORCE WEATHER
  741. ; ------------------------------------------------------------------------------------------------------------
  742.  
  743. Function HH_ForceWeather(Int MyForecast)
  744. If !Player.IsInInterior() ; If destination is NOT indoors...
  745. Weather MyWeather
  746.  
  747. If MyForecast == 1
  748. MyWeather = CommonwealthClear ; Clear
  749. ElseIf MyForecast == 2
  750. MyWeather = CommonwealthDusty ; Dusty
  751. ElseIf MyForecast == 3
  752. MyWeather = CommonwealthFoggy ; Foggy
  753. ElseIf MyForecast == 4
  754. MyWeather = CommonwealthMisty ; Misty
  755. ElseIf MyForecast == 5
  756. MyWeather = CommonwealthMistyRainy ; Misty Rainy
  757. ElseIf MyForecast == 6
  758. MyWeather = CommonwealthOvercast ; Overcast
  759. ElseIf MyForecast == 7
  760. MyWeather = CommonwealthGSRadstorm ; Radstorm
  761. ElseIf MyForecast == 8
  762. MyWeather = CommonwealthRain ; Rain
  763. Else
  764. MyWeather = DefaultWeather ; Default Weather (outdoors)
  765. EndIf
  766.  
  767. MyWeather.ForceActive() ; Force weather change now
  768. EndIf
  769. EndFunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement