Advertisement
ThoraldGM

Hitchhiker Teleport

Jan 10th, 2018
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.03 KB | None | 0 0
  1. Event OnMenuOpenCloseEvent(string asMenuName, bool abOpening)
  2. UnregisterForMenuOpenCloseEvent("PipboyMenu") ; Cancel player button spams
  3.  
  4. If (asMenuName== "PipboyMenu") ; When the Pip-Boy
  5. If (!abOpening) ; closes,
  6. ; Thanks to ehtyeci for Vault Boy list!
  7. ; Thread: https://forums.nexusmods.com/index.php?/topic/6271136-i-there-a-list-of-perks-in-their-swf-forms/
  8. ; VB Viewer: http://powback.com/public/Fallout/?mobile=true
  9.  
  10. If HH_OptionTeleportSound.GetValue() as Int == 1 ; If player wants teleport sound,
  11. Int iInstanceID = DRSVertibirdFlightLoadOpen.Play(Player) ; play teleport start sound at player
  12. EndIf
  13.  
  14. If HH_OptionVaultBoy.GetValue() as Int == 1 ; If player wants Vault Boy animations, show thumbs up
  15. Game.ShowPerkVaultBoyOnHUD("Components\\VaultBoys\\Perks\\PerkClip_Default.swf")
  16. Utility.Wait(2) ; Give Vault Boy time to display
  17. EndIf
  18.  
  19. Player.AddPerk(HH_TeleportNoFallDamage) ; IMPORTANT: Temp perk so teleport falls don't kill player!
  20.  
  21. If HH_OptionSpinGhost.GetValue() as Int == 1 ; If player wants no spin damage (default)
  22. If HH_OptionSpinCamera.GetValue() as Int == 1 ; If player wants spincam after teleport,
  23. Player.SetGhost() ; IMPORTANT: Player immune to all damage!
  24. EndIf ; *** Set ghost now BEFORE the spin! ***
  25.  
  26. If HH_OptionDevTracking.GetValue() as Int == 1 ; If player wants dev messages...
  27. If Player.IsGhost() ; If player is a ghost,
  28. Debug.Notification("Hitchhiker: Player is a ghost!") ; display dev message
  29. EndIf
  30. EndIf
  31. EndIf ; NOTE: Unghosting happens in HH_SpinCamera()
  32.  
  33. If HH_OptionVaultBoy.GetValue() as Int == 1 ; If player wants Vault Boy animations, show VANS ride
  34. Game.ShowPerkVaultBoyOnHUD("Components\\VaultBoys\\Perks\\PerkClip_207d1.swf")
  35. Utility.Wait(2) ; Give Vault Boy time to display
  36. EndIf
  37.  
  38. If HH_OptionTeleportSound.GetValue() as Int == 1 ; If player wants teleport sound,
  39. Int iInstanceID = OBJHijackerTeleportOut2DA.Play(Player) ; play teleport end sound at player
  40. EndIf
  41.  
  42. ObjectReference DestinationMarker = Player.PlaceAtMe(pXMarker) ; Dynamically spawn xmarker at player
  43. Int Category = HH_Category.GetValue() as Int ; Retrieve Category from global
  44. Int TargetID = HH_TargetID.GetValue() as Int ; Retrieve TargetID from global
  45.  
  46. If HH_IsInFarHarbor(Category, TargetID) == 1
  47. Go_File = "DLCCoast.esm"
  48. ElseIf HH_IsInNukaWorld(Category, TargetID) == 1
  49. Go_File = "DLCNukaWorld.esm"
  50. ElseIf Category == VAULTS && TargetID == 5
  51. Go_File = "DLCworkshop03.esm"
  52. Else
  53. Go_File = "Fallout4.esm"
  54. EndIf
  55.  
  56. String Coc_Target ; Target placeholder array for COC
  57. ObjectReference TargetObject ; Destination target as ObjectReference
  58. Int Hex2Dec ; Destination hex converted to decimal
  59.  
  60. If Category == BUS_SHELTERS
  61. Coc_Target = Coc_Bus[TargetID]
  62. DestinationMarker.MoveTo(Game.GetFormFromFile(Go_Bus[TargetID], Go_File) as ObjectReference)
  63. TargetObject = Game.GetFormFromFile(Go_Bus[TargetID], Go_File) as ObjectReference
  64. Hex2Dec = Go_Bus[TargetID]
  65. ElseIf Category == DINERS
  66. Coc_Target = Coc_Diner[TargetID]
  67. DestinationMarker.MoveTo(Game.GetFormFromFile(Go_Diner[TargetID], Go_File) as ObjectReference)
  68. TargetObject = Game.GetFormFromFile(Go_Diner[TargetID], Go_File) as ObjectReference
  69. Hex2Dec = Go_Diner[TargetID]
  70. ElseIf Category == DIVES
  71. Coc_Target = Coc_Dive[TargetID]
  72. DestinationMarker.MoveTo(Game.GetFormFromFile(Go_Dive[TargetID], Go_File) as ObjectReference)
  73. TargetObject = Game.GetFormFromFile(Go_Dive[TargetID], Go_File) as ObjectReference
  74. Hex2Dec = Go_Dive[TargetID]
  75. ElseIf Category == DRIVE_INS
  76. Coc_Target = Coc_Drive[TargetID]
  77. DestinationMarker.MoveTo(Game.GetFormFromFile(Go_Drive[TargetID], Go_File) as ObjectReference)
  78. TargetObject = Game.GetFormFromFile(Go_Drive[TargetID], Go_File) as ObjectReference
  79. Hex2Dec = Go_Drive[TargetID]
  80. ElseIf Category == FACTORIES
  81. Coc_Target = Coc_Factory[TargetID]
  82. DestinationMarker.MoveTo(Game.GetFormFromFile(Go_Factory[TargetID], Go_File) as ObjectReference)
  83. TargetObject = Game.GetFormFromFile(Go_Factory[TargetID], Go_File) as ObjectReference
  84. Hex2Dec = Go_Factory[TargetID]
  85. ElseIf Category == FARMS
  86. Coc_Target = Coc_Farm[TargetID]
  87. DestinationMarker.MoveTo(Game.GetFormFromFile(Go_Farm[TargetID], Go_File) as ObjectReference)
  88. TargetObject = Game.GetFormFromFile(Go_Farm[TargetID], Go_File) as ObjectReference
  89. Hex2Dec = Go_Farm[TargetID]
  90. ElseIf Category == JUNKYARDS
  91. Coc_Target = Coc_Junkyard[TargetID]
  92. DestinationMarker.MoveTo(Game.GetFormFromFile(Go_Junkyard[TargetID], Go_File) as ObjectReference)
  93. TargetObject = Game.GetFormFromFile(Go_Junkyard[TargetID], Go_File) as ObjectReference
  94. Hex2Dec = Go_Junkyard[TargetID]
  95. ElseIf Category == MILITARY_BASES
  96. Coc_Target = Coc_Military[TargetID]
  97. DestinationMarker.MoveTo(Game.GetFormFromFile(Go_Military[TargetID], Go_File) as ObjectReference)
  98. TargetObject = Game.GetFormFromFile(Go_Military[TargetID], Go_File) as ObjectReference
  99. Hex2Dec = Go_Military[TargetID]
  100. ElseIf Category == MONUMENTS
  101. Coc_Target = Coc_Monument[TargetID]
  102. DestinationMarker.MoveTo(Game.GetFormFromFile(Go_Monument[TargetID], Go_File) as ObjectReference)
  103. TargetObject = Game.GetFormFromFile(Go_Monument[TargetID], Go_File) as ObjectReference
  104. Hex2Dec = Go_Monument[TargetID]
  105. ElseIf Category == POWER_LIFTS
  106. Coc_Target = Coc_Power[TargetID]
  107. DestinationMarker.MoveTo(Game.GetFormFromFile(Go_Power[TargetID], Go_File) as ObjectReference)
  108. TargetObject = Game.GetFormFromFile(Go_Power[TargetID], Go_File) as ObjectReference
  109. Hex2Dec = Go_Power[TargetID]
  110. ElseIf Category == RED_ROCKETS
  111. Coc_Target = Coc_Red[TargetID]
  112. DestinationMarker.MoveTo(Game.GetFormFromFile(Go_Red[TargetID], Go_File) as ObjectReference)
  113. TargetObject = Game.GetFormFromFile(Go_Red[TargetID], Go_File) as ObjectReference
  114. Hex2Dec = Go_Red[TargetID]
  115. Else
  116. Coc_Target = Coc_Vault[TargetID]
  117. DestinationMarker.MoveTo(Game.GetFormFromFile(Go_Vault[TargetID], Go_File) as ObjectReference)
  118. TargetObject = Game.GetFormFromFile(Go_Vault[TargetID], Go_File) as ObjectReference
  119. Hex2Dec = Go_Vault[TargetID]
  120. EndIf
  121.  
  122. If HH_OptionDevTracking.GetValue() as Int == 1
  123. Debug.TraceAndBox("Hitching to "+Coc_Target+"\nCategory: "+Category+"\nTargetID: "+TargetID+"\nHex2Dec: "+Hex2Dec+"\nHH Go_File: "+Go_File)
  124. EndIf
  125.  
  126. ; ************************************************************************************************
  127. ; Move the player in a manner that best utilizes player's gaming system and declared preferences!
  128. ; ************************************************************************************************
  129.  
  130. WorldSpace OriginWS = Player.GetWorldSpace() ; Check player worldspace
  131. WorldSpace TargetWS ; Check target worldspace
  132.  
  133. If TargetObject
  134. TargetWS = TargetObject.GetWorldSpace()
  135.  
  136. If HH_OptionDevTracking.GetValue() as Int == 1
  137. Debug.TraceAndBox("Hitchhiker\nTargetObject: "+TargetObject+"\nTargetWS: "+TargetWS)
  138. EndIf
  139.  
  140. EndIf
  141.  
  142. If ((!TargetWS || TargetWS != OriginWS) && (HH_PlayerHasPC.GetValue() as Int == 1)) || (HH_OptionAlwaysCOC.GetValue() as Int == 1)
  143.  
  144. Debug.CenterOnCell(Coc_Target) ; CenterOnCell to target destination
  145.  
  146. If HH_OptionDevTracking.GetValue() as Int == 1
  147. Debug.TraceAndBox("HITCHHIKER: CENTER ON CELL CALLED.")
  148. EndIf
  149.  
  150. Else ; ELSE DO THE USUAL MOVETO ATTEMPT!!!
  151.  
  152. STATIC TargetBase = TargetObject.GetBaseObject() as STATIC ; Check if target base object is an X/COC marker/heading
  153.  
  154. If TargetBase == pXMarker || TargetBase == pXMarkerHeading || TargetBase == pCOCMarkerHeading
  155.  
  156. ; Do not use XYZ offsets if destination is a marker, because teleport placed player directly on the X
  157.  
  158. Else ; else move marker to static ref with XYZ offsets
  159. Float OffsetX = HH_OptionOffsetX.GetValue() ; Player sets X (default 250)
  160. Float OffsetY = HH_OptionOffsetY.GetValue() ; Player sets Y (default 250)
  161. Float OffsetZ
  162.  
  163. If DestinationMarker.IsInInterior() ; If destination is indoors,
  164. OffsetZ = 50 ; don't land in the rafters
  165. Else
  166. OffsetZ = HH_OptionOffsetZ.GetValue() ; Else player sets Z (default 500)
  167. EndIf
  168.  
  169. Utility.Wait(0.1)
  170. DestinationMarker.MoveTo(DestinationMarker, OffsetX, OffsetY, OffsetZ) ; Move marker with XYZ offsets
  171. DestinationMarker.MoveToNearestNavmeshLocation() ; Then move marker to nearest navmesh
  172. EndIf
  173.  
  174. If HH_OptionFastTravel.GetValue() as Int == 1 ; If player wants loading screens,
  175. Game.FastTravel(DestinationMarker) ; move player to marker (with load screens?)
  176.  
  177. If HH_OptionDevTracking.GetValue() as Int == 1
  178. Debug.TraceAndBox("HITCHHIKER: FAST TRAVEL CALLED.")
  179. EndIf
  180. Else
  181. Player.MoveTo(DestinationMarker) ; else move player (with black screen)
  182.  
  183. If HH_OptionDevTracking.GetValue() as Int == 1
  184. Debug.TraceAndBox("HITCHHIKER: MOVETO CALLED.")
  185. EndIf
  186. EndIf
  187. EndIf
  188.  
  189. Utility.Wait(0.1)
  190.  
  191. ; "If TargetObject Is Furniture" caused illegal typecast compiler error, so I wrote a custom function
  192. HH_TryToUseFurniture(Player, TargetObject)
  193.  
  194. ; ********************************************************************************************************
  195. ; Optional automatic time change on teleport
  196. ; ********************************************************************************************************
  197. If HH_OptionSetTime.GetValue() as Int == 1 ; If player wants automatic time change (default is NO)
  198. Int PrefTime = HH_OptionSetTimePreference.GetValue() as Int ; get preferred time
  199. HH_ForceTime(PrefTime) ; and set it
  200. EndIf
  201.  
  202. ; ********************************************************************************************************
  203. ; Optional automatic weather change on teleport
  204. ; ********************************************************************************************************
  205. If !Player.IsInInterior() ; If destination is NOT indoors...
  206. If HH_OptionSetWeather.GetValue() as Int == 1 ; If player wants automatic weather change (default is NO)
  207. Int PrefWeather = HH_OptionSetWeatherPreference.GetValue() as Int ; get preferred weather
  208. HH_ForceWeather(PrefWeather) ; and set it
  209. EndIf
  210. EndIf
  211.  
  212. If HH_OptionSpinCamera.GetValue() as Int == 1 ; If player wants spincam after teleport,
  213. HH_SpinCamera() ; call the custom spin camera function
  214. EndIf
  215.  
  216. StartTimer(10, 2) ; Remove HH_TeleportNoFallDamage perk in 10 seconds
  217. EndIf
  218. EndIf
  219. EndEvent
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement