### Get Closest Player - Spatial Query in Verse Source: https://context7.com/lilwikipedia/uefn-verse-collection/llms.txt A Verse device that finds the nearest player to a specified viewpoint. It iterates through all fort_characters, calculates distances, and returns the closest one. Dependencies include Fortnite.com/Characters and UnrealEngine.com/Temporary/SpatialMath. ```verse using { /Fortnite.com/Characters } using { /UnrealEngine.com/Temporary/SpatialMath } get_closest_player := class(creative_device): GetClosestPlayerToViewpoint(AllPlayers: []player, Viewpoint:vector3, InitialCharacter: fort_character): fort_character = var ClosestCharacter : fort_character = InitialCharacter var ClosestDistance: float = 1000000000.0 for (Player : AllPlayers): if (FNCharacter : fort_character = Player.GetFortCharacter[]): if (FNCharacter <> InitialCharacter): PlayerLocation := FNCharacter.GetTransform().Translation EDistance := Distance(Viewpoint, PlayerLocation) if (EDistance < ClosestDistance): set ClosestCharacter = FNCharacter set ClosestDistance = EDistance return ClosestCharacter ``` -------------------------------- ### UEFN Hello World Device - Verse Source: https://context7.com/lilwikipedia/uefn-verse-collection/llms.txt A basic UEFN Verse device demonstrating the fundamental structure and the OnBegin lifecycle method. It requires no external dependencies and prints 'Hello, world!' and a simple calculation to the output log. ```verse using { /Fortnite.com/Devices } using { /Verse.org/Simulation } hello_world_device := class(creative_device): OnBegin():void= Print("Hello, world!") Print("2 + 2 = {2 + 2}") ``` -------------------------------- ### Handle Optionals Safely in Verse Source: https://context7.com/lilwikipedia/uefn-verse-collection/llms.txt Illustrates the use of Verse's optional types (`?`) to safely manage values that might not be present. It shows how to subscribe to an event and use the optional value to trigger another device. ```verse using { /Fortnite.com/Devices } my_device := class(creative_device): var SavedPlayer : ?player = false @editable PlayerSpawn : player_spawner_device = player_spawner_device{} @editable Trigger : trigger_device = trigger_device{} OnBegin() : void = PlayerSpawn.PlayerSpawnedEvent.Subscribe(OnPlayerSpawned) OnPlayerSpawned(Player : player) : void = set SavedPlayer = option{Player} if (TriggerPlayer := SavedPlayer?): Trigger.Trigger(TriggerPlayer) ``` -------------------------------- ### Instant Spawn - Immediate Respawn System Source: https://context7.com/lilwikipedia/uefn-verse-collection/llms.txt Respawns players immediately after elimination with minimal delay. It subscribes to an elimination manager's EliminatedEvent and calls the Agent.Respawn function with a configured position. ```Verse using { /Fortnite.com/Devices } using { /Verse.org/Simulation } instant_spawn := class(creative_device): respawnposition: vector3=vector3{X:=0.0,Y:=0.0,Z:=0.0} @editable ElimManager: elimination_manager_device = elimination_manager_device{} OnBegin():void= ElimManager.EliminatedEvent.Subscribe(OnEliminated) OnEliminated(Agent:agent):void= spawn: RespawnEvent(Agent) RespawnEvent(Agent:agent):void= Sleep(0.1) Agent.Respawn(respawnposition,rotation{}) ``` -------------------------------- ### Player Stats Manager System in Verse Source: https://context7.com/lilwikipedia/uefn-verse-collection/llms.txt A Verse implementation for managing player statistics. It defines abstract stat types, concrete stat implementations (Score, Win, Loss), and provides methods to retrieve and record player stats. ```verse using { /Fortnite.com/Devices } using { /Verse.org/Simulation } stat_type := class: DebugString():string StatType := module: score_stat := class(stat_type): DebugString():string = "Score" Score:score_stat = score_stat{} Win:win_stat = win_stat{} Loss:loss_stat = loss_stat{} player_stats_manager := class(): GetPlayerStats(Agent:agent):player_stats_table= var PlayerStats:player_stats_table = player_stats_table{} if: Player := player[Agent] PlayerStatsTable := PlayerStatsMap[Player] set PlayerStats = MakePlayerStatsTable(PlayerStatsTable) PlayerStats RecordPlayerStat(Agent:agent, Stat:stat_type, ?Wins:int = 0):void= if: Player := player[Agent] PlayerStatsTable := PlayerStatsMap[Player] if(Stat = StatType.Score): WinStat := PlayerStatsTable.Wins set PlayerStatsMap[Player] = player_stats_table: MakePlayerStatsTable(PlayerStatsTable) Wins := MakeUpdatedPlayerStat(WinStat, Wins) ``` -------------------------------- ### Boss Device - AI Following System Source: https://context7.com/lilwikipedia/uefn-verse-collection/llms.txt Creates an AI boss that continuously tracks and moves toward the player. It uses prop movement and rotation calculations, subscribing to a mutator zone's AgentEntersEvent to initiate the follow behavior. ```Verse using { /Fortnite.com/Devices } using { /Fortnite.com/Characters } using { /UnrealEngine.com/Temporary/SpatialMath } BossDevice := class(creative_device): @editable Bossprop : creative_prop = creative_prop{} @editable Zonedevice : mutator_zone_device = mutator_zone_device{} OnBegin():void= Zonedevice.AgentEntersEvent.Subscribe(OnTriggered) OnTriggered(Agent: agent):void = spawn{FollowPlayer()} FollowPlayer():void = loop: Sleep(0.01) if (PlayerList := GetPlayspace().GetPlayers(), FortCharacter := PlayerList[0].GetFortCharacter[]): Playerpostion : vector3 = FortCharacter.GetTransform().Translation Proptranslation : vector3 = Bossprop.GetTransform().Translation VectorToPlayer : vector3 = Playerpostion - Proptranslation RadiansVectorToPlayer: float = ArcTan(VectorToPlayer.X, VectorToPlayer.Y) - (PiFloat / 2.0) NewRotation : rotation =MakeRotation(axis := ProptranslationAxis, AngleRadians := RadiansVectorToPlayer) Bossprop.MoveTo(Playerpostion, NewRotation, 1.0) else: break ``` -------------------------------- ### Countdown Timer UI - Verse Source: https://context7.com/lilwikipedia/uefn-verse-collection/llms.txt A reusable countdown timer class implemented in Verse, featuring canvas-based UI, event signaling, and dynamic time adjustment. It depends on Verse.org/Simulation, Fortnite.com/UI, and UnrealEngine.com/Temporary/UI. The timer signals an event when countdown ends and allows adding time. ```verse using { /Verse.org/Simulation } using { /Fortnite.com/UI } using { /UnrealEngine.com/Temporary/UI } MakeCountdownTimer(MaxTime : float, InPlayer : agent) := countdown_timer: RemainingTime := MaxTime MaybePlayerUI := option{GetPlayerUI[player[InPlayer]]} countdown_timer := class: CountdownEndedEvent : event(float) = event(float){} StartCountdown() : void = if (PlayerUI := MaybePlayerUI?): PlayerUI.AddWidget(Canvas) UpdateUI() spawn: RunCountdown() AddRemainingTime(Time : float) : void = set RemainingTime += Time UpdateUI() spawn: AddedTimeCallout(Time) RunCountdown() : void = loop: Sleep(TimerTickPeriod) set TotalTime += TimerTickPeriod set RemainingTime -= TimerTickPeriod UpdateUI() if (RemainingTime <= 0.0): Canvas.RemoveWidget(RemainingTimeTextBlock) if (UI := MaybePlayerUI?): UI.RemoveWidget(Canvas) CountdownEndedEvent.Signal(TotalTime) break ``` -------------------------------- ### Verse Custom Horizontal Progress Bar UI Source: https://context7.com/lilwikipedia/uefn-verse-collection/llms.txt A customizable horizontal progress bar UI element with smooth lerp animation for progress updates. It allows for configuration of background, foreground, and border colors, as well as widget dimensions. The progress is displayed as a percentage. ```verse using { /Fortnite.com/UI } using { /UnrealEngine.com/Temporary/UI } using { /Verse.org/Simulation } custom_progress_bar := class: var BackgroundColor : color var ForegroundColor : color var BorderColor : color var XSize : float var YSize : float var ProgressPercent : float = 0.0 Init() : overlay = TextBlockProgress.SetTextOpacity(0.5) TextBlockProgress.SetText(StringToText("0%")) ColorBlockBG.SetDesiredSize(vector2{ X := XSize, Y := YSize}) ColorBlockFG.SetDesiredSize(vector2{ X := 0.0, Y := YSize}) ColorBlockBorder.SetDesiredSize(vector2{ X := XSize + (XSize * 0.09), Y := YSize + (YSize * 0.25)}) ColorBlockBG.SetColor(BackgroundColor) ColorBlockFG.SetColor(ForegroundColor) ColorBlockBorder.SetColor(BorderColor) return OuterOverlay SetProgress(InProgress : float) : task(void) = NewProgressUpdatePolledEvent.Signal() set ProgressPercent = InProgress if (ProgressPercent > 100.0) then set ProgressPercent = 100.0 if (ProgressPercent < 0.000) then set ProgressPercent = 000.0 spawn{ UpdateBarLengthToProgressSmooth(60) } ``` -------------------------------- ### Team Management Device - Verse Source: https://context7.com/lilwikipedia/uefn-verse-collection/llms.txt A Verse device for managing player team assignments using teleporter-based selection and billboard counters for population display. It depends on Fortnite.com/Devices and Verse.org/Simulation. The device subscribes to a teleporter's enter event to assign agents to teams. ```verse using { /Fortnite.com/Devices } using { /Verse.org/Simulation } team_management_device := class(creative_device): @editable TeamChoiceTeleporter : teleporter_device = teleporter_device{} @editable TeamPlayerCounter : team_player_counter_device = team_player_counter_device{} @editable var TeamID : int = 1 OnBegin():void= TeamChoiceTeleporter.EnterEvent.Subscribe(ChooseTeam) return ChooseTeam(AgentIn : agent) : void = TeamCollection := GetPlayspace().GetTeamCollection() Teams : []team = TeamCollection.GetTeams() TeamPlayerCounter.DecrementAgentTeamCount(AgentIn) if (TeamCollection.AddToTeam[AgentIn, Teams[TeamID-1]]): TeamPlayerCounter.IncrementAgentTeamCount(AgentIn) ``` -------------------------------- ### Array Utilities - Collection Manipulation Source: https://context7.com/lilwikipedia/uefn-verse-collection/llms.txt Provides essential array operations in Verse. This includes adding elements, iterating with index, selecting random elements, and general collection manipulation patterns. ```Verse # Adding an item to an array set SideChestsPositions += array{Position} # Go over an array with index for (Index -> Spawner : CreatureSpawners): Spawner.Disable() # Get a random element from an array Index := GetRandomInt(0, CreatureSpawners.Length) ``` -------------------------------- ### Random Teleporter - Randomized Teleportation Source: https://context7.com/lilwikipedia/uefn-verse-collection/llms.txt Teleports agents to random locations from a configured array of teleporter devices. It subscribes to the AgentEntersEvent of a mutator zone to trigger teleportation. ```Verse using { /Fortnite.com/Devices } using { /Verse.org/Random } using { /Verse.org/Simulation } random_teleporter := class(creative_device): @editable Teleporters: []teleporter_device = array{} @editable EnterRandomTeleporter: mutator_zone_device = mutator_zone_device{} OnBegin():void= EnterRandomTeleporter.AgentEntersEvent.Subscribe(EnterEvent) EnterEvent(Agent:agent):void= var RandomTeleporter:int = GetRandomInt(1, 21) if(SelectedTeleporter := Teleporters[RandomTeleporter]): SelectedTeleporter.Teleport(Agent) ``` -------------------------------- ### Verse Player Freeze System Source: https://context7.com/lilwikipedia/uefn-verse-collection/llms.txt Implements a system to freeze players using stasis mechanics when they are damaged by specific items. It subscribes to damage events and utilizes a timer and conditional button device for control. The FreezePlayer function puts a target character into stasis for a set duration. ```verse using { /Fortnite.com/Characters } using { /Fortnite.com/Devices } using { /Verse.org/Simulation } Template := class(creative_device): @editable FreezeClass: class_and_team_selector_device = class_and_team_selector_device{} @editable FreezeTimer: timer_device = timer_device{} @editable FreezeDetector: conditional_button_device = conditional_button_device{} @editable FreezeTime : float = 3.0 OnBegin():void= GetPlayspace().PlayerAddedEvent().Subscribe(OnPlayerAdded) for (Player : GetPlayspace().GetPlayers(), FortCharacter := Player.GetFortCharacter[]): FortCharacter.DamagedEvent().Subscribe(OnPlayerDamaged) OnPlayerDamaged(DamageResult : damage_result): void = if: Instigator := DamageResult.Instigator? Agent := Instigator.GetInstigatorAgent[] FreezeDetector.IsHoldingItem[Agent] Target := fort_character[DamageResult.Target] then: spawn: FreezePlayer(Target) FreezePlayer(Target : fort_character) : void = Target.PutInStasis(stasis_args{}) Sleep(FreezeTime) Target.ReleaseFromStasis() ``` -------------------------------- ### Elimination Game Device - Gun Game Mode Source: https://context7.com/lilwikipedia/uefn-verse-collection/llms.txt Implements a gun game progression system. Players receive new weapons after each elimination. Requires an array of item granter devices and a win condition based on eliminations. ```Verse using { /Fortnite.com/Devices } using { /Fortnite.com/Characters } using { /Verse.org/Simulation } elimination_game_device := class(creative_device): @editable var WeaponItemGranters : []item_granter_device = array{} var NumberOfEliminationsToWin : int = 0 var AgentMap : [agent]int = map{} OnBegin():void= set NumberOfEliminationsToWin = WeaponItemGranters.Length set WeaponItemGranters = Shuffle(WeaponItemGranters) AllPlayers := GetPlayspace().GetPlayers() for (EliminationGamePlayer : AllPlayers): if (FortCharacter := EliminationGamePlayer.GetFortCharacter[]): FortCharacter.EliminatedEvent().Subscribe(OnPlayerEliminated) if (set AgentMap[EliminationGamePlayer] = 1) {} if (FirstItemGranter:item_granter_device = WeaponItemGranters[0]): FirstItemGranter.GrantItem(EliminationGamePlayer) GrantNextWeapon(Agent:agent):void= if (var CurrentItemNumber:int = AgentMap[Agent]): if (IsVictoryConditionMet(CurrentItemNumber) = true): EndGame(Agent) else: set CurrentItemNumber = CurrentItemNumber + 1 if (ItemGranter := WeaponItemGranters[CurrentItemNumber - 1]): ItemGranter.GrantItem(Agent) if (set AgentMap[Agent] = CurrentItemNumber) {} ``` -------------------------------- ### Sort Array with Custom Comparer in Verse Source: https://context7.com/lilwikipedia/uefn-verse-collection/llms.txt Implements a generic sorting function for arrays in Verse, allowing for custom comparison logic and ascending/descending order. It uses a quicksort-like approach. ```verse Sort(Items : []t, IsAscending : logic, Comparer: type{_(:t, :t) : int}) : []t = if (Items.Length > 1, Pivot := Items[Floor(Items.Length/2)]): Left := for(Item : Items, Comparer(Item, Pivot) < 0) do Item Middle := for(Item : Items, Comparer(Item, Pivot) = 0) do Item Right := for(Item : Items, Comparer(Item, Pivot) > 0) do Item if(IsAscending?): Sort(Left, IsAscending, Comparer) + Middle + Sort(Right, IsAscending, Comparer) else: Sort(Right, IsAscending, Comparer) + Middle + Sort(Left, IsAscending, Comparer) else: Items ``` -------------------------------- ### Verse Player Damage and Health Management Source: https://context7.com/lilwikipedia/uefn-verse-collection/llms.txt Manages player health by applying calculated damage, ensuring a minimum health threshold to prevent unintended eliminations. It uses functions to calculate damage based on current health and desired damage amount. Dependencies include Fortnite character and playspace modules. ```verse using { /Fortnite.com/Characters } using { /Fortnite.com/Playspaces } HurtPlayer(DamageAmount : float):void= Playspace: fort_playspace = GetPlayspace() AllPlayers: []player = Playspace.GetPlayers() if (Player : player = AllPlayers[0]): if (FortniteCharacter : fort_character = Player.GetFortCharacter[]): MyCharacterHealth : float = FortniteCharacter.GetHealth() DamageToDo : float = CalculateDamage(MyCharacterHealth, DamageAmount, 1.0) FortniteCharacter.Damage(DamageToDo) CalculateDamage(PlayerHealth:float, DesiredDamageAmount:float, MinHealth:float):float = if (PlayerHealth > DesiredDamageAmount): return DesiredDamageAmount else if (PlayerHealth > MinHealth): return PlayerHealth - MinHealth else: return PlayerHealth ``` -------------------------------- ### Remove Element from Array in Verse Source: https://context7.com/lilwikipedia/uefn-verse-collection/llms.txt Demonstrates how to remove an element from an array by its index in Verse. This operation returns a new array without the specified element. ```verse var MyDeviceArray:[]creative_device = array{} if (NewArray := MyDeviceArray.RemoveElement[0]): set MyDeviceArray = NewArray ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.