# Returns the ceiling of a float as an int
Ceil(Value : float) : int =
IntValue := Value as int
if (Value > IntValue as float):
return IntValue + 1
else:
return IntValue
Anyone know how can fix this error vErr:S77: Unexpected “as” following expression
IntValue := Value as int
using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /Fortnite.com/Game }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath }
GameLogicDevice := class(creative_device):
# ========== DEVICE REFERENCES ==========
# Timer device to track player's remaining time
@editable
TimeDevice : timer_device = timer_device{}
# Player spawner for game setup
@editable
PlayerSpawner : player_spawner_device = player_spawner_device{}
# Zombie spawners - one for each wave, adjust properties in-device
@editable
ZombieSpawnerWave1 : creature_spawner_device = creature_spawner_device{}
@editable
ZombieSpawnerWave2 : creature_spawner_device = creature_spawner_device{}
@editable
ZombieSpawnerWave3 : creature_spawner_device = creature_spawner_device{}
# Final boss spawner
@editable
BossSpawner : creature_spawner_device = creature_spawner_device{}
# UI to display game information
@editable
GameInfoDisplay : hud_message_device = hud_message_device{}
# Sound effects for various game events
@editable
HeadshotSound : audio_player_device = audio_player_device{}
@editable
WaveCompleteSound : audio_player_device = audio_player_device{}
@editable
GameOverSound : audio_player_device = audio_player_device{}
@editable
VictorySound : audio_player_device = audio_player_device{}
# ========== GAME VARIABLES ==========
# Main game state tracking
var IsGameRunning : logic = false
var CurrentWave : int = 0
var ZombiesRemaining : int = 0
var IsBossFight : logic = false
var PlayerScore : int = 0
# Wave configuration - edit these to adjust difficulty
WaveZombieCounts : []int = array{5, 10, 15} # Number of zombies per wave
# Player reference to track who's playing
var CurrentPlayer : ?player = false
# ========== INITIALIZATION ==========
# Called when the game device is started
OnBegin<override>()<suspends> : void =
# Listen for player spawns to initialize game
PlayerSpawner.PlayerSpawnedEvent.Subscribe(OnPlayerSpawned)
Print("Zombie Survival Game initialized and waiting for players.")
# ========== PLAYER MANAGEMENT ==========
# Called when a player spawns in the game
OnPlayerSpawned(InPlayer : player) : void =
# Store reference to the player
set CurrentPlayer = option{InPlayer}
# Attach event listeners to the player
if (Agent := InPlayer.GetAgent[], FortCharacter := Agent.GetFortCharacter[]):
# Listen for elimination events to detect zombie kills
FortCharacter.EliminatedEvent.Subscribe(OnEliminationOccurred)
# Listen for damage events to detect headshots
FortCharacter.DamagedEvent.Subscribe(OnDamageDealt)
# Start the game for this player
InitializeGame()
# ========== GAME INITIALIZATION ==========
# Sets up a new game with fresh state
InitializeGame() : void =
# Reset game state
set IsGameRunning = true
set CurrentWave = 0
set ZombiesRemaining = WaveZombieCounts[0]
set IsBossFight = false
set PlayerScore = 0
# Set player's starting time (3 minutes = 180 seconds)
TimeDevice.SetRemainingTime(180.0)
TimeDevice.Start()
# Display initial game info
UpdateGameDisplay()
# Start the first wave after a short delay
Sleep(2.0)
StartWave(0)
# Monitor time remaining
spawn { MonitorPlayerTime() }
# ========== TIME MANAGEMENT ==========
# Continuously checks player's remaining time
MonitorPlayerTime()<suspends> : void =
# Keep checking time while the game is running
loop:
if (IsGameRunning = false):
break
# Check if time has run out
if (TimeDevice.GetRemainingTime() <= 0.0):
EndGame(false) # Player lost due to time running out
break
# Brief pause before checking again
Sleep(0.1)
# ========== WAVE MANAGEMENT ==========
# Starts a specific wave of zombies
StartWave(WaveIndex : int)<suspends> : void =
# Ensure we're within valid wave range
if (WaveIndex < 0 or WaveIndex >= WaveZombieCounts.Length):
return
# Update game state for new wave
set CurrentWave = WaveIndex
set ZombiesRemaining = WaveZombieCounts[WaveIndex]
# Display wave information
GameInfoDisplay.ShowMessage("Wave {CurrentWave + 1} begins! {ZombiesRemaining} zombies approaching!")
# Select the appropriate spawner based on wave
var CurrentSpawner : creature_spawner_device = ZombieSpawnerWave1
if (WaveIndex = 1):
set CurrentSpawner = ZombieSpawnerWave2
else if (WaveIndex = 2):
set CurrentSpawner = ZombieSpawnerWave3
# Activate the spawner
CurrentSpawner.Enable()
# Wait for wave to be completed (monitored via zombie eliminations)
# ========== COMBAT MECHANICS ==========
# Called when any elimination occurs in the game
OnEliminationOccurred(EliminatedCharacter : fort_character, Eliminator : ?agent) : void =
# Verify we're in a valid game state
if (IsGameRunning = false):
return
# Check if a player eliminated a zombie
if (Player := CurrentPlayer?, Eliminator?):
if (PlayerAgent := Player.GetAgent?):
if (Eliminator = PlayerAgent):
# Player killed a zombie, decrease remaining count
set ZombiesRemaining = Max(ZombiesRemaining - 1, 0)
set PlayerScore += 10
# Update display
UpdateGameDisplay()
# Check if wave is complete
if (ZombiesRemaining <= 0):
WaveCompleted()
# Called when damage is dealt to track headshots
OnDamageDealt(DamagedCharacter : fort_character, Damage : float, InstigatorAgent : ?agent, HitResult : damage_hit_result) : void =
# Verify we're in a valid game state
if (IsGameRunning = false):
return
# Check if this was a player-caused headshot
if (Player := CurrentPlayer?, InstigatorAgent?):
if (PlayerAgent := Player.GetAgent?):
if (InstigatorAgent = PlayerAgent and HitResult = damage_hit_result.Headshot):
# This was a headshot! Add time to player's clock
if (IsBossFight):
# Boss headshots give 0.5 seconds
TimeDevice.SetRemainingTime(TimeDevice.GetRemainingTime() + 0.5)
GameInfoDisplay.ShowMessage("BOSS HEADSHOT! +0.5 seconds")
else:
# Regular zombie headshots give 3 seconds
TimeDevice.SetRemainingTime(TimeDevice.GetRemainingTime() + 3.0)
GameInfoDisplay.ShowMessage("HEADSHOT! +3 seconds")
# Play headshot sound for feedback
HeadshotSound.Play()
# ========== WAVE PROGRESSION ==========
# Called when all zombies in a wave are eliminated
WaveCompleted()<suspends> : void =
# Stop the current wave's spawner
if (CurrentWave = 0):
ZombieSpawnerWave1.Disable()
else if (CurrentWave = 1):
ZombieSpawnerWave2.Disable()
else if (CurrentWave = 2):
ZombieSpawnerWave3.Disable()
# Play wave completion sound
WaveCompleteSound.Play()
# Display wave completion message
GameInfoDisplay.ShowMessage("Wave {CurrentWave + 1} completed!")
# Small pause between waves
Sleep(3.0)
# Check if this was the final wave
if (CurrentWave >= WaveZombieCounts.Length - 1):
# Final wave completed, start boss fight
StartBossFight()
else:
# Start the next wave
StartWave(CurrentWave + 1)
# ========== BOSS FIGHT ==========
# Initiates the final boss encounter
StartBossFight()<suspends> : void =
# Update game state
set IsBossFight = true
# Display boss fight message
GameInfoDisplay.ShowMessage("FINAL BOSS APPROACHING! Aim for headshots!")
# Pause for dramatic effect
Sleep(2.0)
# Spawn the boss
BossSpawner.Enable()
# Boss fight is managed through damage events
# Victory condition is eliminating the boss
# ========== GAME CONCLUSION ==========
# Ends the game with either victory or defeat
EndGame(IsVictory : logic)<suspends> : void =
# Update game state
set IsGameRunning = false
# Stop all spawners
ZombieSpawnerWave1.Disable()
ZombieSpawnerWave2.Disable()
ZombieSpawnerWave3.Disable()
BossSpawner.Disable()
# Stop the timer
TimeDevice.Stop()
# Play appropriate sound
if (IsVictory):
VictorySound.Play()
GameInfoDisplay.ShowMessage("VICTORY! You survived with {Ceil(TimeDevice.GetRemainingTime())} seconds remaining! Score: {PlayerScore}")
else:
GameOverSound.Play()
GameInfoDisplay.ShowMessage("DEFEAT! The zombies have overwhelmed you. Score: {PlayerScore}")
# Wait before restarting
Sleep(10.0)
# Reset for new game
if (Player := CurrentPlayer?):
PlayerSpawner.Respawn(Player)
# ========== UTILITY FUNCTIONS ==========
# Updates the game display with current information
UpdateGameDisplay() : void =
var StatusMessage : string = "Wave: {CurrentWave + 1}/3 | Zombies: {ZombiesRemaining} | Score: {PlayerScore}"
if (IsBossFight):
set StatusMessage = "BOSS FIGHT! | Score: {PlayerScore}"
GameInfoDisplay.SetDisplayTime(5.0) # Ensure message stays visible
GameInfoDisplay.ShowMessage(StatusMessage)
# Returns the maximum of two integers
Max(A : int, B : int) : int =
if (A > B):
return A
else:
return B
# Returns the ceiling of a float as an int
Ceil(Value : float) : int =
IntValue := int(Value)
if (Value > IntValue as float):
return IntValue + 1
else:
return IntValue
This is the entire code I need the Ceil to conclude the game
Still not working after deleting Ceil Thank you for your help I don’t want to waste more of your time I believe I need to read more about verse after deleting the Ceil I was hit with 34 errorr
Most of this code is impossible btw, aside from the Ceil its trying to do stuff just not possible. I don’t recommend using AI in creation of code I would recommend following verse tutorials or something