# KillRewards.verse # This script listens for eliminations and upgrades the winner's weapon. using { /Fortnite.com/Devices } using { /Fortnite.com/Characters } using { /Fortnite.com/Playspaces } using { /Fortnite.com/Game } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # We define our main script here. Think of this as the "Brain" of the island. # It must be a creative_device so UEFN can place it on the island as an actor. KillRewards := class(creative_device): # Step 1: Reference the Elimination Manager. # In Verse, we declare a device property and then wire it up in the # UEFN Details panel — drag your placed Elimination Manager into this slot. @editable EliminationManager : elimination_manager_device = elimination_manager_device{} # Step 2: Per-player kill counter. # We use a weak_map so entries are cleaned up automatically when a player leaves. # var means the map itself can be replaced with an updated copy. var KillCounts : [player]int = map{} # OnBegin is the Verse entry point — called once when the game session starts. OnBegin() : void = # Step 3: Subscribe to the EliminationManager's elimination event. # EliminatedEvent fires with an ?agent whenever a player # is knocked out. We pass our handler as the subscriber. EliminationManager.EliminationEvent.Subscribe(OnElimination) # Step 4: Our handler — called automatically each time an elimination occurs. # The EliminationEvent passes an ?agent representing the eliminating agent. OnElimination(EliminatingAgent : ?agent) : void = # Pull the eliminating agent out of the option type. # It is an ?agent (option type) because environment kills have no killer. if (EliminatingAgentValue := EliminatingAgent?): # Cast the agent to a player. Bots are agents but not players. if (EliminatingPlayer := player[EliminatingAgentValue]): # Step 5: Look up — or initialise — the player's kill count. CurrentKills : int = if (Existing := KillCounts[EliminatingPlayer]): Existing else: 0 # Increment and store the new count. NewKills := CurrentKills + 1 if (set KillCounts[EliminatingPlayer] = NewKills) {} # Step 6: The Logic (If/Else). # Fewer than 3 kills → "Noob" tier → grant a Shotgun via Item Granter. # 3 or more kills → "Pro" tier → grant a Rocket Launcher. # # Real Verse has no bare Items.Shotgun constant; item granting is done # through item_granter_device instances wired up in the Details panel. # Wire "ShotgunGranter" to an Item Granter set to grant a Shotgun, # and "RocketGranter" to one set to grant a Rocket Launcher. if (NewKills < 3): ShotgunGranter.GrantItem(EliminatingPlayer) Print("Got a Shotgun! Keep killing!") # note: prints to UEFN log else: RocketGranter.GrantItem(EliminatingPlayer) Print("You're on fire! Here's a Rocket Launcher!") # Step 7: Item Granter device references. # Wire these in the UEFN Details panel to Item Granter devices placed on the map. # Set each Item Granter's item to the weapon you want to award. @editable ShotgunGranter : item_granter_device = item_granter_device{} @editable RocketGranter : item_granter_device = item_granter_device{}