AI Voiceline Manager
using { /Fortnite.com/AI}
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Fortnite.com/Characters}
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Verse.org/Random}
# A Verse-authored creative device that can be placed in a level
audio_voiceline := class<concrete>:
# Audio device to play barks
@editable
Voiceline:audio_player_device := audio_player_device{}
# Option to allow NPCs to repeat the bark
@editable
CanRepeat:logic = true
# Delay between the event and the beginning of the bark
@editable
Delay:float = 0.0
# Delay before repeating this bark
@editable
Cooldown:float = 3.0
# Bark name for logging
@editable
LineID:string = "Missing ID"
# Is the cooldown timer elapsed
var<private> IsInCooldown:logic = false
# Event to stop the bark
StopBarkEvent<private>:event() = event(){}
PlayVoiceline(Agent:agent)<suspends>:void=
var IsPlaying:logic = false;
defer:
if (IsPlaying?):
set IsPlaying = false
set IsInCooldown = false
Voiceline.Stop(Agent)
race:
block:
StopBarkEvent.Await()
return
block:
AwaitAgentDown(Agent)
return
block:
if (Delay > 0.0):
Sleep(Delay)
if (IsInCooldown?):
return
Voiceline.Play(Agent)
set IsPlaying = true
set IsInCooldown = true
Sleep(2.0)
set IsPlaying = false
if (CanRepeat?):
Sleep(Cooldown)
set IsInCooldown = false
StopBark():void=
StopBarkEvent.Signal()
AwaitAgentDown<private>(Agent:agent)<suspends>:void=
if (Character := Agent.GetFortCharacter[]):
loop:
if (Character.GetHealth() <= 0.0):
return
Character.DamagedEvent().Await()
You're reading a preview
The full reference is free for BrainDeadGuild Discord members — sign in to read it all, or open the original at the source.
Sign in with your BrainDead.TV / BrainDeadGuild Discord account for full access.