# Source URL: https://dev.epicgames.com/documentation/en-us/uefn/learn-code-basics-7-practice-time-in-verse
# Local doc: epic-docs/documentation/en-us/uefn/learn-code-basics-7-practice-time-in-verse.md
# Section: Complete Script
using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /Fortnite.com/Playspaces }
using { /Verse.org/Simulation }
using { /Verse.org/Verse }
hello_world_device := class(creative_device):
# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=
HurtPlayer()
Print("Player Hurt")
CalculateDamage() : float =
MaxHealth : float = 100.0
MinHealth : float = 1.0
PotionDamageAmount: float = 80.0
var PlayerHealth : float = 100.0
# If the damage amount would not eliminate the player, do that amount of damage
if (PlayerHealth > PotionDamageAmount):
return PotionDamageAmount
else if (PlayerHealth > MinHealth):
# Give player one more chance if their health is low
return PlayerHealth - MinHealth
else:
Verse Library
verse
04 Complete Script
Demonstrates custom damage calculation functions that safely reduce player health without causing negative values.
extracted-snippets/documentation/en-us/uefn/learn-code-basics-7-practice-time-in-verse/04-complete-script.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.