# This is our main game script. # It is like the brain of the Seeker. using { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # We create a "class". This is like a box for our code. # It must be placed in the editor as a Verse device. hide_and_seek_game := class(creative_device): # This is the "Perception Trigger" device. # Drag it from the editor into this property slot. @editable PerceptionTrigger : perception_trigger_device = perception_trigger_device{} # This is the "Timer" device. # It controls when the eyes open and close. @editable TimerDevice : timer_device = timer_device{} # This is the "Damage Volume". # It is the invisible box that catches players. @editable DamageVolume : damage_volume_device = damage_volume_device{} # We track whether the seeker's eyes are open. # false means the eyes start closed. var EyesOpen : logic = false # This function runs when the game starts. OnBegin() : void = # Subscribe to the timer's completion event. # When the timer finishes, call OnTimerFinished. TimerDevice.SuccessEvent.Subscribe(OnTimerFinished) # Subscribe to the perception trigger's triggered event. # When a player is spotted, call OnPlayerSeen. PerceptionTrigger.TriggeredEvent.Subscribe(OnPlayerSeen) # Turn the perception trigger off at the start. # The eyes begin closed so players have time to hide. PerceptionTrigger.Disable() # Start the timer for 5 seconds. # It will wait before the seeker first opens its eyes. TimerDevice.Start() # This function runs when the timer finishes. OnTimerFinished(Agent : ?agent) : void = # Toggle the seeker's eyes. # If eyes are open, close them. # If eyes are closed, open them. if (EyesOpen?): set EyesOpen = false PerceptionTrigger.Disable() else: set EyesOpen = true PerceptionTrigger.Enable() # Restart the timer to keep the blinking loop going. TimerDevice.Start() # This function runs when the seeker sees a player. OnPlayerSeen(Agent : agent) : void = # Only deal damage if the eyes are currently open. if (EyesOpen?): # Enable the damage volume so it hurts players inside its volume. # damage_volume_device has no per-player Activate API; Enable() # triggers it for anyone already inside its volume. DamageVolume.Enable()