-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathLegion.lua
238 lines (205 loc) · 8.55 KB
/
Legion.lua
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
local cc, packs = CrowdControl, CrowdControl.Packs
local pack = ModUtil.Mod.Register( "Legion", packs.Hades, false )
pack.Effects = { }; pack.Actions = { }; pack.Triggers = { }
pack.Parametric = { Actions = { }, Triggers = { } }
do
-- =====================================================
-- Triggers
-- =====================================================
function pack.Triggers.IfNotFirstRoom(id, action, ...)
if CurrentRun.CurrentRoom.Name ~= "RoomOpening" then
cc.InvokeEffect( id, action, ... )
return true
end
return false
end
function pack.Parametric.Triggers.DuplicateCheck( enemyName )
return function(...)
if CurrentRun.CurrentRoom.Name == "RoomOpening" then
return false
end
for enemyid, enemy in pairs( ActiveEnemies ) do
-- ModUtil.Hades.PrintStack("Enemy present: "..enemy.Name)
if enemy.Name == enemyName then
return false
end
end
cc.InvokeEffect(...)
return true
end
end
function pack.Triggers.BossCheck(id, action, ... )
local currentEncounter = CurrentRun.CurrentRoom.Encounter
local numBoss = 0
if CurrentRun.CurrentRoom.Name == "RoomOpening" or not ( currentEncounter.InProgress and currentEncounter.EncounterType ~= "NonCombat" ) then
return false
end
for enemyid, enemy in pairs( ActiveEnemies ) do
-- ModUtil.Hades.PrintStack("Enemy present: "..enemy.Name)
if enemy.IsBoss then
numBoss = numBoss + 1
end
end
if numBoss >= 2 then
return false
end
cc.InvokeEffect(id, action, ...)
return true
end
function pack.Parametric.Triggers.DoubleBossCheck( bossName )
return function( ... )
local currentEncounter = CurrentRun.CurrentRoom.Encounter
local numBoss = 0
if CurrentRun.CurrentRoom.Name == "RoomOpening" or not ( currentEncounter.InProgress and currentEncounter.EncounterType ~= "NonCombat" ) then
return false
end
for enemyid, enemy in pairs( ActiveEnemies ) do
-- ModUtil.Hades.PrintStack("Enemy present: "..enemy.Name)
if enemy.IsBoss then
numBoss = numBoss + 1
end
if enemy.Name == bossName then
-- ModUtil.Hades.PrintStack("Same boss")
return false
end
end
if numBoss >= 2 then
-- ModUtil.Hades.PrintStack("Too many")
return false
end
cc.InvokeEffect( ... )
return true
end
end
-- =====================================================
-- Actions
-- =====================================================
local function getHealthScalingForBiome()
local biomeNumber = GetBiomeDepth(CurrentRun)
-- biomeNumber ==
-- Tartarus -> 1
-- Asphodel -> 2
-- Elysium -> 3
-- Styx/Surface -> 4
-- scaledHealthMultiplier ==
-- Tartarus -> 1
-- Asphodel -> 1.5
-- Elysium -> 2
-- Styx/Surface -> 2.5
-- if biomeNumber == nil then
-- return 1
-- end
return 0.5 * (biomeNumber + 1)
end
function SpawnEnemy(enemyData, scaledHealth)
local currentEncounter = CurrentRun.CurrentRoom.Encounter
local newEnemy = DeepCopyTable( enemyData )
if scaledHealth then
local newHealth = scaledHealth * getHealthScalingForBiome()
newEnemy.MaxHealth = newHealth
end
newEnemy.AIOptions = enemyData.AIOptions
-- newEnemy.BlocksLootInteraction = false
local invaderSpawnPoint = SelectSpawnPoint(CurrentRun.CurrentRoom, newEnemy, currentEncounter)
newEnemy.ObjectId = SpawnUnit({
Name = enemyData.Name,
Group = "Standing",
DestinationId = invaderSpawnPoint,
OffsetX = math.random(-200,200),
OffsetY = math.random(-200,200)
})
SetupEnemyObject( newEnemy, CurrentRun )
return true
end
function pack.Parametric.Actions.SpawnEnemies(selection, count, scaledHealth)
return function (...)
PlaySound({ Name = "/SFX/FightGong" })
local enemyData = EnemyData[selection]
for i=1, count do
SpawnEnemy(enemyData, scaledHealth)
end
return true
end
end
function RefreshBossHealthUI()
for enemyid, enemy in pairs( ActiveEnemies ) do
-- ModUtil.Hades.PrintStack("Enemy present: "..enemy.Name)
if enemy.IsBoss then
RemoveEnemyUI( enemy )
-- enemy.HasHealthBar = false
CreateBossHealthBar( enemy )
end
end
-- for enemyid, enemy in pairs( ActiveEnemies ) do
-- -- ModUtil.Hades.PrintStack("Enemy present: "..enemy.Name)
-- if enemy.IsBoss then
-- enemy.HasHealthBar = false
-- CreateBossHealthBar( enemy )
-- -- CreateCCBossHealthBar( enemy )
-- end
-- end
end
function pack.Parametric.Actions.SpawnBoss(bossName, scaledHealth)
return function (...)
PlaySound({ Name = "/SFX/FightGong" })
thread(InCombatTextArgs, { TargetId = CurrentRun.Hero.ObjectId, Text = "BossSpawnText", Duration = 1 })
local currentEncounter = CurrentRun.CurrentRoom.Encounter
local enemyData = EnemyData[bossName]
local newEnemy = DeepCopyTable( enemyData )
newEnemy.IsBoss = false
newEnemy.UseBossHealthBar = false
if scaledHealth then
local newHealth = scaledHealth * getHealthScalingForBiome()
newEnemy.MaxHealth = newHealth
end
newEnemy.AIOptions = enemyData.AIOptions
newEnemy.BlocksLootInteraction = false
local invaderSpawnPoint = SelectSpawnPoint(CurrentRun.CurrentRoom, newEnemy, currentEncounter)
newEnemy.ObjectId = SpawnUnit({ Name = enemyData.Name, Group = "Standing",
DestinationId = invaderSpawnPoint,
OffsetX = math.random(-5,5),
OffsetY = math.random(-5,5)
})
SetupEnemyObject( newEnemy, CurrentRun, { SkipSpawnVoiceLines = true } )
UseableOff({ Id = newEnemy.ObjectId })
-- wait(0.5)
-- thread( CreateBossHealthBar, newEnemy )
-- RefreshBossHealthUI()
return true
end
end
-- =====================================================
-- Effects
-- =====================================================
pack.Effects.SpawnNumbskull = cc.BindEffect(pack.Triggers.IfNotFirstRoom, pack.Parametric.Actions.SpawnEnemies("SwarmerHelmeted", 5, 30))
pack.Effects.SpawnPest = cc.BindEffect(pack.Triggers.IfNotFirstRoom, pack.Parametric.Actions.SpawnEnemies("ThiefMineLayer", 5, 40))
pack.Effects.SpawnVoidstone = cc.BindEffect(pack.Triggers.IfNotFirstRoom, pack.Parametric.Actions.SpawnEnemies("ShieldRanged", 1, 175))
pack.Effects.SpawnButterflyBall = cc.BindEffect(pack.Triggers.IfNotFirstRoom, pack.Parametric.Actions.SpawnEnemies("FlurrySpawner", 1, 275))
pack.Effects.SpawnFlameWheel = cc.BindEffect(pack.Triggers.IfNotFirstRoom, pack.Parametric.Actions.SpawnEnemies("ChariotSuicide", 5))
pack.Effects.SpawnSnakestone = cc.BindEffect(pack.Triggers.IfNotFirstRoom, pack.Parametric.Actions.SpawnEnemies("HeavyRangedForked", 1, 215))
pack.Effects.SpawnSatyr = cc.BindEffect(pack.Triggers.IfNotFirstRoom, pack.Parametric.Actions.SpawnEnemies("SatyrRanged", 1, 375))
-- pack.Effects.SpawnMeg = cc.RigidEffect(cc.BindEffect(pack.Triggers.BossCheck, pack.Parametric.Actions.SpawnBoss( "Harpy", 4400 )))
-- pack.Effects.SpawnAlecto = cc.RigidEffect(cc.BindEffect(pack.Triggers.BossCheck, pack.Parametric.Actions.SpawnBoss( "Harpy2", 4600 )))
-- pack.Effects.SpawnTis = cc.RigidEffect(cc.BindEffect(pack.Triggers.BossCheck, pack.Parametric.Actions.SpawnBoss( "Harpy3", 5200 )))
-- pack.Effects.SpawnTheseus = cc.RigidEffect(cc.BindEffect(pack.Triggers.BossCheck, pack.Parametric.Actions.SpawnBoss( "Theseus", 4500 )))
-- pack.Effects.SpawnAsterius = cc.RigidEffect(cc.BindEffect(pack.Triggers.BossCheck, pack.Parametric.Actions.SpawnBoss( "Minotaur", 7000 )))
pack.Effects.SpawnMeg = cc.RigidEffect(cc.BindEffect(pack.Parametric.Triggers.DoubleBossCheck("Harpy"), pack.Parametric.Actions.SpawnBoss( "Harpy", 4400 )))
pack.Effects.SpawnAlecto = cc.RigidEffect(cc.BindEffect(pack.Parametric.Triggers.DoubleBossCheck("Harpy2"), pack.Parametric.Actions.SpawnBoss( "Harpy2", 4600 )))
pack.Effects.SpawnTis = cc.RigidEffect(cc.BindEffect(pack.Parametric.Triggers.DoubleBossCheck("Harpy3"), pack.Parametric.Actions.SpawnBoss( "Harpy3", 5200 )))
pack.Effects.SpawnTheseus = cc.RigidEffect(cc.BindEffect(pack.Parametric.Triggers.DoubleBossCheck("Theseus"), pack.Parametric.Actions.SpawnBoss( "Theseus", 4500 )))
pack.Effects.SpawnAsterius = cc.RigidEffect(cc.BindEffect(pack.Parametric.Triggers.DoubleBossCheck("Minotaur"), pack.Parametric.Actions.SpawnBoss( "Minotaur", 7000 )))
end
-- put our effects into the centralised Effects table, under the "Hades.Legion" path
ModUtil.Path.Set( "Legion", ModUtil.Table.Copy( pack.Effects ), cc.Effects )
-- For testing purposes
-- ModUtil.Path.Wrap( "BeginOpeningCodex",
-- function(baseFunc)
-- if not CanOpenCodex() then
-- local myfunc = pack.Parametric.Actions.SpawnBoss( "Harpy", 4400 )
-- myfunc()
-- -- local myfunc2 = pack.Parametric.Actions.SpawnBoss( "Harpy2", 4400 )
-- -- myfunc2()
-- end
-- baseFunc()
-- end
-- )