Advertisement
ThoraldGM

Hitchhiker quest script 20171118

Dec 4th, 2017
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.64 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 20171118
  5. ; Hitchhiker mod: (url pending)
  6.  
  7. ; ------------------------------------------------------------------------------------------------------------
  8. ; PROPERTIES
  9. ; ------------------------------------------------------------------------------------------------------------
  10.  
  11. Actor Player ; Player actor
  12. Book Property HH_Map Auto Const Mandatory ; Hitchhiker map
  13. GlobalVariable Property HH_IsSpinning Auto Mandatory ; Is the camera currently spinning?
  14. GlobalVariable Property HH_OptionCamMaxDistance Auto Mandatory ; Max camera distance (default: 200, vanilla: 150)
  15. GlobalVariable Property HH_OptionCamMinDistance Auto Mandatory ; Min camera distance (default: 100, vanilla: 0)
  16. GlobalVariable Property HH_OptionDevTracking Auto Mandatory ; Does player want dev messages? (default: no)
  17. GlobalVariable Property HH_OptionFastTravel Auto Mandatory ; Does player want loading screens? (default: yes)
  18. GlobalVariable Property HH_OptionOffsetX Auto Mandatory ; Player can choose X offset (default: 250)
  19. GlobalVariable Property HH_OptionOffsetY Auto Mandatory ; Player can choose Y offset (default: 250)
  20. GlobalVariable Property HH_OptionOffsetZ Auto Mandatory ; Player can choose Z offset (default: 500)
  21. GlobalVariable Property HH_OptionSpinCamera Auto Mandatory ; Does player want teleport to spin camera? (default: yes)
  22. GlobalVariable Property HH_OptionSpinDuration Auto Mandatory ; How long should camera spin? (default: 20 seconds)
  23. GlobalVariable Property HH_OptionSpinGhost Auto Mandatory ; Does player want invulnerable spin? (default: yes)
  24. GlobalVariable Property HH_OptionSpinHeal Auto Mandatory ; Does player want to heal after spin? (default: no)
  25. GlobalVariable Property HH_OptionTeleportSound Auto Mandatory ; Does player want teleport sound? (default: yes)
  26. GlobalVariable Property HH_RandomLocation Auto Mandatory ; Did player select any location or specific?
  27. GlobalVariable Property HH_ShowMenu Auto Mandatory ; Don't show menu when map placed in inventory
  28. GlobalVariable Property HH_SpecificLocation Auto Mandatory ; Which specific location did player select?
  29. Quest Property QuestRefPowerLifts Auto Const Mandatory ; Quest stores Power Lifts ref aliases
  30. Quest Property QuestRefRedRocket Auto Const Mandatory ; Quest stores Red Rocket ref aliases
  31. Sound Property DRSVertibirdFlightLoadOpen Auto Const Mandatory ; Teleport start sound effect
  32. Sound Property OBJHijackerTeleportOut2DA Auto Const Mandatory ; Teleport end sound effect
  33. STATIC Property pXMarker Auto Const Mandatory ; Xmarker static from CK as a property
  34.  
  35. ; ------------------------------------------------------------------------------------------------------------
  36. ; EVENT: ON INIT
  37. ; ------------------------------------------------------------------------------------------------------------
  38.  
  39. Event OnInit()
  40. Player = Game.GetPlayer() ; Player actor
  41. Utility.Wait(0.1) ; Wait a moment before using actor
  42.  
  43. If Player.GetItemCount(HH_Map) == 0 ; If player doesn't have hitchhiker map,
  44. HH_ShowMenu.SetValue(0) ; don't show menu when map placed in inventory
  45. Utility.Wait(5) ; wait 5 seconds
  46. Player.AddItem(HH_Map) ; spawn hitchhiker map in player inventory
  47. EndIf
  48. EndEvent
  49.  
  50. ; ------------------------------------------------------------------------------------------------------------
  51. ; CUSTOM FUNCTION: START HITCHING
  52. ; ------------------------------------------------------------------------------------------------------------
  53.  
  54. Function StartHitching(Int LocationSelected)
  55. Quest QuestToGrab ; Which quest do we need refs from
  56.  
  57. If LocationSelected == 0 ; If player selected anywhere...
  58. ; go anywhere (but here?)
  59. ElseIf LocationSelected < 100 ; If player selected any destination,
  60. HH_RandomLocation.SetValue(1) ; Set random to YES
  61. Else
  62. HH_RandomLocation.SetValue(0) ; Else set random to NO
  63. HH_SpecificLocation.SetValue(LocationSelected) ; and remember specific location in global
  64. EndIf
  65.  
  66. If (LocationSelected == 1) || (LocationSelected >= 100 && LocationSelected < 200) ; If player selected Power Lifts
  67. QuestToGrab = QuestRefPowerLifts ; select refs quest
  68. EndIf
  69.  
  70. If (LocationSelected == 2) || (LocationSelected >= 200 && LocationSelected < 300) ; If player selected Red Rocket
  71. QuestToGrab = QuestRefRedRocket ; select refs quest
  72. EndIf
  73.  
  74. RegisterForRemoteEvent(QuestToGrab, "OnQuestInit") ; Listen for refs quest start
  75. Utility.Wait(0.1) ; Wait a moment for registration to finish
  76.  
  77. If HH_OptionTeleportSound.GetValue() as Int == 1 ; If player wants teleport sound,
  78. Int iInstanceID = DRSVertibirdFlightLoadOpen.Play(Player) ; play teleport start sound at player
  79. EndIf
  80.  
  81. QuestToGrab.Start() ; Start the refs quest
  82. EndFunction
  83.  
  84. ; ------------------------------------------------------------------------------------------------------------
  85. ; EVENT: ON QUEST INIT
  86. ; ------------------------------------------------------------------------------------------------------------
  87.  
  88. Event Quest.OnQuestInit(Quest akSender) ; When quest starts & aliases are filled
  89. ObjectReference DestinationMarker ; DOES THIS PERSIST?! HOPEFULLY NOT.
  90. ObjectReference StaticRef ; DOES THIS PERSIST?! HOPEFULLY NOT.
  91.  
  92. If akSender ; Selected quest's refs are filled
  93. Int MyIndex
  94. Int NumAliases
  95. Int QuestID
  96. Int i
  97.  
  98. If akSender == QuestRefPowerLifts ; 13 power lifts, QuestID 100
  99. NumAliases = 13
  100. QuestID = 100
  101. ElseIf akSender == QuestRefRedRocket ; 20 Red Rockets, QuestID 200
  102. NumAliases = 20
  103. QuestID = 200
  104. EndIf
  105.  
  106. If HH_RandomLocation.GetValue() as Int == 1 ; Player selected "Any" destination
  107. ReferenceAlias[] MyDestination = new ReferenceAlias[NumAliases] ; Create temp array to hold aliases
  108.  
  109. ; Grab all teh refs
  110. i = 0
  111. While i < NumAliases
  112. MyDestination[i] = akSender.GetAlias(i) as ReferenceAlias
  113. i += 1
  114. EndWhile
  115.  
  116. MyIndex = Utility.RandomInt(0, (NumAliases - 1)) ; Roll random index
  117. StaticRef = (MyDestination[MyIndex]).GetReference() ; and grab ref of random static
  118. Else ; Else player selected specific location
  119. MyIndex = (HH_SpecificLocation.GetValue() as Int) - QuestID ; Convert 3 digit location to 2 digit ID
  120.  
  121. ; and grab ref of specific static
  122. StaticRef = (akSender.GetAlias(MyIndex) as ReferenceAlias).GetReference()
  123. EndIf
  124.  
  125. akSender.Stop() ; Done with quest until next time
  126. EndIf
  127.  
  128. If HH_OptionSpinGhost.GetValue() as Int == 1 ; If player wants no spin damage (default)
  129. Player.SetGhost() ; IMPORTANT: Player immune to all damage!
  130.  
  131. If HH_OptionDevTracking.GetValue() as Int == 1 ; If player wants dev messages...
  132. If Player.IsGhost() ; If player is a ghost,
  133. Debug.Notification("Hitchhiker: Player is a ghost!") ; display dev message
  134. EndIf
  135. EndIf
  136. EndIf ; NOTE: Unghosting happens in HH_SpinCamera()
  137.  
  138. If HH_OptionTeleportSound.GetValue() as Int == 1 ; If player wants teleport sound,
  139. Int iInstanceID = OBJHijackerTeleportOut2DA.Play(Player) ; play teleport end sound at player
  140. EndIf
  141.  
  142. DestinationMarker = Player.PlaceAtMe(pXMarker) ; Dynamically spawn xmarker at player
  143.  
  144. Float OffsetX = HH_OptionOffsetX.GetValue() ; Player sets X (default 250)
  145. Float OffsetY = HH_OptionOffsetY.GetValue() ; Player sets Y (default 250)
  146. Float OffsetZ = HH_OptionOffsetZ.GetValue() ; Player sets Z (default 500)
  147.  
  148. If akSender == QuestRefPowerLifts ; If player selected Power Lift,
  149. DestinationMarker.MoveTo(StaticRef) ; move marker to power lift ref (vanilla xmarker)
  150. Else
  151. DestinationMarker.MoveTo(StaticRef, OffsetX, OffsetY, OffsetZ) ; else move marker to static ref with XYZ offsets
  152. EndIf
  153.  
  154. DestinationMarker.MoveToNearestNavmeshLocation() ; Then move marker to nearest navmesh
  155.  
  156. If HH_OptionFastTravel.GetValue() as Int == 1 ; If player wants loading screens,
  157. Game.FastTravel(DestinationMarker) ; move player to marker (with load screens?)
  158. Else
  159. Player.MoveTo(DestinationMarker) ; else move player (with black screen)
  160. EndIf
  161.  
  162. If HH_OptionSpinCamera.GetValue() as Int == 1 ; If player wants spincam after teleport,
  163. HH_SpinCamera() ; call the custom spin camera function
  164. EndIf
  165. EndEvent ; Event end should dump the temp refs array!
  166.  
  167. ; ------------------------------------------------------------------------------------------------------------
  168. ; CUSTOM FUNCTION: HH SPIN CAMERA
  169. ; ------------------------------------------------------------------------------------------------------------
  170.  
  171. Function HH_SpinCamera()
  172. Int SpinSeconds
  173. Game.ForceFirstPerson() ; IMPORTANT: Must start/run spin in first person!
  174.  
  175. ; Thx steve40 for distance & setini code
  176. Float CamMinDistance = HH_OptionCamMinDistance.GetValue() ; Player chooses min distance (default: 100, vanilla: 0)
  177. Float CamMaxDistance = HH_OptionCamMaxDistance.GetValue() ; Player chooses max distance (default: 200, vanilla: 150)
  178. Utility.SetIniFloat("fVanityModeMinDist:Camera", CamMinDistance) ; Set min
  179. Utility.SetIniFloat("fVanityModeMaxDist:Camera", CamMaxDistance) ; Set max (NEED TO RESET THESE AFTER SPIN STOPS?)
  180.  
  181. Utility.Wait(1) ; Wait a moment
  182. Utility.SetINIBool("bForceAutoVanityMode:Camera", true) ; Spin the idle camera around player
  183.  
  184. HH_IsSpinning.SetValue(1) ; Flag player / camera as spinning
  185.  
  186. SpinSeconds = HH_OptionSpinDuration.GetValue() as Int ; Player chooses how long to spin (default: 20 seconds)
  187. StartTimer(SpinSeconds, 1) ; Wait SpinSeconds then call StopSpinning from OnTimer event
  188. EndFunction
  189.  
  190. ; -----------------------------------------------------------------------------------------------------------
  191. ; EVENT: ON TIMER
  192. ; -----------------------------------------------------------------------------------------------------------
  193.  
  194. Event OnTimer(int aiTimerID) ; Cancel timer
  195. If aiTimerID == 1
  196. HH_StopSpinning() ; Call StopSpinning function
  197. EndIf
  198. EndEvent
  199.  
  200. ; ------------------------------------------------------------------------------------------------------------
  201. ; CUSTOM FUNCTION: HH STOP SPINNING
  202. ; ------------------------------------------------------------------------------------------------------------
  203.  
  204. Function HH_StopSpinning()
  205. CancelTimer(1) ; Cancel any lingering StopSpinning timers
  206.  
  207. If Player.IsGhost() ; If player is a ghost,
  208. Player.SetGhost(false) ; IMPORTANT: Undo player's temporary invulnerability
  209.  
  210. If HH_OptionDevTracking.GetValue() as Int == 1 ; If player wants dev messages
  211. If Player.IsGhost() == false ; If player is no longer a ghost,
  212. Debug.Notification("Hitchhiker: Player is not a ghost.") ; display dev message
  213. EndIf
  214. EndIf
  215. EndIf
  216.  
  217. If HH_IsSpinning.GetValue() as Int == 1 ; If player is spinning,
  218. Utility.SetINIBool("bForceAutoVanityMode:Camera", false) ; stop spinning
  219.  
  220. Game.ForceFirstPerson() ; IMPORTANT: Call this or spin will last forever!
  221.  
  222. If HH_OptionSpinHeal.GetValue() as Int == 1 ; If player wants healed,
  223. Player.ResetHealthAndLimbs() ; Undo any damage taken during spin (obsolete by ghost)
  224. EndIf
  225.  
  226. HH_IsSpinning.SetValue(0) ; Flag player / camera as no longer spinning
  227.  
  228. EndIf ; Done with optional spincam effect
  229. EndFunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement