# Import the necessary Verse modules using { /Fortnite.com/Devices } using { /Fortnite.com/Game } using { /Fortnite.com/Characters } using { /Fortnite.com/Playspaces } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } using { /UnrealEngine.com/Temporary/SpatialMath } # A creative_device placed in the scene acts as our spawner manager. # It listens for eliminations and stamps out a new trap each time. revenge_spawner_device := class(creative_device): # Drag your RevengeTrapPrefab asset into this field in the UEFN # Details panel so Verse knows which prefab to stamp. @editable TrapPrefab : creative_prop_asset = DefaultCreativePropAsset # OnBegin runs once when the island starts — our "Start Game" button. OnBegin() : void = # Retrieve the Fortnite game manager so we can listen for events. FortPlayspace := GetPlayspace() # Subscribe to the elimination event. # Every time any player is eliminated this lambda fires. FortPlayspace.PlayerAddedEvent().Subscribe(OnPlayerAdded) # Park the coroutine here so the subscription stays alive # for the whole match. loop: Sleep(60.0) # Called when a player is added so we can subscribe to their elimination event. OnPlayerAdded(Player : player) : void = if (Character := Player.GetFortCharacter[]): Character.EliminatedEvent().Subscribe(OnCharacterEliminated) # Called automatically each time a character is eliminated. OnCharacterEliminated(Result : elimination_result) : void = SpawnTrap(Result.EliminatedCharacter.GetTransform().Translation) # The function that actually creates the trap. SpawnTrap(Location : vector3) : void = # Build the transform: place the trap at the elimination spot, # rotated flat (identity rotation), at normal scale. SpawnTransform := transform{ Translation := Location, Rotation := IdentityRotation(), Scale := vector3{X := 1.0, Y := 1.0, Z := 1.0} } # SpawnProp stamps our prefab into the world at SpawnTransform. # It returns an option, so we unwrap it with `if`. # Note: SpawnProp is the real UEFN API for spawning prop assets # at runtime; full Entity/Instantiate APIs are not yet public. SpawnedProp := SpawnProp(TrapPrefab, SpawnTransform) # The prop is visible and collidable the moment it spawns. # If your asset has a trap_device component wired up in the # prefab, it will activate automatically; no extra Enable() # call is required for creative_prop assets. Print("Revenge trap spawned at elimination site.")