Advertisement
ThoraldGM

HH Quest Script 20171215

Dec 17th, 2017
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 38.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 20171215
  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. Utility.Wait(0.1)
  175.  
  176. akSender.Stop() ; Done with quest until next time
  177. EndIf
  178.  
  179. Player.AddPerk(HH_TeleportNoFallDamage) ; IMPORTANT: Temp perk so teleport falls don't kill player!
  180.  
  181. If HH_OptionSpinGhost.GetValue() as Int == 1 ; If player wants no spin damage (default)
  182. If HH_OptionSpinCamera.GetValue() as Int == 1 ; If player wants spincam after teleport,
  183. Player.SetGhost() ; IMPORTANT: Player immune to all damage!
  184. EndIf ; *** Set ghost now BEFORE the spin! ***
  185.  
  186. If HH_OptionDevTracking.GetValue() as Int == 1 ; If player wants dev messages...
  187. If Player.IsGhost() ; If player is a ghost,
  188. Debug.Notification("Hitchhiker: Player is a ghost!") ; display dev message
  189. EndIf
  190. EndIf
  191. EndIf ; NOTE: Unghosting happens in HH_SpinCamera()
  192.  
  193. If HH_OptionTeleportSound.GetValue() as Int == 1 ; If player wants teleport sound,
  194. Int iInstanceID = OBJHijackerTeleportOut2DA.Play(Player) ; play teleport end sound at player
  195. EndIf
  196.  
  197. DestinationMarker = Player.PlaceAtMe(pXMarker) ; Dynamically spawn xmarker at player
  198.  
  199. STATIC TargetBase = TargetRef.GetBaseObject() as STATIC ; Check if target base object is an X/COC marker/header
  200.  
  201. If TargetBase == pXMarker || TargetBase == pXMarkerHeading || TargetBase == pCOCMarkerHeading ; Do not use XYZ offsets if destination is a marker
  202. DestinationMarker.MoveTo(TargetRef) ; so teleport will place player directly on the X
  203. Else ; else move marker to static ref with XYZ offsets
  204. Float OffsetX = HH_OptionOffsetX.GetValue() ; Player sets X (default 250)
  205. Float OffsetY = HH_OptionOffsetY.GetValue() ; Player sets Y (default 250)
  206. Float OffsetZ = HH_OptionOffsetZ.GetValue() ; Player sets Z (default 500)
  207. Utility.Wait(0.1)
  208. DestinationMarker.MoveTo(TargetRef, OffsetX, OffsetY, OffsetZ) ; Move marker with XYZ offsets
  209. DestinationMarker.MoveToNearestNavmeshLocation() ; Then move marker to nearest navmesh
  210. EndIf
  211.  
  212. If HH_OptionFastTravel.GetValue() as Int == 1 ; If player wants loading screens,
  213. Game.FastTravel(DestinationMarker) ; move player to marker (with load screens?)
  214. Else
  215. Player.MoveTo(DestinationMarker) ; else move player (with black screen)
  216. EndIf
  217.  
  218. Utility.Wait(0.1)
  219.  
  220. ; "If TargetRef Is Furniture" caused illegal typecast compiler error, so I wrote a custom function
  221. HH_TryToUseFurniture(Player, TargetRef)
  222.  
  223. ; ********************************************************************************************************
  224. ; Optional automatic time change on teleport
  225. ; ********************************************************************************************************
  226. If HH_OptionSetTime.GetValue() as Int == 1 ; If player wants automatic time change (default is NO)
  227. Int PrefTime = HH_OptionSetTimePreference.GetValue() as Int ; get preferred time
  228. HH_ForceTime(PrefTime) ; and set it
  229. EndIf
  230.  
  231. ; ********************************************************************************************************
  232. ; Optional automatic weather change on teleport
  233. ; ********************************************************************************************************
  234. If !Player.IsInInterior() ; If destination is NOT indoors...
  235. If HH_OptionSetWeather.GetValue() as Int == 1 ; If player wants automatic weather change (default is NO)
  236. Int PrefWeather = HH_OptionSetWeatherPreference.GetValue() as Int ; get preferred weather
  237. HH_ForceWeather(PrefWeather) ; and set it
  238. EndIf
  239. EndIf
  240.  
  241. If HH_OptionSpinCamera.GetValue() as Int == 1 ; If player wants spincam after teleport,
  242. HH_SpinCamera() ; call the custom spin camera function
  243. EndIf
  244.  
  245. StartTimer(10, 2) ; Remove HH_TeleportNoFallDamage perk in 10 seconds
  246. EndEvent
  247.  
  248. ; ------------------------------------------------------------------------------------------------------------
  249. ; CUSTOM FUNCTION: HH SPIN CAMERA
  250. ; ------------------------------------------------------------------------------------------------------------
  251.  
  252. Function HH_SpinCamera()
  253. Int SpinSeconds
  254. Game.ForceFirstPerson() ; IMPORTANT: Must start/run spin in first person!
  255.  
  256. ; Thx steve40 for distance & setini code
  257. Float CamMinDistance = HH_OptionCamMinDistance.GetValue() ; Player chooses min distance (default: 100, vanilla: 0)
  258. Float CamMaxDistance = HH_OptionCamMaxDistance.GetValue() ; Player chooses max distance (default: 200, vanilla: 150)
  259. Utility.SetIniFloat("fVanityModeMinDist:Camera", CamMinDistance) ; Set min
  260. Utility.SetIniFloat("fVanityModeMaxDist:Camera", CamMaxDistance) ; Set max
  261.  
  262. Utility.Wait(1) ; Wait a moment
  263. Utility.SetINIBool("bForceAutoVanityMode:Camera", true) ; Spin the idle camera around player
  264.  
  265. HH_IsSpinning.SetValue(1) ; Flag player / camera as spinning
  266.  
  267. SpinSeconds = HH_OptionSpinDuration.GetValue() as Int ; Player chooses how long to spin (default: 20 seconds)
  268. StartTimer(SpinSeconds, 1) ; Wait SpinSeconds then call StopSpinning from OnTimer event
  269. EndFunction
  270.  
  271. ; -----------------------------------------------------------------------------------------------------------
  272. ; EVENT: ON TIMER
  273. ; -----------------------------------------------------------------------------------------------------------
  274.  
  275. Event OnTimer(int aiTimerID) ; Cancel timer
  276. If aiTimerID == 1
  277. HH_StopSpinning() ; Call StopSpinning function
  278. ElseIf aiTimerID == 2
  279. Player.RemovePerk(HH_TeleportNoFallDamage) ; Temp perk removed after teleport is safely completed
  280.  
  281. If HH_OptionHeal.GetValue() as Int == 1 ; If player wants healed after teleport,
  282. Player.ResetHealthAndLimbs() ; reset health and limbs
  283. EndIf
  284.  
  285. Else
  286. ; Placeholder for additional timers
  287. EndIf
  288. EndEvent
  289.  
  290. ; ------------------------------------------------------------------------------------------------------------
  291. ; CUSTOM FUNCTION: HH STOP SPINNING
  292. ; ------------------------------------------------------------------------------------------------------------
  293.  
  294. Function HH_StopSpinning()
  295. CancelTimer(1) ; Cancel any lingering StopSpinning timers
  296.  
  297. If Player.IsGhost() ; If player is a ghost,
  298. Player.SetGhost(false) ; IMPORTANT: Undo player's temporary invulnerability
  299.  
  300. If HH_OptionDevTracking.GetValue() as Int == 1 ; If player wants dev messages
  301. If Player.IsGhost() == false ; If player is no longer a ghost,
  302. Debug.Notification("Hitchhiker: Player is not a ghost.") ; display dev message
  303. EndIf
  304. EndIf
  305. EndIf
  306.  
  307. If HH_IsSpinning.GetValue() as Int == 1 ; If player is spinning,
  308. Utility.SetINIBool("bForceAutoVanityMode:Camera", false) ; stop spinning
  309.  
  310. Game.ForceFirstPerson() ; IMPORTANT: Call this or spin will last forever!
  311.  
  312. HH_IsSpinning.SetValue(0) ; Flag player / camera as no longer spinning
  313.  
  314. EndIf ; Done with optional spincam effect
  315. EndFunction
  316.  
  317. ; ------------------------------------------------------------------------------------------------------------
  318. ; CUSTOM FUNCTION: HH SET DESTINATION
  319. ; ------------------------------------------------------------------------------------------------------------
  320.  
  321. Function HH_SetDestination(Quest RefQuest, Int RefAliasID)
  322. QuestToGrab = RefQuest
  323.  
  324. If HH_OptionDevTracking.GetValue() as Int == 1
  325. Debug.TraceAndBox("Hitchhiker: Set Dest Quest is " + QuestToGrab + ".")
  326. EndIf
  327.  
  328. HH_RefAliasID.SetValue(RefAliasID)
  329.  
  330. If HH_OptionDevTracking.GetValue() as Int == 1
  331. Debug.TraceAndBox("Hitchhiker: RefAliasID is " + HH_RefAliasID.GetValue() as Int + ".")
  332. EndIf
  333.  
  334. EndFunction
  335.  
  336. ; ------------------------------------------------------------------------------------------------------------
  337. ; CUSTOM FUNCTION: HH SET RANDOM DESTINATION
  338. ; ------------------------------------------------------------------------------------------------------------
  339.  
  340. Function HH_SetRandomDestination(Int Category)
  341. Quest RefQuest
  342. Int RefAliasCount
  343. Int RefAliasID
  344. Int ReRoll
  345. Int ExcludeDLC = HH_OptionExcludeDLC.GetValue() as Int
  346. Int ExcludeFH = HH_OptionExcludeFH.GetValue() as Int
  347. Int ExcludeNW = HH_OptionExcludeNW.GetValue() as Int
  348. Int ExcludeVT = HH_OptionExcludeVT.GetValue() as Int
  349.  
  350. If HH_PlayerHasFH.GetValue() as Int == 0
  351. ExcludeFH = 1
  352. EndIf
  353.  
  354. If HH_PlayerHasNW.GetValue() as Int == 0
  355. ExcludeNW = 1
  356. EndIf
  357.  
  358. If HH_PlayerHasVT.GetValue() as Int == 0
  359. ExcludeVT = 1
  360. EndIf
  361.  
  362. If Category == 1
  363. RefQuest = QuestRefBusShelters
  364. RefAliasCount = 10
  365. ElseIf Category == 2
  366. RefQuest = QuestRefDiners
  367. RefAliasCount = 30
  368. ElseIf Category == 3
  369. RefQuest = QuestRefDriveIns
  370. RefAliasCount = 12
  371. ElseIf Category == 4
  372. RefQuest = QuestRefDives
  373. RefAliasCount = 13
  374. ElseIf Category == 5
  375. RefQuest = QuestRefFactories
  376. RefAliasCount = 12
  377. ElseIf Category == 6
  378. RefQuest = QuestRefFarms
  379. RefAliasCount = 12
  380. ElseIf Category == 7
  381. RefQuest = QuestRefJunkyards
  382. RefAliasCount = 20
  383. ElseIf Category == 8
  384. RefQuest = QuestRefMilitaryBases
  385. RefAliasCount = 20
  386. ElseIf Category == 9
  387. RefQuest = QuestRefMonuments
  388. RefAliasCount = 30
  389. ElseIf Category == 10
  390. RefQuest = QuestRefPowerLifts
  391. RefAliasCount = 15
  392. ElseIf Category == 11
  393. RefQuest = QuestRefRedRocket
  394. RefAliasCount = 25
  395. Else
  396. RefQuest = QuestRefVaults
  397. RefAliasCount = 10
  398. EndIf
  399.  
  400. If HH_OptionDevTracking.GetValue() as Int == 1
  401. Debug.TraceAndBox("Hitchhiker: SRD RefQuest is " + RefQuest + ".")
  402. Debug.TraceAndBox("Hitchhiker: RefAliasCount is " + RefAliasCount +".")
  403. EndIf
  404.  
  405. ; ********************************************************************************************************
  406. ; Do-while functionality. Only loops if rolled destination is unwanted DLC.
  407. ; ********************************************************************************************************
  408.  
  409. ReRoll = 1
  410.  
  411. While ReRoll == 1
  412. ReRoll = 0
  413. RefAliasID = Utility.RandomInt(0, (RefAliasCount - 1)) ; Roll random 0 through (count - 1)
  414.  
  415. If ExcludeDLC == 1 || ExcludeFH == 1
  416. If HH_IsInFarHarbor(RefQuest, RefAliasID) == 1
  417. ReRoll = 1
  418. If HH_OptionDevTracking.GetValue() as Int == 1
  419. Debug.TraceAndBox("Hitchhiker: FH ReRoll.")
  420. EndIf
  421. EndIf
  422. EndIf
  423.  
  424. If !ReRoll
  425. If ExcludeDLC == 1 || ExcludeNW == 1
  426. If HH_IsInNukaWorld(RefQuest, RefAliasID) == 1
  427. ReRoll = 1
  428. If HH_OptionDevTracking.GetValue() as Int == 1
  429. Debug.TraceAndBox("Hitchhiker: NW ReRoll.")
  430. EndIf
  431. EndIf
  432. EndIf
  433. EndIf
  434.  
  435. If !ReRoll
  436. If ExcludeDLC == 1 || ExcludeVT == 1
  437. If RefQuest == QuestRefVaults && RefAliasID == 5
  438. ReRoll = 1
  439. If HH_OptionDevTracking.GetValue() as Int == 1
  440. Debug.TraceAndBox("Hitchhiker: VT ReRoll.")
  441. EndIf
  442. EndIf
  443. EndIf
  444. EndIf
  445. EndWhile
  446.  
  447. QuestToGrab = RefQuest
  448. HH_RefAliasID.SetValue(RefAliasID)
  449.  
  450. If HH_OptionDevTracking.GetValue() as Int == 1
  451. Debug.TraceAndBox("Hitchhiker: SRD QuestToGrab is " + QuestToGrab + ".")
  452. Debug.TraceAndBox("Hitchhiker: RefAliasID is " + RefAliasID +".")
  453. EndIf
  454.  
  455. EndFunction
  456.  
  457. ; ------------------------------------------------------------------------------------------------------------
  458. ; CUSTOM FUNCTION: HH IS IN FAR HARBOR
  459. ; ------------------------------------------------------------------------------------------------------------
  460.  
  461. Int Function HH_IsInFarHarbor(Quest TargetQuest, Int TargetAliasID)
  462. Int Located = 0
  463.  
  464. If HH_OptionDevTracking.GetValue() as Int == 1
  465. Debug.TraceAndBox("Hitchhiker: Checking IsInFarHarbor.")
  466. EndIf
  467.  
  468. If TargetQuest == QuestRefBusShelters
  469. ; No bus shelters
  470. ElseIf TargetQuest == QuestRefDiners
  471. If TargetAliasID == 3
  472. Located = 1
  473. EndIf
  474. ElseIf TargetQuest == QuestRefDives
  475. If TargetAliasID == 10
  476. Located = 1
  477. EndIf
  478. ElseIf TargetQuest == QuestRefDriveIns
  479. If TargetAliasID == 5
  480. Located = 1
  481. EndIf
  482. ElseIf TargetQuest == QuestRefFactories
  483. If TargetAliasID == 7 || TargetAliasID == 10
  484. Located = 1
  485. EndIf
  486. ElseIf TargetQuest == QuestRefFarms
  487. ; No farms
  488. ElseIf TargetQuest == QuestRefJunkyards
  489. Int[] MyArray
  490. MyArray.Add(1)
  491. MyArray.Add(3)
  492. MyArray.Add(4)
  493. MyArray.Add(6)
  494. MyArray.Add(8)
  495. MyArray.Add(10)
  496. MyArray.Add(12)
  497. MyArray.Add(17)
  498. If MyArray.Find(TargetAliasID) >= 0
  499. Located = 1
  500. EndIf
  501. ElseIf TargetQuest == QuestRefMilitaryBases
  502. If TargetAliasID == 0 || TargetAliasID == 18
  503. Located = 1
  504. EndIf
  505. ElseIf TargetQuest == QuestRefMonuments
  506. If TargetAliasID == 2 || TargetAliasID == 21 || TargetAliasID == 26
  507. Located = 1
  508. EndIf
  509. ElseIf TargetQuest == QuestRefPowerLifts
  510. ; No power lifts
  511. ElseIf TargetQuest == QuestRefRedRocket
  512. If TargetAliasID == 20 || TargetAliasID == 21 || TargetAliasID == 22
  513. Located = 1
  514. EndIf
  515. ElseIf TargetQuest == QuestRefVaults
  516. If TargetAliasID == 9
  517. Located = 1
  518. EndIf
  519. Else
  520. Debug.TraceAndBox("HITCHHIKER: NULL IN FH CHECK!")
  521. EndIf
  522.  
  523. If Located
  524. Return 1
  525. Else
  526. Return 0
  527. EndIf
  528. EndFunction
  529.  
  530. ; ------------------------------------------------------------------------------------------------------------
  531. ; CUSTOM FUNCTION: HH IS IN NUKA WORLD
  532. ; ------------------------------------------------------------------------------------------------------------
  533.  
  534. Int Function HH_IsInNukaWorld(Quest TargetQuest, Int TargetAliasID)
  535. Int Located = 0
  536.  
  537. If HH_OptionDevTracking.GetValue() as Int == 1
  538. Debug.TraceAndBox("Hitchhiker: Checking IsInNukaWorld.")
  539. EndIf
  540.  
  541. If TargetQuest == QuestRefBusShelters
  542. ; No bus shelters
  543. ElseIf TargetQuest == QuestRefDiners
  544. If TargetAliasID == 2 || TargetAliasID == 13
  545. Located = 1
  546. EndIf
  547. ElseIf TargetQuest == QuestRefDives
  548. If TargetAliasID == 2
  549. Located = 1
  550. EndIf
  551. ElseIf TargetQuest == QuestRefDriveIns
  552. If TargetAliasID == 0 || TargetAliasID == 3 || TargetAliasID == 9 || TargetAliasID == 10
  553. Located = 1
  554. EndIf
  555. ElseIf TargetQuest == QuestRefFactories
  556. If TargetAliasID == 11
  557. Located = 1
  558. EndIf
  559. ElseIf TargetQuest == QuestRefFarms
  560. ; No farms
  561. ElseIf TargetQuest == QuestRefJunkyards
  562. If TargetAliasID == 9
  563. Located = 1
  564. EndIf
  565. ElseIf TargetQuest == QuestRefMilitaryBases
  566. If TargetAliasID == 11 || TargetAliasID == 12
  567. Located = 1
  568. EndIf
  569. ElseIf TargetQuest == QuestRefMonuments
  570. If TargetAliasID == 4 || TargetAliasID == 9 || TargetAliasID == 23 || TargetAliasID == 24
  571. Located = 1
  572. EndIf
  573. ElseIf TargetQuest == QuestRefPowerLifts
  574. If TargetAliasID == 13 || TargetAliasID == 14
  575. Located = 1
  576. EndIf
  577. ElseIf TargetQuest == QuestRefRedRocket
  578. If TargetAliasID == 23 || TargetAliasID == 24
  579. Located = 1
  580. EndIf
  581. ElseIf TargetQuest == QuestRefVaults
  582. ; No vaults
  583. Else
  584. Debug.TraceAndBox("HITCHHIKER: NULL IN NW CHECK!")
  585. EndIf
  586.  
  587. If Located
  588. Return 1
  589. Else
  590. Return 0
  591. EndIf
  592. EndFunction
  593.  
  594. ; ------------------------------------------------------------------------------------------------------------
  595. ; CUSTOM FUNCTION: HH QUERY QUEST
  596. ; ------------------------------------------------------------------------------------------------------------
  597.  
  598. Quest Function HH_QueryQuest()
  599. Return QuestToGrab
  600. EndFunction
  601.  
  602. ; ------------------------------------------------------------------------------------------------------------
  603. ; CUSTOM FUNCTION: IS FURNITURE
  604. ; ------------------------------------------------------------------------------------------------------------
  605.  
  606. ; Declared in properties: FormList Property HH_IsFurniture Auto Const Mandatory
  607. ; NESTED: Property is a formlist of formlists of furnitures. (Total = 302 NPC/Player furniture actions)
  608. ; [0] IsFurnitureBed 34
  609. ; [1] IsFurnitureBedWorkshop 20
  610. ; [2] IsFurnitureBench 19
  611. ; [3] IsFurnitureChair 57
  612. ; [4] IsFurnitureCouch 24
  613. ; [5] IsFurnitureInstitute 11
  614. ; [6] IsFurnitureInv 6
  615. ; [7] IsFurnitureKneel 6
  616. ; [8] IsFurnitureMisc 104
  617. ; [9] IsFurnitureStand 8
  618. ; [10] IsFurnitureStool 13
  619.  
  620. Int Function IsFurniture(ObjectReference TargetToCheck)
  621. Form TargetBaseObject = TargetToCheck.GetBaseObject()
  622. FormList FurnList = HH_IsFurniture ; FormList declared in properties
  623. FormList NestedList
  624. Int FurnSize = FurnList.GetSize()
  625. Int i = 0
  626. Int Found = 0
  627.  
  628. While i < FurnSize && !Found ; Stop loop if form found in furniture
  629. NestedList = FurnList.GetAt(i) as FormList ; Loop grabs next unchecked formlist
  630.  
  631. If NestedList.HasForm(TargetBaseObject) ; If found,
  632. Found = 1 ; mark as found and break loop
  633. Else
  634. i += 1 ; else iterate and keep looking
  635. EndIf
  636. EndWhile
  637.  
  638. Return Found ; return found (1) or not found (0) to caller
  639. EndFunction
  640.  
  641. ; ------------------------------------------------------------------------------------------------------------
  642. ; CUSTOM FUNCTION: HH TRY TO USE FURNITURE
  643. ; ------------------------------------------------------------------------------------------------------------
  644.  
  645. Int Function HH_TryToUseFurniture(Actor Person, ObjectReference TargetRef)
  646. Int DidItWork = 0
  647.  
  648. If IsFurniture(TargetRef) == 1 ; If target can be used (chair, wall lean, etc)
  649. If TargetRef.IsFurnitureInUse(True) == False ; and target is not in use right now (ignores reserved)
  650. If Person.SnapIntoInteraction(TargetRef) ; then attempt to use the furniture
  651. DidItWork = 1
  652. EndIf
  653. EndIf
  654. EndIf
  655.  
  656. Return DidItWork
  657. EndFunction
  658.  
  659. ; ------------------------------------------------------------------------------------------------------------
  660. ; CUSTOM FUNCTION: HH FORCE TIME
  661. ; ------------------------------------------------------------------------------------------------------------
  662.  
  663. Function HH_ForceTime(Int TargetHour)
  664. Int CurrentHour = pGameHour.GetValue() as Int ; Get current game hour
  665. Int MyDuration ; and determine how long to wait
  666.  
  667. If TargetHour < 0 || TargetHour > 24
  668. TargetHour = 9
  669. EndIf
  670.  
  671. If CurrentHour < TargetHour ; If target is later in same day,
  672. MyDuration = TargetHour - CurrentHour ; waiting period is easy to calculate
  673. Else
  674. Int Difference = CurrentHour - TargetHour
  675. MyDuration = 24 - Difference ; else duration is difference subtracted from midnight
  676. EndIf
  677.  
  678. If MyDuration > 0 && MyDuration < 24 ; If duration will result in a time change,
  679. Game.PassTime(MyDuration) ; wait that duration
  680. EndIf
  681. EndFunction
  682.  
  683. ; ------------------------------------------------------------------------------------------------------------
  684. ; CUSTOM FUNCTION: HH FORCE WEATHER
  685. ; ------------------------------------------------------------------------------------------------------------
  686.  
  687. Function HH_ForceWeather(Int MyForecast)
  688. If !Player.IsInInterior() ; If destination is NOT indoors...
  689. Weather MyWeather
  690.  
  691. If MyForecast == 1
  692. MyWeather = CommonwealthClear ; Clear
  693. ElseIf MyForecast == 2
  694. MyWeather = CommonwealthDusty ; Dusty
  695. ElseIf MyForecast == 3
  696. MyWeather = CommonwealthFoggy ; Foggy
  697. ElseIf MyForecast == 4
  698. MyWeather = CommonwealthMisty ; Misty
  699. ElseIf MyForecast == 5
  700. MyWeather = CommonwealthMistyRainy ; Misty Rainy
  701. ElseIf MyForecast == 6
  702. MyWeather = CommonwealthOvercast ; Overcast
  703. ElseIf MyForecast == 7
  704. MyWeather = CommonwealthGSRadstorm ; Radstorm
  705. ElseIf MyForecast == 8
  706. MyWeather = CommonwealthRain ; Rain
  707. Else
  708. MyWeather = DefaultWeather ; Default Weather (outdoors)
  709. EndIf
  710.  
  711. MyWeather.ForceActive() ; Force weather change now
  712. EndIf
  713. EndFunction
  714.  
  715. ; ------------------------------------------------------------------------------------------------------------
  716. ; CUSTOM FUNCTION: HH FORCE DLC REFALIAS
  717. ; ------------------------------------------------------------------------------------------------------------
  718.  
  719. Int Function HH_ForceDLCRefAlias(Quest TargetQuest, Int TargetAliasID)
  720. ObjectReference DLCObjRef
  721. ReferenceAlias TargetAlias
  722.  
  723. ; ********************************************************************************************************
  724. ; Grab the desired object reference from the correct DLC
  725. ; ********************************************************************************************************
  726.  
  727. If TargetQuest == QuestRefBusShelters
  728. ; No DLC refs
  729.  
  730. ElseIf TargetQuest == QuestRefDiners
  731.  
  732. If TargetAliasID == 2
  733. DLCObjRef = Game.GetFormFromFile(0x01038291, "DLCNukaWorld.esm") as ObjectReference ;
  734. EndIf
  735.  
  736. If TargetAliasID == 3
  737. DLCObjRef = Game.GetFormFromFile(0x0102A675, "DLCCoast.esm") as ObjectReference ;
  738. EndIf
  739.  
  740. If TargetAliasID == 13
  741. DLCObjRef = Game.GetFormFromFile(0x010377CB, "DLCNukaWorld.esm") as ObjectReference ;
  742. EndIf
  743.  
  744. ElseIf TargetQuest == QuestRefDives
  745.  
  746. If TargetAliasID == 2
  747. DLCObjRef = Game.GetFormFromFile(0x01044720, "DLCNukaWorld.esm") as ObjectReference ;
  748. EndIf
  749.  
  750. If TargetAliasID == 10
  751. DLCObjRef = Game.GetFormFromFile(0x010034DC, "DLCCoast.esm") as ObjectReference ;
  752. EndIf
  753.  
  754. ElseIf TargetQuest == QuestRefDriveIns
  755.  
  756. If TargetAliasID == 0
  757. DLCObjRef = Game.GetFormFromFile(0x0104A69F, "DLCNukaWorld.esm") as ObjectReference ;
  758. EndIf
  759.  
  760. If TargetAliasID == 3
  761. DLCObjRef = Game.GetFormFromFile(0x010447FE, "DLCNukaWorld.esm") as ObjectReference ;
  762. EndIf
  763.  
  764. If TargetAliasID == 5
  765. DLCObjRef = Game.GetFormFromFile(0x01004BEF, "DLCCoast.esm") as ObjectReference ;
  766. EndIf
  767.  
  768. If TargetAliasID == 9
  769. DLCObjRef = Game.GetFormFromFile(0x0100E76F, "DLCNukaWorld.esm") as ObjectReference ;
  770. EndIf
  771.  
  772. If TargetAliasID == 10
  773. DLCObjRef = Game.GetFormFromFile(0x01021D80, "DLCNukaWorld.esm") as ObjectReference ;
  774. EndIf
  775.  
  776. ElseIf TargetQuest == QuestRefFactories
  777.  
  778. If TargetAliasID == 7
  779. DLCObjRef = Game.GetFormFromFile(0x01037958, "DLCCoast.esm") as ObjectReference ;
  780. EndIf
  781.  
  782. If TargetAliasID == 10
  783. DLCObjRef = Game.GetFormFromFile(0x01016F96, "DLCCoast.esm") as ObjectReference ;
  784. EndIf
  785.  
  786. If TargetAliasID == 11
  787. DLCObjRef = Game.GetFormFromFile(0x01019534, "DLCNukaWorld.esm") as ObjectReference ;
  788. EndIf
  789.  
  790. ElseIf TargetQuest == QuestRefFarms
  791. ; No DLC refs
  792.  
  793. ElseIf TargetQuest == QuestRefJunkyards
  794.  
  795. If TargetAliasID == 1
  796. DLCObjRef = Game.GetFormFromFile(0x010093F3, "DLCCoast.esm") as ObjectReference ;
  797. EndIf
  798.  
  799. If TargetAliasID == 3
  800. DLCObjRef = Game.GetFormFromFile(0x0102074A, "DLCCoast.esm") as ObjectReference ;
  801. EndIf
  802.  
  803. If TargetAliasID == 4
  804. DLCObjRef = Game.GetFormFromFile(0x010093F2, "DLCCoast.esm") as ObjectReference ;
  805. EndIf
  806.  
  807. If TargetAliasID == 6
  808. DLCObjRef = Game.GetFormFromFile(0x0100B1CF, "DLCCoast.esm") as ObjectReference ;
  809. EndIf
  810.  
  811. If TargetAliasID == 8
  812. DLCObjRef = Game.GetFormFromFile(0x0102065A, "DLCCoast.esm") as ObjectReference ;
  813. EndIf
  814.  
  815. If TargetAliasID == 9
  816. DLCObjRef = Game.GetFormFromFile(0x0101742A, "DLCNukaWorld.esm") as ObjectReference ;
  817. EndIf
  818.  
  819. If TargetAliasID == 10
  820. DLCObjRef = Game.GetFormFromFile(0x0104FFA7, "DLCCoast.esm") as ObjectReference ;
  821. EndIf
  822.  
  823. If TargetAliasID == 12
  824. DLCObjRef = Game.GetFormFromFile(0x0105422F, "DLCCoast.esm") as ObjectReference ;
  825. EndIf
  826.  
  827. If TargetAliasID == 17
  828. DLCObjRef = Game.GetFormFromFile(0x010399CB, "DLCCoast.esm") as ObjectReference ;
  829. EndIf
  830.  
  831. ElseIf TargetQuest == QuestRefMilitaryBases
  832.  
  833. If TargetAliasID == 0
  834. DLCObjRef = Game.GetFormFromFile(0x01034345, "DLCCoast.esm") as ObjectReference ;
  835. EndIf
  836.  
  837. If TargetAliasID == 11
  838. DLCObjRef = Game.GetFormFromFile(0x0105666F, "DLCNukaWorld.esm") as ObjectReference ;
  839. EndIf
  840.  
  841. If TargetAliasID == 12
  842. DLCObjRef = Game.GetFormFromFile(0x0104B18E, "DLCNukaWorld.esm") as ObjectReference ;
  843. EndIf
  844.  
  845. If TargetAliasID == 18
  846. DLCObjRef = Game.GetFormFromFile(0x01004D15, "DLCCoast.esm") as ObjectReference ;
  847. EndIf
  848.  
  849. ElseIf TargetQuest == QuestRefMonuments
  850.  
  851. If TargetAliasID == 2
  852. DLCObjRef = Game.GetFormFromFile(0x0100ECE7, "DLCCoast.esm") as ObjectReference ;
  853. EndIf
  854.  
  855. If TargetAliasID == 4
  856. DLCObjRef = Game.GetFormFromFile(0x010566B8, "DLCNukaWorld.esm") as ObjectReference ;
  857. EndIf
  858.  
  859. If TargetAliasID == 9
  860. DLCObjRef = Game.GetFormFromFile(0x0104E0EF, "DLCNukaWorld.esm") as ObjectReference ;
  861. EndIf
  862.  
  863. If TargetAliasID == 21
  864. DLCObjRef = Game.GetFormFromFile(0x0100AB27, "DLCCoast.esm") as ObjectReference ;
  865. EndIf
  866.  
  867. If TargetAliasID == 23
  868. DLCObjRef = Game.GetFormFromFile(0x010379BD, "DLCNukaWorld.esm") as ObjectReference ;
  869. EndIf
  870.  
  871. If TargetAliasID == 24
  872. DLCObjRef = Game.GetFormFromFile(0x0100ADB5, "DLCNukaWorld.esm") as ObjectReference ;
  873. EndIf
  874.  
  875. If TargetAliasID == 26
  876. DLCObjRef = Game.GetFormFromFile(0x01056917, "DLCCoast.esm") as ObjectReference ;
  877. EndIf
  878.  
  879. ElseIf TargetQuest == QuestRefPowerLifts
  880.  
  881. If TargetAliasID == 13
  882. DLCObjRef = Game.GetFormFromFile(0x010496B9, "DLCNukaWorld.esm") as ObjectReference ;
  883. EndIf
  884.  
  885. If TargetAliasID == 14
  886. DLCObjRef = Game.GetFormFromFile(0x01051EAD, "DLCNukaWorld.esm") as ObjectReference ;
  887. EndIf
  888.  
  889. ElseIf TargetQuest == QuestRefRedRocket
  890.  
  891. If TargetAliasID == 20
  892. DLCObjRef = Game.GetFormFromFile(0x01004D6F, "DLCCoast.esm") as ObjectReference ;
  893. EndIf
  894.  
  895. If TargetAliasID == 21
  896. DLCObjRef = Game.GetFormFromFile(0x0100C51A, "DLCCoast.esm") as ObjectReference ;
  897. EndIf
  898.  
  899. If TargetAliasID == 22
  900. DLCObjRef = Game.GetFormFromFile(0x0102CE92, "DLCCoast.esm") as ObjectReference ;
  901. EndIf
  902.  
  903. If TargetAliasID == 23
  904. DLCObjRef = Game.GetFormFromFile(0x0100D393, "DLCNukaWorld.esm") as ObjectReference ;
  905. EndIf
  906.  
  907. If TargetAliasID == 24
  908. DLCObjRef = Game.GetFormFromFile(0x01043C13, "DLCNukaWorld.esm") as ObjectReference ;
  909. EndIf
  910.  
  911. ElseIf TargetQuest == QuestRefVaults
  912.  
  913. If TargetAliasID == 5
  914. DLCObjRef = Game.GetFormFromFile(0x01004217, "DLCworkshop03.esm") as ObjectReference ;
  915. EndIf
  916.  
  917. If TargetAliasID == 9
  918. DLCObjRef = Game.GetFormFromFile(0x01038AFB, "DLCCoast.esm") as ObjectReference ;
  919. EndIf
  920.  
  921. Else
  922.  
  923. Debug.TraceAndBox("HITCHHIKER: FORCE DLC REF IS NULL!")
  924.  
  925. EndIf
  926.  
  927. ; ********************************************************************************************************
  928. ; Grab the desired reference alias from the correct quest
  929. ; ********************************************************************************************************
  930.  
  931. Utility.Wait(0.1)
  932. TargetAlias = TargetQuest.GetAlias(TargetAliasID) as ReferenceAlias
  933.  
  934. ; ********************************************************************************************************
  935. ; Force the refalias to the DLC objref
  936. ; ********************************************************************************************************
  937.  
  938. TargetAlias.Clear()
  939.  
  940. While TargetAlias.GetReference() != NONE
  941. ; Pause until TargetAlias is cleared
  942. EndWhile
  943.  
  944. TargetAlias.ForceRefTo(DLCObjRef)
  945.  
  946. While TargetAlias.GetReference() == NONE
  947. ; Pause until TargetAlias is filled
  948. EndWhile
  949.  
  950. Return 1
  951. EndFunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement