Verse Library verse

01 Device

Tracks player eliminations using an event from an elimination manager device to update per-kill counters.

verse-library/create-an-elimination-game-in-fortnite-creative/01-device.verse

# KillRewards.verse
# This script listens for eliminations and upgrades the winner's weapon.

using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /Fortnite.com/Playspaces }
using { /Fortnite.com/Game }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }

# We define our main script here. Think of this as the "Brain" of the island.
# It must be a creative_device so UEFN can place it on the island as an actor.
KillRewards := class(creative_device):

    # Step 1: Reference the Elimination Manager.
    # In Verse, we declare a device property and then wire it up in the
    # UEFN Details panel — drag your placed Elimination Manager into this slot.
    @editable
    EliminationManager : elimination_manager_device = elimination_manager_device{}

    # Step 2: Per-player kill counter.
    # We use a weak_map so entries are cleaned up automatically when a player leaves.
    # var means the map itself can be replaced with an updated copy.
    var KillCounts : [player]int = map{}

    # OnBegin is the Verse entry point — called once when the game session starts.
    OnBegin<override>()<suspends> : void =
        # Step 3: Subscribe to the EliminationManager's elimination event.
        # EliminatedEvent fires with an ?agent whenever a player
        # is knocked out. We pass our handler as the subscriber.

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.

Sign in with Discord

Comments

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