-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNpc_Damage from medicexmp
More file actions
142 lines (114 loc) · 5.19 KB
/
Npc_Damage from medicexmp
File metadata and controls
142 lines (114 loc) · 5.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
using { /Fortnite.com/AI }
using { /Fortnite.com/Game }
using { /Fortnite.com/Animation/PlayAnimation }
using { /Verse.org/Simulation }
using { /Fortnite.com/Characters }
using { /Fortnite.com/Devices }
using { /Verse.org/Colors }
using { /Verse.org/Random }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath }
BH_ScarletPriests<public> := class(npc_behavior):
@editable
DamageThreshold:float = 0.1 # Threshold at which the NPC stops dealing damage.
@editable
DamageDelay:float = 1.5 # Delay between each damage instance.
@editable
DamageAmount:float = 5.0 # Amount of damage dealt per instance.
@editable
DamageVolume:mutator_zone_device = mutator_zone_device{} # Volume characters enter to receive damage.
@editable
HolyScarletRay:cinematic_sequence_device = cinematic_sequence_device{}
@editable
VFXSpawner:vfx_spawner_device = vfx_spawner_device {} # VFX for damage effects.
var AgentToFollow:?agent = false
var AgentsToDamage<public>:queue(agent) = queue(agent){}
UpdateRateSeconds<private>:float = 0.1
OnBegin<override>()<suspends>:void=
VFXSpawner.Disable()
DamageVolume.AgentEntersEvent.Subscribe(OnAgentEnters)
DamageVolume.AgentExitsEvent.Subscribe(OnAgentExits)
if:
Agent := GetAgent[]
Character := Agent.GetFortCharacter[]
Navigatable := Character.GetNavigatable[]
Focusable := Character.GetFocusInterface[]
then:
# Subscribe the character's damaged event to OnDamaged
Character.DamagedEvent().Subscribe(OnDamaged)
spawn{DeviceFollowCharacter()}
loop:
if:
DequeueResult := AgentsToDamage.Dequeue[]
set AgentsToDamage = DequeueResult(0)
AgentToDamage := DequeueResult(1)
then:
Print("Dequeued the next agent to damage")
DamageCharacter(AgentToDamage, Navigatable, Focusable)
else:
Print("AgentsToDamage is empty!")
Sleep(DamageDelay)
DamageVolume.AgentEntersEvent.Await()
else:
Print("Error in NPC Behavior Script on NPC Setup")
DamageCharacter(AgentToDamage:agent, Navigatable:navigatable, Focusable:focus_interface)<suspends>:void=
if:
DamageVolume.IsInVolume[AgentToDamage]
CharacterToDamage := AgentToDamage.GetFortCharacter[]
then:
Print("Character is in volume, starting damage")
NavigationTarget := MakeNavigationTarget(AgentToDamage)
branch:
Navigatable.NavigateTo(NavigationTarget)
Focusable.MaintainFocus(AgentToDamage)
VFXSpawner.Enable()
HolyScarletRay.Play()
Sleep(2.70)
HolyScarletRay.Stop()
defer:
VFXSpawner.Disable()
race:
loop:
CurrentHealth := CharacterToDamage.GetHealth()
if(CurrentHealth - DamageAmount < DamageThreshold):
if (CurrentHealth > DamageThreshold):
CharacterToDamage.SetHealth(DamageThreshold)
Print("Character has reached DamageThreshold, stopping damage")
break
else:
CharacterToDamage.SetHealth(CurrentHealth - DamageAmount)
Sleep(DamageDelay)
DamageVolume.AgentExitsEvent.Await()
OnDamaged(DamageResult:damage_result):void=
Instigator := DamageResult.Instigator
if:
Agent := GetAgent[]
Character := Agent.GetFortCharacter[]
Navigatable := Character.GetNavigatable[]
# Get the agent that instigated the damage
InstigatingAgent := agent[Instigator?]
then:
# Start navigating to the InstigatingAgent
NavigationTarget := MakeNavigationTarget(InstigatingAgent)
spawn{Navigatable.NavigateTo(NavigationTarget)}
DeviceFollowCharacter()<suspends>:void=
if:
Agent := GetAgent[]
Character := Agent.GetFortCharacter[]
then:
loop:
CharacterTransform := Character.GetTransform()
VFXSpawner.MoveTo(CharacterTransform.Translation, CharacterTransform.Rotation, UpdateRateSeconds)
DamageVolume.MoveTo(CharacterTransform.Translation, CharacterTransform.Rotation, UpdateRateSeconds)
Sleep(UpdateRateSeconds)
OnAgentEnters(EnteredAgent:agent):void=
Print("Agent entered the damage volume")
if (EnteredAgent <> GetAgent[]):
set AgentsToDamage = AgentsToDamage.Enqueue(EnteredAgent)
OnAgentExits(ExitAgent:agent):void=
Print("Agent exited the damage volume")
PrintNPCB(Msg:string, ?Duration:float = 3.0, ?TextColor:color = NamedColors.Green):void =
Print("[new_npc_behavior] {Msg}", ?Color := TextColor, ?Duration := Duration)
OnEnd<override>():void =
PrintNPCB("OnEnd")