# Revenge_Tracker.verse # 1. IMPORT THE STUFF WE NEED using { /Fortnite.com/Devices } using { /Fortnite.com/Characters } using { /Fortnite.com/UI } using { /UnrealEngine.com/Temporary/UI } using { /UnrealEngine.com/Temporary/SpatialMath } using { /Verse.org/Simulation } # 2. THE DEVICE CLASS # Attach this to a Verse Device actor placed in the level. # It manages the Revenge Tracker HUD for each player. revenge_tracker_device := class(creative_device): # 3. THE MAIN LOGIC # OnBegin fires once when the game session starts on the server. # We then fan out to each player locally via . OnBegin() : void = # Subscribe to player-added so late-joiners also get the HUD. GetPlayspace().PlayerAddedEvent().Subscribe(OnPlayerAdded) # Also set up HUD for any players already in the session. for (P : GetPlayspace().GetPlayers()): spawn { RunClientHUD(P) } # Called whenever a new player joins. OnPlayerAdded(P : player) : void = spawn { RunClientHUD(P) } # 4. CLIENT-SIDE HUD LOGIC # ensures this executes on the player's local machine, # not the server — keeping UI updates fast and cheap. RunClientHUD(P : player) : void = # Build the text widget that will display elim count. ElimCount_Text := text_block: DefaultText := StringToMessage("Elims: 0") # Wrap it in a stack_box (vertical stack). # # note: stack_box children are set at construction in current Verse UI API. TrackerStack := stack_box: Orientation := orientation.Vertical Slots := array: stack_box_slot: Widget := ElimCount_Text # Add the widget to this player's screen via player_ui. # player_ui.AddWidget only takes (:widget) or (:widget,:player_ui_slot) — no player arg. if (PlayerUI := GetPlayerUI[P]): PlayerUI.AddWidget(TrackerStack, player_ui_slot{ZOrder := 1}) # Track elim count manually — no GetEliminations() API exists yet. # # note: Verse does not expose a GetEliminations() method; we count via EliminatedEvent. var ElimCount : int = 0 # 5. LISTEN FOR ELIMINATIONS # fort_character exposes EliminatedEvent, which fires when this character is eliminated. # We listen on all characters; filter to kills made BY player P. loop: # Wait until P has a valid fort_character, then watch for events. if (FortChar := P.GetFortCharacter[]): # EliminatedEvent fires on the eliminated character. # The event message contains the instigator (killer). EliminatedMessage := FortChar.EliminatedEvent().Await() # EliminatedMessage.EliminatingCharacter is the fort_character who got the kill. if (KillerChar := EliminatedMessage.EliminatingCharacter?): if (Killer := KillerChar.GetAgent[]): if (Killer = P): set ElimCount += 1 UpdateDisplay(ElimCount_Text, ElimCount) else: # Character not ready yet; yield and retry. Sleep(0.1) # 6. HELPER FUNCTION # Updates the text widget with the latest elim count. UpdateDisplay(ElimText : text_block, NewCount : int) : void = ElimText.SetText(StringToMessage("Elims: {NewCount}"))