Skip to content

Instantly share code, notes, and snippets.

@LionGet
Last active November 6, 2023 01:36
Show Gist options
  • Save LionGet/9ac553289ba6a93554fd33d387efaa66 to your computer and use it in GitHub Desktop.
Save LionGet/9ac553289ba6a93554fd33d387efaa66 to your computer and use it in GitHub Desktop.
Floating Damage Numbers
using { /Fortnite.com/Devices }
using { /Fortnite.com/Game }
using { /Fortnite.com/Characters }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /UnrealEngine.com/Temporary/UI }
using { /Verse.org/Assets }
using { /Verse.org/Random }
Materials := module:
# A Verse-authored creative device that can be placed in a level
floating_combat_text := class(creative_device):
@editable DigitsBP : creative_prop_asset = DefaultCreativePropAsset
@editable Button : button_device = button_device{}
# Initial Material (blank)
var HundMat:material=Materials.Clear
var TensMat:material=Materials.Clear
var OnesMat:material=Materials.Clear
# Array of Materials
var DigitsMatArray : []material = array{}
# Set to the amount of time you want to wait before disposing props
DisplayTime : float = 0.5
OnBegin<override>()<suspends>:void=
set DigitsMatArray = array{
Materials.Digits0
Materials.Digits1
Materials.Digits2
Materials.Digits3
Materials.Digits4
Materials.Digits5
Materials.Digits6
Materials.Digits7
Materials.Digits8
Materials.Digits9}
Button.InteractedWithEvent.Subscribe(DealDamage)
DealDamage(Agent:agent):void=
FakeDmg:=GetRandomFloat(50.0,950.0)
Print("FakeDmg{FakeDmg}")
if(Fort:=Agent.GetFortCharacter[]):
ParseDamage(Agent,Fort,FakeDmg)
ParseDamage(Agent:agent,Fort:fort_character,Damage:float):void=
var Hundred:int=0
var Ten:int=0
var One:int=0
if(IntDamage:int=(Int[Damage])):
if(var L_Hundred:int=Mod[IntDamage, 1000]
set L_Hundred = Int[L_Hundred*0.01]):
set Hundred = L_Hundred
if(var L_Ten:int=Mod[IntDamage, 100],
set L_Ten = Int[L_Ten*0.1]):
set Ten = L_Ten
if(L_One:int=Mod[IntDamage, 10]):
set One = L_One
spawn{InitNumbers(Agent,Fort,Hundred,Ten,One)}
Print("Sending Hundred:{Hundred},Ten:{Ten},One:{One} Damage")
InitNumbers(Agent:agent,Fort:fort_character,Hund:int,Ten:int,One:int)<suspends>:void=
var Digits : creative_prop = creative_prop{}
# Set Material to Array Index Per Digit
if(set HundMat=DigitsMatArray[Hund]):
if(set TensMat=DigitsMatArray[Ten]):
if(set OnesMat=DigitsMatArray[One]):
# Locational Data of Target Player (Who received damage)
var TargetXform:transform=Fort.GetTransform()
var TargetLocation:vector3=TargetXform.Translation
set TargetLocation.Z+=140.0
# Get Rotation Facing Viewing Player & Spawn Prop
if(L_Fort:=Agent.GetFortCharacter[]):
AgentLocation : vector3=L_Fort.GetViewLocation()
if (LookDirection := (AgentLocation - TargetLocation).MakeUnitVector[]):
Yaw := RadiansToDegrees(ArcTan(LookDirection.Y, LookDirection.X))
Pitch := 0.0
Roll := 0.0
NewRotation := MakeRotationFromYawPitchRollDegrees(Yaw,Pitch,Roll)
if (L_Prop := SpawnProp(DigitsBP,TargetLocation,NewRotation)(0)?):
set Digits = L_Prop
# Set Material
Digits.SetMaterial(HundMat,?Index:=0)
Digits.SetMaterial(TensMat,?Index:=1)
Digits.SetMaterial(OnesMat,?Index:=2)
# Sleep for Display Duration then Dispose
Sleep(DisplayTime)
if(Digits.IsValid[]):
Digits.Dispose()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment