Verse Library verse

01 Fragment

Creates a damage trap script that applies damage to any agent entering a specified volume.

verse-library/using-damage-volume-devices-in-fortnite-creative/01-fragment.verse

# This line imports the tools we need to talk to Fortnite devices.
# Think of it as opening your toolbelt.
using { /Fortnite.com/Devices }

# This is the "Blueprint" for our script.
# It defines what our script *is* and what it *needs* to work.
template RevengeSpireDevice : ISimpleScript {
    # Here we define the "Variables" or "Slots".
    # Think of these as the input ports on a device.
    # We need to connect our Damage Volume device here.
    
    # 'TargetVolume' is the name of the slot.
    # ': DamageVolume' tells Verse: "This slot must be filled with a Damage Volume device."
    # If you try to run this script without connecting a Damage Volume, Verse will yell at you.
    TargetVolume: DamageVolume
    
    # 'DamageAmount' is a constant setting.
    # It’s like setting the difficulty level. We can change this number in the editor.
    DamageAmount: int = 50
    
    # This is the "Event Handler".
    # It’s a function that Verse calls automatically when something happens.
    # Specifically, when an 'Agent' (player) enters the volume.
    OnAgentEntered(Agent: agent) -> void:
        # This line is the "Action".
        # We are telling the TargetVolume to deal damage.
        # We pass in the Agent (the player) and the DamageAmount (50).
        TargetVolume.DealDamage(Agent, DamageAmount)
}

Comments

    Sign in to vote, comment, or suggest an edit. Sign in