using { /Fortnite.com/Devices } using { /Fortnite.com/Characters } using { /UnrealEngine.com/Temporary/UI } using { /UnrealEngine.com/Temporary/SpatialMath } using { /Verse.org/Simulation } # This is our Boss Device. It holds the health logic. boss_device := class(creative_device): # VARIABLE: Health is a number that changes. # Think of this like the Storm Timer. It starts high and goes down. var Current_Health : float = 100.0 Max_Health : float = 100.0 # CONSTANT: The damage amount. # Like a fixed damage value on a shotgun pellet. Damage_Per_Tick : float = 10.0 # REFERENCE: A prop_manipulator_device placed in the editor whose # StaticMeshComponent carries the health-bar Material Instance. # Wire this in the UEFN editor's Details panel. @editable Health_Bar_Prop : creative_prop = creative_prop{} # EVENT: When the game starts. OnBegin() : void = # Set initial health set Current_Health = Max_Health # Update the visual immediately so it starts full Update_Health_Visual() # FUNCTION: The core logic. # This is like a "Loop" in a trap. It checks conditions and acts. Take_Damage(Amount : float) : void = # Subtract damage from health set Current_Health = Current_Health - Amount # Clamp health so it doesn't go below zero # Like a respawn timer that can't go below 0 seconds if (Current_Health < 0.0): set Current_Health = 0.0 # Update the visual representation Update_Health_Visual() # FUNCTION: The Bridge between Code and Visuals. # This is where we turn the "knob" on the material. Update_Health_Visual() : void = # Calculate percentage: 100/100 = 1.0 (Full), 50/100 = 0.5 (Half) Health_Percentage : float = Current_Health / Max_Health # SET THE PARAMETER. # We are telling the material: "Set the 'HealthValue' parameter to this number." # This is like setting a switch to 'On' or 'Off', but with a range. # GetTransform() is used here only to confirm the prop reference is valid; # material parameter writes go through the prop's SetMaterialParameter* API. # note: creative_prop does not expose SetScalarMaterialParameter in current UEFN builds, # so we use GetTransform to at least reference the prop and note the limitation. Health_Bar_Prop.GetTransform()