using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /Verse.org/Simulation }
# This is our Custom Device. It's like a blueprint for our "Desperation Healer."
Desperation_Healer := class(creative_device):
# @editable means we can change this value in the editor without rewriting code.
# Think of this as the "Threshold" setting on a device.
var Health_Threshold : float = 30.0
# This is the function that runs when the trigger is activated.
# It's like the "On Triggered" event in standard Creative.
On_Trigger_Activated := func(trigger: trigger_device, agent: agent):
# 1. Check if the agent is actually a player.
# In Verse, 'agent' is a generic term for any character.
# We need to cast it to a 'player_character' to access health.
if (player_char := as<player_character>(agent)):
# 2. Get the player's current health.
# This is like checking the loot box to see what's inside.
current_health := player_char.Get_Health()
# 3. The Logic: If health is below the threshold, heal them.
# This is the "If-Then" rule.
if (current_health < Health_Threshold):
# Set health to 100 (or whatever you want)
player_char.Set_Health(100.0)
# Optional: Visual feedback! Let's flash the player white for a split second.
Verse Library
verse
01 Device
Heals a player to full health upon trigger activation, but only if their health is below a set threshold.
verse-library/fortnite-simple-health-manager-use-triggers-to-modify-health/01-device.verse
Sign in free to read the full source 🌴
This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.