Advertisement
ThoraldGM

HH Quest Script 20171227 (2)

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