# This is the blueprint for our "Streak Observer" # Think of this as the Referee's Notepad and Whistle combined using { /Fortnite.com/Devices } using { /Verse.org/Simulation } # We create a "class" marked as a creative_device — this makes it # show up in the UEFN editor so you can drag devices into its properties. # Think of it as a backpack that holds two things: the Kill Count and the Radio. streak_observer := class(creative_device): # The Radio Device we want to control. # In the editor, you will drag your Radio device here. @editable Radio : radio_device = radio_device{} # The Tracker Device counting the kills. # In the editor, you will drag your Tracker device here. @editable KillTracker : tracker_device = tracker_device{} # This is our "Variable" - a number that changes. # We use 'var' so Verse lets us reassign it later. # We start at 0. var CurrentStreak : int = 0 # This is the target number. # Set this to whatever streak you want (e.g., 5 for a 5-kill streak). @editable TargetStreak : int = 5 # OnBegin is called when the game starts. # It's like the "Start Game" button. # It is 'suspends' because Verse devices run their startup logic as async tasks. OnBegin() : void = # We want to listen for updates from the Tracker. # The Tracker fires CompleteEvent whenever its tracked value reaches the target. # We connect our "OnKillEvent" function to that event. KillTracker.CompleteEvent.Subscribe(OnKillEvent) # This is the "Event" listener. # It doesn't run continuously. It only runs when the Tracker sends a signal. # Think of it as a doorbell. You only answer when it rings. # CompleteEvent passes the agent who triggered the change. OnKillEvent(Agent : agent) : void = # Increment our internal variable by 1 each time an elimination fires. set CurrentStreak += 1 # This is the "Conditional" (The If/Else statement). # "If CurrentStreak is exactly equal to TargetStreak..." if (CurrentStreak = TargetStreak): # ...Then Play the Radio! # We tell the Radio device to start playing its audio. Radio.Play() # Reset the streak so the fanfare can trigger again next round. set CurrentStreak = 0