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 20171118
- ; Hitchhiker mod: (url pending)
- ; ------------------------------------------------------------------------------------------------------------
- ; PROPERTIES
- ; ------------------------------------------------------------------------------------------------------------
- Actor Player ; Player actor
- Book Property HH_Map Auto Const Mandatory ; Hitchhiker map
- GlobalVariable Property HH_IsSpinning Auto Mandatory ; Is the camera currently spinning?
- GlobalVariable Property HH_OptionCamMaxDistance Auto Mandatory ; Max camera distance (default: 200, vanilla: 150)
- GlobalVariable Property HH_OptionCamMinDistance Auto Mandatory ; Min camera distance (default: 100, vanilla: 0)
- GlobalVariable Property HH_OptionDevTracking Auto Mandatory ; Does player want dev messages? (default: no)
- GlobalVariable Property HH_OptionFastTravel Auto Mandatory ; Does player want loading screens? (default: yes)
- GlobalVariable Property HH_OptionOffsetX Auto Mandatory ; Player can choose X offset (default: 250)
- GlobalVariable Property HH_OptionOffsetY Auto Mandatory ; Player can choose Y offset (default: 250)
- GlobalVariable Property HH_OptionOffsetZ Auto Mandatory ; Player can choose Z offset (default: 500)
- GlobalVariable Property HH_OptionSpinCamera Auto Mandatory ; Does player want teleport to spin camera? (default: yes)
- GlobalVariable Property HH_OptionSpinDuration Auto Mandatory ; How long should camera spin? (default: 20 seconds)
- GlobalVariable Property HH_OptionSpinGhost Auto Mandatory ; Does player want invulnerable spin? (default: yes)
- GlobalVariable Property HH_OptionSpinHeal Auto Mandatory ; Does player want to heal after spin? (default: no)
- GlobalVariable Property HH_OptionTeleportSound Auto Mandatory ; Does player want teleport sound? (default: yes)
- GlobalVariable Property HH_RandomLocation Auto Mandatory ; Did player select 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 QuestRefPowerLifts Auto Const Mandatory ; Quest stores Power Lifts ref aliases
- Quest Property QuestRefRedRocket Auto Const Mandatory ; Quest stores Red Rocket ref aliases
- Sound Property DRSVertibirdFlightLoadOpen Auto Const Mandatory ; Teleport start sound effect
- Sound Property OBJHijackerTeleportOut2DA Auto Const Mandatory ; Teleport end sound effect
- STATIC Property pXMarker Auto Const Mandatory ; Xmarker static from CK as a property
- ; ------------------------------------------------------------------------------------------------------------
- ; EVENT: ON INIT
- ; ------------------------------------------------------------------------------------------------------------
- Event OnInit()
- Player = Game.GetPlayer() ; Player actor
- Utility.Wait(0.1) ; Wait a moment before using actor
- 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
- If LocationSelected == 0 ; If player selected anywhere...
- ; go anywhere (but here?)
- ElseIf LocationSelected < 100 ; If player selected any destination,
- HH_RandomLocation.SetValue(1) ; Set random to YES
- Else
- HH_RandomLocation.SetValue(0) ; Else set random to NO
- HH_SpecificLocation.SetValue(LocationSelected) ; and remember specific location in global
- EndIf
- If (LocationSelected == 1) || (LocationSelected >= 100 && LocationSelected < 200) ; If player selected Power Lifts
- QuestToGrab = QuestRefPowerLifts ; select refs quest
- EndIf
- If (LocationSelected == 2) || (LocationSelected >= 200 && LocationSelected < 300) ; If player selected Red Rocket
- QuestToGrab = QuestRefRedRocket ; select refs quest
- EndIf
- RegisterForRemoteEvent(QuestToGrab, "OnQuestInit") ; Listen for refs quest start
- Utility.Wait(0.1) ; Wait a moment for registration to finish
- If HH_OptionTeleportSound.GetValue() as Int == 1 ; If player wants teleport sound,
- Int iInstanceID = DRSVertibirdFlightLoadOpen.Play(Player) ; play teleport start sound at player
- EndIf
- 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.
- If akSender ; Selected quest's refs are filled
- Int MyIndex
- Int NumAliases
- Int QuestID
- Int i
- If akSender == QuestRefPowerLifts ; 13 power lifts, QuestID 100
- NumAliases = 13
- QuestID = 100
- ElseIf akSender == QuestRefRedRocket ; 20 Red Rockets, QuestID 200
- NumAliases = 20
- QuestID = 200
- EndIf
- If HH_RandomLocation.GetValue() as Int == 1 ; Player selected "Any" destination
- ReferenceAlias[] MyDestination = new ReferenceAlias[NumAliases] ; Create temp array to hold aliases
- ; Grab all teh refs
- i = 0
- While i < NumAliases
- MyDestination[i] = akSender.GetAlias(i) as ReferenceAlias
- i += 1
- EndWhile
- MyIndex = Utility.RandomInt(0, (NumAliases - 1)) ; Roll random index
- StaticRef = (MyDestination[MyIndex]).GetReference() ; and grab ref of random static
- Else ; Else player selected specific location
- MyIndex = (HH_SpecificLocation.GetValue() as Int) - QuestID ; Convert 3 digit location to 2 digit ID
- ; and grab ref of specific static
- StaticRef = (akSender.GetAlias(MyIndex) as ReferenceAlias).GetReference()
- EndIf
- akSender.Stop() ; Done with quest until next time
- EndIf
- If HH_OptionSpinGhost.GetValue() as Int == 1 ; If player wants no spin damage (default)
- Player.SetGhost() ; IMPORTANT: Player immune to all damage!
- If HH_OptionDevTracking.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 dev message
- EndIf
- EndIf
- EndIf ; NOTE: Unghosting happens in HH_SpinCamera()
- If HH_OptionTeleportSound.GetValue() as Int == 1 ; If player wants teleport sound,
- Int iInstanceID = OBJHijackerTeleportOut2DA.Play(Player) ; play teleport end sound at player
- EndIf
- DestinationMarker = Player.PlaceAtMe(pXMarker) ; Dynamically spawn xmarker at player
- Float OffsetX = HH_OptionOffsetX.GetValue() ; Player sets X (default 250)
- Float OffsetY = HH_OptionOffsetY.GetValue() ; Player sets Y (default 250)
- Float OffsetZ = HH_OptionOffsetZ.GetValue() ; Player sets Z (default 500)
- If akSender == QuestRefPowerLifts ; If player selected Power Lift,
- DestinationMarker.MoveTo(StaticRef) ; move marker to power lift ref (vanilla xmarker)
- Else
- DestinationMarker.MoveTo(StaticRef, OffsetX, OffsetY, OffsetZ) ; else move marker to static ref with XYZ offsets
- EndIf
- DestinationMarker.MoveToNearestNavmeshLocation() ; Then move marker to nearest navmesh
- If HH_OptionFastTravel.GetValue() as Int == 1 ; If player wants loading screens,
- Game.FastTravel(DestinationMarker) ; move player to marker (with load screens?)
- Else
- Player.MoveTo(DestinationMarker) ; else move player (with black screen)
- EndIf
- If HH_OptionSpinCamera.GetValue() as Int == 1 ; If player wants spincam after teleport,
- HH_SpinCamera() ; call the custom spin camera function
- EndIf
- EndEvent ; Event end should dump the temp refs array!
- ; ------------------------------------------------------------------------------------------------------------
- ; CUSTOM FUNCTION: HH SPIN CAMERA
- ; ------------------------------------------------------------------------------------------------------------
- Function HH_SpinCamera()
- Int SpinSeconds
- Game.ForceFirstPerson() ; IMPORTANT: Must start/run spin in first person!
- ; Thx steve40 for distance & setini code
- Float CamMinDistance = HH_OptionCamMinDistance.GetValue() ; Player chooses min distance (default: 100, vanilla: 0)
- Float CamMaxDistance = HH_OptionCamMaxDistance.GetValue() ; Player chooses max distance (default: 200, vanilla: 150)
- Utility.SetIniFloat("fVanityModeMinDist:Camera", CamMinDistance) ; Set min
- Utility.SetIniFloat("fVanityModeMaxDist:Camera", CamMaxDistance) ; Set max (NEED TO RESET THESE AFTER SPIN STOPS?)
- Utility.Wait(1) ; Wait a moment
- Utility.SetINIBool("bForceAutoVanityMode:Camera", true) ; Spin the idle camera around player
- HH_IsSpinning.SetValue(1) ; Flag player / camera as spinning
- SpinSeconds = HH_OptionSpinDuration.GetValue() as Int ; Player chooses how long to spin (default: 20 seconds)
- StartTimer(SpinSeconds, 1) ; Wait SpinSeconds then call StopSpinning from OnTimer event
- EndFunction
- ; -----------------------------------------------------------------------------------------------------------
- ; EVENT: ON TIMER
- ; -----------------------------------------------------------------------------------------------------------
- Event OnTimer(int aiTimerID) ; Cancel timer
- If aiTimerID == 1
- HH_StopSpinning() ; Call StopSpinning function
- EndIf
- EndEvent
- ; ------------------------------------------------------------------------------------------------------------
- ; CUSTOM FUNCTION: HH STOP SPINNING
- ; ------------------------------------------------------------------------------------------------------------
- Function HH_StopSpinning()
- CancelTimer(1) ; Cancel any lingering StopSpinning timers
- If Player.IsGhost() ; If player is a ghost,
- Player.SetGhost(false) ; IMPORTANT: Undo player's temporary invulnerability
- If HH_OptionDevTracking.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 dev message
- EndIf
- EndIf
- EndIf
- If HH_IsSpinning.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 HH_OptionSpinHeal.GetValue() as Int == 1 ; If player wants healed,
- Player.ResetHealthAndLimbs() ; Undo any damage taken during spin (obsolete by ghost)
- EndIf
- HH_IsSpinning.SetValue(0) ; Flag player / camera as no longer spinning
- EndIf ; Done with optional spincam effect
- EndFunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement