Verse Library verse

01 Device

Listens for a guard hire event and directs the spawner to assign it to a player.

verse-library/guard-hire/01-device.verse

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

# This is our main script
Guard_Hire_Script := class(creative_device):

    # This connects to your Guard Spawner device
    @editable
    My_Guard_Spawner : guard_spawner_device = guard_spawner_device{}

    # This runs when the game starts
    OnBegin<override>()<suspends> : void =
        # Now, listen for the hire event
        # When a player hires, this code runs
        My_Guard_Spawner.HiredEvent.Subscribe(On_Guard_Hired)

    # This function handles the hiring
    On_Guard_Hired(Result : device_ai_interaction_result) : void =
        # 'Result' contains info about the interaction, including the player who hired the guard
        # We tell the spawner to hire this specific guard for this player
        if (Instigator := Result.Source?):
            My_Guard_Spawner.Hire(Instigator)

        # Optional: You can print a message here
        # Print("Guard hired by player!")

Comments

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