-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBossCode
More file actions
136 lines (95 loc) · 4.87 KB
/
BossCode
File metadata and controls
136 lines (95 loc) · 4.87 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
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Fortnite.com/Game }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Fortnite.com/Characters }
using { /Verse.org/Random }
Zombie_boss := class(creative_device):
@editable ZombieBossBP : creative_prop = creative_prop{}
@editable MoveSpeed : float = 15.0
@editable PoisanCloud : attack_PoisanCloud = attack_PoisanCloud{}
@editable ZombieBossManipulator : prop_manipulator_device = prop_manipulator_device{}
# Cinematics
@editable ZombieBossAttack : cinematic_sequence_device = cinematic_sequence_device{}
@editable ZombieBossIdle : cinematic_sequence_device = cinematic_sequence_device{}
@editable ZombieBossWalk : cinematic_sequence_device = cinematic_sequence_device{}
@editable ZombieBossAoe : cinematic_sequence_device = cinematic_sequence_device{}
@editable ZombieBossDeath : cinematic_sequence_device = cinematic_sequence_device{}
@editable ZombieBosshit : cinematic_sequence_device = cinematic_sequence_device{}
@editable ZombieIntro : cinematic_sequence_device = cinematic_sequence_device{}
# Audio
@editable AttackEffort : audio_player_device = audio_player_device{}
@editable BossMusic : audio_player_device = audio_player_device{}
BOSS_TOTAL_HP : float = 10000.0
var BossCurrentHP<private> : float = 10000.0
# This should be stored in a custom player and be adjustable
PLAYER_DAMAGE : float = 20.0
OnBegin<override>()<suspends>:void=
ZombieBossManipulator.DamagedEvent.Subscribe(OnBossDamaged)
StartBossFight()<suspends>:void=
BossMusic.Play()
# Show the bar for all players
for (GP : GamePlayers()):
spawn{GP.BossUI.Start()}
# These can be adjusted to make the fight more difficult, easier, or
# for better gameplay
loop:
Sleep(0.3)
StopLoopingAnims()
StartMeleeAttack1()
Sleep(0.5)
StartSkyAttack()
StartIdle()<suspends>:void=
ZombieBossIdle.Play()
StartMeleeAttack1()<suspends>:void=
StartLocation := ZombieBossBP.GetTransform().Translation
# Find the nearest player
Players := GetPlayspace().GetPlayers().ToPositionals()
if (Target := ZombieBossBP.GetTransform().GetClosestPositional(Players)?):
var TargetLocation : vector3 = Target.GetTransform().Translation
# Rotate toward player before moving
var NewRotation : rotation = ZombieBossBP.GetTransform().GetLookAtRotation(TargetLocation)
ZombieBossBP.MoveTo(ZombieBossBP.GetTransform().Translation, NewRotation, 0.3)
# Calculate how long it will take to move to the player using Miles Per Hour
MoveDistance := DistanceXY(StartLocation, TargetLocation)
DistanceCoveredPerSecond := 25.0 * MoveSpeed
var MoveTime: float = MoveDistance / DistanceCoveredPerSecond
if (MoveTime <= 0.0):
set MoveTime = 1.0
#Play the dash animation
ZombieBossWalk.Play()
ZombieBossBP.MoveTo(TargetLocation, NewRotation, MoveTime)
ZombieBossWalk.Stop()
# Get target's latest position
set TargetLocation = Target.GetTransform().Translation
# One more quick rotation to face the player
set NewRotation = ZombieBossBP.GetTransform().GetLookAtRotation(TargetLocation)
ZombieBossBP.MoveTo(ZombieBossBP.GetTransform().Translation, NewRotation, 0.3)
# Play attack
AttackEffort.Play()
ZombieBossAttack.Play()
ZombieBossBP.MoveTo(TargetLocation, NewRotation, MoveTime)
StartSkyAttack()<suspends>:void=
spawn{PoisanCloud.StartAttack(GetPlayspace().GetPlayers(), 45.0, 3.5, ZombieBossBP.GetTransform().Translation)}
AttackEffort.Play()
ZombieBossAoe.PlayOneShot().Await()
# Always remember to stop other animations when starting a new one
# Or they will both play at the same time and you may get unexpected results
StopLoopingAnims():void=
ZombieBossIdle.Stop()
ZombieBossWalk.Stop()
# Update the progress bar for all players and/or end the game
OnBossDamaged(Agent : agent):void=
set BossCurrentHP -= PLAYER_DAMAGE
if (BossCurrentHP <= 0.0) { OnBossDefeated()}
else:
HPPercent := (BossCurrentHP / BOSS_TOTAL_HP) * 100.0
for (GP : GamePlayers()):
GP.BossUI.UpdateProgressBar(HPPercent)
ZombieBosshit .Play()
OnBossDefeated():void=
for (GP : GamePlayers()):
GP.BossUI.Hide()
ZombieBossDeath.Play()
ZombieBossBP.Dispose()