# invisibility_manager.verse using { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Symbols } # This is our "Loot Bag" of data. # Key: The Player (Agent) # Value: How many seconds they have left to be visible (float) var PlayerVisibilitySeconds:[agent]float = map{} # This is the main script class. It runs when the game starts. class InvisibilityManager(World:world) extends VerseWorld(): # This function starts everything up. StartInvisibilityManager(AllTeams:[]team, AllPlayers:[]player, Infiltrators:team):void= Logger.Print("Invisibility Protocol Activated!") # 1. Subscribe to the Spawn Event. # This means: "Every time a player spawns, run OnPlayerSpawn." for(PlayerSpawner:PlayersSpawners): PlayerSpawner.SpawnedEvent.Subscribe(OnPlayerSpawn) # 2. Handle players who already spawned before the script started. for(TeamPlayer:AllPlayers): ProcessPlayer(TeamPlayer, Infiltrators) # This function is called whenever a new player spawns. OnPlayerSpawn(SpawnedPlayer:agent):void= Logger.Print("New infiltrator spotted!") ProcessPlayer(SpawnedPlayer, Infiltrators) # This is the heavy lifter. It checks the team and hides the player. ProcessPlayer(TeamPlayer:agent, Infiltrators:team):void= # Get the character component from the player agent. # Think of this as "Equipping" the character model. if(FortCharacter:fort_character = TeamPlayer.GetFortCharacter[]): # Get the team this player belongs to. CurrentTeam:team := GetPlayspace().GetTeamCollection().GetTeam[TeamPlayer] # CHECK: Is this player on the Infiltrator team? if(CurrentTeam == Infiltrators): Logger.Print("Confirmed: Infiltrator detected. Engaging cloaking device.") # Set their visibility timer to 0. # We'll explain the timer logic in the next step, but for now, # we just ensure the map entry exists. PlayerVisibilitySeconds[TeamPlayer] = 0.0 # THE MAGIC LINE: Hide the character. # This calls the Hide() method on the FortCharacter component. fort_character.Hide() else: Logger.Print("Not an infiltrator. Keeping them visible.")