Verse Library verse

01 Fragment

Listens for eliminations, increments a counter, and transmits a signal when a kill target is reached.

verse-library/elimination-streak-upgrade/01-fragment.verse

# KillstreakController.v

# This is our "Scoreboard" variable.
# It starts at 0.
var eliminations_count: int = 0

# The target number of kills to unlock the upgrade.
const TARGET_KILLS: int = 3

# This is the "Event" handler.
# It runs automatically whenever a player elimination happens in the game.
OnPlayerEliminated(EliminationResult: elimination_result): void =
    # 1. Increment the scoreboard by 1.
    # Think of this as adding a point to the scoreboard.
    eliminations_count += 1
    
    # 2. Check if we hit the target.
    # If eliminations_count equals 3, run the code inside the block.
    if (eliminations_count == TARGET_KILLS):
        # 3. Transmit on Channel 100.
        # This is like shouting "UNLOCK THE CANNON!" on walkie-talkie freq 100.
        # We transmit from the current device (this script's entity).
        Self.TransmitOn(Channel(100))
        
        # Optional: Reset the count for the next round (if you want it to be repeatable)
        # eliminations_count = 0

Comments

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