Verse Library verse

02 Device

Uses race for concurrent perfect and good hit detection to grant items to players.

verse-library/skilled-interaction-device-design-examples/02-device.verse

# Extended version: handles both Perfect and Good zones at once.

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }

target_practice_script := class(creative_device):

    @editable
    TargetDevice : skilled_interaction_device = skilled_interaction_device{}

    # Prize for the bullseye (Perfect zone).
    @editable
    PerfectPrizeBox : item_granter_device = item_granter_device{}

    # Prize for the outer ring (Good zone).
    @editable
    GoodPrizeBox : item_granter_device = item_granter_device{}

    OnBegin<override>()<suspends> : void =
        # Run both listeners at the same time using 'race'.
        # 'race' runs all branches concurrently; here we restart
        # the loop so both zones stay active for the whole game.
        loop:
            race:
                # Branch 1: wait for a Perfect hit.
                block:
                    Agent := TargetDevice.InteractedWithPerfectEvent.Await()
                    PerfectPrizeBox.GrantItem(Agent)

                # Branch 2: wait for a Good hit.

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