# This script makes the boulder trigger a DBNO state on hit using { /Fortnite.com/Devices } using { /Fortnite.com/Characters } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # A creative_device subclass that holds a reference to the # down_but_not_out_device placed in the editor and a # damage_volume_device that surrounds the boulder's collision area. # Because Verse creative devices cannot directly subscribe to # physics-body collision events, we use a damage_volume_device # to detect when the boulder's area overlaps a player, then # apply the DBNO effect through the down_but_not_out_device. boulder_manager_device := class(creative_device): # This is a 'Constant' - a value that never changes. # Think of it like the 'Game Mode' setting in the island settings. # Wire this to your Down But Not Out device in the editor. @editable DownButNotOutDevice : down_but_not_out_device = down_but_not_out_device{} # Wire this damage_volume_device so it surrounds the rolling boulder. # Set its damage to 100 in the editor so it knocks players to 0 HP, # which the DBNO device intercepts before elimination. @editable BoulderDamageVolume : damage_volume_device = damage_volume_device{} # This is the 'Main' function. It runs once when the island starts. # Think of it like the 'Start Button' on the battle bus. OnBegin() : void = # We need to listen for when the boulder area overlaps a player. # In Verse, we 'subscribe' a function to an event. # Event: 'AgentEntersEvent' -> Function: 'HandleBoulderHit' BoulderDamageVolume.AgentEntersEvent.Subscribe(HandleBoulderHit) # This is a 'Function' - a reusable block of code. # Think of it like a 'Trap' that activates when triggered. # AgentEntersEvent always delivers an agent, so we know it is a player. HandleBoulderHit(HitAgent : agent) : void = # Cast the agent to fort_character so we can check game state. # 'GetFortCharacter[]' fails if the agent has no living character, # which guards us from acting on already-eliminated players. if (Character := HitAgent.GetFortCharacter[]): # If the character is already in a downed state, do nothing. # We don't want to double-down them. # IsActive[] fails (returns false) when the character is downed # or eliminated, so we only proceed when they are fully active. if (Character.IsActive[]): # Here is the magic: Trigger the DBNO state. # Down() tells the down_but_not_out_device to immediately # set this agent into the downed state instead of a full # elimination. This is like pressing the 'Revive' button, # but backwards. DownButNotOutDevice.Down(HitAgent) # note: down_but_not_out_device.Down() directly places the # agent into the Downed state. Pair this with the damage # from BoulderDamageVolume (set to 100 in editor settings) # to immediately trigger the transition.