Hi this is a segment of code that freezes the target for 2 seconds after being shot by a weapon within a conditional button. The problem is that the character who holds weapon freezes whenever he takes damage and holds the weapon simultaneosly (Storm, Other Players)
using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /Fortnite.com/Game }
using { /Fortnite.com/UI }
using { /Verse.org/Simulation }
using { /Verse.org/Colors }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /UnrealEngine.com/Temporary/Diagnostics }
freeze_device := class(creative_device):
@editable ConditionalButton : conditional_button_device = conditional_button_device{}
@editable FreezeTime : float = 2.0
OnPlayerDamaged(DamageResult : damage_result): void =
if:
Instigator := DamageResult.Instigator?
Agent := Instigator.GetInstigatorAgent[]
ConditionalButton.IsHoldingItem[Agent]
Target := fort_character[DamageResult.Target]
then:
spawn:
FreezePlayer(Target)
FreezePlayer(Target : fort_character)<suspends> : void =
Target.PutInStasis(stasis_args{})
Sleep(FreezeTime)
Target.ReleaseFromStasis()
OnPlayerAdded(Player : player) : void =
if (FortCharacter := Player.GetFortCharacter[]):
FortCharacter.DamagedEvent().Subscribe(OnPlayerDamaged)
OnBegin<override>()<suspends>:void =
GetPlayspace().PlayerAddedEvent().Subscribe(OnPlayerAdded)
for (Player : GetPlayspace().GetPlayers(), FortCharacter := Player.GetFortCharacter[]):
FortCharacter.DamagedEvent().Subscribe(OnPlayerDamaged)