Advertisement
ThoraldGM

HH Quest Script 20171214

Dec 14th, 2017
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.11 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 20171214
  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.  
  28. ; ------------------------------------------------------------------------------------------------------------
  29. ; PROPERTIES
  30. ; ------------------------------------------------------------------------------------------------------------
  31.  
  32. ; ************************************************************************************************************
  33. ; Player menu options (21 total):
  34. ; ************************************************************************************************************
  35. GlobalVariable Property HH_OptionCamMaxDistance Auto Mandatory ; Max camera distance (default: 200, vanilla: 150)
  36. GlobalVariable Property HH_OptionCamMinDistance Auto Mandatory ; Min camera distance (default: 100, vanilla: 0)
  37. GlobalVariable Property HH_OptionDevTracking Auto Mandatory ; Does player want dev messages? (default: no)
  38. GlobalVariable Property HH_OptionExcludeDLC Auto Mandatory ; Turn all DLC on/off in available destinations (default: on if installed)
  39. GlobalVariable Property HH_OptionExcludeFH Auto Mandatory ; Turn Far Harbor DLC on/off in destinations (default: on if installed)
  40. GlobalVariable Property HH_OptionExcludeNW Auto Mandatory ; Turn Nuka-World DLC on/off in destinations (default: on if installed)
  41. GlobalVariable Property HH_OptionExcludeVT Auto Mandatory ; Turn Vault-Tec DLC on/off in destinations (default: on if installed)
  42. GlobalVariable Property HH_OptionFastTravel Auto Mandatory ; Does player want loading screens? (default: yes)
  43. GlobalVariable Property HH_OptionHeal Auto Mandatory ; Does player want to heal after teleport? (default: no)
  44. GlobalVariable Property HH_OptionOffsetX Auto Mandatory ; Player can choose X offset (default: 250)
  45. GlobalVariable Property HH_OptionOffsetY Auto Mandatory ; Player can choose Y offset (default: 250)
  46. GlobalVariable Property HH_OptionOffsetZ Auto Mandatory ; Player can choose Z offset (default: 500)
  47. GlobalVariable Property HH_OptionSetTime Auto Mandatory ; Change time after teleport? (default: no)
  48. GlobalVariable Property HH_OptionSetTimePreference Auto Mandatory ; Preferred game hour (player sets in menu)
  49. GlobalVariable Property HH_OptionSetWeather Auto Mandatory ; Change weather after teleport? (default: no)
  50. GlobalVariable Property HH_OptionSetWeatherPreference Auto Mandatory ; Preferred game weather (player sets in menu)
  51. GlobalVariable Property HH_OptionSitFurniture Auto Mandatory ; If destination is furniture, choose whether to use it (default: yes)
  52. GlobalVariable Property HH_OptionSpinCamera Auto Mandatory ; Does player want teleport to spin camera? (default: yes)
  53. GlobalVariable Property HH_OptionSpinDuration Auto Mandatory ; How long should camera spin? (default: 20 seconds)
  54. GlobalVariable Property HH_OptionSpinGhost Auto Mandatory ; Does player want invulnerable spin? (default: yes)
  55. GlobalVariable Property HH_OptionTeleportSound Auto Mandatory ; Does player want teleport sound? (default: yes)
  56.  
  57. ; ************************************************************************************************************
  58. ; Ref quests to avoid persistence / bloat:
  59. ; ************************************************************************************************************
  60. Quest Property QuestRefBusShelters Auto Const Mandatory ; Quest stores Bus Shelters ref aliases
  61. Quest Property QuestRefDiners Auto Const Mandatory ; Quest stores Diners ref aliases
  62. Quest Property QuestRefDives Auto Const Mandatory ; Quest stores Dives ref aliases
  63. Quest Property QuestRefDriveIns Auto Const Mandatory ; Quest stores Drive-Ins ref aliases
  64. Quest Property QuestRefFactories Auto Const Mandatory ; Quest stores Factories ref aliases
  65. Quest Property QuestRefFarms Auto Const Mandatory ; Quest stores Farms ref aliases
  66. Quest Property QuestRefJunkyards Auto Const Mandatory ; Quest stores Junkyards ref aliases
  67. Quest Property QuestRefMilitaryBases Auto Const Mandatory ; Quest stores Military Bases ref aliases
  68. Quest Property QuestRefMonuments Auto Const Mandatory ; Quest stores Monuments ref aliases
  69. Quest Property QuestRefPowerLifts Auto Const Mandatory ; Quest stores Power Lifts ref aliases
  70. Quest Property QuestRefRedRocket Auto Const Mandatory ; Quest stores Red Rocket ref aliases
  71. Quest Property QuestRefVaults Auto Const Mandatory ; Quest stores Vaults ref aliases
  72. Quest QuestToGrab
  73.  
  74. ; ************************************************************************************************************
  75. ; Weather:
  76. ; ************************************************************************************************************
  77. Weather Property DefaultWeather Auto Const Mandatory ; Default weather (outdoors)
  78. Weather Property CommonwealthClear Auto Const Mandatory ; Clear
  79. Weather Property CommonwealthDusty Auto Const Mandatory ; Dusty
  80. Weather Property CommonwealthFoggy Auto Const Mandatory ; Foggy
  81. Weather Property CommonwealthMisty Auto Const Mandatory ; Misty
  82. Weather Property CommonwealthMistyRainy Auto Const Mandatory ; Misty Rainy
  83. Weather Property CommonwealthOvercast Auto Const Mandatory ; Overcast
  84. Weather Property CommonwealthGSRadstorm Auto Const Mandatory ; Radstorm
  85. Weather Property CommonwealthRain Auto Const Mandatory ; Rain
  86.  
  87. ; ************************************************************************************************************
  88. ; Everything else:
  89. ; ************************************************************************************************************
  90. Actor Player ; Player actor
  91. Book Property HH_Map Auto Const Mandatory ; Hitchhiker map
  92. FormList Property HH_IsFurniture Auto Const Mandatory ; Formlist of formlists of furnitures
  93. GlobalVariable Property HH_IsSpinning Auto Mandatory ; Is the camera currently spinning?
  94. GlobalVariable Property HH_PlayerHasFH Auto Mandatory ; Does player have Far Harbor DLC?
  95. GlobalVariable Property HH_PlayerHasNW Auto Mandatory ; Does player have Nuka-World DLC?
  96. GlobalVariable Property HH_PlayerHasVT Auto Mandatory ; Does player have Vault-Tec DLC?
  97. GlobalVariable Property HH_RefAliasID Auto Mandatory ; Which specific location did player select?
  98. GlobalVariable Property HH_ShowMenu Auto Mandatory ; Don't show menu when map placed in inventory
  99. GlobalVariable Property pGameHour Auto Mandatory ; Current game hour (from vanilla CK)
  100. Perk Property HH_TeleportNoFallDamage Auto Const Mandatory ; Temp perk so teleport falls don't kill player
  101. Sound Property DRSVertibirdFlightLoadOpen Auto Const Mandatory ; Teleport start sound effect
  102. Sound Property OBJHijackerTeleportOut2DA Auto Const Mandatory ; Teleport end sound effect
  103. STATIC Property pXMarker Auto Const Mandatory ; Xmarker (from vanilla CK)
  104. STATIC Property pXMarkerHeading Auto Const Mandatory ; Xmarker heading (from vanilla CK)
  105. STATIC Property pCOCMarkerHeading Auto Const Mandatory ; COC Xmarker heading (from vanilla CK)
  106.  
  107. ; ------------------------------------------------------------------------------------------------------------
  108. ; EVENT: ON INIT
  109. ; ------------------------------------------------------------------------------------------------------------
  110.  
  111. Event OnInit()
  112. Player = Game.GetPlayer() ; Player actor
  113. Utility.Wait(0.1) ; Wait a moment before using actor
  114.  
  115. If Player.GetItemCount(HH_Map) == 0 ; If player doesn't have hitchhiker map,
  116. HH_ShowMenu.SetValue(0) ; don't show menu when map placed in inventory
  117. Utility.Wait(5) ; wait 5 seconds
  118. Player.AddItem(HH_Map) ; spawn hitchhiker map in player inventory
  119. EndIf
  120. EndEvent
  121.  
  122. ; ------------------------------------------------------------------------------------------------------------
  123. ; CUSTOM FUNCTION: HH START HITCHING
  124. ; ------------------------------------------------------------------------------------------------------------
  125.  
  126. Function HH_StartHitching()
  127. RegisterForRemoteEvent(QuestToGrab, "OnQuestInit") ; Listen for refs quest start
  128. Utility.Wait(0.1) ; Wait a moment for registration to finish
  129.  
  130. If HH_OptionTeleportSound.GetValue() as Int == 1 ; If player wants teleport sound,
  131. Int iInstanceID = DRSVertibirdFlightLoadOpen.Play(Player) ; play teleport start sound at player
  132. EndIf
  133.  
  134. If HH_OptionDevTracking.GetValue() as Int == 1
  135. Debug.TraceAndBox("Hitchhiker: StartHitching quest is " + QuestToGrab + ".")
  136. EndIf
  137.  
  138. QuestToGrab.Start() ; Start the refs quest
  139. EndFunction
  140.  
  141. ; ------------------------------------------------------------------------------------------------------------
  142. ; EVENT: ON QUEST INIT
  143. ; ------------------------------------------------------------------------------------------------------------
  144.  
  145. Event Quest.OnQuestInit(Quest akSender) ; When quest starts & aliases are filled
  146. ObjectReference DestinationMarker
  147. ObjectReference TargetRef
  148.  
  149. If HH_OptionDevTracking.GetValue() as Int == 1
  150. Debug.TraceAndBox("Hitchhiker: Event OnQuestInit fired.")
  151. EndIf
  152.  
  153. If akSender ; Selected quest's refs are filled
  154.  
  155. Int RefAliasID = HH_RefAliasID.GetValue() as Int ; Retrieve the ref's AliasID from global
  156. Utility.Wait(0.1)
  157. TargetRef = (akSender.GetAlias(RefAliasID) as ReferenceAlias).GetReference()
  158.  
  159. akSender.Stop() ; Done with quest until next time
  160. EndIf
  161.  
  162. Player.AddPerk(HH_TeleportNoFallDamage) ; IMPORTANT: Temp perk so teleport falls don't kill player!
  163.  
  164. If HH_OptionSpinGhost.GetValue() as Int == 1 ; If player wants no spin damage (default)
  165. If HH_OptionSpinCamera.GetValue() as Int == 1 ; If player wants spincam after teleport,
  166. Player.SetGhost() ; IMPORTANT: Player immune to all damage!
  167. EndIf ; *** Set ghost now BEFORE the spin! ***
  168.  
  169. If HH_OptionDevTracking.GetValue() as Int == 1 ; If player wants dev messages...
  170. If Player.IsGhost() ; If player is a ghost,
  171. Debug.Notification("Hitchhiker: Player is a ghost!") ; display dev message
  172. EndIf
  173. EndIf
  174. EndIf ; NOTE: Unghosting happens in HH_SpinCamera()
  175.  
  176. If HH_OptionTeleportSound.GetValue() as Int == 1 ; If player wants teleport sound,
  177. Int iInstanceID = OBJHijackerTeleportOut2DA.Play(Player) ; play teleport end sound at player
  178. EndIf
  179.  
  180. DestinationMarker = Player.PlaceAtMe(pXMarker) ; Dynamically spawn xmarker at player
  181.  
  182. STATIC TargetBase = TargetRef.GetBaseObject() as STATIC ; Check if target base object is an X/COC marker/header
  183.  
  184. If TargetBase == pXMarker || TargetBase == pXMarkerHeading || TargetBase == pCOCMarkerHeading ; Do not use XYZ offsets if destination is a marker
  185. DestinationMarker.MoveTo(TargetRef) ; so teleport will place player directly on the X
  186. Else ; else move marker to static ref with XYZ offsets
  187. Float OffsetX = HH_OptionOffsetX.GetValue() ; Player sets X (default 250)
  188. Float OffsetY = HH_OptionOffsetY.GetValue() ; Player sets Y (default 250)
  189. Float OffsetZ = HH_OptionOffsetZ.GetValue() ; Player sets Z (default 500)
  190. Utility.Wait(0.1)
  191. DestinationMarker.MoveTo(TargetRef, OffsetX, OffsetY, OffsetZ) ; Move marker with XYZ offsets
  192. DestinationMarker.MoveToNearestNavmeshLocation() ; Then move marker to nearest navmesh
  193. EndIf
  194.  
  195. If HH_OptionFastTravel.GetValue() as Int == 1 ; If player wants loading screens,
  196. Game.FastTravel(DestinationMarker) ; move player to marker (with load screens?)
  197. Else
  198. Player.MoveTo(DestinationMarker) ; else move player (with black screen)
  199. EndIf
  200.  
  201. Utility.Wait(0.1)
  202.  
  203. ; "If TargetRef Is Furniture" caused illegal typecast compiler error, so I wrote a custom function
  204. HH_TryToUseFurniture(Player, TargetRef)
  205.  
  206. ; ********************************************************************************************************
  207. ; Optional automatic time change on teleport
  208. ; ********************************************************************************************************
  209. If HH_OptionSetTime.GetValue() as Int == 1 ; If player wants automatic time change (default is NO)
  210. Int PrefTime = HH_OptionSetTimePreference.GetValue() as Int ; get preferred time
  211. HH_ForceTime(PrefTime) ; and set it
  212. EndIf
  213.  
  214. ; ********************************************************************************************************
  215. ; Optional automatic weather change on teleport
  216. ; ********************************************************************************************************
  217. If !Player.IsInInterior() ; If destination is NOT indoors...
  218. If HH_OptionSetWeather.GetValue() as Int == 1 ; If player wants automatic weather change (default is NO)
  219. Int PrefWeather = HH_OptionSetWeatherPreference.GetValue() as Int ; get preferred weather
  220. HH_ForceWeather(PrefWeather) ; and set it
  221. EndIf
  222. EndIf
  223.  
  224. If HH_OptionSpinCamera.GetValue() as Int == 1 ; If player wants spincam after teleport,
  225. HH_SpinCamera() ; call the custom spin camera function
  226. EndIf
  227.  
  228. StartTimer(10, 2) ; Remove HH_TeleportNoFallDamage perk in 10 seconds
  229. EndEvent
  230.  
  231. ; ------------------------------------------------------------------------------------------------------------
  232. ; CUSTOM FUNCTION: HH SPIN CAMERA
  233. ; ------------------------------------------------------------------------------------------------------------
  234.  
  235. Function HH_SpinCamera()
  236. Int SpinSeconds
  237. Game.ForceFirstPerson() ; IMPORTANT: Must start/run spin in first person!
  238.  
  239. ; Thx steve40 for distance & setini code
  240. Float CamMinDistance = HH_OptionCamMinDistance.GetValue() ; Player chooses min distance (default: 100, vanilla: 0)
  241. Float CamMaxDistance = HH_OptionCamMaxDistance.GetValue() ; Player chooses max distance (default: 200, vanilla: 150)
  242. Utility.SetIniFloat("fVanityModeMinDist:Camera", CamMinDistance) ; Set min
  243. Utility.SetIniFloat("fVanityModeMaxDist:Camera", CamMaxDistance) ; Set max
  244.  
  245. Utility.Wait(1) ; Wait a moment
  246. Utility.SetINIBool("bForceAutoVanityMode:Camera", true) ; Spin the idle camera around player
  247.  
  248. HH_IsSpinning.SetValue(1) ; Flag player / camera as spinning
  249.  
  250. SpinSeconds = HH_OptionSpinDuration.GetValue() as Int ; Player chooses how long to spin (default: 20 seconds)
  251. StartTimer(SpinSeconds, 1) ; Wait SpinSeconds then call StopSpinning from OnTimer event
  252. EndFunction
  253.  
  254. ; -----------------------------------------------------------------------------------------------------------
  255. ; EVENT: ON TIMER
  256. ; -----------------------------------------------------------------------------------------------------------
  257.  
  258. Event OnTimer(int aiTimerID) ; Cancel timer
  259. If aiTimerID == 1
  260. HH_StopSpinning() ; Call StopSpinning function
  261. ElseIf aiTimerID == 2
  262. Player.RemovePerk(HH_TeleportNoFallDamage) ; Temp perk removed after teleport is safely completed
  263.  
  264. If HH_OptionHeal.GetValue() as Int == 1 ; If player wants healed after teleport,
  265. Player.ResetHealthAndLimbs() ; reset health and limbs
  266. EndIf
  267.  
  268. Else
  269. ; Placeholder for additional timers
  270. EndIf
  271. EndEvent
  272.  
  273. ; ------------------------------------------------------------------------------------------------------------
  274. ; CUSTOM FUNCTION: HH STOP SPINNING
  275. ; ------------------------------------------------------------------------------------------------------------
  276.  
  277. Function HH_StopSpinning()
  278. CancelTimer(1) ; Cancel any lingering StopSpinning timers
  279.  
  280. If Player.IsGhost() ; If player is a ghost,
  281. Player.SetGhost(false) ; IMPORTANT: Undo player's temporary invulnerability
  282.  
  283. If HH_OptionDevTracking.GetValue() as Int == 1 ; If player wants dev messages
  284. If Player.IsGhost() == false ; If player is no longer a ghost,
  285. Debug.Notification("Hitchhiker: Player is not a ghost.") ; display dev message
  286. EndIf
  287. EndIf
  288. EndIf
  289.  
  290. If HH_IsSpinning.GetValue() as Int == 1 ; If player is spinning,
  291. Utility.SetINIBool("bForceAutoVanityMode:Camera", false) ; stop spinning
  292.  
  293. Game.ForceFirstPerson() ; IMPORTANT: Call this or spin will last forever!
  294.  
  295. HH_IsSpinning.SetValue(0) ; Flag player / camera as no longer spinning
  296.  
  297. EndIf ; Done with optional spincam effect
  298. EndFunction
  299.  
  300. ; ------------------------------------------------------------------------------------------------------------
  301. ; CUSTOM FUNCTION: HH SET DESTINATION
  302. ; ------------------------------------------------------------------------------------------------------------
  303.  
  304. Function HH_SetDestination(Quest RefQuest, Int RefAliasID)
  305. QuestToGrab = RefQuest
  306.  
  307. If HH_OptionDevTracking.GetValue() as Int == 1
  308. Debug.TraceAndBox("Hitchhiker: Set Dest Quest is " + QuestToGrab + ".")
  309. EndIf
  310.  
  311. HH_RefAliasID.SetValue(RefAliasID)
  312.  
  313. If HH_OptionDevTracking.GetValue() as Int == 1
  314. Debug.TraceAndBox("Hitchhiker: RefAliasID is " + HH_RefAliasID.GetValue() as Int + ".")
  315. EndIf
  316.  
  317. EndFunction
  318.  
  319. ; ------------------------------------------------------------------------------------------------------------
  320. ; CUSTOM FUNCTION: HH SET RANDOM DESTINATION
  321. ; ------------------------------------------------------------------------------------------------------------
  322.  
  323. Function HH_SetRandomDestination(Int Category)
  324. Quest RefQuest
  325. Int RefAliasCount
  326. Int RefAliasID
  327. Int ReRoll
  328. Int ExcludeDLC = HH_OptionExcludeDLC.GetValue() as Int
  329. Int ExcludeFH = HH_OptionExcludeFH.GetValue() as Int
  330. Int ExcludeNW = HH_OptionExcludeNW.GetValue() as Int
  331. Int ExcludeVT = HH_OptionExcludeVT.GetValue() as Int
  332.  
  333. If HH_PlayerHasFH.GetValue() as Int == 0
  334. ExcludeFH = 1
  335. EndIf
  336.  
  337. If HH_PlayerHasNW.GetValue() as Int == 0
  338. ExcludeNW = 1
  339. EndIf
  340.  
  341. If HH_PlayerHasVT.GetValue() as Int == 0
  342. ExcludeVT = 1
  343. EndIf
  344.  
  345. If Category == 1
  346. RefQuest = QuestRefBusShelters
  347. RefAliasCount = 10
  348. ElseIf Category == 2
  349. RefQuest = QuestRefDiners
  350. RefAliasCount = 30
  351. ElseIf Category == 3
  352. RefQuest = QuestRefDriveIns
  353. RefAliasCount = 12
  354. ElseIf Category == 4
  355. RefQuest = QuestRefDives
  356. RefAliasCount = 13
  357. ElseIf Category == 5
  358. RefQuest = QuestRefFactories
  359. RefAliasCount = 12
  360. ElseIf Category == 6
  361. RefQuest = QuestRefFarms
  362. RefAliasCount = 12
  363. ElseIf Category == 7
  364. RefQuest = QuestRefJunkyards
  365. RefAliasCount = 20
  366. ElseIf Category == 8
  367. RefQuest = QuestRefMilitaryBases
  368. RefAliasCount = 20
  369. ElseIf Category == 9
  370. RefQuest = QuestRefMonuments
  371. RefAliasCount = 30
  372. ElseIf Category == 10
  373. RefQuest = QuestRefPowerLifts
  374. RefAliasCount = 15
  375. ElseIf Category == 11
  376. RefQuest = QuestRefRedRocket
  377. RefAliasCount = 25
  378. Else
  379. RefQuest = QuestRefVaults
  380. RefAliasCount = 10
  381. EndIf
  382.  
  383. If HH_OptionDevTracking.GetValue() as Int == 1
  384. Debug.TraceAndBox("Hitchhiker: SRD RefQuest is " + RefQuest + ".")
  385. Debug.TraceAndBox("Hitchhiker: RefAliasCount is " + RefAliasCount +".")
  386. EndIf
  387.  
  388. ; ********************************************************************************************************
  389. ; Do-while functionality. Only loops if rolled destination is unwanted DLC.
  390. ; ********************************************************************************************************
  391.  
  392. ReRoll = 1
  393.  
  394. While ReRoll == 1
  395. ReRoll = 0
  396. RefAliasID = Utility.RandomInt(0, (RefAliasCount - 1)) ; Roll random 0 through (count - 1)
  397.  
  398. If ExcludeDLC == 1 || ExcludeFH == 1
  399. If HH_IsInFarHarbor(RefQuest, RefAliasID) == 1
  400. ReRoll = 1
  401. If HH_OptionDevTracking.GetValue() as Int == 1
  402. Debug.TraceAndBox("Hitchhiker: FH ReRoll.")
  403. EndIf
  404. EndIf
  405. EndIf
  406.  
  407. If !ReRoll
  408. If ExcludeDLC == 1 || ExcludeNW == 1
  409. If HH_IsInNukaWorld(RefQuest, RefAliasID) == 1
  410. ReRoll = 1
  411. If HH_OptionDevTracking.GetValue() as Int == 1
  412. Debug.TraceAndBox("Hitchhiker: NW ReRoll.")
  413. EndIf
  414. EndIf
  415. EndIf
  416. EndIf
  417.  
  418. If !ReRoll
  419. If ExcludeDLC == 1 || ExcludeVT == 1
  420. If RefQuest == QuestRefVaults && RefAliasID == 5
  421. ReRoll = 1
  422. If HH_OptionDevTracking.GetValue() as Int == 1
  423. Debug.TraceAndBox("Hitchhiker: VT ReRoll.")
  424. EndIf
  425. EndIf
  426. EndIf
  427. EndIf
  428. EndWhile
  429.  
  430. QuestToGrab = RefQuest
  431. HH_RefAliasID.SetValue(RefAliasID)
  432.  
  433. If HH_OptionDevTracking.GetValue() as Int == 1
  434. Debug.TraceAndBox("Hitchhiker: SRD QuestToGrab is " + QuestToGrab + ".")
  435. Debug.TraceAndBox("Hitchhiker: RefAliasID is " + RefAliasID +".")
  436. EndIf
  437.  
  438. EndFunction
  439.  
  440. ; ------------------------------------------------------------------------------------------------------------
  441. ; CUSTOM FUNCTION: HH IS IN FAR HARBOR
  442. ; ------------------------------------------------------------------------------------------------------------
  443.  
  444. Int Function HH_IsInFarHarbor(Quest TargetQuest, Int TargetAliasID)
  445. Int Located = 0
  446.  
  447. If HH_OptionDevTracking.GetValue() as Int == 1
  448. Debug.TraceAndBox("Hitchhiker: Checking IsInFarHarbor.")
  449. EndIf
  450.  
  451. If TargetQuest == QuestRefBusShelters
  452. ; No bus shelters
  453. ElseIf TargetQuest == QuestRefDiners
  454. If TargetAliasID == 3
  455. Located = 1
  456. EndIf
  457. ElseIf TargetQuest == QuestRefDives
  458. If TargetAliasID == 10
  459. Located = 1
  460. EndIf
  461. ElseIf TargetQuest == QuestRefDriveIns
  462. If TargetAliasID == 5
  463. Located = 1
  464. EndIf
  465. ElseIf TargetQuest == QuestRefFactories
  466. If TargetAliasID == 7 || TargetAliasID == 10
  467. Located = 1
  468. EndIf
  469. ElseIf TargetQuest == QuestRefFarms
  470. ; No farms
  471. ElseIf TargetQuest == QuestRefJunkyards
  472. Int[] MyArray
  473. MyArray.Add(1)
  474. MyArray.Add(3)
  475. MyArray.Add(4)
  476. MyArray.Add(6)
  477. MyArray.Add(8)
  478. MyArray.Add(10)
  479. MyArray.Add(12)
  480. MyArray.Add(17)
  481. If MyArray.Find(TargetAliasID) >= 0
  482. Located = 1
  483. EndIf
  484. ElseIf TargetQuest == QuestRefMilitaryBases
  485. If TargetAliasID == 0 || TargetAliasID == 18
  486. Located = 1
  487. EndIf
  488. ElseIf TargetQuest == QuestRefMonuments
  489. If TargetAliasID == 2 || TargetAliasID == 21 || TargetAliasID == 26
  490. Located = 1
  491. EndIf
  492. ElseIf TargetQuest == QuestRefPowerLifts
  493. ; No power lifts
  494. ElseIf TargetQuest == QuestRefRedRocket
  495. If TargetAliasID == 20 || TargetAliasID == 21 || TargetAliasID == 22
  496. Located = 1
  497. EndIf
  498. ElseIf TargetQuest == QuestRefVaults
  499. If TargetAliasID == 9
  500. Located = 1
  501. EndIf
  502. Else
  503. Debug.TraceAndBox("HITCHHIKER: NULL IN FH CHECK!")
  504. EndIf
  505.  
  506. If Located
  507. Return 1
  508. Else
  509. Return 0
  510. EndIf
  511. EndFunction
  512.  
  513. ; ------------------------------------------------------------------------------------------------------------
  514. ; CUSTOM FUNCTION: HH IS IN NUKA WORLD
  515. ; ------------------------------------------------------------------------------------------------------------
  516.  
  517. Int Function HH_IsInNukaWorld(Quest TargetQuest, Int TargetAliasID)
  518. Int Located = 0
  519.  
  520. If HH_OptionDevTracking.GetValue() as Int == 1
  521. Debug.TraceAndBox("Hitchhiker: Checking IsInNukaWorld.")
  522. EndIf
  523.  
  524. If TargetQuest == QuestRefBusShelters
  525. ; No bus shelters
  526. ElseIf TargetQuest == QuestRefDiners
  527. If TargetAliasID == 2 || TargetAliasID == 13
  528. Located = 1
  529. EndIf
  530. ElseIf TargetQuest == QuestRefDives
  531. If TargetAliasID == 2
  532. Located = 1
  533. EndIf
  534. ElseIf TargetQuest == QuestRefDriveIns
  535. If TargetAliasID == 0 || TargetAliasID == 3 || TargetAliasID == 9 || TargetAliasID == 10
  536. Located = 1
  537. EndIf
  538. ElseIf TargetQuest == QuestRefFactories
  539. If TargetAliasID == 11
  540. Located = 1
  541. EndIf
  542. ElseIf TargetQuest == QuestRefFarms
  543. ; No farms
  544. ElseIf TargetQuest == QuestRefJunkyards
  545. If TargetAliasID == 9
  546. Located = 1
  547. EndIf
  548. ElseIf TargetQuest == QuestRefMilitaryBases
  549. If TargetAliasID == 11 || TargetAliasID == 12
  550. Located = 1
  551. EndIf
  552. ElseIf TargetQuest == QuestRefMonuments
  553. If TargetAliasID == 4 || TargetAliasID == 9 || TargetAliasID == 23 || TargetAliasID == 24
  554. Located = 1
  555. EndIf
  556. ElseIf TargetQuest == QuestRefPowerLifts
  557. If TargetAliasID == 13 || TargetAliasID == 14
  558. Located = 1
  559. EndIf
  560. ElseIf TargetQuest == QuestRefRedRocket
  561. If TargetAliasID == 23 || TargetAliasID == 24
  562. Located = 1
  563. EndIf
  564. ElseIf TargetQuest == QuestRefVaults
  565. ; No vaults
  566. Else
  567. Debug.TraceAndBox("HITCHHIKER: NULL IN NW CHECK!")
  568. EndIf
  569.  
  570. If Located
  571. Return 1
  572. Else
  573. Return 0
  574. EndIf
  575. EndFunction
  576.  
  577. ; ------------------------------------------------------------------------------------------------------------
  578. ; CUSTOM FUNCTION: HH QUERY QUEST
  579. ; ------------------------------------------------------------------------------------------------------------
  580.  
  581. Quest Function HH_QueryQuest()
  582. Return QuestToGrab
  583. EndFunction
  584.  
  585. ; ------------------------------------------------------------------------------------------------------------
  586. ; CUSTOM FUNCTION: IS FURNITURE
  587. ; ------------------------------------------------------------------------------------------------------------
  588.  
  589. ; Declared in properties: FormList Property HH_IsFurniture Auto Const Mandatory
  590. ; NESTED: Property is a formlist of formlists of furnitures. (Total = 302 NPC/Player furniture actions)
  591. ; [0] IsFurnitureBed 34
  592. ; [1] IsFurnitureBedWorkshop 20
  593. ; [2] IsFurnitureBench 19
  594. ; [3] IsFurnitureChair 57
  595. ; [4] IsFurnitureCouch 24
  596. ; [5] IsFurnitureInstitute 11
  597. ; [6] IsFurnitureInv 6
  598. ; [7] IsFurnitureKneel 6
  599. ; [8] IsFurnitureMisc 104
  600. ; [9] IsFurnitureStand 8
  601. ; [10] IsFurnitureStool 13
  602.  
  603. Int Function IsFurniture(ObjectReference TargetToCheck)
  604. Form TargetBaseObject = TargetToCheck.GetBaseObject()
  605. FormList FurnList = HH_IsFurniture ; FormList declared in properties
  606. FormList NestedList
  607. Int FurnSize = FurnList.GetSize()
  608. Int i = 0
  609. Int Found = 0
  610.  
  611. While i < FurnSize && !Found ; Stop loop if form found in furniture
  612. NestedList = FurnList.GetAt(i) as FormList ; Loop grabs next unchecked formlist
  613.  
  614. If NestedList.HasForm(TargetBaseObject) ; If found,
  615. Found = 1 ; mark as found and break loop
  616. Else
  617. i += 1 ; else iterate and keep looking
  618. EndIf
  619. EndWhile
  620.  
  621. Return Found ; return found (1) or not found (0) to caller
  622. EndFunction
  623.  
  624. ; ------------------------------------------------------------------------------------------------------------
  625. ; CUSTOM FUNCTION: HH TRY TO USE FURNITURE
  626. ; ------------------------------------------------------------------------------------------------------------
  627.  
  628. Int Function HH_TryToUseFurniture(Actor Person, ObjectReference TargetRef)
  629. Int DidItWork = 0
  630.  
  631. If IsFurniture(TargetRef) == 1 ; If target can be used (chair, wall lean, etc)
  632. If TargetRef.IsFurnitureInUse(True) == False ; and target is not in use right now (ignores reserved)
  633. If Person.SnapIntoInteraction(TargetRef) ; then attempt to use the furniture
  634. DidItWork = 1
  635. EndIf
  636. EndIf
  637. EndIf
  638.  
  639. Return DidItWork
  640. EndFunction
  641.  
  642. ; ------------------------------------------------------------------------------------------------------------
  643. ; CUSTOM FUNCTION: HH FORCE TIME
  644. ; ------------------------------------------------------------------------------------------------------------
  645.  
  646. Function HH_ForceTime(Int TargetHour)
  647. Int CurrentHour = pGameHour.GetValue() as Int ; Get current game hour
  648. Int MyDuration ; and determine how long to wait
  649.  
  650. If TargetHour < 0 || TargetHour > 24
  651. TargetHour = 9
  652. EndIf
  653.  
  654. If CurrentHour < TargetHour ; If target is later in same day,
  655. MyDuration = TargetHour - CurrentHour ; waiting period is easy to calculate
  656. Else
  657. MyDuration = 24 - (CurrentHour - TargetHour) ; else duration is difference subtracted from midnight
  658. EndIf
  659.  
  660. If MyDuration > 0 && MyDuration < 24 ; If duration will result in a time change,
  661. Game.PassTime(MyDuration) ; wait that duration
  662. EndIf
  663. EndFunction
  664.  
  665. ; ------------------------------------------------------------------------------------------------------------
  666. ; CUSTOM FUNCTION: HH FORCE WEATHER
  667. ; ------------------------------------------------------------------------------------------------------------
  668.  
  669. Function HH_ForceWeather(Int MyForecast)
  670. If !Player.IsInInterior() ; If destination is NOT indoors...
  671. Weather MyWeather
  672.  
  673. If MyForecast == 1
  674. MyWeather = CommonwealthClear ; Clear
  675. ElseIf MyForecast == 2
  676. MyWeather = CommonwealthDusty ; Dusty
  677. ElseIf MyForecast == 3
  678. MyWeather = CommonwealthFoggy ; Foggy
  679. ElseIf MyForecast == 4
  680. MyWeather = CommonwealthMisty ; Misty
  681. ElseIf MyForecast == 5
  682. MyWeather = CommonwealthMistyRainy ; Misty Rainy
  683. ElseIf MyForecast == 6
  684. MyWeather = CommonwealthOvercast ; Overcast
  685. ElseIf MyForecast == 7
  686. MyWeather = CommonwealthGSRadstorm ; Radstorm
  687. ElseIf MyForecast == 8
  688. MyWeather = CommonwealthRain ; Rain
  689. Else
  690. MyWeather = DefaultWeather ; Default Weather (outdoors)
  691. EndIf
  692.  
  693. MyWeather.ForceActive() ; Force weather change now
  694. EndIf
  695. EndFunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement