using { /Fortnite.com/Devices } using { /Fortnite.com/Characters } using { /UnrealEngine.com/Temporary/Diagnostics } # This is our main class, the "Brain" of our device. # Think of it as the device itself, but with a brain attached. class RevengeTrapDevice(creative_device): # --- VARIABLES (The Stats) --- # This is a variable. It starts as false (off). # Like a light switch that is currently in the 'off' position. is_active: bool = false # This is a reference to the Prop we placed in the editor. # Think of this as "pointing" to the specific chest in your loot pool. @editable target_prop: creative_prop = creative_prop{} # --- FUNCTIONS (The Abilities) --- # A function to turn the trap ON. # Like pressing the 'Activate' button on a trap. ActivateTrap() -> void: is_active = true # Change the prop's color to red. # We are accessing the 'material' component of the prop. target_prop.SetMaterialColor(Color{R:1.0, G:0.0, B:0.0}) PrintToAll("Trap Activated! Watch your back.") # A function to turn the trap OFF. ResetTrap() -> void: is_active = false # Change the prop's color back to gray (inactive). target_prop.SetMaterialColor(Color{R:0.5, G:0.5, B:0.5}) # --- EVENTS (The Triggers) --- # This event runs when the device is first placed in the world. # Like when the match starts and the bus drops. OnBegin() -> void: PrintToAll("Revenge Trap is online.") # Start in the 'off' state. ResetTrap() # This event runs when a player is eliminated. # We need to listen for this specific game moment. OnPlayerEliminated(eliminated_player: player, killer: player) -> void: # If the trap is active, trigger the revenge effect. if is_active: # Show a message to the eliminated player. # Think of this as the "Elimination" banner, but custom. eliminated_player.PrintMessage("You were eliminated by the Revenge Trap!") # Flash the prop to indicate the kill. target_prop.SetMaterialColor(Color{R:1.0, G:0.0, B:0.0}) # Turn it back off after 2 seconds (simulating a cooldown). # We use a simple timer here to reset the state. Timer(2.0, fun(): ResetTrap())