-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpawnable Attack
More file actions
68 lines (56 loc) · 2.7 KB
/
Spawnable Attack
File metadata and controls
68 lines (56 loc) · 2.7 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
using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /Verse.org/Simulation }
using { /Verse.org/Random }
using { /Verse.org/Concurrency }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath }
# Spawnable lightning attack that damages players in a radius
# Can drag and drop into any project
attack_PoisanCloud := class<concrete>():
# The LightningAsset is a Blueprint with the "Building Prop" parent class
# We put a Niagara VFX inside of it and when it is spawned the VFX automatically plays
@editable PoisanCloud: creative_prop_asset = DefaultCreativePropAsset
# The audio player device is used to play the lightning sound
@editable PoisanCloudAudio : audio_player_device = audio_player_device{}
var Players<private> : []player = array{}
var AttackDamage<private> : float = 10.0
TOTAL_ATTACKS : int = 6
ATTACK_RANGE : int = 1000
BOLT_DAMAGE_RADIUS : float = 300.0
StartAttack(AttackPlayers : []player, LightningAttackDamage : float, Delay : float, SourceLocation : vector3)<suspends>:void=
Sleep(Delay)
set Players = AttackPlayers
set AttackDamage = LightningAttackDamage
Points := GenerateRandomPointsInCircle(TOTAL_ATTACKS, SourceLocation, ATTACK_RANGE)
spawn{PlayAudio(true, 1.0)}
for (IDX := 0..Points.Length - 1):
if (Point := Points[IDX]):
spawn{SpawnAtPoint(Point)}
Sleep(0.5)
# Because we have more than one lightning attack, the audio is put into a Cue
# And the bolts are timed there. If we increase TOTAL_ATTACKS here, we'll need to add those
# Sounds to the Cue as well
PlayAudio<private>(Start : logic, Delay : float)<suspends>:void=
Sleep(Delay)
if (Start?):
PoisanCloudAudio.Play()
else:
PoisanCloudAudio.Stop()
# Spawns the actual lightning Bolt Creative prop
SpawnAtPoint<private>(Point: vector3)<suspends>:void=
Prop := SpawnProp(PoisanCloud, Point, IdentityRotation())
DamagePlayersInRadius(Point)
Sleep(3.0)
if (P := Prop(0)?, P.IsValid[]):
P.Dispose()
# Checks the distance of current players, and if within damage radius
# We apply damage to the player
DamagePlayersInRadius<private>(Point: vector3):void=
for (Player : Players, Fort := Player.GetFortCharacter[]):
Loc := Fort.GetTransform().Translation
Dis := DistanceXY(Point, Loc)
if (Dis <= BOLT_DAMAGE_RADIUS):
Fort.Damage(AttackDamage)
else if (Dis <= BOLT_DAMAGE_RADIUS + (BOLT_DAMAGE_RADIUS * 0.2)):
Fort.Damage(AttackDamage / 2.0)