Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Scriptname HH_QuestScript extends Quest
- { It just works. }
- ; Fallout 4 Papyrus script by ThoraldGM | http://thoraldgm.com | Updated 20171111
- ; Hitchhiker mod: (url pending)
- ; ------------------------------------------------------------------------------------------------------------
- ; PROPERTIES
- ; ------------------------------------------------------------------------------------------------------------
- Actor Player ; Player
- Book Property HH_Map Auto Const Mandatory ; Hitchhiker map
- GlobalVariable Property HH_DevTracking Auto Mandatory ; Does player want dev messages?
- GlobalVariable Property HH_OptionCamMaxDistance Auto Mandatory ; Max camera distance
- GlobalVariable Property HH_OptionCamMinDistance Auto Mandatory ; Min camera distance
- GlobalVariable Property HH_OptionOffsetX Auto Mandatory ; X offset
- GlobalVariable Property HH_OptionOffsetY Auto Mandatory ; Y offset
- GlobalVariable Property HH_OptionOffsetZ Auto Mandatory ; Z offset
- GlobalVariable Property HH_OptionSpinCamera Auto Mandatory ; Does player want spincam after teleport?
- GlobalVariable Property HH_OptionSpinDuration Auto Mandatory ; How long should camera spin? (Default 20 seconds)
- GlobalVariable Property HH_OptionTeleportSound Auto Mandatory ; Does player want teleport sound?
- GlobalVariable Property HH_RandomLocation Auto Mandatory ; Does player want any location or specific?
- GlobalVariable Property HH_ShowMenu Auto Mandatory ; Don't show menu when map placed in inventory
- GlobalVariable Property HH_SpecificLocation Auto Mandatory ; Which specific location did player select?
- Quest Property QuestRefRedRocket Auto Const Mandatory ; Quest stores Red Rocket ref aliases
- Sound Property OBJHijackerTeleportOut2DA Auto Const Mandatory ; Teleport sound effect
- STATIC Property pXMarker Auto Const Mandatory ; Xmarker static from CK as a property
- ; ------------------------------------------------------------------------------------------------------------
- ; EVENT: ON INIT
- ; ------------------------------------------------------------------------------------------------------------
- Event OnInit()
- Player = Game.GetPlayer()
- Utility.Wait(0.1)
- If Player.GetItemCount(HH_Map) == 0 ; If player doesn't have hitchhiker map,
- HH_ShowMenu.SetValue(0) ; don't show menu when map placed in inventory
- Utility.Wait(5) ; wait 5 seconds
- Player.AddItem(HH_Map) ; spawn hitchhiker map in player inventory
- EndIf
- EndEvent
- ; ------------------------------------------------------------------------------------------------------------
- ; CUSTOM FUNCTION: START HITCHING
- ; ------------------------------------------------------------------------------------------------------------
- Function StartHitching(Int LocationSelected)
- Quest QuestToGrab ; Which quest do we need refs from
- ; HH_DisableEnable() did NOT work. Tested 20171111
- Player.MoveTo(Player, afZOffset = 1) ; Exits book/pip but no player controls after teleport!
- If LocationSelected < 100 ; If player selected any...
- HH_RandomLocation.SetValue(1) ; Set random
- Else
- HH_RandomLocation.SetValue(0) ; Else specific
- HH_SpecificLocation.SetValue(LocationSelected) ; Remember specific location in global
- EndIf
- If (LocationSelected == 1) || (LocationSelected >= 100 && LocationSelected < 200) ; If player selected Red Rocket
- QuestToGrab = QuestRefRedRocket ; assign which quest to grab
- EndIf
- RegisterForRemoteEvent(QuestToGrab, "OnQuestInit") ; Listen for refs quest start
- Utility.Wait(0.1) ; Wait a moment for registration to finish
- QuestToGrab.Start() ; Start the refs quest
- EndFunction
- ; ------------------------------------------------------------------------------------------------------------
- ; EVENT: ON QUEST INIT
- ; ------------------------------------------------------------------------------------------------------------
- Event Quest.OnQuestInit(Quest akSender) ; When quest starts & aliases are filled
- ObjectReference DestinationMarker ; DOES THIS PERSIST?! HOPEFULLY NOT.
- ObjectReference StaticRef ; DOES THIS PERSIST?! HOPEFULLY NOT.
- Int MyIndex
- Int PreSpinCameraView
- Int SpinSeconds
- Int i
- If akSender == QuestRefRedRocket ; If the starting quest is Red Rocket...
- ; Red Rocket's refs are ready to be grabbed
- If HH_RandomLocation.GetValue() as Int == 1 ; Player selected Any Red Rocket
- ReferenceAlias[] DestinationRedRocket = new ReferenceAlias[20] ; Create temp array to hold aliases
- ; Grab all teh refs
- i = 0
- While i < 20
- DestinationRedRocket[i] = QuestRefRedRocket.GetAlias(i) as ReferenceAlias
- i += 1
- EndWhile
- MyIndex = Utility.RandomInt(0, 19) ; Roll random index
- StaticRef = (DestinationRedRocket[MyIndex]).GetReference() ; and grab ref of random static
- Else ; Else player selected specific location
- MyIndex = (HH_SpecificLocation.GetValue() as Int) - 100 ; Convert 3 digit location to 2 digit ID
- ; and grab ref of specific static
- StaticRef = (QuestRefRedRocket.GetAlias(MyIndex) as ReferenceAlias).GetReference()
- EndIf
- QuestRefRedRocket.Stop() ; Done with quest until next time
- EndIf
- Player.SetGhost() ; IMPORTANT: Player immune to all damage!
- If HH_DevTracking.GetValue() as Int == 1 ; If player wants dev messages
- If Player.IsGhost() ; If player is a ghost,
- Debug.Notification("Hitchhiker: Player is a ghost!") ; display message
- EndIf
- EndIf
- If HH_OptionTeleportSound.GetValue() as Int == 1 ; If player wants teleport sound,
- Int iInstanceID = OBJHijackerTeleportOut2DA.Play(Player) ; play teleport sound at player
- EndIf
- DestinationMarker = Player.PlaceAtMe(pXMarker) ; Dynamically spawn xmarker at player
- Float OffsetX = HH_OptionOffsetX.GetValue()
- Float OffsetY = HH_OptionOffsetY.GetValue()
- Float OffsetZ = HH_OptionOffsetZ.GetValue()
- DestinationMarker.MoveTo(StaticRef, OffsetX, OffsetY, OffsetZ) ; Move marker to static ref with XYZ offsets
- DestinationMarker.MoveToNearestNavmeshLocation() ; Then move marker to nearest navmesh
- Game.FastTravel(DestinationMarker) ; Move player to marker (with load screens?)
- If HH_OptionSpinCamera.GetValue() as Int == 1 ; If player wants spincam after teleport
- Bool FirstView = Player.GetAnimationVariableBool("IsFirstPerson") ; Is player in first person view? (thx registrator2000)
- If FirstView ; If yes,
- PreSpinCameraView = 1 ; flag as first person (int declared earlier)
- Else
- PreSpinCameraView = 3 ; else flag as third person
- EndIf
- Game.ForceThirdPerson() ; IMPORTANT: Must start/run spin in third person!
- ; Thx steve40 for all of the utility camera code
- Float CamMinDistance = HH_OptionCamMinDistance.GetValue()
- Float CamMaxDistance = HH_OptionCamMaxDistance.GetValue()
- Utility.SetIniFloat("fVanityModeMinDist:Camera", CamMinDistance)
- Utility.SetIniFloat("fVanityModeMaxDist:Camera", CamMaxDistance)
- Utility.Wait(0.1)
- Utility.SetINIBool("bForceAutoVanityMode:Camera", true) ; Spin the idle camera around player
- EndIf
- SpinSeconds = HH_OptionSpinDuration.GetValue() as Int ; Default is 20 seconds but player can change
- Utility.Wait(SpinSeconds) ; Wait specified number of seconds
- Player.SetGhost(false) ; IMPORTANT: Undo player's temporary invulnerability
- If HH_DevTracking.GetValue() as Int == 1 ; If player wants dev messages
- If Player.IsGhost() == false ; If player is no longer a ghost,
- Debug.Notification("Hitchhiker: Player is not a ghost.") ; display message
- EndIf
- EndIf
- If HH_OptionSpinCamera.GetValue() as Int == 1 ; If player is spinning,
- Utility.SetINIBool("bForceAutoVanityMode:Camera", false) ; stop spinning
- Game.ForceFirstPerson() ; IMPORTANT: Call this or spin will last forever!
- If PreSpinCameraView == 3 ; If player preferred third person view,
- Game.ForceThirdPerson() ; can resume third now that spin handling is done
- EndIf
- Player.ResetHealthAndLimbs() ; Undo any damage taken during spin (obsolete by ghost?)
- EndIf ; Done with optional spincam effect
- EndEvent ; Event end should dump the temp refs array!
- ; ------------------------------------------------------------------------------------------------------------
- ; CUSTOM FUNCTION: HH DISABLE ENABLE
- ; ------------------------------------------------------------------------------------------------------------
- Function HH_DisableEnable()
- InputEnableLayer myLayer = InputEnableLayer.Create()
- myLayer.DisablePlayerControls(true, true, true, true, true, true, true, true, true, true, true)
- Utility.Wait(1)
- myLayer.EnablePlayerControls()
- EndFunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement