Verse Library verse

04 Grant The First Weapon To Each Player

Manages weapon progression and victory checks for elimination game modes.

extracted-snippets/documentation/fortnite/verse-elimination-template-in-unreal-editor-for-fortnite/04-grant-the-first-weapon-to-each-player.verse

# Source URL: https://dev.epicgames.com/documentation/fortnite/verse-elimination-template-in-unreal-editor-for-fortnite
# Local doc:  epic-docs/documentation/fortnite/verse-elimination-template-in-unreal-editor-for-fortnite.md
# Section:    Grant the first weapon to each player
# Check if there is a winner for the game, if not then grant the next weapon
GrantNextWeapon(Agent:agent):void=
    if (var CurrentItemNumber:int = AgentMap[Agent]):
        if (IsVictoryConditionMet(CurrentItemNumber) = true):
            EndGame(Agent) # Game has been won
        else: # Game is not over yet
            set CurrentItemNumber = CurrentItemNumber + 1
            if (ItemGranter := WeaponItemGranters[CurrentItemNumber - 1]):
                ItemGranter.GrantItem(Agent)
            
            if (set AgentMap[Agent] = CurrentItemNumber) {}

Comments

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