# 1. IMPORTS # Think of this like opening your backpack. # We need access to the basic Fortnite tools. using { /Fortnite.com/Devices } using { /Fortnite.com/Characters } using { /Fortnite.com/Game } using { /Verse.org/Simulation } using { /Verse.org/SpatialMath } using { /UnrealEngine.com/Temporary/Diagnostics } # 2. THE BLUEPRINT (CLASS) # This defines what our custom device IS. # It inherits from creative_device, which means # "I am a thing that can be placed in the world." RevengeTrap := class(creative_device): # 3. CONFIGURABLE STATS # These are like the stats on a weapon you can tweak. # DamageAmount: How much hurt? # LaunchForce: How hard do they fly? @editable DamageAmount: float = 10.0 @editable LaunchForce: float = 2000.0 # We wire a trigger_device in the UEFN editor so the device # can detect when a player steps on it. # Select this device in the Properties panel and point it # at a Trigger you have placed on the floor. @editable Trigger: trigger_device = trigger_device{} # 4. THE "BEGIN" FUNCTION # This runs ONCE when the game starts. # Think of it as the "Loadout" phase. You set up your gear here. OnBegin(): void = # We want to listen for when a player steps on the Trigger. # Subscribe is like setting a tripwire: # "If the Trigger fires, call OnPlayerStep." Trigger.TriggeredEvent.Subscribe(OnPlayerStep) # 5. THE EVENT HANDLER # This is the logic that runs when the event happens. # agent? is the optional agent (player) that activated the Trigger. OnPlayerStep(Agent: ?agent): void = # Unwrap the optional agent. If no agent triggered it, stop here. if (ValidAgent := Agent?): # Cast the agent to a fort_character so we can # apply damage and impulse through its interface. if (Character := ValidAgent.GetFortCharacter[]): # Deal damage (like a shotgun blast). # note: Damage() is the real fort_character damage method. Character.Damage(DamageAmount) # Launch them! We create a force vector pointing straight UP. # vector3 uses Forward/Left/Up; Up is the up/down axis. LaunchVector := vector3{Forward := 0.0, Left := 0.0, Up := LaunchForce} Character.ApplyLinearImpulse(LaunchVector) # Optional: Play a sound or change color here! # But for now, let's just let the physics do the work.