using { /Fortnite.com/Devices } using { /Verse.org/Simulation } # This is our main brain. It holds the score and knows about the targets. shooting_range_manager_device := class(creative_device): # The device that actually tracks the player's score. # Think of this as the scoreboard in the lobby. @editable ScoreManager:score_manager_device = score_manager_device{} # This is a "Wrapper" class. It bundles a target device with its specific rules. # It’s like a "Loot Table" entry: here is the item, here is the value. TargetInfo := struct: # The actual target device in the world Target:shooting_range_target_device = shooting_range_target_device{} # How many points this target is worth Points:int = 0 # Has this target already been hit in this round? (Prevents double-dipping) IsHit:bool = false # This function runs when the target is hit. OnTargetHit := func():void = # If we already hit this one, do nothing. # It’s like trying to pick up a loot item that’s already gone. if (IsHit?): return # Mark it as hit so we don’t score it again. IsHit = true # Disable the target visually (it disappears or goes limp). # This is like a building piece being destroyed. Target.Disable() # Tell the Manager to update the score. # If Points is negative, the score goes down! ScoreManager.AddScore(Points) # Optional: Reset the target after a few seconds? # We'll leave that for Part 2. # These are the "slots" you fill in the editor. # You can drag multiple targets here if you want more targets. @editable GoodTarget1:TargetInfo = TargetInfo{Points: 100} @editable BadTarget1:TargetInfo = TargetInfo{Points: -50} # Negative points! Ouch. # This is the initialization function. It runs when the game starts. OnBegin():void= # Subscribe to the "Hit" event for GoodTarget1. # This means: "Whenever GoodTarget1 gets hit, run the OnTargetHit function." GoodTarget1.Target.HitEvent.Subscribe(GoodTarget1.OnTargetHit) # Subscribe to the "Hit" event for BadTarget1. BadTarget1.Target.HitEvent.Subscribe(BadTarget1.OnTargetHit) # Wait until the game ends. await GetWorld().GetGame().GetEndOfGameEvent().Subscribe()