Advertisement
ThoraldGM

Hitchhiker Quest Script

Nov 12th, 2017
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.16 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 20171111
  5. ; Hitchhiker mod: (url pending)
  6.  
  7. ; ------------------------------------------------------------------------------------------------------------
  8. ; PROPERTIES
  9. ; ------------------------------------------------------------------------------------------------------------
  10.  
  11. Actor Player ; Player
  12. Book Property HH_Map Auto Const Mandatory ; Hitchhiker map
  13. GlobalVariable Property HH_DevTracking Auto Mandatory ; Does player want dev messages?
  14. GlobalVariable Property HH_OptionCamMaxDistance Auto Mandatory ; Max camera distance
  15. GlobalVariable Property HH_OptionCamMinDistance Auto Mandatory ; Min camera distance
  16. GlobalVariable Property HH_OptionOffsetX Auto Mandatory ; X offset
  17. GlobalVariable Property HH_OptionOffsetY Auto Mandatory ; Y offset
  18. GlobalVariable Property HH_OptionOffsetZ Auto Mandatory ; Z offset
  19. GlobalVariable Property HH_OptionSpinCamera Auto Mandatory ; Does player want spincam after teleport?
  20. GlobalVariable Property HH_OptionSpinDuration Auto Mandatory ; How long should camera spin? (Default 20 seconds)
  21. GlobalVariable Property HH_OptionTeleportSound Auto Mandatory ; Does player want teleport sound?
  22. GlobalVariable Property HH_RandomLocation Auto Mandatory ; Does player want any location or specific?
  23. GlobalVariable Property HH_ShowMenu Auto Mandatory ; Don't show menu when map placed in inventory
  24. GlobalVariable Property HH_SpecificLocation Auto Mandatory ; Which specific location did player select?
  25. Quest Property QuestRefRedRocket Auto Const Mandatory ; Quest stores Red Rocket ref aliases
  26. Sound Property OBJHijackerTeleportOut2DA Auto Const Mandatory ; Teleport sound effect
  27. STATIC Property pXMarker Auto Const Mandatory ; Xmarker static from CK as a property
  28.  
  29. ; ------------------------------------------------------------------------------------------------------------
  30. ; EVENT: ON INIT
  31. ; ------------------------------------------------------------------------------------------------------------
  32.  
  33. Event OnInit()
  34. Player = Game.GetPlayer()
  35. Utility.Wait(0.1)
  36.  
  37. If Player.GetItemCount(HH_Map) == 0 ; If player doesn't have hitchhiker map,
  38. HH_ShowMenu.SetValue(0) ; don't show menu when map placed in inventory
  39. Utility.Wait(5) ; wait 5 seconds
  40. Player.AddItem(HH_Map) ; spawn hitchhiker map in player inventory
  41. EndIf
  42. EndEvent
  43.  
  44. ; ------------------------------------------------------------------------------------------------------------
  45. ; CUSTOM FUNCTION: START HITCHING
  46. ; ------------------------------------------------------------------------------------------------------------
  47.  
  48. Function StartHitching(Int LocationSelected)
  49. Quest QuestToGrab ; Which quest do we need refs from
  50.  
  51. ; HH_DisableEnable() did NOT work. Tested 20171111
  52.  
  53. Player.MoveTo(Player, afZOffset = 1) ; Exits book/pip but no player controls after teleport!
  54.  
  55. If LocationSelected < 100 ; If player selected any...
  56. HH_RandomLocation.SetValue(1) ; Set random
  57. Else
  58. HH_RandomLocation.SetValue(0) ; Else specific
  59. HH_SpecificLocation.SetValue(LocationSelected) ; Remember specific location in global
  60. EndIf
  61.  
  62. If (LocationSelected == 1) || (LocationSelected >= 100 && LocationSelected < 200) ; If player selected Red Rocket
  63. QuestToGrab = QuestRefRedRocket ; assign which quest to grab
  64. EndIf
  65.  
  66. RegisterForRemoteEvent(QuestToGrab, "OnQuestInit") ; Listen for refs quest start
  67. Utility.Wait(0.1) ; Wait a moment for registration to finish
  68. QuestToGrab.Start() ; Start the refs quest
  69. EndFunction
  70.  
  71. ; ------------------------------------------------------------------------------------------------------------
  72. ; EVENT: ON QUEST INIT
  73. ; ------------------------------------------------------------------------------------------------------------
  74.  
  75. Event Quest.OnQuestInit(Quest akSender) ; When quest starts & aliases are filled
  76. ObjectReference DestinationMarker ; DOES THIS PERSIST?! HOPEFULLY NOT.
  77. ObjectReference StaticRef ; DOES THIS PERSIST?! HOPEFULLY NOT.
  78. Int MyIndex
  79. Int PreSpinCameraView
  80. Int SpinSeconds
  81. Int i
  82.  
  83. If akSender == QuestRefRedRocket ; If the starting quest is Red Rocket...
  84. ; Red Rocket's refs are ready to be grabbed
  85. If HH_RandomLocation.GetValue() as Int == 1 ; Player selected Any Red Rocket
  86. ReferenceAlias[] DestinationRedRocket = new ReferenceAlias[20] ; Create temp array to hold aliases
  87.  
  88. ; Grab all teh refs
  89. i = 0
  90. While i < 20
  91. DestinationRedRocket[i] = QuestRefRedRocket.GetAlias(i) as ReferenceAlias
  92. i += 1
  93. EndWhile
  94.  
  95. MyIndex = Utility.RandomInt(0, 19) ; Roll random index
  96. StaticRef = (DestinationRedRocket[MyIndex]).GetReference() ; and grab ref of random static
  97. Else ; Else player selected specific location
  98. MyIndex = (HH_SpecificLocation.GetValue() as Int) - 100 ; Convert 3 digit location to 2 digit ID
  99.  
  100. ; and grab ref of specific static
  101. StaticRef = (QuestRefRedRocket.GetAlias(MyIndex) as ReferenceAlias).GetReference()
  102. EndIf
  103.  
  104. QuestRefRedRocket.Stop() ; Done with quest until next time
  105. EndIf
  106.  
  107. Player.SetGhost() ; IMPORTANT: Player immune to all damage!
  108.  
  109. If HH_DevTracking.GetValue() as Int == 1 ; If player wants dev messages
  110. If Player.IsGhost() ; If player is a ghost,
  111. Debug.Notification("Hitchhiker: Player is a ghost!") ; display message
  112. EndIf
  113. EndIf
  114.  
  115. If HH_OptionTeleportSound.GetValue() as Int == 1 ; If player wants teleport sound,
  116. Int iInstanceID = OBJHijackerTeleportOut2DA.Play(Player) ; play teleport sound at player
  117. EndIf
  118.  
  119. DestinationMarker = Player.PlaceAtMe(pXMarker) ; Dynamically spawn xmarker at player
  120.  
  121. Float OffsetX = HH_OptionOffsetX.GetValue()
  122. Float OffsetY = HH_OptionOffsetY.GetValue()
  123. Float OffsetZ = HH_OptionOffsetZ.GetValue()
  124. DestinationMarker.MoveTo(StaticRef, OffsetX, OffsetY, OffsetZ) ; Move marker to static ref with XYZ offsets
  125.  
  126. DestinationMarker.MoveToNearestNavmeshLocation() ; Then move marker to nearest navmesh
  127. Game.FastTravel(DestinationMarker) ; Move player to marker (with load screens?)
  128.  
  129. If HH_OptionSpinCamera.GetValue() as Int == 1 ; If player wants spincam after teleport
  130. Bool FirstView = Player.GetAnimationVariableBool("IsFirstPerson") ; Is player in first person view? (thx registrator2000)
  131.  
  132. If FirstView ; If yes,
  133. PreSpinCameraView = 1 ; flag as first person (int declared earlier)
  134. Else
  135. PreSpinCameraView = 3 ; else flag as third person
  136. EndIf
  137.  
  138. Game.ForceThirdPerson() ; IMPORTANT: Must start/run spin in third person!
  139.  
  140. ; Thx steve40 for all of the utility camera code
  141. Float CamMinDistance = HH_OptionCamMinDistance.GetValue()
  142. Float CamMaxDistance = HH_OptionCamMaxDistance.GetValue()
  143. Utility.SetIniFloat("fVanityModeMinDist:Camera", CamMinDistance)
  144. Utility.SetIniFloat("fVanityModeMaxDist:Camera", CamMaxDistance)
  145. Utility.Wait(0.1)
  146. Utility.SetINIBool("bForceAutoVanityMode:Camera", true) ; Spin the idle camera around player
  147. EndIf
  148.  
  149. SpinSeconds = HH_OptionSpinDuration.GetValue() as Int ; Default is 20 seconds but player can change
  150. Utility.Wait(SpinSeconds) ; Wait specified number of seconds
  151. Player.SetGhost(false) ; IMPORTANT: Undo player's temporary invulnerability
  152.  
  153. If HH_DevTracking.GetValue() as Int == 1 ; If player wants dev messages
  154. If Player.IsGhost() == false ; If player is no longer a ghost,
  155. Debug.Notification("Hitchhiker: Player is not a ghost.") ; display message
  156. EndIf
  157. EndIf
  158.  
  159. If HH_OptionSpinCamera.GetValue() as Int == 1 ; If player is spinning,
  160. Utility.SetINIBool("bForceAutoVanityMode:Camera", false) ; stop spinning
  161.  
  162. Game.ForceFirstPerson() ; IMPORTANT: Call this or spin will last forever!
  163.  
  164. If PreSpinCameraView == 3 ; If player preferred third person view,
  165. Game.ForceThirdPerson() ; can resume third now that spin handling is done
  166. EndIf
  167.  
  168. Player.ResetHealthAndLimbs() ; Undo any damage taken during spin (obsolete by ghost?)
  169.  
  170. EndIf ; Done with optional spincam effect
  171.  
  172. EndEvent ; Event end should dump the temp refs array!
  173.  
  174. ; ------------------------------------------------------------------------------------------------------------
  175. ; CUSTOM FUNCTION: HH DISABLE ENABLE
  176. ; ------------------------------------------------------------------------------------------------------------
  177.  
  178. Function HH_DisableEnable()
  179. InputEnableLayer myLayer = InputEnableLayer.Create()
  180. myLayer.DisablePlayerControls(true, true, true, true, true, true, true, true, true, true, true)
  181. Utility.Wait(1)
  182. myLayer.EnablePlayerControls()
  183. EndFunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement