Skip to content

Commit ab51509

Browse files
committed
zLightning: Partial match on zLightning_Update
1 parent 5fc1336 commit ab51509

File tree

1 file changed

+64
-1
lines changed

1 file changed

+64
-1
lines changed

src/SB/Game/zLightning.cpp

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
#include <types.h>
77
#include <rwcore.h>
88

9+
#define NUM_LIGHTNING 48
10+
911
_tagLightningAdd gLightningTweakAddInfo;
1012

11-
static zLightning* sLightning[48];
13+
static zLightning* sLightning[NUM_LIGHTNING];
1214
static xFuncPiece sLFuncX[10];
1315
static xFuncPiece sLFuncY[10];
1416
static xFuncPiece sLFuncZ[10];
@@ -79,6 +81,67 @@ static void lightningTweakStart(const tweak_info& t)
7981
zLightningAdd(&gLightningTweakAddInfo);
8082
}
8183

84+
void zLightningUpdate(F32 dt)
85+
{
86+
S32 i;
87+
for (i = 0; i < NUM_LIGHTNING; i++)
88+
{
89+
if (sLightning[i] != NULL && sLightning[i]->flags & 0x1)
90+
{
91+
UpdateLightning(sLightning[i], dt);
92+
}
93+
}
94+
95+
sLFuncUVOffset = 1.0f * dt + sLFuncUVOffset;
96+
if (sLFuncUVOffset > 1.0f)
97+
{
98+
sLFuncUVOffset -= 1.0f;
99+
}
100+
101+
sLFuncJerkTime += 20.0f * dt;
102+
if (!(sLFuncJerkTime > 1.0f))
103+
{
104+
return;
105+
}
106+
107+
S32 picker = 9.0f * xurand();
108+
if (picker >= 9)
109+
{
110+
picker = 8;
111+
}
112+
if (picker < 0)
113+
{
114+
picker = 0;
115+
}
116+
117+
xVec3Init(&sLFuncVal[picker], 2.0f * (xurand() - 0.5f), 2.0f * (xurand() - 0.5f), 2.0f * (xurand() - 0.5f));
118+
xVec3Init(&sLFuncSlope[picker][0], 2.0f * (xurand() - 0.5f), 2.0f * (xurand() - 0.5f), 2.0f * (xurand() - 0.5f));
119+
xVec3Init(&sLFuncSlope[picker][1], 2.0f * (xurand() - 0.5f), 2.0f * (xurand() - 0.5f), 2.0f * (xurand() - 0.5f));
120+
121+
sLFuncEnd[picker] = 0.25f * (xurand() * 0.5f) + (picker + 1);
122+
123+
for (S32 j = 0; j <= picker + 1; j++)
124+
{
125+
F32 prevEnd;
126+
if (picker == 0)
127+
{
128+
i = 9;
129+
prevEnd = 0.0f;
130+
}
131+
else
132+
{
133+
i = picker - 1;
134+
prevEnd = sLFuncEnd[i];
135+
}
136+
137+
xFuncPiece_EndPoints(&sLFuncX[j], prevEnd, sLFuncEnd[j], sLFuncVal[j].x, sLFuncVal[i].x);
138+
xFuncPiece_EndPoints(&sLFuncY[j], prevEnd, sLFuncEnd[j], sLFuncVal[j].y, sLFuncVal[i].y);
139+
xFuncPiece_EndPoints(&sLFuncZ[j], prevEnd, sLFuncEnd[j], sLFuncVal[j].z, sLFuncVal[i].z);
140+
}
141+
142+
sLFuncJerkTime = 0.0f;
143+
}
144+
82145
void zLightningRender()
83146
{
84147
if (sLightningRaster != NULL)

0 commit comments

Comments
 (0)