0% found this document useful (0 votes)
16 views7 pages

Fortnite Rank Progress Bar System

rank

Uploaded by

desganfn
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views7 pages

Fortnite Rank Progress Bar System

rank

Uploaded by

desganfn
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

#Made by Oleszyk

using { /[Link]/Devices }
using { /[Link]/Characters }
using { /[Link]/Simulation }
using { /[Link]/Random }
using { /[Link]/Temporary/Diagnostics }
using { /[Link]/Temporary/UI }
using { /[Link]/UI }
using { /[Link]/Temporary/SpatialMath}
using { /[Link]/Colors }
using { /[Link]/Colors/NamedColors }
using { /[Link]/Simulation/Tags }
using { /[Link]/Assets }

RankProgressBar := class():
ProgressBarColorBase<private> : color_block = color_block{
DefaultColor := MakeColorFromHex("000000")
DefaultDesiredSize := vector2{X:= 202.0, Y := 43.0}}

var ProgressBarColorTop<private> : color_block = color_block{}


var Overlay<private> : overlay = overlay{}

PBarTitleTextBlock<private> : text_block = text_block{DefaultTextColor :=


MakeColorFromHex("FFFFFF")}

HPTitleText<private><localizes>(HPText : string) : message = "{HPText}"

Init(Current : int, Goal : int):void=


[Link](HPTitleText("{Current}/{Goal}"))

UpdateWidthAndText(iCurrent : int, Goal : int):void=


var NewCurrent : float = iCurrent * 1.0
var NewGoal : float = Goal * 1.0

RankPercentage := NewCurrent / NewGoal


BarSize := [Link]
NewHealthBarWidth := BarSize.X * RankPercentage
if (Current := float[NewGoal], Total := float[NewGoal]):
[Link](HPTitleText("{iCurrent}/{Goal}"))

UpdateHealthBar(NewHealthBarWidth)

ShowUIForPlayer(Player : player):void=
if (PlayerUI := GetPlayerUI[Player]):
if (Fortchar := [Link][]):
if (Instigator : agent = [Link][]):
[Link](CreateUI(Instigator))

UpdateHealthBar(NewWidth : float):void=
[Link](PBarTitleTextBlock)
[Link](ProgressBarColorTop)
set ProgressBarColorTop = CreateTopHealthBar(NewWidth)

[Link](CreateOverlaySlot(ProgressBarColorTop,
horizontal_alignment.Left))

[Link](CreateOverlaySlot(PBarTitleTextBlock,horizontal_alignment.Center)
)

CreateOverlaySlot<private>(TheWidget : widget, HAlignment :


horizontal_alignment):overlay_slot=
overlay_slot:
Widget := TheWidget
HorizontalAlignment := HAlignment

CreateTopHealthBar<private>(Width: float):color_block=
ColorBlock := color_block{
DefaultColor := MakeColorFromHex("00eeff")
DefaultDesiredSize := vector2{X:= Width, Y := 43.0}}

set ProgressBarColorTop = ColorBlock

CreateOverlay<private>(Agent : agent) : overlay=


TheOverlay := overlay:
Slots := array:
overlay_slot:
Widget := ProgressBarColorBase
overlay_slot:
Widget := CreateTopHealthBar(1200.0)
overlay_slot:
Widget := PBarTitleTextBlock
set Overlay = TheOverlay

CreateUI<private>(Agent : agent) : canvas=


TheCanvas : canvas = canvas:
Slots := array:
canvas_slot:
Anchors := anchors{Minimum := vector2{X := 0.175149, Y :=
0.833333}, Maximum := vector2{X := 0.175149, Y := 0.833333}}
Offsets := margin{Top := -20.0, Left := -96.0, Right := 0.0,
Bottom := 0.0}
Alignment := vector2{X := 0.0, Y := 0.0}
Widget := stack_box:
Orientation := [Link]
Slots := array:
stack_box_slot:
Widget := CreateOverlay(Agent)

return TheCanvas

AllSpawners := class(tag){}

RankSystem := class(creative_device):

var PlayerMap : [agent]PlayerVariable = map{}

#Change names to your texture ones

@editable EliminationTracker : tracker_device = tracker_device{}

Unreanked : texture = [Link]


Bronze1 : texture = ImagesRankj.Bronze_1

Bronze2 : texture = ImagesRankj.Bronze_2

Bronze3 : texture = ImagesRankj.Bronze_3

Silver1 : texture = ImagesRankj.Silver_1

Silver2 : texture = ImagesRankj.Silver_2

Silver3 : texture = ImagesRankj.Silver_3

Gold1 : texture = ImagesRankj.Gold_1

Gold2 : texture = ImagesRankj.Gold_2

Gold3 : texture = ImagesRankj.Gold_3

Plat1 : texture = ImagesRankj.Platinum_1

Plat2 : texture = ImagesRankj.Platinum_2

Plat3 : texture = ImagesRankj.Platinum_3

Diamond1 : texture = ImagesRankj.Diamond_1

Diamond2 : texture = ImagesRankj.Diamond_2

Diamond3 : texture = ImagesRankj.Diamond_3

Elite : texture = ImagesRankj.ELITE_1

Champion : texture = ImagesRankj.Champ_1

Unreal : texture = ImagesRankj.Unreal_1

InitSpawners():void=
Spawners := GetCreativeObjectsWithTag(AllSpawners{})
for (Obj : Spawners):
if (Spawner := player_spawner_device[Obj]):
[Link](OnPlayerAdded)

# Runs when the device is started in a running game


OnBegin<override>()<suspends>:void=

# TODO: Replace this with your code


InitSpawners()
GetPlayspace().PlayerRemovedEvent().Subscribe(OnPlayerRemoved)
Sleep(0.3)
AlllPlayers := GetPlayspace().GetPlayers()
for(Player : AlllPlayers):
OnPlayerAdded(Player)

OnPlayerAdded(Agent : agent):void=
if (PlayerObj := player[Agent]):
if (PlayerExists := PlayerMap[Agent]):
else:
PV : PlayerVariable = PlayerVariable{AgentOB := Agent}

[Link]([Link](), [Link]())

[Link](PlayerObj)

spawn{MakeCurrentValue(Agent)}

spawn{RankedLoopHudMessage(Agent, PlayerObj)}

option:
set PlayerMap[Agent] = PV

MakeCurrentValue(Agent : agent)<suspends>:void=
loop:
Sleep(0.01)
if (PV : PlayerVariable = PlayerMap[Agent]):
[Link]([Link](Agent))
[Link]([Link](),
[Link]())

RankedLoopHudMessage(Agent : agent, Player : player)<suspends>:void =

RankTextureBlock : texture_block = texture_block{DefaultImage := Unreanked,


DefaultDesiredSize := vector2{X := 390.0, Y := 130.0}}

loop:
Sleep(0.01)
if ([Link](Agent) >0 ):
if (PV : PlayerVariable = PlayerMap[Agent]):
[Link](10)
[Link](Unreanked)
NewCanvas : canvas = canvas:
Slots := array:
canvas_slot:
Widget := RankTextureBlock
Anchors := anchors{Minimum := vector2{X := 0.15,
Y := 0.8}, Maximum := vector2{X := 0.15, Y := 0.8}}
Offsets := margin{Top := -60.0,Left := -212.0,
Right :=0.0, Bottom :=0.0}
Alignment := vector2{X := 0.0, Y := 0.0}
if (PlayerUI := GetPlayerUI[Player]):
[Link](NewCanvas)
break
loop:
Sleep(0.01)
if ([Link](Agent) >= 10):
if (PV : PlayerVariable = PlayerMap[Agent]):
[Link](20)
[Link](Bronze1)
break
loop:
Sleep(0.01)
if ([Link](Agent) >= 20 ):
if (PV : PlayerVariable = PlayerMap[Agent]):
[Link](30)
[Link](Bronze2)
break
loop:
Sleep(0.01)
if ([Link](Agent) >= 30 ):
if (PV : PlayerVariable = PlayerMap[Agent]):
[Link](50)
[Link](Bronze3)
break
loop:
Sleep(0.01)
if ([Link](Agent) >= 50):
if (PV : PlayerVariable = PlayerMap[Agent]):
[Link](70)
[Link](Silver1)
break
loop:
Sleep(0.01)
if ([Link](Agent) >= 70 ):
if (PV : PlayerVariable = PlayerMap[Agent]):
[Link](90)
[Link](Silver2)
break
loop:
Sleep(0.01)
if ([Link](Agent) >= 90):
if (PV : PlayerVariable = PlayerMap[Agent]):
[Link](120)
[Link](Silver3)
break
loop:
Sleep(0.01)
if ([Link](Agent) >= 120):
if (PV : PlayerVariable = PlayerMap[Agent]):
[Link](150)
[Link](Gold1)
break
loop:
Sleep(0.01)
if ([Link](Agent) >= 150):
if (PV : PlayerVariable = PlayerMap[Agent]):
[Link](180)
[Link](Gold2)
break
loop:
Sleep(0.01)
if ([Link](Agent) >= 180):
if (PV : PlayerVariable = PlayerMap[Agent]):
[Link](220)
[Link](Gold3)
break
loop:
Sleep(0.01)
if ([Link](Agent) >= 220):
if (PV : PlayerVariable = PlayerMap[Agent]):
[Link](260)
[Link](Plat1)
break
loop:
Sleep(0.01)
if ([Link](Agent) >= 260):
if (PV : PlayerVariable = PlayerMap[Agent]):
[Link](300)
[Link](Plat2)
break
loop:
Sleep(0.01)
if ([Link](Agent) >= 300):
if (CP : PlayerVariable = PlayerMap[Agent]):
[Link](350)
[Link](Plat3)
break
loop:
Sleep(0.01)
if ([Link](Agent) >= 350):
if (PV : PlayerVariable = PlayerMap[Agent]):
[Link](400)
[Link](Diamond1)
break
loop:
Sleep(0.01)
if ([Link](Agent) >= 400):
if (PV : PlayerVariable = PlayerMap[Agent]):
[Link](450)
[Link](Diamond2)
break
loop:
Sleep(0.01)
if ([Link](Agent) >= 450):
if (PV : PlayerVariable = PlayerMap[Agent]):
[Link](510)
[Link](Diamond3)
break
loop:
Sleep(0.01)
if ([Link](Agent) >= 510):
if (PV : PlayerVariable = PlayerMap[Agent]):
[Link](570)
[Link](Elite)
break
loop:
Sleep(0.01)
if ([Link](Agent) >= 570):
if (PV : PlayerVariable = PlayerMap[Agent]):
[Link](640)
[Link](Champion)
break
loop:
Sleep(0.01)
if ([Link](Agent) >= 640):
if (PV : PlayerVariable = PlayerMap[Agent]):
[Link](Unreal)
break

