Verse Library verse

02 Device

Creates a loot box device that grants random items when a player triggers a designated zone.

verse-library/or-right/02-device.verse

# Import the Verse standard modules we need
using { /Verse.org/Simulation }
using { /Verse.org/Random }
using { /Fortnite.com/Devices }
using { /UnrealEngine.com/Temporary/Diagnostics }

# Define our creative device class.
# A creative_device is the standard base for all Verse-powered island devices.
loot_box_device := class(creative_device) {

    # We need to reference our devices.
    # These are "Properties" – variables that hold references to devices in the level.
    # You will set these in the Verse Device's properties panel in the editor.
    @editable
    LootBoxTrigger : trigger_device = trigger_device{}

    @editable
    ShieldGranter : item_granter_device = item_granter_device{}

    @editable
    BandageGranter : item_granter_device = item_granter_device{}

    # This function picks the loot and gives it.
    GiveRandomLoot(Agent : agent) : void =
        # Roll the die: 0 or 1
        Roll := GetRandomInt(0, 1)

        # Use an if/else to pick which granter to use based on Roll,
        # then grant the item to the agent.
        if (Roll = 0):

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