# Import the core Verse libraries using /Fortnite.com/Devices using /Fortnite.com/Characters using /Fortnite.com/FortPlayerUtilities using /UnrealEngine.com/Temporary/Diagnostics # This is our main device. It's the "Brain" of our healing zone. # It sits in the world and waits for players to touch it. med_mist_device := class(creative_device): # 'TriggerDevice' is the trigger_device placed in the world. # Wire this up in the UEFN editor by selecting your Trigger Volume. @editable TriggerDevice : trigger_device = trigger_device{} # 'Health_Per_Tick' is a CONSTANT. # It's like setting the dial on a heater. You set it once in the editor, # and it doesn't change during the game. @editable Health_Per_Tick : float = 10.0 # 'Is_Healing' is a VARIABLE (specifically a mutable boolean). # It's like a light switch: true (on) or false (off). # We use this to track if anyone is currently standing in the mist. var Is_Healing : logic = false # 'CurrentPlayer' holds a reference to whoever walked into the zone. # option(player) means it might be empty (no one inside yet). var CurrentPlayer : ?player = false # OnBegin runs once when the game session starts. # We use it to subscribe to the trigger's enter and exit events. OnBegin() : void = TriggerDevice.TriggeredEvent.Subscribe(OnPlayerEnter) # This function is called every time the trigger fires (player enters). # 'Agent' is the entity that walked in; we cast it to a player below. OnPlayerEnter(Agent : agent) : void = # Try to cast the generic agent to a concrete player type. if (FortnitePlayer := player[Agent]): set CurrentPlayer = option{FortnitePlayer} set Is_Healing = true # Kick off the repeating heal loop as an async task # so it doesn't block other game logic. spawn{ HealLoop() } # HealLoop runs on its own async fiber, ticking every second. HealLoop() : void = loop: # Stop looping the moment the player leaves the zone. if (Is_Healing = false): break # Unwrap the stored player reference safely. if (P := CurrentPlayer?): # Cast the player to a fort_character to access HP functions. if (Character := P.GetFortCharacter[]): CurrentHp := Character.GetHealth() MaxHp := Character.GetMaxHealth() # Cap the new value at the character's actual maximum. NewHp := Min(MaxHp, CurrentHp + Health_Per_Tick) Character.SetHealth(NewHp) # Wait one second before the next heal tick. # Sleep is the real Verse async-pause function. Sleep(1.0) # This function is called when the player exits the zone. # Wire TriggerDevice's "Exited" event to this in the editor, # or subscribe to a separate exit trigger if your device exposes one. OnPlayerExit(Agent : agent) : void = set Is_Healing = false set CurrentPlayer = false