Skip to content

Commit 4b81e7c

Browse files
authored
Merge pull request #5768 from SteelBlueZK/singudisarm
Singu hides ball on disarm, also hides halo effect
2 parents 0de7b88 + f042ba3 commit 4b81e7c

5 files changed

Lines changed: 18 additions & 11 deletions

File tree

LuaUI/Configs/lupsFXs.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ shieldBursts350 = {
273273
-- LIGHT -------------------------------------------------------------------
274274
----------------------------------------------------------------------------
275275
energysinguCorona = {
276-
pos = {0,66,0},
277276
life = math.huge,
278277
lifeSpread = 0,
279278
size = 110,

LuaUI/Configs/lupsUnitFXs.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ effectUnitDefs = {
5555
--// FUSIONS //--------------------------
5656
energysingu = {
5757
{class='Bursts', options=energysinguBursts},
58-
{class='StaticParticles', options=energysinguCorona},
58+
{class='StaticParticles', options=MergeTable(energysinguCorona, {piece="energyball", sizeScaleParam="ballSwell"})},
5959
--{class='ShieldSphere', options=energysinguShieldSphere},
6060
--{class='ShieldJitter', options={layer=-16, life=math.huge, pos={0,58.9,0}, size=100, precision=22, strength = 0.001, repeatEffect=true}},
6161
{class='GroundFlash', options=groundFlashOrange},
@@ -206,7 +206,7 @@ effectUnitDefs = {
206206

207207
-- portable singularity
208208
{class='Bursts', options=MergeTable(energysinguBursts,{piece="ball", noIconDraw = true, size=5, pos={0,0,0}})},
209-
{class='StaticParticles', options=MergeTable(energysinguCorona,{piece="ball", noIconDraw = true, size=18, pos={0,0,0}})},
209+
{class='StaticParticles', options=MergeTable(energysinguCorona,{piece="ball", onUnitRulesParam="ballHalo", noIconDraw = true, size=18})},
210210

211211
-- blinky lights
212212
{class='StaticParticles', options=MergeTable(blinkyLightRed, {piece="extra_L"}) },

lups/ParticleClasses/StaticParticles.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ StaticParticles.Default = {
4747
size = 0,
4848
sizeSpread = 0,
4949
sizeGrowth = 0,
50+
-- sizeScaleParam= unset, overrides sizeGrowth property if set.
5051
colormap = { {0, 0, 0, 0} }, --//max 12 entries
5152
srcBlend = GL.ONE,
5253
dstBlend = GL.ONE_MINUS_SRC_ALPHA,
@@ -74,6 +75,7 @@ local spGetPositionLosState = Spring.GetPositionLosState
7475
local spGetUnitViewPosition = Spring.GetUnitViewPosition
7576
local spIsSphereInView = Spring.IsSphereInView
7677
local spGetUnitRadius = Spring.GetUnitRadius
78+
local spGetUnitRulesParam = Spring.GetUnitRulesParam
7779
local spGetProjectilePosition = Spring.GetProjectilePosition
7880

7981
local glTexture = gl.Texture
@@ -246,7 +248,11 @@ end
246248

247249
function StaticParticles:Update(n)
248250
self.frame = self.frame + n
249-
self.usize = self.usize + n*self.sizeGrowth
251+
if self.sizeScaleParam then
252+
self.usize = spGetUnitRulesParam(self.unit, self.sizeScaleParam) * self.size
253+
else
254+
self.usize = self.usize + n*self.sizeGrowth -- overridden if self.sizeScaleParam
255+
end
250256
end
251257

252258
-- used if repeatEffect=true;

scripts/bomberheavy.lua

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ include "constants.lua"
22
include "bombers.lua"
33
include "fixedwingTakeOff.lua"
44

5+
local spSetUnitRulesParam = Spring.SetUnitRulesParam
56

67
local base = piece 'base'
78
local wing_L = piece 'wing_L'
@@ -29,8 +30,7 @@ local takeoffHeight = UnitDefNames["bomberheavy"].cruiseAltitude
2930

3031
local function ShowBall()
3132
Show(ball)
32-
Move(ball, y_axis, 0)
33-
Move(ball, z_axis, 0)
33+
spSetUnitRulesParam(unitID, "ballHalo", 1, INLOS) -- show halo
3434

3535
Move(radiator_L, z_axis, 0, 2)
3636
Move(radiator_R, z_axis, 0, 2)
@@ -53,13 +53,10 @@ end
5353

5454
local function HideBall()
5555
Hide(ball)
56+
spSetUnitRulesParam(unitID, "ballHalo", 0, INLOS) -- hide halo
5657
Scale(ball, 0)
5758
Turn(ball_emit, y_axis, 0)
5859
Spin(ball_emit, y_axis, 0)
59-
60-
-- apparently to hide the LUPS glow
61-
Move(ball, y_axis, 27)
62-
Move(ball, z_axis, 1)
6360

6461
Show(radiator_L)
6562
Show(radiator_R)
@@ -197,6 +194,7 @@ function script.Create()
197194

198195
WingStart()
199196
Hide(ball)
197+
spSetUnitRulesParam(unitID, "ballHalo", 0, INLOS) -- hide halo
200198
Hide(radiator_L)
201199
Hide(radiator_R)
202200

scripts/energysingu.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ local smokePiece = { piece "base", piece "arm1", piece "arm2", piece "arm3" }
1515

1616
local ballSize = 0
1717
local is_stunned = true
18+
local spSetUnitRulesParam = Spring.SetUnitRulesParam
1819

1920
local function SizeControl()
2021
local mag = math.random() + 1
@@ -41,6 +42,7 @@ local function SizeControl()
4142
end
4243

4344
local ballSwellFactor = 1.13^(sin(t/period)*mag) * (ballSize^2 / 11000)
45+
spSetUnitRulesParam(unitID, "ballSwell", 1.15*ballSwellFactor - 0.1, INLOS)
4446
Scale(energyball, ballSwellFactor)
4547

4648
t = t + 1
@@ -66,9 +68,10 @@ end
6668

6769
local function Anim()
6870
local spGetUnitIsStunned = Spring.GetUnitIsStunned
71+
local spGetUnitRulesParam = Spring.GetUnitRulesParam
6972
local was_stunned = true
7073
while true do
71-
is_stunned = spGetUnitIsStunned(unitID)
74+
is_stunned = spGetUnitIsStunned(unitID) or (spGetUnitRulesParam(unitID, "disarmed") == 1)
7275
if is_stunned ~= was_stunned then
7376
was_stunned = is_stunned
7477
if is_stunned then
@@ -84,6 +87,7 @@ end
8487

8588
function script.Create()
8689
Hide(energyball)
90+
spSetUnitRulesParam(unitID, "ballSwell", 0, INLOS) -- halo size
8791

8892
StartThread(GG.Script.SmokeUnit, unitID, smokePiece)
8993
StartThread(Anim)

0 commit comments

Comments
 (0)