Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Scriptname ScavverUnloadedAlgorithm extends Package
- { It just works. }
- ; SCAVVER MOD BY @THORALDGM | [email protected] | SCRIPT UPDATED 20160706
- ; -----------------------------------------------------------------------------------------------------------
- ; PROPERTIES
- ; -----------------------------------------------------------------------------------------------------------
- ObjectReference Property pScavver Auto Const Mandatory ; Scavver ObjRef
- Actor Property pScavverActor Auto Const Mandatory ; Scavver ActorRef
- GlobalVariable Property pgvScavverStatusSniffer Auto Mandatory ; Does player have Scavver dev tracking on?
- GlobalVariable Property pgvScavverIsInLimbo Auto Mandatory ; Is Scavver in an unloaded cell?
- ObjectReference Property pScavverMarker Auto Const Mandatory ; Alert system for stuck NPCs
- ObjectReference Property pScavverTriggerVolume Auto Const Mandatory ; Trigger volume is stuck path failsafe
- ObjectReference Property pScavMarker000 Auto Const Mandatory ; Scavver's moving target for travel location
- ObjectReference[] Property arScavMarkers Auto ; Array of ScavMarkers (0 = 100, 1 = 101 ...)
- GlobalVariable Property pgvScavverCurrentMarker Auto Mandatory ; Track route progress / location (0 to 22)
- GlobalVariable Property pgvScavverLootedArea Auto Mandatory ; Condition for package stack. Important!
- GlobalVariable Property pgvScavverDoNotLootHere Auto Mandatory
- GlobalVariable Property pgvScavverIsHome Auto Mandatory
- GlobalVariable Property pgvScavverStartRoute Auto Mandatory
- GlobalVariable Property pgvScavverLapsCompleted Auto Mandatory
- ScavverUtilityScript Property pScavverUtilityScript Auto Const Mandatory
- ObjectReference Property pTgmScavverUnloadedLoot Auto Const Mandatory
- ; -----------------------------------------------------------------------------------------------------------
- ; EVENT: ON CELL LOAD (PLAYER HAS ARRIVED, RESUME SWEEP AND TRAVEL PACKAGES)
- ; -----------------------------------------------------------------------------------------------------------
- Event ObjectReference.OnCellLoad(ObjectReference akSender)
- pgvScavverIsInLimbo.SetValue(0) ; Remove limbo flag
- pgvScavverLootedArea.SetValue(1) ; Flag area as looted
- pgvScavverDoNotLootHere.SetValue(0)
- pgvScavverIsHome.SetValue(0) ; No longer staying home
- pgvScavverStartRoute.SetValue(1) ; Ok to start route again
- ; THESE ARE THE 5 CONDITION FLAGS FOR PACKAGE STACK. THIS MEANS SCAVVER WILL TRAVEL ON CELL LOAD!
- UnregisterForRemoteEvent(pScavverActor, "OnCellLoad") ; Stop listening for event
- CancelTimer(1) ; Cancel limbo timer
- CancelTimer(2) ; Cancel wait at home timer
- CancelTimer(3) ; Cancel loot container reset
- If pgvScavverStatusSniffer.GetValue() == 1
- Debug.Notification("Scavver exited limbo as player arrived.") ; Notify Scavver is exiting limbo
- EndIf
- pScavverActor.EvaluatePackage() ; Wake up and resume normal behavior
- EndEvent
- ; -----------------------------------------------------------------------------------------------------------
- ; EVENT: ON START ("Called when the package starts.")
- ; -----------------------------------------------------------------------------------------------------------
- Event OnStart(Actor akActor)
- int CurrentMarker = pgvScavverCurrentMarker.GetValue() as int ; Pkg only runs if Scavver is in limbo
- pScavver.MoveTo(arScavMarkers[CurrentMarker]) ; Move Scavver to current marker
- pScavMarker000.MoveTo(pScavver) ; Move travel marker to Scavver
- pScavverMarker.MoveTo(pScavver) ; Place distance marker at Scavver
- pScavverTriggerVolume.MoveTo(pScavver) ; Place trigger volume at Scavver
- ; Debug.Trace("SCAVVER UNLOADED ALGORITHM: ON START FIRED")
- CancelTimer(1)
- StartTimer(600, 1) ; Stand in limbo for 10 minutes
- If pgvScavverStatusSniffer.GetValue() == 1
- Debug.Notification("Scavver started limbo at marker #" + CurrentMarker + ".")
- EndIf
- RegisterForRemoteEvent(pScavverActor, "OnCellLoad")
- EndEvent
- ; -----------------------------------------------------------------------------------------------------------
- ; EVENT: ON TIMER
- ; -----------------------------------------------------------------------------------------------------------
- Event OnTimer(int aiTimerID) ; Cancel timer
- int CurrentMarker = pgvScavverCurrentMarker.GetValue() as int
- int NextMarker
- If aiTimerID == 1
- pTgmScavverUnloadedLoot.RemoveAllItems(pScavver, false) ; Move loot from "unloaded" container
- StartTimer(60, 3) ; Reset "unloaded" loot for next time
- If pgvScavverStatusSniffer.GetValue() == 1
- Debug.Notification("Scavver completed limbo at marker #" + CurrentMarker + ".")
- EndIf
- NextMarker = CurrentMarker + 1
- If NextMarker == arScavMarkers.Length
- NextMarker = 0 ; SCAVVER IS MOVING TO VAULT 111 EXT
- pgvScavverIsHome.SetValue(1) ; Flag that Scavver has arrived home
- pgvScavverStartRoute.SetValue(0) ; Scavver will pause at home for building
- pgvScavverLapsCompleted.Mod(1) ; Increment number of laps completed
- pScavMarker000.MoveTo(arScavMarkers[NextMarker]) ; Move travel marker to next location
- pScavver.MoveTo(pScavMarker000) ; Move Scavver to travel marker
- pScavverMarker.MoveTo(pScavver) ; Place distance marker at Scavver
- pScavverTriggerVolume.MoveTo(pScavver) ; Place trigger volume at Scavver
- pgvScavverCurrentMarker.SetValue(NextMarker as float)
- pScavverUtilityScript.BuildScavverSettlement() ; Build next stage of settlement
- StartTimer(4320, 2) ; Wait one game day (72 RL minutes)
- Else ; ELSE NOT MOVING TO VAULT 111 EXT
- pScavMarker000.MoveTo(arScavMarkers[NextMarker]) ; Move travel marker to next location
- pScavver.MoveTo(pScavMarker000) ; Move Scavver to travel marker
- pScavverMarker.MoveTo(pScavver) ; Place distance marker at Scavver
- pScavverTriggerVolume.MoveTo(pScavver) ; Place trigger volume at Scavver
- pgvScavverCurrentMarker.SetValue(NextMarker as float)
- pScavverActor.EvaluatePackage() ; This pkg will repeat until limbo == 0
- EndIf
- ElseIf aiTimerID == 2 ; Entire home stay was in limbo
- pgvScavverIsHome.SetValue(0) ; No longer staying home
- pgvScavverStartRoute.SetValue(1) ; Ok to start route again
- Utility.Wait(1)
- pScavverActor.EvaluatePackage() ; Move along
- ElseIf aiTimerID == 3
- pTgmScavverUnloadedLoot.Reset() ; Reset "unloaded" loot for next time
- Else
- ; Timer is not 1-3, do nothing
- EndIf
- EndEvent
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement