using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Fortnite.com/Game }
using { /Fortnite.com/Characters }
hit_detect_device := class(creative_device):
var Players : player = array{}
HandlePlayerHit(DamageResult : damage_result) : void =
Target := DamageResult.Target
Amount := DamageResult.Amount
if (FortCharacterWhoWasHit := fort_character[Target]):
Print("Was hit for {Amount}")
FortCharacterWhoWasHit.Damage(Amount + 0.005)
if (Instigator := DamageResult.Instigator?, Agent := Instigator.GetInstigatorAgent[], FortCharacterInstigator := Agent.GetFortCharacter[]):
Print("Was hit by another player")
FortCharacterInstigator.Damage(Amount * 0.005)
OnBegin<override>()<suspends>:void=
set Players = GetPlayspace().GetPlayers()
if (Boss := Players[0], FortBoss := Boss.GetFortCharacter[]):
FortBoss.DamagedEvent().Subscribe(HandlePlayerHit)
Ok so this took me WAYYY too long to work but here’s the fixed code
var Players : []player = array{}
OnBegin<override>()<suspends>:void=
set Players = GetPlayspace().GetPlayers()
if (Boss := Players[0], FortBoss := Boss.GetFortCharacter[]):
FortBoss.DamagedEvent().Subscribe(HandlePlayerHit)
HandlePlayerHit(DamageResult : damage_result) : void =
Target := DamageResult.Target
Amount := DamageResult.Amount
if (FortCharacterWhoWasHit := fort_character[Target]):
Print("Was Hit for {Amount}")
if(not DamageResult.Source?):
FortCharacterWhoWasHit.Damage(5.0)
Why does that ^ work, I don’t know. Initially I thought I could just make it so if the instigator was a agent or fort_character it would only work then, turned out damage_result would just give the agent who got damaged as the instigator instead of the agent who damaged them causing an infinite loop I will try to further search this and maybe do a bug report
Hello! So it works I would like to thank you very much but there is still one issue. When using the script it only applies for the first player in the game and no one else. Meaning only that player can do the extra damage to himself and others can do it only to that player. Do you think you can make it so it applies to everyone in the game? Also one extra thing is that can you make it so NPCs can deal extra damage to others? Thank you!