OnPlayerRemoved(PlayerLeft : agent):void =
if (Agent := agent[PlayerLeft]):
if (ActualPlayer := PlayerMap[Agent]):
var TempAllPlayersMap : [agent]PlayerVariable = map{}
for (Key -> Value : PlayerMap, Key <> Agent):
set TempAllPlayersMap = ConcatenateMaps(TempAllPlayersMap,
map{Key => Value})

set PlayerMap = TempAllPlayersMap


#Don't share this code

Common questions

Powered by AI

To manage spawn events, the system utilizes event subscription and mapping strategies. Spawners are initialized, and each player spawn event is subscribed to an OnPlayerAdded handler function. This function is triggered whenever a player is spawned, ensuring the player's rank details are initialized and updated. The strategy involves mapping each player to a PlayerVariable instance within the PlayerMap, updating their rank progress bar status, and tracking their ranking in real-time .

The system uses color and size adjustments on the progress bar to visually indicate a change in a player's rank. As the player progresses towards their goal, the width of the progress bar changes proportionally to show visual feedback of advancement. Additionally, the color block associated with the top of the progress bar may change to reflect different stages of achievement. This change in the visual aspect of the progress bar serves as an immediate and intuitive visual marker of rank progression .

The system determines the player's rank advancement by tracking the number of eliminations a player achieves. For each threshold of eliminations reached, the system updates the player's goal and rank texture accordingly. For instance, reaching 10 eliminations upgrades the player's rank goal to 20, and the rank texture changes to Bronze1. This process continues in increments, and each rank stage has a specific elimination goal ranging from 10 to 640 eliminations, associated with textures such as Bronze, Silver, Gold, and up to Champion .

To set up a player's UI for the rank progress bar, the system utilizes attributes such as a color block for the progress bar, an overlay to manage widget placement, and a text block to display the current and goal values. The default color for these UI components is specified using hex codes, such as '000000' for color_block. The text within the progress bar displays the player's current and goal values, formatted as "{Current}/{Goal}". The system dynamically adjusts the width of the progress bar based on the player's progress using the method UpdateWidthAndText .

Upon a player's removal, the system updates the PlayerMap by excluding the removed player's data. It creates a temporary map for all the remaining players, ensuring no data for the removed player persists. This involves iterating through the PlayerMap, copying all players' data except the removed one, into a new map, which then replaces the old PlayerMap. This ensures data integrity and avoids retaining unnecessary data after a player's exit .

Persisting player data through the PlayerMap after game termination could lead to unnecessary data retention and potential memory management issues. While it is useful for maintaining continuity of player rank data during a session, without adequate data clearing protocols, it could result in bloated data storage if old, no longer relevant player data is retained beyond necessary use. This persistence is vital during active sessions for real-time updates and UI display, yet post-session, effective data management strategies must be implemented to clear outdated information, ensuring optimal system performance and data integrity .

The 'canvas' plays a crucial role as the main container for UI widgets in the ranking UI creation and update processes. It holds the slots necessary for arranging different UI elements like the rank progress bar and the rank texture display. Whenever a player's rank is updated based on eliminations, new canvases with updated widgets are generated and added to the player's UI. This modular design pattern facilitates organized and efficient UI updates, providing a flexible framework to incorporate dynamic content changes reflecting the player's current ranking state .

The system ensures dynamic updating of rank textures on the UI by using a loop that checks the player's current elimination count against predefined thresholds. When the player reaches or exceeds a specified number of eliminations, the system updates the player's goal and rank texture accordingly. The rank texture is updated by setting the appropriate image based on the current elimination count, which is then displayed through a canvas widget added to the player's UI. This process occurs in real-time to ensure the UI reflects the player's current rank status .

Elimination count directly influences a player's rank texture display by determining the thresholds at which rank textures are updated. As a player accumulates eliminations, they progress through predefined thresholds that elevate their rank status, changing the texture displayed on the UI. Each threshold corresponds to a specific rank texture, such as Bronze1 for 10 eliminations, Silver1 for 50 eliminations, and so forth up to Unreal for 640 eliminations. This mechanic ensures that the visual representation of a player's rank is directly tied to their performance as measured by eliminations .

The player variable map serves as a data structure to maintain and track player-specific ranking information. Each entry in the map corresponds to a unique player agent and their associated PlayerVariable instance, which holds data such as the player's current value, goal, and UI settings for rank display. This map is critical for retrieving, updating, and managing players' rank progressions and UI elements efficiently .

You might also like