Advertisement
ThoraldGM

HH Quest Script 20171219

Dec 20th, 2017
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 39.39 KB | None | 0 0
  1. Scriptname HH_QuestScript extends Quest
  2. { It just works. }
  3.  
  4. ; Fallout 4 Papyrus script by ThoraldGM | http://thoraldgm.com | Updated 20171219
  5. ; Hitchhiker mod: (url pending)
  6.  
  7. ; SCRIPT SECTIONS:
  8.  
  9. ; LINE : PROPERTIES
  10. ; LINE : ON INIT
  11. ; LINE : HH START HITCHING
  12. ; LINE : ON QUEST INIT
  13. ; LINE : (OPTIONAL AUTO TIME CHANGE)
  14. ; LINE : (OPTIONAL AUTO WEATHER CHANGE)
  15. ; LINE : HH SPIN CAMERA
  16. ; LINE : ON TIMER
  17. ; LINE : HH STOP SPINNING
  18. ; LINE : HH SET DESTINATION
  19. ; LINE : HH SET RANDOM DESTINATION
  20. ; LINE : HH IS IN FAR HARBOR
  21. ; LINE : HH IS IN NUKA WORLD
  22. ; LINE : HH QUERY QUEST
  23. ; LINE : IS FURNITURE
  24. ; LINE : HH TRY TO USE FURNITURE
  25. ; LINE : HH FORCE TIME
  26. ; LINE : HH FORCE WEATHER
  27. ; LINE : HH FORCE DLC REFALIAS
  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 ; Max camera distance (default: 200, vanilla: 150)
  37. GlobalVariable Property HH_OptionCamMinDistance Auto Mandatory ; Min camera distance (default: 100, vanilla: 0)
  38. GlobalVariable Property HH_OptionDevTracking Auto Mandatory ; Does player want dev messages? (default: no)
  39. GlobalVariable Property HH_OptionExcludeDLC Auto Mandatory ; Turn all DLC on/off in available destinations (default: on if installed)
  40. GlobalVariable Property HH_OptionExcludeFH Auto Mandatory ; Turn Far Harbor DLC on/off in destinations (default: on if installed)
  41. GlobalVariable Property HH_OptionExcludeNW Auto Mandatory ; Turn Nuka-World DLC on/off in destinations (default: on if installed)
  42. GlobalVariable Property HH_OptionExcludeVT Auto Mandatory ; Turn Vault-Tec DLC on/off in destinations (default: on if installed)
  43. GlobalVariable Property HH_OptionFastTravel Auto Mandatory ; Does player want loading screens? (default: yes)
  44. GlobalVariable Property HH_OptionHeal Auto Mandatory ; Does player want to heal after teleport? (default: no)
  45. GlobalVariable Property HH_OptionOffsetX Auto Mandatory ; Player can choose X offset (default: 250)
  46. GlobalVariable Property HH_OptionOffsetY Auto Mandatory ; Player can choose Y offset (default: 250)
  47. GlobalVariable Property HH_OptionOffsetZ Auto Mandatory ; Player can choose Z offset (default: 500)
  48. GlobalVariable Property HH_OptionSetTime Auto Mandatory ; Change time after teleport? (default: no)
  49. GlobalVariable Property HH_OptionSetTimePreference Auto Mandatory ; Preferred game hour (player sets in menu)
  50. GlobalVariable Property HH_OptionSetWeather Auto Mandatory ; Change weather after teleport? (default: no)
  51. GlobalVariable Property HH_OptionSetWeatherPreference Auto Mandatory ; Preferred game weather (player sets in menu)
  52. GlobalVariable Property HH_OptionSitFurniture Auto Mandatory ; If destination is furniture, choose whether to use it (default: yes)
  53. GlobalVariable Property HH_OptionSpinCamera Auto Mandatory ; Does player want teleport to spin camera? (default: yes)
  54. GlobalVariable Property HH_OptionSpinDuration Auto Mandatory ; How long should camera spin? (default: 20 seconds)
  55. GlobalVariable Property HH_OptionSpinGhost Auto Mandatory ; Does player want invulnerable spin? (default: yes)
  56. GlobalVariable Property HH_OptionTeleportSound Auto Mandatory ; Does player want teleport sound? (default: yes)
  57.  
  58. ; ************************************************************************************************************
  59. ; Ref quests to avoid persistence / bloat:
  60. ; ************************************************************************************************************
  61. Quest Property QuestRefBusShelters Auto Const Mandatory ; Quest stores Bus Shelters ref aliases
  62. Quest Property QuestRefDiners Auto Const Mandatory ; Quest stores Diners ref aliases
  63. Quest Property QuestRefDives Auto Const Mandatory ; Quest stores Dives ref aliases
  64. Quest Property QuestRefDriveIns Auto Const Mandatory ; Quest stores Drive-Ins ref aliases
  65. Quest Property QuestRefFactories Auto Const Mandatory ; Quest stores Factories ref aliases
  66. Quest Property QuestRefFarms Auto Const Mandatory ; Quest stores Farms ref aliases
  67. Quest Property QuestRefJunkyards Auto Const Mandatory ; Quest stores Junkyards ref aliases
  68. Quest Property QuestRefMilitaryBases Auto Const Mandatory ; Quest stores Military Bases ref aliases
  69. Quest Property QuestRefMonuments Auto Const Mandatory ; Quest stores Monuments ref aliases
  70. Quest Property QuestRefPowerLifts Auto Const Mandatory ; Quest stores Power Lifts ref aliases
  71. Quest Property QuestRefRedRocket Auto Const Mandatory ; Quest stores Red Rocket ref aliases
  72. Quest Property QuestRefVaults Auto Const Mandatory ; Quest stores Vaults ref aliases
  73. Quest QuestToGrab
  74.  
  75. ; ************************************************************************************************************
  76. ; Weather:
  77. ; ************************************************************************************************************
  78. Weather Property DefaultWeather Auto Const Mandatory ; Default weather (outdoors)
  79. Weather Property CommonwealthClear Auto Const Mandatory ; Clear
  80. Weather Property CommonwealthDusty Auto Const Mandatory ; Dusty
  81. Weather Property CommonwealthFoggy Auto Const Mandatory ; Foggy
  82. Weather Property CommonwealthMisty Auto Const Mandatory ; Misty
  83. Weather Property CommonwealthMistyRainy Auto Const Mandatory ; Misty Rainy
  84. Weather Property CommonwealthOvercast Auto Const Mandatory ; Overcast
  85. Weather Property CommonwealthGSRadstorm Auto Const Mandatory ; Radstorm
  86. Weather Property CommonwealthRain Auto Const Mandatory ; Rain
  87.  
  88. ; ************************************************************************************************************
  89. ; Everything else:
  90. ; ************************************************************************************************************
  91. Actor Player ; Player actor
  92. Book Property HH_Map Auto Const Mandatory ; Hitchhiker map
  93. FormList Property HH_IsFurniture Auto Const Mandatory ; Formlist of formlists of furnitures
  94. GlobalVariable Property HH_IsSpinning Auto Mandatory ; Is the camera currently spinning?
  95. GlobalVariable Property HH_PlayerHasFH Auto Mandatory ; Does player have Far Harbor DLC?
  96. GlobalVariable Property HH_PlayerHasNW Auto Mandatory ; Does player have Nuka-World DLC?
  97. GlobalVariable Property HH_PlayerHasVT Auto Mandatory ; Does player have Vault-Tec DLC?
  98. GlobalVariable Property HH_RefAliasID Auto Mandatory ; Which specific location did player select?
  99. GlobalVariable Property HH_ShowMenu Auto Mandatory ; Don't show menu when map placed in inventory
  100. GlobalVariable Property pGameHour Auto Mandatory ; Current game hour (from vanilla CK)
  101. Perk Property HH_TeleportNoFallDamage Auto Const Mandatory ; Temp perk so teleport falls don't kill player
  102. Sound Property DRSVertibirdFlightLoadOpen Auto Const Mandatory ; Teleport start sound effect
  103. Sound Property OBJHijackerTeleportOut2DA Auto Const Mandatory ; Teleport end sound effect
  104. STATIC Property pXMarker Auto Const Mandatory ; Xmarker (from vanilla CK)
  105. STATIC Property pXMarkerHeading Auto Const Mandatory ; Xmarker heading (from vanilla CK)
  106. STATIC Property pCOCMarkerHeading Auto Const Mandatory ; COC Xmarker heading (from vanilla CK)
  107.  
  108. ; ------------------------------------------------------------------------------------------------------------
  109. ; EVENT: ON INIT
  110. ; ------------------------------------------------------------------------------------------------------------
  111.  
  112. Event OnInit()
  113. Player = Game.GetPlayer() ; Player actor
  114. Utility.Wait(0.1) ; Wait a moment before using actor
  115.  
  116. If Player.GetItemCount(HH_Map) == 0 ; If player doesn't have hitchhiker map,
  117. HH_ShowMenu.SetValue(0) ; don't show menu when map placed in inventory
  118. Utility.Wait(5) ; wait 5 seconds
  119. Player.AddItem(HH_Map) ; spawn hitchhiker map in player inventory
  120. EndIf
  121. EndEvent
  122.  
  123. ; ------------------------------------------------------------------------------------------------------------
  124. ; CUSTOM FUNCTION: HH START HITCHING
  125. ; ------------------------------------------------------------------------------------------------------------
  126.  
  127. Function HH_StartHitching()
  128. RegisterForRemoteEvent(QuestToGrab, "OnQuestInit") ; Listen for refs quest start
  129. Utility.Wait(0.1) ; Wait a moment for registration to finish
  130.  
  131. If HH_OptionTeleportSound.GetValue() as Int == 1 ; If player wants teleport sound,
  132. Int iInstanceID = DRSVertibirdFlightLoadOpen.Play(Player) ; play teleport start sound at player
  133. EndIf
  134.  
  135. If HH_OptionDevTracking.GetValue() as Int == 1
  136. Debug.TraceAndBox("Hitchhiker: StartHitching quest is " + QuestToGrab + ".")
  137. EndIf
  138.  
  139. QuestToGrab.Start() ; Start the refs quest
  140. EndFunction
  141.  
  142. ; ------------------------------------------------------------------------------------------------------------
  143. ; EVENT: ON QUEST INIT
  144. ; ------------------------------------------------------------------------------------------------------------
  145.  
  146. Event Quest.OnQuestInit(Quest akSender) ; When quest starts & aliases are filled
  147. ObjectReference DestinationMarker
  148. ObjectReference TargetRef
  149.  
  150. If HH_OptionDevTracking.GetValue() as Int == 1
  151. Debug.TraceAndBox("Hitchhiker: Event OnQuestInit fired.")
  152. EndIf
  153.  
  154. If akSender ; Selected quest's refs are filled
  155.  
  156. Int RefAliasID = HH_RefAliasID.GetValue() as Int ; Retrieve the ref's AliasID from global
  157. Utility.Wait(0.1)
  158.  
  159. ; ****************************************************************************************************
  160. ; IMPORTANT: REPLACE TODD'S PORTRAIT PLACEHOLDER WITH DLC REF!!!! OR PLAYER WILL GO TO DUGOUT INN INTERIOR INSTEAD OF DLC TARGET!!!!
  161. ;
  162. ; The placeholders are in the 42 DLC refaliases because OnQuestInit would not fire otherwise. (The NONE refaliases were never filled.)
  163. ; The DLC refs are assigned now to avoid DLC dependency, for those players who do not have all/any DLC.
  164. ;
  165. ; It just works! Thanks Todd *Vault Boy thumbs up*
  166. ;
  167. ; ****************************************************************************************************
  168.  
  169. Int GetDLC = HH_ForceDLCRefAlias(akSender, RefAliasID)
  170.  
  171. Utility.Wait(0.1)
  172. TargetRef = (akSender.GetAlias(RefAliasID) as ReferenceAlias).GetReference()
  173.  
  174. StartTimer(60, 3) ; Done with quest in 60 seconds
  175. EndIf
  176.  
  177. Player.AddPerk(HH_TeleportNoFallDamage) ; IMPORTANT: Temp perk so teleport falls don't kill player!
  178.  
  179. If HH_OptionSpinGhost.GetValue() as Int == 1 ; If player wants no spin damage (default)
  180. If HH_OptionSpinCamera.GetValue() as Int == 1 ; If player wants spincam after teleport,
  181. Player.SetGhost() ; IMPORTANT: Player immune to all damage!
  182. EndIf ; *** Set ghost now BEFORE the spin! ***
  183.  
  184. If HH_OptionDevTracking.GetValue() as Int == 1 ; If player wants dev messages...
  185. If Player.IsGhost() ; If player is a ghost,
  186. Debug.Notification("Hitchhiker: Player is a ghost!") ; display dev message
  187. EndIf
  188. EndIf
  189. EndIf ; NOTE: Unghosting happens in HH_SpinCamera()
  190.  
  191. If HH_OptionTeleportSound.GetValue() as Int == 1 ; If player wants teleport sound,
  192. Int iInstanceID = OBJHijackerTeleportOut2DA.Play(Player) ; play teleport end sound at player
  193. EndIf
  194.  
  195. DestinationMarker = Player.PlaceAtMe(pXMarker) ; Dynamically spawn xmarker at player
  196.  
  197. STATIC TargetBase = TargetRef.GetBaseObject() as STATIC ; Check if target base object is an X/COC marker/header
  198.  
  199. If TargetBase == pXMarker || TargetBase == pXMarkerHeading || TargetBase == pCOCMarkerHeading ; Do not use XYZ offsets if destination is a marker
  200. DestinationMarker.MoveTo(TargetRef) ; so teleport will place player directly on the X
  201. Else ; else move marker to static ref with XYZ offsets
  202. Float OffsetX = HH_OptionOffsetX.GetValue() ; Player sets X (default 250)
  203. Float OffsetY = HH_OptionOffsetY.GetValue() ; Player sets Y (default 250)
  204. Float OffsetZ = HH_OptionOffsetZ.GetValue() ; Player sets Z (default 500)
  205. Utility.Wait(0.1)
  206. DestinationMarker.MoveTo(TargetRef, OffsetX, OffsetY, OffsetZ) ; Move marker with XYZ offsets
  207. DestinationMarker.MoveToNearestNavmeshLocation() ; Then move marker to nearest navmesh
  208. EndIf
  209.  
  210. If HH_OptionFastTravel.GetValue() as Int == 1 ; If player wants loading screens,
  211. Game.FastTravel(DestinationMarker) ; move player to marker (with load screens?)
  212. Else
  213. Player.MoveTo(DestinationMarker) ; else move player (with black screen)
  214. EndIf
  215.  
  216. Utility.Wait(0.1)
  217.  
  218. ; "If TargetRef Is Furniture" caused illegal typecast compiler error, so I wrote a custom function
  219. HH_TryToUseFurniture(Player, TargetRef)
  220.  
  221. ; ********************************************************************************************************
  222. ; Optional automatic time change on teleport
  223. ; ********************************************************************************************************
  224. If HH_OptionSetTime.GetValue() as Int == 1 ; If player wants automatic time change (default is NO)
  225. Int PrefTime = HH_OptionSetTimePreference.GetValue() as Int ; get preferred time
  226. HH_ForceTime(PrefTime) ; and set it
  227. EndIf
  228.  
  229. ; ********************************************************************************************************
  230. ; Optional automatic weather change on teleport
  231. ; ********************************************************************************************************
  232. If !Player.IsInInterior() ; If destination is NOT indoors...
  233. If HH_OptionSetWeather.GetValue() as Int == 1 ; If player wants automatic weather change (default is NO)
  234. Int PrefWeather = HH_OptionSetWeatherPreference.GetValue() as Int ; get preferred weather
  235. HH_ForceWeather(PrefWeather) ; and set it
  236. EndIf
  237. EndIf
  238.  
  239. If HH_OptionSpinCamera.GetValue() as Int == 1 ; If player wants spincam after teleport,
  240. HH_SpinCamera() ; call the custom spin camera function
  241. EndIf
  242.  
  243. StartTimer(10, 2) ; Remove HH_TeleportNoFallDamage perk in 10 seconds
  244. EndEvent
  245.  
  246. ; ------------------------------------------------------------------------------------------------------------
  247. ; CUSTOM FUNCTION: HH SPIN CAMERA
  248. ; ------------------------------------------------------------------------------------------------------------
  249.  
  250. Function HH_SpinCamera()
  251. Int SpinSeconds
  252. Game.ForceFirstPerson() ; IMPORTANT: Must start/run spin in first person!
  253.  
  254. ; Thx steve40 for distance & setini code
  255. Float CamMinDistance = HH_OptionCamMinDistance.GetValue() ; Player chooses min distance (default: 100, vanilla: 0)
  256. Float CamMaxDistance = HH_OptionCamMaxDistance.GetValue() ; Player chooses max distance (default: 200, vanilla: 150)
  257. Utility.SetIniFloat("fVanityModeMinDist:Camera", CamMinDistance) ; Set min
  258. Utility.SetIniFloat("fVanityModeMaxDist:Camera", CamMaxDistance) ; Set max
  259.  
  260. Utility.Wait(1) ; Wait a moment
  261. Utility.SetINIBool("bForceAutoVanityMode:Camera", true) ; Spin the idle camera around player
  262.  
  263. HH_IsSpinning.SetValue(1) ; Flag player / camera as spinning
  264.  
  265. SpinSeconds = HH_OptionSpinDuration.GetValue() as Int ; Player chooses how long to spin (default: 20 seconds)
  266. StartTimer(SpinSeconds, 1) ; Wait SpinSeconds then call StopSpinning from OnTimer event
  267. EndFunction
  268.  
  269. ; -----------------------------------------------------------------------------------------------------------
  270. ; EVENT: ON TIMER
  271. ; -----------------------------------------------------------------------------------------------------------
  272.  
  273. Event OnTimer(int aiTimerID) ; Cancel timer
  274. If aiTimerID == 1
  275. HH_StopSpinning() ; Call StopSpinning function
  276. ElseIf aiTimerID == 2
  277. Player.RemovePerk(HH_TeleportNoFallDamage) ; Temp perk removed after teleport is safely completed
  278.  
  279. If HH_OptionHeal.GetValue() as Int == 1 ; If player wants healed after teleport,
  280. Player.ResetHealthAndLimbs() ; reset health and limbs
  281. EndIf
  282.  
  283. ElseIf aiTimerID == 3
  284. QuestToGrab.Stop() ; Done with quest until next time
  285. ; NEED BUTTON SPAM HANDLING HERE! IF PLAYER TELEPORTS AGAIN BEFORE TIMER FIRES...
  286. Else
  287. ; Placeholder for additional timers
  288. EndIf
  289. EndEvent
  290.  
  291. ; ------------------------------------------------------------------------------------------------------------
  292. ; CUSTOM FUNCTION: HH STOP SPINNING
  293. ; ------------------------------------------------------------------------------------------------------------
  294.  
  295. Function HH_StopSpinning()
  296. CancelTimer(1) ; Cancel any lingering StopSpinning timers
  297.  
  298. If Player.IsGhost() ; If player is a ghost,
  299. Player.SetGhost(false) ; IMPORTANT: Undo player's temporary invulnerability
  300.  
  301. If HH_OptionDevTracking.GetValue() as Int == 1 ; If player wants dev messages
  302. If Player.IsGhost() == false ; If player is no longer a ghost,
  303. Debug.Notification("Hitchhiker: Player is not a ghost.") ; display dev message
  304. EndIf
  305. EndIf
  306. EndIf
  307.  
  308. If HH_IsSpinning.GetValue() as Int == 1 ; If player is spinning,
  309. Utility.SetINIBool("bForceAutoVanityMode:Camera", false) ; stop spinning
  310.  
  311. Game.ForceFirstPerson() ; IMPORTANT: Call this or spin will last forever!
  312.  
  313. HH_IsSpinning.SetValue(0) ; Flag player / camera as no longer spinning
  314.  
  315. EndIf ; Done with optional spincam effect
  316. EndFunction
  317.  
  318. ; ------------------------------------------------------------------------------------------------------------
  319. ; CUSTOM FUNCTION: HH SET DESTINATION
  320. ; ------------------------------------------------------------------------------------------------------------
  321.  
  322. Function HH_SetDestination(Quest RefQuest, Int RefAliasID)
  323. QuestToGrab = RefQuest
  324.  
  325. If HH_OptionDevTracking.GetValue() as Int == 1
  326. Debug.TraceAndBox("Hitchhiker: Set Dest Quest is " + QuestToGrab + ".")
  327. EndIf
  328.  
  329. HH_RefAliasID.SetValue(RefAliasID)
  330.  
  331. If HH_OptionDevTracking.GetValue() as Int == 1
  332. Debug.TraceAndBox("Hitchhiker: RefAliasID is " + HH_RefAliasID.GetValue() as Int + ".")
  333. EndIf
  334.  
  335. EndFunction
  336.  
  337. ; ------------------------------------------------------------------------------------------------------------
  338. ; CUSTOM FUNCTION: HH SET RANDOM DESTINATION
  339. ; ------------------------------------------------------------------------------------------------------------
  340.  
  341. Function HH_SetRandomDestination(Int Category)
  342. Quest RefQuest
  343. Int RefAliasCount
  344. Int RefAliasID
  345. Int ReRoll
  346. Int ExcludeDLC = HH_OptionExcludeDLC.GetValue() as Int
  347. Int ExcludeFH = HH_OptionExcludeFH.GetValue() as Int
  348. Int ExcludeNW = HH_OptionExcludeNW.GetValue() as Int
  349. Int ExcludeVT = HH_OptionExcludeVT.GetValue() as Int
  350.  
  351. If HH_PlayerHasFH.GetValue() as Int == 0
  352. ExcludeFH = 1
  353. EndIf
  354.  
  355. If HH_PlayerHasNW.GetValue() as Int == 0
  356. ExcludeNW = 1
  357. EndIf
  358.  
  359. If HH_PlayerHasVT.GetValue() as Int == 0
  360. ExcludeVT = 1
  361. EndIf
  362.  
  363. If Category == 1
  364. RefQuest = QuestRefBusShelters
  365. RefAliasCount = 10
  366. ElseIf Category == 2
  367. RefQuest = QuestRefDiners
  368. RefAliasCount = 30
  369. ElseIf Category == 3
  370. RefQuest = QuestRefDriveIns
  371. RefAliasCount = 12
  372. ElseIf Category == 4
  373. RefQuest = QuestRefDives
  374. RefAliasCount = 13
  375. ElseIf Category == 5
  376. RefQuest = QuestRefFactories
  377. RefAliasCount = 12
  378. ElseIf Category == 6
  379. RefQuest = QuestRefFarms
  380. RefAliasCount = 12
  381. ElseIf Category == 7
  382. RefQuest = QuestRefJunkyards
  383. RefAliasCount = 20
  384. ElseIf Category == 8
  385. RefQuest = QuestRefMilitaryBases
  386. RefAliasCount = 20
  387. ElseIf Category == 9
  388. RefQuest = QuestRefMonuments
  389. RefAliasCount = 30
  390. ElseIf Category == 10
  391. RefQuest = QuestRefPowerLifts
  392. RefAliasCount = 15
  393. ElseIf Category == 11
  394. RefQuest = QuestRefRedRocket
  395. RefAliasCount = 25
  396. Else
  397. RefQuest = QuestRefVaults
  398. RefAliasCount = 10
  399. EndIf
  400.  
  401. If HH_OptionDevTracking.GetValue() as Int == 1
  402. Debug.TraceAndBox("Hitchhiker: SRD RefQuest is " + RefQuest + ".")
  403. Debug.TraceAndBox("Hitchhiker: RefAliasCount is " + RefAliasCount +".")
  404. EndIf
  405.  
  406. ; ********************************************************************************************************
  407. ; Do-while functionality. Only loops if rolled destination is unwanted DLC.
  408. ; ********************************************************************************************************
  409.  
  410. ReRoll = 1
  411.  
  412. While ReRoll == 1
  413. ReRoll = 0
  414. RefAliasID = Utility.RandomInt(0, (RefAliasCount - 1)) ; Roll random 0 through (count - 1)
  415.  
  416. If ExcludeDLC == 1 || ExcludeFH == 1
  417. If HH_IsInFarHarbor(RefQuest, RefAliasID) == 1
  418. ReRoll = 1
  419. If HH_OptionDevTracking.GetValue() as Int == 1
  420. Debug.TraceAndBox("Hitchhiker: FH ReRoll.")
  421. EndIf
  422. EndIf
  423. EndIf
  424.  
  425. If !ReRoll
  426. If ExcludeDLC == 1 || ExcludeNW == 1
  427. If HH_IsInNukaWorld(RefQuest, RefAliasID) == 1
  428. ReRoll = 1
  429. If HH_OptionDevTracking.GetValue() as Int == 1
  430. Debug.TraceAndBox("Hitchhiker: NW ReRoll.")
  431. EndIf
  432. EndIf
  433. EndIf
  434. EndIf
  435.  
  436. If !ReRoll
  437. If ExcludeDLC == 1 || ExcludeVT == 1
  438. If RefQuest == QuestRefVaults && RefAliasID == 5
  439. ReRoll = 1
  440. If HH_OptionDevTracking.GetValue() as Int == 1
  441. Debug.TraceAndBox("Hitchhiker: VT ReRoll.")
  442. EndIf
  443. EndIf
  444. EndIf
  445. EndIf
  446. EndWhile
  447.  
  448. QuestToGrab = RefQuest
  449. HH_RefAliasID.SetValue(RefAliasID)
  450.  
  451. If HH_OptionDevTracking.GetValue() as Int == 1
  452. Debug.TraceAndBox("Hitchhiker: SRD QuestToGrab is " + QuestToGrab + ".")
  453. Debug.TraceAndBox("Hitchhiker: RefAliasID is " + RefAliasID +".")
  454. EndIf
  455.  
  456. EndFunction
  457.  
  458. ; ------------------------------------------------------------------------------------------------------------
  459. ; CUSTOM FUNCTION: HH IS IN FAR HARBOR
  460. ; ------------------------------------------------------------------------------------------------------------
  461.  
  462. Int Function HH_IsInFarHarbor(Quest TargetQuest, Int TargetAliasID)
  463. Int Located = 0
  464.  
  465. If HH_OptionDevTracking.GetValue() as Int == 1
  466. Debug.TraceAndBox("Hitchhiker: Checking IsInFarHarbor.")
  467. EndIf
  468.  
  469. If TargetQuest == QuestRefBusShelters
  470. ; No bus shelters
  471. ElseIf TargetQuest == QuestRefDiners
  472. If TargetAliasID == 3
  473. Located = 1
  474. EndIf
  475. ElseIf TargetQuest == QuestRefDives
  476. If TargetAliasID == 10
  477. Located = 1
  478. EndIf
  479. ElseIf TargetQuest == QuestRefDriveIns
  480. If TargetAliasID == 5
  481. Located = 1
  482. EndIf
  483. ElseIf TargetQuest == QuestRefFactories
  484. If TargetAliasID == 7 || TargetAliasID == 10
  485. Located = 1
  486. EndIf
  487. ElseIf TargetQuest == QuestRefFarms
  488. ; No farms
  489. ElseIf TargetQuest == QuestRefJunkyards
  490. Int[] MyArray
  491. MyArray.Add(1)
  492. MyArray.Add(3)
  493. MyArray.Add(4)
  494. MyArray.Add(6)
  495. MyArray.Add(8)
  496. MyArray.Add(10)
  497. MyArray.Add(12)
  498. MyArray.Add(17)
  499. If MyArray.Find(TargetAliasID) >= 0
  500. Located = 1
  501. EndIf
  502. ElseIf TargetQuest == QuestRefMilitaryBases
  503. If TargetAliasID == 0 || TargetAliasID == 18
  504. Located = 1
  505. EndIf
  506. ElseIf TargetQuest == QuestRefMonuments
  507. If TargetAliasID == 2 || TargetAliasID == 21 || TargetAliasID == 26
  508. Located = 1
  509. EndIf
  510. ElseIf TargetQuest == QuestRefPowerLifts
  511. ; No power lifts
  512. ElseIf TargetQuest == QuestRefRedRocket
  513. If TargetAliasID == 20 || TargetAliasID == 21 || TargetAliasID == 22
  514. Located = 1
  515. EndIf
  516. ElseIf TargetQuest == QuestRefVaults
  517. If TargetAliasID == 9
  518. Located = 1
  519. EndIf
  520. Else
  521. Debug.TraceAndBox("HITCHHIKER: NULL IN FH CHECK!")
  522. EndIf
  523.  
  524. If Located
  525. Return 1
  526. Else
  527. Return 0
  528. EndIf
  529. EndFunction
  530.  
  531. ; ------------------------------------------------------------------------------------------------------------
  532. ; CUSTOM FUNCTION: HH IS IN NUKA WORLD
  533. ; ------------------------------------------------------------------------------------------------------------
  534.  
  535. Int Function HH_IsInNukaWorld(Quest TargetQuest, Int TargetAliasID)
  536. Int Located = 0
  537.  
  538. If HH_OptionDevTracking.GetValue() as Int == 1
  539. Debug.TraceAndBox("Hitchhiker: Checking IsInNukaWorld.")
  540. EndIf
  541.  
  542. If TargetQuest == QuestRefBusShelters
  543. ; No bus shelters
  544. ElseIf TargetQuest == QuestRefDiners
  545. If TargetAliasID == 2 || TargetAliasID == 13
  546. Located = 1
  547. EndIf
  548. ElseIf TargetQuest == QuestRefDives
  549. If TargetAliasID == 2
  550. Located = 1
  551. EndIf
  552. ElseIf TargetQuest == QuestRefDriveIns
  553. If TargetAliasID == 0 || TargetAliasID == 3 || TargetAliasID == 9 || TargetAliasID == 10
  554. Located = 1
  555. EndIf
  556. ElseIf TargetQuest == QuestRefFactories
  557. If TargetAliasID == 11
  558. Located = 1
  559. EndIf
  560. ElseIf TargetQuest == QuestRefFarms
  561. ; No farms
  562. ElseIf TargetQuest == QuestRefJunkyards
  563. If TargetAliasID == 9
  564. Located = 1
  565. EndIf
  566. ElseIf TargetQuest == QuestRefMilitaryBases
  567. If TargetAliasID == 11 || TargetAliasID == 12
  568. Located = 1
  569. EndIf
  570. ElseIf TargetQuest == QuestRefMonuments
  571. If TargetAliasID == 4 || TargetAliasID == 9 || TargetAliasID == 23 || TargetAliasID == 24
  572. Located = 1
  573. EndIf
  574. ElseIf TargetQuest == QuestRefPowerLifts
  575. If TargetAliasID == 13 || TargetAliasID == 14
  576. Located = 1
  577. EndIf
  578. ElseIf TargetQuest == QuestRefRedRocket
  579. If TargetAliasID == 23 || TargetAliasID == 24
  580. Located = 1
  581. EndIf
  582. ElseIf TargetQuest == QuestRefVaults
  583. ; No vaults
  584. Else
  585. Debug.TraceAndBox("HITCHHIKER: NULL IN NW CHECK!")
  586. EndIf
  587.  
  588. If Located
  589. Return 1
  590. Else
  591. Return 0
  592. EndIf
  593. EndFunction
  594.  
  595. ; ------------------------------------------------------------------------------------------------------------
  596. ; CUSTOM FUNCTION: HH QUERY QUEST
  597. ; ------------------------------------------------------------------------------------------------------------
  598.  
  599. Quest Function HH_QueryQuest()
  600. Return QuestToGrab
  601. EndFunction
  602.  
  603. ; ------------------------------------------------------------------------------------------------------------
  604. ; CUSTOM FUNCTION: IS FURNITURE
  605. ; ------------------------------------------------------------------------------------------------------------
  606.  
  607. ; Declared in properties: FormList Property HH_IsFurniture Auto Const Mandatory
  608. ; NESTED: Property is a formlist of formlists of furnitures. (Total = 302 NPC/Player furniture actions)
  609. ; [0] IsFurnitureBed 34
  610. ; [1] IsFurnitureBedWorkshop 20
  611. ; [2] IsFurnitureBench 19
  612. ; [3] IsFurnitureChair 57
  613. ; [4] IsFurnitureCouch 24
  614. ; [5] IsFurnitureInstitute 11
  615. ; [6] IsFurnitureInv 6
  616. ; [7] IsFurnitureKneel 6
  617. ; [8] IsFurnitureMisc 104
  618. ; [9] IsFurnitureStand 8
  619. ; [10] IsFurnitureStool 13
  620.  
  621. Int Function IsFurniture(ObjectReference TargetToCheck)
  622. Form TargetBaseObject = TargetToCheck.GetBaseObject()
  623. FormList FurnList = HH_IsFurniture ; FormList declared in properties
  624. FormList NestedList
  625. Int FurnSize = FurnList.GetSize()
  626. Int i = 0
  627. Int Found = 0
  628.  
  629. While i < FurnSize && !Found ; Stop loop if form found in furniture
  630. NestedList = FurnList.GetAt(i) as FormList ; Loop grabs next unchecked formlist
  631.  
  632. If NestedList.HasForm(TargetBaseObject) ; If found,
  633. Found = 1 ; mark as found and break loop
  634. Else
  635. i += 1 ; else iterate and keep looking
  636. EndIf
  637. EndWhile
  638.  
  639. Return Found ; return found (1) or not found (0) to caller
  640. EndFunction
  641.  
  642. ; ------------------------------------------------------------------------------------------------------------
  643. ; CUSTOM FUNCTION: HH TRY TO USE FURNITURE
  644. ; ------------------------------------------------------------------------------------------------------------
  645.  
  646. Int Function HH_TryToUseFurniture(Actor Person, ObjectReference TargetRef)
  647. Int DidItWork = 0
  648.  
  649. If IsFurniture(TargetRef) == 1 ; If target can be used (chair, wall lean, etc)
  650. If TargetRef.IsFurnitureInUse(True) == False ; and target is not in use right now (ignores reserved)
  651. If Person.SnapIntoInteraction(TargetRef) ; then attempt to use the furniture
  652. DidItWork = 1
  653. If HH_OptionSpinCamera.GetValue() as Int == 0
  654. Game.ForceFirstPerson() ; IMPORTANT: Prevents getting stuck in furniture if no spincam
  655. EndIf
  656. EndIf
  657. EndIf
  658. EndIf
  659.  
  660. Return DidItWork
  661. EndFunction
  662.  
  663. ; ------------------------------------------------------------------------------------------------------------
  664. ; CUSTOM FUNCTION: HH FORCE TIME
  665. ; ------------------------------------------------------------------------------------------------------------
  666.  
  667. Function HH_ForceTime(Int TargetHour)
  668. Int CurrentHour = pGameHour.GetValue() as Int ; Get current game hour
  669. Int MyDuration ; and determine how long to wait
  670.  
  671. If TargetHour < 0 || TargetHour > 24
  672. TargetHour = 9
  673. EndIf
  674.  
  675. If CurrentHour < TargetHour ; If target is later in same day,
  676. MyDuration = TargetHour - CurrentHour ; waiting period is easy to calculate
  677. Else
  678. Int Difference = CurrentHour - TargetHour
  679. MyDuration = 24 - Difference ; else duration is difference subtracted from midnight
  680. EndIf
  681.  
  682. If MyDuration > 0 && MyDuration < 24 ; If duration will result in a time change,
  683. Game.PassTime(MyDuration) ; wait that duration
  684. EndIf
  685. EndFunction
  686.  
  687. ; ------------------------------------------------------------------------------------------------------------
  688. ; CUSTOM FUNCTION: HH FORCE WEATHER
  689. ; ------------------------------------------------------------------------------------------------------------
  690.  
  691. Function HH_ForceWeather(Int MyForecast)
  692. If !Player.IsInInterior() ; If destination is NOT indoors...
  693. Weather MyWeather
  694.  
  695. If MyForecast == 1
  696. MyWeather = CommonwealthClear ; Clear
  697. ElseIf MyForecast == 2
  698. MyWeather = CommonwealthDusty ; Dusty
  699. ElseIf MyForecast == 3
  700. MyWeather = CommonwealthFoggy ; Foggy
  701. ElseIf MyForecast == 4
  702. MyWeather = CommonwealthMisty ; Misty
  703. ElseIf MyForecast == 5
  704. MyWeather = CommonwealthMistyRainy ; Misty Rainy
  705. ElseIf MyForecast == 6
  706. MyWeather = CommonwealthOvercast ; Overcast
  707. ElseIf MyForecast == 7
  708. MyWeather = CommonwealthGSRadstorm ; Radstorm
  709. ElseIf MyForecast == 8
  710. MyWeather = CommonwealthRain ; Rain
  711. Else
  712. MyWeather = DefaultWeather ; Default Weather (outdoors)
  713. EndIf
  714.  
  715. MyWeather.ForceActive() ; Force weather change now
  716. EndIf
  717. EndFunction
  718.  
  719. ; ------------------------------------------------------------------------------------------------------------
  720. ; CUSTOM FUNCTION: HH FORCE DLC REFALIAS
  721. ; ------------------------------------------------------------------------------------------------------------
  722.  
  723. Int Function HH_ForceDLCRefAlias(Quest TargetQuest, Int TargetAliasID)
  724. ObjectReference DLCObjRef
  725. ReferenceAlias TargetAlias
  726. Int Found = 0
  727.  
  728. ; ********************************************************************************************************
  729. ; Grab the desired object reference from the correct DLC
  730. ; ********************************************************************************************************
  731.  
  732. If TargetQuest == QuestRefBusShelters
  733. ; No DLC refs
  734.  
  735. ElseIf TargetQuest == QuestRefDiners
  736.  
  737. If TargetAliasID == 2
  738. Found = 1
  739. DLCObjRef = Game.GetFormFromFile(0x01038291, "DLCNukaWorld.esm") as ObjectReference ;
  740. EndIf
  741.  
  742. If TargetAliasID == 3
  743. Found = 1
  744. DLCObjRef = Game.GetFormFromFile(0x0102A675, "DLCCoast.esm") as ObjectReference ;
  745. EndIf
  746.  
  747. If TargetAliasID == 13
  748. Found = 1
  749. DLCObjRef = Game.GetFormFromFile(0x010377CB, "DLCNukaWorld.esm") as ObjectReference ;
  750. EndIf
  751.  
  752. ElseIf TargetQuest == QuestRefDives
  753.  
  754. If TargetAliasID == 2
  755. Found = 1
  756. DLCObjRef = Game.GetFormFromFile(0x01044720, "DLCNukaWorld.esm") as ObjectReference ;
  757. EndIf
  758.  
  759. If TargetAliasID == 10
  760. Found = 1
  761. DLCObjRef = Game.GetFormFromFile(0x010034DC, "DLCCoast.esm") as ObjectReference ;
  762. If HH_OptionDevTracking.GetValue() as Int == 1
  763. Debug.TraceAndBox("Hitchhiker: The Last Plank located!")
  764. EndIf
  765. EndIf
  766.  
  767. ElseIf TargetQuest == QuestRefDriveIns
  768.  
  769. If TargetAliasID == 0
  770. Found = 1
  771. DLCObjRef = Game.GetFormFromFile(0x0104A69F, "DLCNukaWorld.esm") as ObjectReference ;
  772. EndIf
  773.  
  774. If TargetAliasID == 3
  775. Found = 1
  776. DLCObjRef = Game.GetFormFromFile(0x010447FE, "DLCNukaWorld.esm") as ObjectReference ;
  777. EndIf
  778.  
  779. If TargetAliasID == 5
  780. Found = 1
  781. DLCObjRef = Game.GetFormFromFile(0x01004BEF, "DLCCoast.esm") as ObjectReference ;
  782. EndIf
  783.  
  784. If TargetAliasID == 9
  785. Found = 1
  786. DLCObjRef = Game.GetFormFromFile(0x0100E76F, "DLCNukaWorld.esm") as ObjectReference ;
  787. EndIf
  788.  
  789. If TargetAliasID == 10
  790. Found = 1
  791. DLCObjRef = Game.GetFormFromFile(0x01021D80, "DLCNukaWorld.esm") as ObjectReference ;
  792. EndIf
  793.  
  794. ElseIf TargetQuest == QuestRefFactories
  795.  
  796. If TargetAliasID == 7
  797. Found = 1
  798. DLCObjRef = Game.GetFormFromFile(0x01037958, "DLCCoast.esm") as ObjectReference ;
  799. EndIf
  800.  
  801. If TargetAliasID == 10
  802. Found = 1
  803. DLCObjRef = Game.GetFormFromFile(0x01016F96, "DLCCoast.esm") as ObjectReference ;
  804. EndIf
  805.  
  806. If TargetAliasID == 11
  807. Found = 1
  808. DLCObjRef = Game.GetFormFromFile(0x01019534, "DLCNukaWorld.esm") as ObjectReference ;
  809. EndIf
  810.  
  811. ElseIf TargetQuest == QuestRefFarms
  812. ; No DLC refs
  813.  
  814. ElseIf TargetQuest == QuestRefJunkyards
  815.  
  816. If TargetAliasID == 1
  817. Found = 1
  818. DLCObjRef = Game.GetFormFromFile(0x010093F3, "DLCCoast.esm") as ObjectReference ;
  819. EndIf
  820.  
  821. If TargetAliasID == 3
  822. Found = 1
  823. DLCObjRef = Game.GetFormFromFile(0x0102074A, "DLCCoast.esm") as ObjectReference ;
  824. EndIf
  825.  
  826. If TargetAliasID == 4
  827. Found = 1
  828. DLCObjRef = Game.GetFormFromFile(0x010093F2, "DLCCoast.esm") as ObjectReference ;
  829. EndIf
  830.  
  831. If TargetAliasID == 6
  832. Found = 1
  833. DLCObjRef = Game.GetFormFromFile(0x0100B1CF, "DLCCoast.esm") as ObjectReference ;
  834. EndIf
  835.  
  836. If TargetAliasID == 8
  837. Found = 1
  838. DLCObjRef = Game.GetFormFromFile(0x0102065A, "DLCCoast.esm") as ObjectReference ;
  839. EndIf
  840.  
  841. If TargetAliasID == 9
  842. Found = 1
  843. DLCObjRef = Game.GetFormFromFile(0x0101742A, "DLCNukaWorld.esm") as ObjectReference ;
  844. EndIf
  845.  
  846. If TargetAliasID == 10
  847. Found = 1
  848. DLCObjRef = Game.GetFormFromFile(0x0104FFA7, "DLCCoast.esm") as ObjectReference ;
  849. EndIf
  850.  
  851. If TargetAliasID == 12
  852. Found = 1
  853. DLCObjRef = Game.GetFormFromFile(0x0105422F, "DLCCoast.esm") as ObjectReference ;
  854. EndIf
  855.  
  856. If TargetAliasID == 17
  857. Found = 1
  858. DLCObjRef = Game.GetFormFromFile(0x010399CB, "DLCCoast.esm") as ObjectReference ;
  859. EndIf
  860.  
  861. ElseIf TargetQuest == QuestRefMilitaryBases
  862.  
  863. If TargetAliasID == 0
  864. Found = 1
  865. DLCObjRef = Game.GetFormFromFile(0x01034345, "DLCCoast.esm") as ObjectReference ;
  866. EndIf
  867.  
  868. If TargetAliasID == 11
  869. Found = 1
  870. DLCObjRef = Game.GetFormFromFile(0x0105666F, "DLCNukaWorld.esm") as ObjectReference ;
  871. EndIf
  872.  
  873. If TargetAliasID == 12
  874. Found = 1
  875. DLCObjRef = Game.GetFormFromFile(0x0104B18E, "DLCNukaWorld.esm") as ObjectReference ;
  876. EndIf
  877.  
  878. If TargetAliasID == 18
  879. Found = 1
  880. DLCObjRef = Game.GetFormFromFile(0x01004D15, "DLCCoast.esm") as ObjectReference ;
  881. EndIf
  882.  
  883. ElseIf TargetQuest == QuestRefMonuments
  884.  
  885. If TargetAliasID == 2
  886. Found = 1
  887. DLCObjRef = Game.GetFormFromFile(0x0100ECE7, "DLCCoast.esm") as ObjectReference ;
  888. EndIf
  889.  
  890. If TargetAliasID == 4
  891. Found = 1
  892. DLCObjRef = Game.GetFormFromFile(0x010566B8, "DLCNukaWorld.esm") as ObjectReference ;
  893. EndIf
  894.  
  895. If TargetAliasID == 9
  896. Found = 1
  897. DLCObjRef = Game.GetFormFromFile(0x0104E0EF, "DLCNukaWorld.esm") as ObjectReference ;
  898. EndIf
  899.  
  900. If TargetAliasID == 21
  901. Found = 1
  902. DLCObjRef = Game.GetFormFromFile(0x0100AB27, "DLCCoast.esm") as ObjectReference ;
  903. EndIf
  904.  
  905. If TargetAliasID == 23
  906. Found = 1
  907. DLCObjRef = Game.GetFormFromFile(0x010379BD, "DLCNukaWorld.esm") as ObjectReference ;
  908. EndIf
  909.  
  910. If TargetAliasID == 24
  911. Found = 1
  912. DLCObjRef = Game.GetFormFromFile(0x0100ADB5, "DLCNukaWorld.esm") as ObjectReference ;
  913. EndIf
  914.  
  915. If TargetAliasID == 26
  916. Found = 1
  917. DLCObjRef = Game.GetFormFromFile(0x01056917, "DLCCoast.esm") as ObjectReference ;
  918. EndIf
  919.  
  920. ElseIf TargetQuest == QuestRefPowerLifts
  921.  
  922. If TargetAliasID == 13
  923. Found = 1
  924. DLCObjRef = Game.GetFormFromFile(0x010496B9, "DLCNukaWorld.esm") as ObjectReference ;
  925. EndIf
  926.  
  927. If TargetAliasID == 14
  928. Found = 1
  929. DLCObjRef = Game.GetFormFromFile(0x01051EAD, "DLCNukaWorld.esm") as ObjectReference ;
  930. EndIf
  931.  
  932. ElseIf TargetQuest == QuestRefRedRocket
  933.  
  934. If TargetAliasID == 20
  935. Found = 1
  936. DLCObjRef = Game.GetFormFromFile(0x01004D6F, "DLCCoast.esm") as ObjectReference ;
  937. EndIf
  938.  
  939. If TargetAliasID == 21
  940. Found = 1
  941. DLCObjRef = Game.GetFormFromFile(0x0100C51A, "DLCCoast.esm") as ObjectReference ;
  942. EndIf
  943.  
  944. If TargetAliasID == 22
  945. Found = 1
  946. DLCObjRef = Game.GetFormFromFile(0x0102CE92, "DLCCoast.esm") as ObjectReference ;
  947. EndIf
  948.  
  949. If TargetAliasID == 23
  950. Found = 1
  951. DLCObjRef = Game.GetFormFromFile(0x0100D393, "DLCNukaWorld.esm") as ObjectReference ;
  952. EndIf
  953.  
  954. If TargetAliasID == 24
  955. Found = 1
  956. DLCObjRef = Game.GetFormFromFile(0x01043C13, "DLCNukaWorld.esm") as ObjectReference ;
  957. EndIf
  958.  
  959. ElseIf TargetQuest == QuestRefVaults
  960.  
  961. If TargetAliasID == 5
  962. Found = 1
  963. DLCObjRef = Game.GetFormFromFile(0x01004217, "DLCworkshop03.esm") as ObjectReference ;
  964. EndIf
  965.  
  966. If TargetAliasID == 9
  967. Found = 1
  968. DLCObjRef = Game.GetFormFromFile(0x01038AFB, "DLCCoast.esm") as ObjectReference ;
  969. EndIf
  970.  
  971. Else
  972.  
  973. Debug.TraceAndBox("HITCHHIKER: TARGET QUEST IS NULL!")
  974.  
  975. EndIf
  976.  
  977. ; ********************************************************************************************************
  978. ; Grab the desired reference alias from the correct quest
  979. ; ********************************************************************************************************
  980.  
  981. If Found
  982. TargetAlias = TargetQuest.GetAlias(TargetAliasID) as ReferenceAlias
  983.  
  984. If HH_OptionDevTracking.GetValue() as Int == 1
  985. Debug.TraceAndBox("Hitchhiker: TargetAlias is " + TargetAlias + ".")
  986. EndIf
  987. EndIf
  988.  
  989. ; ********************************************************************************************************
  990. ; Force the refalias to the DLC objref
  991. ; ********************************************************************************************************
  992.  
  993. If Found
  994. If DLCObjRef
  995. TargetAlias.ForceRefTo(DLCObjRef)
  996. EndIf
  997. EndIf
  998.  
  999. Return Found
  1000. EndFunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement