Action

type
Action<native><epic_internal>: injected_action
Module
AI
Declared in
behavior_tree_injection
Source
fortnite

Used in

OnBegin<override>()<suspends>: void =
        # Wait for a player to enter the trigger
        for player : GetPlayers():
            # If the player is inside, we change the lighting
            ApplyStormMood()

    # 3. FUNCTIONS: The "Action"
    # This is the code that actually does the work.
    # Think of this as the "Building Edit" command.
    ApplyStormMood(): void =
        # We need to find the SkyLight component in the world.
        # In Verse, we use 'Find' to grab a component by name.
        # It's like finding your favorite gun in the loot pool.
Available_Torches := 5

# 2. DEFINE THE FUNCTION (The Action)
# 'Spawn_Torch' is a function. It’s a recipe for what happens when the button is pressed.
# It takes one input: 'Player' (the person who pressed the button).
Spawn_Torch := function(Player: Player):
    # Check if we have any torches left (The Inventory Check)
    if Available_Torches > 0:
        # Decrement the counter.
@editable
    MyTimer : timer_device = timer_device{}

    # The logger lets us print debug messages to the output log.
    Logger : log = log{}

    # OnBegin is the "Action!" command.
    # It runs automatically when the player spawns into the island.
    # The <suspends> tag means this function can pause and wait for things (like players) to happen.
    OnBegin<override>()<suspends> : void =
        # First, we need to find the player.
        # GetPlayspace().GetPlayers() returns all current players.
        # We grab the first one if available.
Give_Weapon_Action := struct {
    # This is an "Action" - the thing that happens.
    Weapon_To_Give := "Assault_Rifle"
    Player_Who_Spawned := "Player_1"
}

# The "Function" is the rule that connects the Event to the Action.
# It’s like the wiring between the pressure plate and the door.
# 1. Define our Variables (The "Inventory Slots")
    # These are 'int' because coins are whole numbers
    var PlayerCoins : int = 100          # Starting gold in the shop
    var ItemCost : int = 25              # Cost of the weapon
    var ItemName : string = "Assault Rifle" # What we are selling

    # 2. The Function (The "Trigger" Action)
    # This runs when we call BuyItem()
    BuyItem() : void =
        # Check if we have enough coins (Equality Operator: =)
        if (PlayerCoins >= ItemCost):
            # 3. Compound Assignment (The Shortcut)
            # Subtract cost from coins: PlayerCoins = PlayerCoins - ItemCost
OnPlayerDowned(player: Player) -> void
    {
        # This line is the "Action."
        # We are telling the player to drop their inventory.
        # It's the same as clicking "Remove Items" on the Item Remover device.
        player.RemoveItems()
        
        # Optional: Let's add some flavor!
        # We can print a message to the debug log.
        # This is like seeing a "Kill Feed" message, but for code.
        print("Loot stripped from ", player.GetName())
if (VanishingPlatform != prop{}) {
            # 4. The Action: Hide the platform
            # We call the Hide() method on our prop.
            # This makes it invisible AND removes its collision 
            # (so players can walk through it).
            VanishingPlatform.Hide()
            
            # Optional: Print a message to the console for debugging
            # This is like the "Elimination Feed" for code errors.
            print("Platform is now gone! Good luck!")
# 2. Do the trap thing!
                # We'll change the color of the indicator prop.
                # In a real map, you might spawn a grenade or play a sound.
                if trap_indicator != None:
                    # Change the material or color of the indicator.
                    # This is the 'Action' part of the event.
                    trap_indicator.SetMaterialColor(Red)

                # 3. Tell the player (and us) what happened.
                # 'PrintToScreen' is like a chat message just for the player.
                PrintToScreen(overlap, "TRAP ACTIVATED! You got caught!")

                # 4. Reset the trap after 5 seconds so it can be used again.
                # This is like a cooldown timer on a storm or ability.
                SetTimer(5.0, ResetTrap)

    # --- FUNCTIONS (The Helpers) ---
    # This is a separate action we can call later.
    # It’s like a 'Heal' ability you cast manually.
    ResetTrap() -> unit:
        # Reset the boolean flag.
        triggered = false

        # Reset the indicator color (let's say Green means safe).
        if trap_indicator != None:
            trap_indicator.SetMaterialColor(Green)

        # Print a message that the trap is ready again.
        PrintToScreen(AllPlayers, "Trap Reset. Good luck.")
# It's like a security camera recording.
    # It watches the SpawnPad.
    OnPlayerSpawned(Player : player) : void =
        # When the spawn pad activates (player respawns), call our function.
        GiveRespawnLoot(Player)

# This function is the "Action" that happens.
# It takes a Player as an argument.
# Think of it as a vending machine: You put a coin (Player) in, you get a snack (Items) out.
GiveRespawnLoot(Player : player) : void =
    # 1. Check if the player is actually alive.
    # We don't want to give items to a ghost.
    # fort_character is the Verse type for a living Fortnite character.
# 2. The Wait.
        # Sleep(5.0) pauses ONLY this coroutine for 5 seconds.
        # The rest of the game keeps running.
        Sleep(5.0)

        # 3. The Action — activate the pre-placed PropMover.
        # Activate() tells the PropMover to move/reveal the prop.
        TargetProp.Activate()
        Print("Loot is here!")