In this step, you will create a gun game-style weapon-leveling system in Verse that uses an Item Granter device to give players a new weapon when they complete a combo.
Modify Your Island
Select the Island Settings device in the viewport or Outliner panel.
In the Details panel, set the following parameters:
Set Infinite Reserve Ammo to True.
Set Infinite Magazine Ammo to False. This change requires the player to reload, an essential aspect of many Fortnite weapons.
Select the Item Granter device in the viewport or Outliner panel.
In the Details panel, set the following parameters:
Set On Grant Action to Clear Inventory.
Set Grant to Current Item.
Remove all elements from the Index List, then add the following five elements:
Assault Rifle L1
Lever Action Rifle L2
Heavy Shotgun L3
Six Shooter L4
Hand Cannon L5
Set Receiving Players to All.
Set Grant on Cycle to True.
Set Grant on Game Start to True.
Remove the Enable and Grant Item function bindings.
Select the Score Manager device in the viewport or Outliner panel.
In the Details panel, set Display Score Update on HUD to True.
Write Verse Code
This page guides you step by step through the code changes, but if you want to check your work, review the Complete Code section for the final result.
Open the
shooting_range_manager_device.versefile.Add the following variables to store a reference to the item granter device and track item level properties.
Verse@editable ItemGranter:item_granter_device = item_granter_device{} @editable MaxWeaponLevel:int = 5 var CurrentWeaponLevel:int = 1Add the
IncreaseWeaponLevelmethod to increase the weapon level variable and cycle to the next item.Verse# Increases the player's weapon level by one (up to the maximum value). IncreaseWeaponLevel():void= if: # If able to retrieve the first player and current weapon level isn't maxed, then... Player:player = GetPlayspace().GetPlayers()[0] CurrentWeaponLevel < MaxWeaponLevel then: # Increase weapon level and cycle to the next item. set CurrentWeaponLevel += 1 ItemGranter.CycleToNextItem(Player)Modify the
OnComboTargetHitmethod to callIncreaseWeaponLevel.Verse# A hit callback that scores the ComboTarget and resets the combo. OnComboTargetHit():void= AdjustScore(ComboTargetScore) <# --- New Code Start --- #> IncreaseWeaponLevel() <# --- New Code End --- #>Modify the
AdjustScoremethod to multiply the score awarded by the weapon level.Verse# Adjusts the player's score by the provided value. AdjustScore(Value:int):void= # Start the timer if it hasn't started yet. if (not IsTimerStarted?): StartTimer() <# --- New Code Start --- #> # Sets the score award to the base value of the target multiplied by the current weapon level. ScoreManager.SetScoreAward(Value * CurrentWeaponLevel)Save and build your Verse code.
Complete Code
using { /Fortnite.com/Devices }
using { /Verse.org/Random }
using { /Verse.org/Simulation }
# A device that manages shooting range gameplay.
shooting_range_manager_device := class(creative_device):
@editable
ScoreManager:score_manager_device = score_manager_device{}
Bring It Together
Select the shooting_range_manager_device in the viewport or Outliner panel.
In the Details panel, set ItemGranter to the Item Granter device.
Push your changes and playtest your island.
Verify the weapon swaps after hitting a combo target, up to 5 times. At the 5th level, it stays the same.
Verify the incoming score multiplies by the weapon level.