Fortnite Wiki

Welcome to the Fortnite Wiki! Feel free to explore and contribute to the wiki with links, articles, categories, templates, and pretty images! Make sure to follow our rules & guidelines! Check out the Community Page!

READ MORE

Fortnite Wiki
Advertisement

Verse is a programming language developed by Epic Games that you can use to create your own gameplay in Unreal Editor for Fortnite, including customizing your devices for Fortnite Creative. Verse’s primary design goals:

  • Simple enough to learn as a first-time programmer.
  • General enough for writing any kind of code and data.
  • Productive in the context of building, iterating, and shipping a project in a team setting, and integrating code and content.
  • Statically verified to catch as many categories of runtime problems as possible at compile time.
  • Performant for writing real-time, open-world, multiplayer games.
  • Complete so that every feature of the language supports programmer abstraction over that feature.
  • Timeless - built for the needs of today, and for foreseeable future needs, without being rooted in the past artifacts of other languages.
You’ll need to install Visual Studio Code in order to write Verse code for your UEFN Project.

For the most up to date verse information; Use Epic Games Documentation

Modules[]

A Verse module is an atomic unit of code that can be redistributed and depended upon, and can evolve over time without breaking dependencies.

An example of how you would import a module would be:

   using { /Fortnite.com/Characters }
   using { /Verse.org/Simulation }
   using { /UnrealEngine.com/Temporary }


  • Verse.org (Top Level Module)
    • Verse
    • Simulation
    • Assets
    • ParameterCollections
    • Colors
    • Random
    • Native
    • Concurrency
  • UnrealEngine.com (Top Level Module)
    • WorldPartition
    • Temporary
  • Fortnite.com (Top Level Module)
    • UI
    • Devices
      • InterpolationTypes
    • Vehicles
    • Teams
    • Playspaces
    • Game
    • FortPlayerUtilities
    • Characters
    • Assets
    • Animation
    • AI

In this Example, We Print a log message when ever a player spawns on a specific spawn location. This is done by using @editable attribute then assigning the desired spawner on our Verse Device.

   # Modules
   using { /Fortnite.com/Devices }
   using { /Fortnite.com/Game }
   using { /Verse.org/Simulation }
   # Name of your device and it's class.
   Test_Verse_Device := class(creative_device):
   
   # Create a customizable option for your device and the accepted targets.
   @editable
   PlayerSpawner : player_spawner_device = player_spawner_device{}
   # When the game begins this section runs instantly.
   OnBegin<override>()<suspends>:void=
       PlayerSpawner.SpawnedEvent.Subscribe(PlayerSpawned) # Player spawns and calls a function.
   
       # Function called when player spawns.
       PlayerSpawned(Player : agent) : void =
           Print("Player Spawned!") # Prints out this message in the Log within Fortnite Client.

In this Example, We create a simple game based off of rolled number by creating a Function and it continues to Loop until player or enemy wins and which point causing the loop to Break. This does not reflect on any actual player or bot.

 # Modules
 using { /Fortnite.com/Devices }
 using { /Verse.org/Simulation }
 using { /UnrealEngine.com/Temporary/Diagnostics }
 using { /Verse.org/Random } # Required to use 'GetRandomInt()'
 Your_Verse_device := class(creative_device):
  
   var PlayerHealth : int = 100
   var EnemyHealth : int = 100
   BasicAttack : int = 26
   HeavyAttack : int = 49
   OnBegin<override>()<suspends>:void=
       StartGame() 
   StartGame():void=
       loop: # Starts the loop
           if(PlayerHealth <= 0):
               Print("Player is dead")
               break # Ends the loop
           else if(EnemyHealth <= 0):
               Print("Enemy is dead.")
               break
           else:
               AttackEnemy()
   AttackEnemy() : void=
      
       var RolledNumber : int = GetRandomInt(1, 10) # Rolls a random number between 1 and 10
       var CanSpecialAttack : int = GetRandomInt(1, 20) # Rolls a random number between 1 and 20
       if(RolledNumber >= 6): # If the rolled number is greater or equal to 6 then the 'Player' attacks. 
           if(CanSpecialAttack >= 15): # If greater or equal to 15 then the 'Player' gets to deal heavy damage.
               Print("Player Attacks for {HeavyAttack}.") # Prints out a message in the Log. 
               set EnemyHealth -= HeavyAttack # Subtracts the ' Enemy's ' health. 
           else:
               Print("Player Attacks for {BasicAttack}.")
               set EnemyHealth -= BasicAttack
       else if(RolledNumber <= 5):
           if(CanSpecialAttack >= 15):
               Print("Enemy Attacks for {HeavyAttack}.")
               set PlayerHealth -= HeavyAttack
           else:
               Print("Enemy Attacks for {BasicAttack}.")
               set PlayerHealth -= BasicAttack
       else:
           Print("Error...") # Just a placeholder in case something didn't work as intended.

In this Example, We set up an Array of creature spawners that Enable and Disable during a round base transaction. Which can be modified in the editor without needing to modify this Verse code.

   # Modules
   using { /Fortnite.com/Devices }
   using { /Verse.org/Simulation }
   using { /UnrealEngine.com/Temporary/Diagnostics }
   # A Verse-authored creative device that can be placed in a level
   # Typed up by xMitchxLuckerx aka NeverExisted on the Fortnite Wiki!
   # Feel free to copy and paste this code snippet into your project!
   creature_control_device := class(creative_device):
       #Custom User Options
       @editable
       CreatureBlocks : []creature_spawner_device = array{}
       @editable
       var IntermissionDuration : float = 10.0
       @editable
       var RoundDuration : float = 20.0
       @editable
       var HighRoundDuration : float = 60.0
       @editable
       var HighRoundNumber : int = 10
       var RoundNumber : int = 1
       # Runs when the device is started in a running game
       OnBegin<override>()<suspends>:void=
           Print("Running: Creature Control Device.")
           spawn:
               Intermission()
       Intermission()<suspends>:void=
           Print("Round Intermission started.")
           Sleep(IntermissionDuration)
           StartRound()
       
       StartRound():void=
           Print("Starting: Round {RoundNumber}")
           for(AllCreatureBlocks : CreatureBlocks): #Enables all creature_spawner_device's
               AllCreatureBlocks.Enable()
           spawn:
               HandleRound()
       HandleRound()<suspends>:void= 
           if (RoundNumber <= HighRoundNumber): # Checks to see if the current round is considered a 'High Round' number.
               Sleep(RoundDuration)
           else:
               Sleep(HighRoundDuration)
           EndRound() # Ends the round once the Verse Timers (Sleep) are over.
       EndRound():void=
           Print("Round Ended")
           set RoundNumber += 1 # When the round is completed increase the round number by 1
           for(AllCreatureBlocks : CreatureBlocks): #Disables all creature_spawner_device's and eliminates creatures from those devices.
               AllCreatureBlocks.Disable()
               AllCreatureBlocks.EliminateCreatures()
           spawn:
               Intermission()

Advertisement