-
Notifications
You must be signed in to change notification settings - Fork 251
Expand file tree
/
Copy pathEffectUtilitiesAeon.lua
More file actions
563 lines (490 loc) · 22.7 KB
/
EffectUtilitiesAeon.lua
File metadata and controls
563 lines (490 loc) · 22.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
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
-- imports for functionality
local AeonBuildBeams01 = import("/lua/effecttemplates.lua").AeonBuildBeams01
local AeonBuildBeams02 = import("/lua/effecttemplates.lua").AeonBuildBeams02
local AttachBeamEntityToEntity = AttachBeamEntityToEntity
local CreateAttachedEmitter = CreateAttachedEmitter
local CreateEmitterOnEntity = CreateEmitterOnEntity
local WaitTicks = WaitTicks
local MathMin = math.min
local EntityCreateProjectile = moho.entity_methods.CreateProjectile
local EntityCreateProjectileAtBone = moho.entity_methods.CreateProjectileAtBone
local EntityGetOrientation = moho.entity_methods.GetOrientation
local EntitySetOrientation = moho.entity_methods.SetOrientation
local IEffectScaleEmitter = moho.IEffect.ScaleEmitter
local IEffectSetEmitterCurveParam = moho.IEffect.SetEmitterCurveParam
local IEffectOffsetEmitter = moho.IEffect.OffsetEmitter
local ProjectileSetScale = moho.projectile_methods.SetScale
local SliderSetGoal = moho.SlideManipulator.SetGoal
local SliderSetSpeed = moho.SlideManipulator.SetSpeed
local SliderSetWorldUnits = moho.SlideManipulator.SetWorldUnits
local UnitGetFractionComplete = moho.unit_methods.GetFractionComplete
local TrashBagAdd = TrashBag.Add
---@alias Animator moho.AnimationManipulator
--- Creates an Aeon mercury pool build effect
---@param unitBeingBuilt Unit Unit to attach mercury pool to
---@param army number Army of the pool
---@param sx number Size x of the pool
---@param sy number Size y of the pool
---@param sz number Size z of the pool
---@param scale number Scale of secondary build effect
---@return Projectile pool
function CreateMercuryPool(unitBeingBuilt, army, sx, sy, sz, scale)
local onDeathTrash = unitBeingBuilt.Trash
local onFinishedTrash = unitBeingBuilt.OnBeingBuiltEffectsBag
-- Create the mercury pool
local pool = unitBeingBuilt:CreateProjectile('/effects/entities/AeonBuildEffect/AeonBuildEffect01_proj.bp', 0, 0, 0, 0, 0, 0)
TrashBagAdd(onDeathTrash, pool)
TrashBagAdd(onFinishedTrash, pool)
ProjectileSetScale(pool, sx, sy, sz)
local offset = unitBeingBuilt.Blueprint.Display.AeonMercuryPoolOffset
if offset then
local position = pool:GetPosition()
position[2] = position[2] + offset
Warp(pool, position)
end
pool:SetOrientation(unitBeingBuilt:GetOrientation(), true)
-- Create effects of build animation
local emitter = CreateEmitterOnEntity(pool, army, '/effects/emitters/aeon_being_built_ambient_02_emit.bp')
IEffectSetEmitterCurveParam(emitter, 'X_POSITION_CURVE', 0, sx * 1.5)
IEffectSetEmitterCurveParam(emitter, 'Z_POSITION_CURVE', 0, sz * 1.5)
TrashBagAdd(onDeathTrash, emitter)
TrashBagAdd(onFinishedTrash, emitter)
emitter = CreateEmitterOnEntity(pool, army, '/effects/emitters/aeon_being_built_ambient_03_emit.bp')
IEffectScaleEmitter(emitter, scale)
TrashBagAdd(onDeathTrash, emitter)
TrashBagAdd(onFinishedTrash, emitter)
return pool
end
--- Creates an Aeon mercury pool build effect
---@param unitBeingBuilt Unit Unit to attach mercury pool to
---@param army number
---@param bone Bone Bone to place pool at
---@param sx number Size x of the pool
---@param sy number Size y of the pool
---@param sz number Size z of the pool
---@param scale number Scale of secondary build effect
---@return Projectile pool
function CreateMercuryPoolOnBone(unitBeingBuilt, army, bone, sx, sy, sz, scale)
local onDeathTrash = unitBeingBuilt.Trash
local onFinishedTrash = unitBeingBuilt.OnBeingBuiltEffectsBag
-- -- Create the mercury pool
local pool = EntityCreateProjectileAtBone(unitBeingBuilt, '/effects/entities/AeonBuildEffect/AeonBuildEffect01_proj.bp', bone)
TrashBagAdd(onDeathTrash, pool)
TrashBagAdd(onFinishedTrash, pool)
EntitySetOrientation(pool, EntityGetOrientation(unitBeingBuilt), true)
ProjectileSetScale(pool, sx, sy, sz)
-- -- Create effects of build animation
local emitter = CreateEmitterOnEntity(pool, army, '/effects/emitters/aeon_being_built_ambient_02_emit.bp')
IEffectSetEmitterCurveParam(emitter, 'X_POSITION_CURVE', 0, sx * 1.5)
IEffectSetEmitterCurveParam(emitter, 'Z_POSITION_CURVE', 0, sz * 1.5)
TrashBagAdd(onDeathTrash, emitter)
TrashBagAdd(onFinishedTrash, emitter)
emitter = CreateEmitterOnEntity(pool, army, '/effects/emitters/aeon_being_built_ambient_03_emit.bp')
IEffectScaleEmitter(emitter, scale)
TrashBagAdd(onDeathTrash, emitter)
TrashBagAdd(onFinishedTrash, emitter)
return pool
end
--- Creates some generic build effects for Aeon
---@param unitBeingBuilt Unit Unit to attach build effects to
---@param army number
---@param sx number Size x of the emitter curve parameter
---@param sz number Size z of the emitter curve parameter
---@param scale number Scale of the build effect
function CreateAeonGenericBuildEffects(unitBeingBuilt, army, sx, sz, scale)
local onDeathTrash = unitBeingBuilt.Trash
local onFinishedTrash = unitBeingBuilt.OnBeingBuiltEffectsBag
-- -- Create effects of build animation
local emitter = CreateEmitterOnEntity(unitBeingBuilt, army, '/effects/emitters/aeon_being_built_ambient_02_emit.bp')
IEffectSetEmitterCurveParam(emitter, 'X_POSITION_CURVE', 0, sx)
IEffectSetEmitterCurveParam(emitter, 'Z_POSITION_CURVE', 0, sz)
TrashBagAdd(onDeathTrash, emitter)
TrashBagAdd(onFinishedTrash, emitter)
emitter = CreateEmitterOnEntity(unitBeingBuilt, army, '/effects/emitters/aeon_being_built_ambient_03_emit.bp')
IEffectScaleEmitter(emitter, scale)
TrashBagAdd(onDeathTrash, emitter)
TrashBagAdd(onFinishedTrash, emitter)
end
--- Creates generic Aeon build sparkles
---@param unitBeingBuilt Unit Unit to attach sparkles to
---@param army number
---@param sx number Size x of the emitter curve parameter
---@param sz number Size z of the emitter curve parameter
function CreateAeonGenericBuildSparkles(unitBeingBuilt, army, sx, sz)
local onDeathTrash = unitBeingBuilt.Trash
local onFinishedTrash = unitBeingBuilt.OnBeingBuiltEffectsBag
-- Create additional sparkles
local quartSx, quartSz = sx * 0.25, sz * 0.25
for k = 1, 10 do
local doubFrac = k / 5
local emitter = CreateEmitterOnEntity(unitBeingBuilt, army, '/effects/emitters/aeon_being_built_ambient_02_emit.bp')
IEffectSetEmitterCurveParam(emitter, 'X_POSITION_CURVE', 0, doubFrac * quartSx)
IEffectSetEmitterCurveParam(emitter, 'Z_POSITION_CURVE', 0, doubFrac * quartSz)
IEffectScaleEmitter(emitter, 2.0)
IEffectOffsetEmitter(emitter, 0, 2 - doubFrac, 0)
TrashBagAdd(onDeathTrash, emitter)
TrashBagAdd(onFinishedTrash, emitter)
end
end
--- The build animation of an engineer.
---@param builder Unit The engineer in question
---@param unitBeingBuilt Unit The unit we're building
---@param buildEffectsBag TrashBag The trash bag for the build effects
function CreateAeonConstructionUnitBuildingEffects(builder, unitBeingBuilt, buildEffectsBag)
local army = builder.Army
-- create effect on builder
TrashBagAdd(buildEffectsBag, CreateEmitterOnEntity(builder, army, '/effects/emitters/aeon_build_01_emit.bp') )
-- create beam builder -> target
for _, effect in AeonBuildBeams01 do
TrashBagAdd(buildEffectsBag, AttachBeamEntityToEntity(builder, -1, unitBeingBuilt, -1, army, effect))
end
end
--- The build animation of the commander.
---@param builder Unit The commander in question
---@param unitBeingBuilt Unit The unit we're building
---@param buildEffectBones string[] The bone(s) of the commander where the effect starts
---@param buildEffectsBag TrashBag The trash bag for the build effects
function CreateAeonCommanderBuildingEffects(builder, unitBeingBuilt, buildEffectBones, buildEffectsBag)
local army = builder.Army
-- create beam builder -> target
for _, bone in buildEffectBones do
TrashBagAdd(buildEffectsBag, CreateAttachedEmitter(builder, bone, army, '/effects/emitters/aeon_build_02_emit.bp'))
for _, effect in AeonBuildBeams01 do
TrashBagAdd(buildEffectsBag, AttachBeamEntityToEntity(builder, bone, unitBeingBuilt, -1, army, effect))
end
end
end
--- The shared functionality between building structures and units
---@param pool Entity The mercury pool for the build effect
---@param unitBeingBuilt Unit The unit that is being made
---@param trash TrashBag The generic trashbag of the unit
---@param onStopBeingBuiltTrash TrashBag The OnStopBeingBuilt trashbag of the unit
---@param sx number
---@param sy number
---@param sz number
local function SharedBuildThread(pool, unitBeingBuilt, trash, onStopBeingBuiltTrash, sx, sy, sz)
-- -- Determine offset for hover units
local offset = 0
local slider = nil
if unitBeingBuilt.Blueprint.CategoriesHash["HOVER"] then
-- set elevation offset
offset = unitBeingBuilt.Blueprint.Elevation or 0
-- create a slider
slider = CreateSlider(unitBeingBuilt, 0)
SliderSetWorldUnits(slider, true)
SliderSetGoal(slider, 0, 0, 0)
SliderSetSpeed(slider, 100)
TrashBagAdd(trash, slider)
TrashBagAdd(onStopBeingBuiltTrash, slider)
end
-- -- Shrink pool accordingly
local fraction = UnitGetFractionComplete(unitBeingBuilt)
local scaledSy = 1.5 * sy
while fraction < 1 do
-- only update when we make progress
local cFraction = UnitGetFractionComplete(unitBeingBuilt)
if cFraction > fraction then
-- store updated value
fraction = cFraction
-- only adjust pool when more than 80% complete to match the shader animation
if fraction > 0.8 then
local progress = 5 * (fraction - 0.8)
if progress < 0 then
progress = 0
end
scale = 1 - progress * progress
ProjectileSetScale(pool, sx * scale, scaledSy * scale, sz * scale)
end
-- adjust slider for hover units
if slider then
SliderSetGoal(slider, 0, fraction * offset, 0)
SliderSetSpeed(slider, fraction * fraction * fraction)
end
end
-- wait a tick
WaitTicks(2)
end
-- set correct shader of unitBeingBuilt so that it happens instantly after finishing
unitBeingBuilt:SetMesh(unitBeingBuilt.Blueprint.Display.MeshBlueprint, true)
end
--- The build animation for Aeon buildings in general.
---@param unitBeingBuilt Unit The unit we're trying to build
---@param builder Unit Unused
---@param effectsBag TrashBag The build effects bag containing the pool and emitters (unused)
function CreateAeonBuildBaseThread(unitBeingBuilt, builder, effectsBag)
-- -- Hold up for orientation to receive an update
WaitTicks(2)
-- always check after a wait
if (not unitBeingBuilt) or unitBeingBuilt.Dead then
return
end
-- -- Initialize various info used throughout the function
local army = unitBeingBuilt.Army
local unitBeingBuiltTrash = unitBeingBuilt.Trash
local unitOnStopBeingBuiltTrash = unitBeingBuilt.OnBeingBuiltEffectsBag
local Physics = unitBeingBuilt.Blueprint.Physics
local Footprint = unitBeingBuilt.Blueprint.Footprint
local sx = Physics.MeshExtentsX or Footprint.SizeX
local sz = Physics.MeshExtentsZ or Footprint.SizeZ
local sy = Physics.MeshExtentsY or Footprint.SizeY or MathMin(sx, sz)
local pool = CreateMercuryPool(unitBeingBuilt, army, sx, sy * 1.5, sz, (sx + sz) * 0.3)
-- -- Create a thread to scale the pool
local thread = ForkThread(SharedBuildThread,
pool, unitBeingBuilt,
unitBeingBuiltTrash, unitOnStopBeingBuiltTrash,
sx, sy, sz
)
TrashBagAdd(unitBeingBuiltTrash, thread)
TrashBagAdd(unitOnStopBeingBuiltTrash, thread)
end
--- The build animation for Aeon factories, including the pool and dummy unit.
---@param builder Unit The factory that is building the unit
---@param unitBeingBuilt Unit The unit we're trying to build
---@param buildEffectBones string[] The arms of the factory where the build beams come from
---@param buildBone string The location where the unit is beint built
---@param effectsBag TrashBag The build effects bag
function CreateAeonFactoryBuildingEffects(builder, unitBeingBuilt, buildEffectBones, buildBone, effectsBag)
-- -- Hold up for orientation to receive an update
WaitTicks(2)
-- always check after a wait
if (not unitBeingBuilt) or unitBeingBuilt.Dead then
return
end
-- -- Create build beams for factory
local army = unitBeingBuilt.Army
for _, bone in buildEffectBones do
TrashBagAdd(effectsBag, CreateAttachedEmitter(builder, bone, army, '/effects/emitters/aeon_build_03_emit.bp'))
for _, effect in AeonBuildBeams02 do
TrashBagAdd(effectsBag, AttachBeamEntityToEntity(builder, bone, builder, buildBone, army, effect))
end
end
-- -- Create persistent state between calls
if not unitBeingBuilt.ConstructionInitialised then
unitBeingBuilt.ConstructionInitialised = true
-- -- Initialize various info used throughout the function
local unitBeingBuiltTrash = unitBeingBuilt.Trash
local unitOnStopBeingBuiltTrash = unitBeingBuilt.OnBeingBuiltEffectsBag
local Physics = unitBeingBuilt.Blueprint.Physics
local Footprint = unitBeingBuilt.Blueprint.Footprint
local sx = Physics.MeshExtentsX or Footprint.SizeX
local sz = Physics.MeshExtentsZ or Footprint.SizeZ
local sy = Physics.MeshExtentsY or Footprint.SizeY or MathMin(sz, sz)
if unitBeingBuilt.Blueprint.CategoriesHash["AIR"] then
local t = sx
sx = sz
sz = t
end
local pool = CreateMercuryPool(unitBeingBuilt, army, sx, sy * 1.5, sz, (sx + sz) * 0.3)
-- -- Create a thread to scale the pool and move the unit accordingly
local thread = ForkThread(SharedBuildThread,
pool, unitBeingBuilt,
unitBeingBuiltTrash, unitOnStopBeingBuiltTrash,
sx, sy, sz
)
TrashBagAdd(unitBeingBuiltTrash, thread)
TrashBagAdd(unitOnStopBeingBuiltTrash, thread)
end
end
--- Bones where the sparkles spawn at
local ColossusEffectBones = {
"Left_Footfall",
"Left_Leg_B01",
"Left_Leg_B02",
"Right_Leg_B02",
"Right_Leg_B01",
"Right_Footfall",
"Right_Arm_Muzzle01",
"Left_Arm_Muzzle101",
}
--- Possible animations of the colossus, prevents a blueprint lookup
local ColossusAnimations = {
'/units/UAL0401/UAL0401_aactivate.sca',
'/units/UAL0401/UAL0401_aactivate_alt.sca',
}
--- Puddle locations of the colossus
local ColossusPuddleBones = {
{
"Right_Footfall",
"Left_Footfall",
}, {
"Right_Footfall",
"Left_Footfall",
}
}
--- A helper function for the full build animation of the Colossus.
---@param unitBeingBuilt Unit The Colossus that is being built
---@param animator Animator The animator that is applied
---@param puddleBones string[] The set of bones to use for puddles
local function CreateAeonColossusBuildingEffectsThread(unitBeingBuilt, animator, puddleBones)
WaitTicks(2)
-- -- Store information used throughout the function
local sx = 1.5
local sy = 2.25
local sz = 1.5
local army = unitBeingBuilt.Army
local onDeathTrash = unitBeingBuilt.Trash
local onFinishedTrash = unitBeingBuilt.OnBeingBuiltEffectsBag
-- -- Create pools of mercury
local pools = { false, false }
for k, bone in puddleBones do
pools[k] = CreateMercuryPoolOnBone(unitBeingBuilt, army, bone, sx, sy, sz, sy)
end
-- -- Apply build effects
for k, _ in ColossusEffectBones do
local emitter = CreateEmitterAtBone(unitBeingBuilt, k, army, '/effects/emitters/aeon_being_built_ambient_02_emit.bp')
IEffectSetEmitterCurveParam(emitter, 'X_POSITION_CURVE', 0, 1)
IEffectSetEmitterCurveParam(emitter, 'Z_POSITION_CURVE', 0, 1)
IEffectScaleEmitter(emitter, 1.0)
TrashBagAdd(onDeathTrash, emitter)
TrashBagAdd(onFinishedTrash, emitter)
end
-- -- Apply a manual animation
local fraction = UnitGetFractionComplete(unitBeingBuilt)
local scaledSy = sy * 1.5
while fraction < 1 do
-- only update when we make progress
local cFraction = UnitGetFractionComplete(unitBeingBuilt)
if cFraction > fraction then
-- store updated value
fraction = cFraction
-- only adjust pool when more than 80% complete to match the shader animation
if fraction > 0.8 then
local progress = 5 * (fraction - 0.8)
if progress < 0 then
progress = 0
end
local prog2 = progress * progress
scale = 1 - prog2
-- progress pool
local scaleX, scaleY, scaleZ = sx * scale, scaledSy * scale, sz * scale
for _, pool in pools do
ProjectileSetScale(pool, scaleX, scaleY, scaleZ)
end
-- progress animation
animator:SetAnimationFraction(progress * prog2)
end
end
-- wait a tick
WaitTicks(2)
end
end
--- Creates the Aeon Tempest build effects, including particles and an animation.
---@param unitBeingBuilt Unit The Colossus that is being built
function CreateAeonColossusBuildingEffects(unitBeingBuilt)
local onDeathTrash = unitBeingBuilt.Trash
local onFinishedTrash = unitBeingBuilt.OnBeingBuiltEffectsBag
-- -- Apply build animation
local animator = CreateAnimator(unitBeingBuilt, false)
TrashBagAdd(onDeathTrash, animator)
TrashBagAdd(onFinishedTrash, animator)
local index = Random(1, 2)
animator:PlayAnim(ColossusAnimations[index], false)
animator:SetRate(0)
animator:SetAnimationFraction(0)
local thread = ForkThread(CreateAeonColossusBuildingEffectsThread, unitBeingBuilt, animator, ColossusPuddleBones[index])
TrashBagAdd(onDeathTrash, thread)
TrashBagAdd(onFinishedTrash, thread)
end
--- Creates the Aeon CZAR build effects, including particles.
---@param unitBeingBuilt Unit The CZAR that is being built
function CreateAeonCZARBuildingEffects(unitBeingBuilt)
-- -- Initialize various info used throughout the function
local army = unitBeingBuilt.Army
local bp = unitBeingBuilt.Blueprint
local sx = 0.6 * bp.Physics.MeshExtentsX or bp.Footprint.SizeX
local sz = 0.6 * bp.Physics.MeshExtentsZ or bp.Footprint.SizeZ
CreateAeonGenericBuildEffects(unitBeingBuilt, army, sx, 0.75 * sx, sz)
CreateAeonGenericBuildSparkles(unitBeingBuilt, army, sx, sz)
end
--- A helper function for the full build animation of the Tempest.
---@param unitBeingBuilt Unit The Tempest that is being built
---@param animator Animator The animator that is applied
local function CreateAeonTempestBuildingEffectsThread(unitBeingBuilt, animator)
local fraction = UnitGetFractionComplete(unitBeingBuilt)
while fraction < 1 do
-- only update when we make progress
local cFraction = UnitGetFractionComplete(unitBeingBuilt)
if cFraction > fraction then
-- store updated value
fraction = cFraction
animator:SetAnimationFraction(fraction)
end
-- wait a tick
WaitTicks(2)
end
end
--- Creates the Aeon Tempest build effects, including particles and an animation.
---@param unitBeingBuilt Unit The tempest that is being built
function CreateAeonTempestBuildingEffects(unitBeingBuilt)
-- -- Initialize various info used throughout the function
local army = unitBeingBuilt.Army
local onDeathTrash = unitBeingBuilt.Trash
local onFinishedTrash = unitBeingBuilt.OnBeingBuiltEffectsBag
local bp = unitBeingBuilt.Blueprint
local sx = 0.55 * bp.Physics.MeshExtentsX or bp.Footprint.SizeX
local sz = 0.55 * bp.Physics.MeshExtentsZ or bp.Footprint.SizeZ
CreateAeonGenericBuildEffects(unitBeingBuilt, army, sx, 0.75 * sx, sz)
CreateAeonGenericBuildSparkles(unitBeingBuilt, army, sx, sz)
-- -- Apply build animation
local animator = CreateAnimator(unitBeingBuilt)
animator:PlayAnim('/units/uas0401/uas0401_build.sca', false)
animator:SetRate(0)
animator:SetAnimationFraction(1)
TrashBagAdd(onDeathTrash, animator)
TrashBagAdd(onFinishedTrash, animator)
local thread = ForkThread(CreateAeonTempestBuildingEffectsThread, unitBeingBuilt, animator)
TrashBagAdd(onDeathTrash, thread)
TrashBagAdd(onFinishedTrash, thread)
end
--- A helper function for the full build animation of the Paragon.
---@param unitBeingBuilt Unit The Paragon that is being built
---@param sx number
---@param sy number unused
---@param sz number
local function CreateAeonParagonBuildingEffectsThread(unitBeingBuilt, sx, sy, sz)
-- -- Initialize various info used throughout the function
local army = unitBeingBuilt.Army
local onDeathTrash = unitBeingBuilt.Trash
local onFinishedTrash = unitBeingBuilt.OnBeingBuiltEffectsBag
local quartSx, quartSz = sx * 0.25, sz * 0.25
-- -- Add various effects over time
local k = 0.1
local fraction = UnitGetFractionComplete(unitBeingBuilt)
while fraction < 1 do
-- only update when we make progress
local cFraction = UnitGetFractionComplete(unitBeingBuilt)
if cFraction > fraction then
-- store updated value
fraction = cFraction
if k < cFraction then
local doubFrac = 2 * (1.1 - k)
local emitter = CreateEmitterOnEntity(unitBeingBuilt, army, '/effects/emitters/aeon_being_built_ambient_02_emit.bp')
IEffectSetEmitterCurveParam(emitter, 'X_POSITION_CURVE', 0, doubFrac * quartSx)
IEffectSetEmitterCurveParam(emitter, 'Z_POSITION_CURVE', 0, doubFrac * quartSz)
IEffectScaleEmitter(emitter, 2.0)
IEffectOffsetEmitter(emitter, 0, 2 - doubFrac, 0)
TrashBagAdd(onDeathTrash, emitter)
TrashBagAdd(onFinishedTrash, emitter)
k = k + 0.08
end
end
-- wait a tick
WaitTicks(2)
end
end
--- Creates the Aeon Paragon build effects, including particles and an animation.
---@param unitBeingBuilt Unit The Tempest that is being built
function CreateAeonParagonBuildingEffects(unitBeingBuilt)
-- -- Initialize various info used throughout the function
local army = unitBeingBuilt.Army
local Physics = unitBeingBuilt.Blueprint.Physics
local Footprint = unitBeingBuilt.Blueprint.Footprint
local sx = Physics.MeshExtentsX or Footprint.SizeX
local sz = Physics.MeshExtentsZ or Footprint.SizeZ
local sy = 2 * Physics.MeshExtentsY or Footprint.SizeY or MathMin(sx, sz)
CreateAeonGenericBuildEffects(unitBeingBuilt, army, sx, sy, sz)
-- -- Create additional sparkles
local thread = ForkThread(CreateAeonParagonBuildingEffectsThread, unitBeingBuilt, sx, sy, sz)
TrashBagAdd(unitBeingBuilt.Trash, thread)
TrashBagAdd(unitBeingBuilt.OnBeingBuiltEffectsBag, thread)
end