Skip to content

Commit 75139fb

Browse files
authored
zCombo: Progress (#714)
* zCombo: Progress * Comment comboHUD
1 parent 8826b05 commit 75139fb

File tree

3 files changed

+94
-110
lines changed

3 files changed

+94
-110
lines changed

configure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ def MatchingFor(*versions):
630630
Object(NonMatching, "SB/Game/zNPCGoalAmbient.cpp"),
631631
Object(NonMatching, "SB/Game/zNPCFXCinematic.cpp"),
632632
Object(Equivalent, "SB/Core/x/xHudText.cpp", extra_cflags=["-sym on"]),
633-
Object(NonMatching, "SB/Game/zCombo.cpp"),
633+
Object(NonMatching, "SB/Game/zCombo.cpp", extra_cflags=["-sym on"]),
634634
Object(NonMatching, "SB/Core/x/xCM.cpp"),
635635
],
636636
},

src/SB/Game/zCombo.cpp

Lines changed: 89 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static xVec3 sUnderCamPos;
3535
static ztextbox* sHideText[5];
3636

3737
/* .sbss */
38-
static widget_chunk* comboHUD;
38+
widget_chunk* comboHUD; // TODO: should be externed in the header, but that doesn't show up in objdiff
3939
static zUIFont* sHideUIF;
4040
static S32 comboPending;
4141
static S32 comboLastCounter;
@@ -47,10 +47,10 @@ static F32 comboMaxTime = 1.0f;
4747
static F32 comboDisplayTime = 2.0f;
4848

4949
static zComboReward comboReward[16] = {
50-
{ 0, "", {}, 0, NULL },
5150
{ 0, "INTENTIONALLY BLANK TXT", {}, 0, NULL },
52-
{ 2, "", {}, 0, NULL },
53-
{ 3, "COMBO_01_TXT", {}, 0, NULL },
51+
{ 0, "INTENTIONALLY BLANK TXT", {}, 0, NULL },
52+
{ 2, "COMBO_01_TXT", {}, 0, NULL },
53+
{ 3, "COMBO_02_TXT", {}, 0, NULL },
5454
{ 3, "COMBO_02_TXT", {}, 0, NULL },
5555
{ 5, "COMBO_03_TXT", {}, 0, NULL },
5656
{ 10, "COMBO_04_TXT", {}, 0, NULL },
@@ -65,7 +65,7 @@ static zComboReward comboReward[16] = {
6565
{ 100, "COMBO_13_TXT", {}, 0, NULL },
6666
};
6767

68-
void fillCombo(zComboReward* reward)
68+
static void fillCombo(zComboReward* reward)
6969
{
7070
S32 rewardLeft = reward->reward;
7171
S32 j = 0;
@@ -102,25 +102,6 @@ void fillCombo(zComboReward* reward)
102102
reward->rewardNum = j;
103103
}
104104

105-
void zCombo_Add(S32 points)
106-
{
107-
if (comboTimer < 0.0f)
108-
{
109-
comboTimer = 1.0f;
110-
comboPending = points - 1;
111-
}
112-
else
113-
{
114-
comboTimer = 1.0f;
115-
comboCounter += points;
116-
if (comboPending != 0)
117-
{
118-
comboCounter += comboPending;
119-
comboPending = 0;
120-
}
121-
}
122-
}
123-
124105
void zCombo_Setup()
125106
{
126107
comboCounter = 0;
@@ -173,6 +154,25 @@ void zCombo_Setup()
173154
sHideUIF = (zUIFont*)zSceneFindObject(xStrHash("MNU4 NPCTALK"));
174155
}
175156

157+
void zCombo_Add(S32 points)
158+
{
159+
if (comboTimer < 0.0f)
160+
{
161+
comboTimer = comboMaxTime;
162+
comboPending = points - 1;
163+
}
164+
else
165+
{
166+
comboTimer = comboMaxTime;
167+
comboCounter += points;
168+
if (comboPending != 0)
169+
{
170+
comboCounter += comboPending;
171+
comboPending = 0;
172+
}
173+
}
174+
}
175+
176176
void zComboHideMessage(xhud::widget& w, xhud::motive& motive)
177177
{
178178
w.hide();
@@ -188,113 +188,99 @@ void zCombo_HideImmediately()
188188

189189
void zCombo_Update(F32 dt)
190190
{
191-
F32 temp_f0;
192-
S32 var_r31;
193-
S32 var_r28;
194-
zComboReward* temp_r5;
195-
zComboReward* temp_r3;
196-
zComboReward* temp_r0;
197-
198191
xVec3Copy(&sUnderCamPos, &globals.camera.mat.pos);
199-
200192
xVec3AddScaled(&sUnderCamPos, &globals.camera.mat.up, -3.0f);
201193

202-
var_r31 = comboCounter;
203-
if (comboCounter >= 0x10)
194+
S32 toShow = comboCounter;
195+
if (comboCounter >= 16)
204196
{
205-
var_r31 = 0xf;
197+
toShow = 15;
206198
}
207199

208-
temp_r3 = comboReward;
209-
temp_r5 = &temp_r3[var_r31];
210-
if (comboLastCounter != comboCounter && temp_r5->reward != 0)
200+
zComboReward* c = &comboReward[toShow];
201+
202+
if (comboLastCounter != comboCounter && c->reward != 0)
211203
{
212204
if (comboHUD != NULL)
213205
{
214-
strcpy(comboHUD->w.text, xTextAssetGetText(temp_r5->textAsset));
206+
strcpy(comboHUD->w.text, xTextAssetGetText(c->textAsset));
215207
comboHUD->w.show();
216208
}
217209
comboLastCounter = comboCounter;
218210
}
219211

220-
var_r28 = 0;
221-
do
212+
for (S32 i = 0; i < 5; i++)
222213
{
223-
if (sHideText[var_r28] != NULL && sHideText[var_r28]->visible())
214+
if (sHideText[i] != NULL && sHideText[i]->visible())
224215
{
225-
// null-terminating character
226-
comboHUD->w.text[0] = '\x00';
216+
comboHUD->w.text[0] = '\0';
227217
break;
228218
}
229-
230-
var_r28 += 1;
231-
} while (var_r28 < 5);
219+
}
232220

233221
if (sHideUIF != NULL && xEntIsVisible(sHideUIF))
234222
{
235-
// null-terminating character
236-
comboHUD->w.text[0] = '\x00';
223+
comboHUD->w.text[0] = '\0';
237224
}
238225

239226
if (comboTimer >= 0.0f)
240227
{
241-
temp_f0 = comboTimer - dt;
242-
comboTimer = temp_f0;
243-
244-
temp_r0 = &comboReward[0];
228+
comboTimer -= dt;
245229

246-
if (comboTimer < 0.0f && temp_r0->reward > 0)
230+
if (comboTimer < 0.0f)
247231
{
248-
zEntPickup_SpawnNRewards(comboReward->rewardList, comboReward->rewardNum,
249-
&sUnderCamPos);
250-
251-
switch (var_r31)
232+
if (c->reward > 0)
252233
{
253-
case 5:
254-
zEntPlayer_SNDPlayStreamRandom(0, 1, ePlayerStreamSnd_Combo1,
255-
ePlayerStreamSnd_Combo2, 0.1f);
256-
break;
257-
case 6:
258-
case 7:
259-
zEntPlayer_SNDPlayStreamRandom(0, 2, ePlayerStreamSnd_Combo1,
260-
ePlayerStreamSnd_Combo2, 0.1f);
261-
break;
262-
case 8:
263-
case 9:
264-
zEntPlayer_SNDPlayStreamRandom(0, 3, ePlayerStreamSnd_Combo1,
265-
ePlayerStreamSnd_Combo2, 0.1f);
266-
break;
267-
case 10:
268-
zEntPlayer_SNDPlayStreamRandom(0, 4, ePlayerStreamSnd_Combo1,
269-
ePlayerStreamSnd_Combo2, 0.1f);
270-
break;
271-
case 11:
272-
case 12:
273-
zEntPlayer_SNDPlayStreamRandom(0, 5, ePlayerStreamSnd_Combo1,
274-
ePlayerStreamSnd_Combo2, 0.1f);
275-
zEntPlayer_SNDPlayStreamRandom(6, 50, ePlayerStreamSnd_Combo1,
276-
ePlayerStreamSnd_Combo5, 0.1f);
277-
break;
278-
case 13:
279-
zEntPlayer_SNDPlayStreamRandom(0, 10, ePlayerStreamSnd_BigCombo1,
280-
ePlayerStreamSnd_BigCombo2, 0.1f);
281-
zEntPlayer_SNDPlayStream(11, 100, ePlayerStreamSnd_BigCombo1, 0x0);
282-
break;
283-
case 14:
284-
zEntPlayer_SNDPlayStreamRandom(0, 10, ePlayerStreamSnd_BigCombo1,
285-
ePlayerStreamSnd_BigCombo2, 0.1f);
286-
zEntPlayer_SNDPlayStream(21, 100, ePlayerStreamSnd_BigCombo1, 0x0);
287-
break;
288-
case 15:
289-
zEntPlayer_SNDPlayStream(0, 100, ePlayerStreamSnd_BigCombo2, 0x0);
290-
break;
291-
}
292-
293-
if (comboHUD != NULL)
294-
{
295-
comboHUD->w.add_motive(xhud::motive(NULL, 0.0f, comboDisplayTime, (F32)0.0f,
296-
xhud::delay_motive_update,
297-
(void*)zComboHideMessage));
234+
zEntPickup_SpawnNRewards(c->rewardList, c->rewardNum, &sUnderCamPos);
235+
236+
switch (toShow)
237+
{
238+
case 5:
239+
zEntPlayer_SNDPlayStreamRandom(0, 1, ePlayerStreamSnd_Combo1,
240+
ePlayerStreamSnd_Combo2, 0.1f);
241+
break;
242+
case 6:
243+
case 7:
244+
zEntPlayer_SNDPlayStreamRandom(0, 2, ePlayerStreamSnd_Combo1,
245+
ePlayerStreamSnd_Combo2, 0.1f);
246+
break;
247+
case 8:
248+
case 9:
249+
zEntPlayer_SNDPlayStreamRandom(0, 3, ePlayerStreamSnd_Combo1,
250+
ePlayerStreamSnd_Combo2, 0.1f);
251+
break;
252+
case 10:
253+
zEntPlayer_SNDPlayStreamRandom(0, 4, ePlayerStreamSnd_Combo1,
254+
ePlayerStreamSnd_Combo2, 0.1f);
255+
break;
256+
case 11:
257+
case 12:
258+
zEntPlayer_SNDPlayStreamRandom(0, 5, ePlayerStreamSnd_Combo1,
259+
ePlayerStreamSnd_Combo2, 0.1f);
260+
zEntPlayer_SNDPlayStreamRandom(6, 50, ePlayerStreamSnd_Combo1,
261+
ePlayerStreamSnd_Combo5, 0.1f);
262+
break;
263+
case 13:
264+
zEntPlayer_SNDPlayStreamRandom(0, 10, ePlayerStreamSnd_BigCombo1,
265+
ePlayerStreamSnd_BigCombo2, 0.1f);
266+
zEntPlayer_SNDPlayStream(11, 100, ePlayerStreamSnd_BigCombo1, 0x0);
267+
break;
268+
case 14:
269+
zEntPlayer_SNDPlayStreamRandom(0, 10, ePlayerStreamSnd_BigCombo1,
270+
ePlayerStreamSnd_BigCombo2, 0.1f);
271+
zEntPlayer_SNDPlayStream(21, 100, ePlayerStreamSnd_BigCombo1, 0x0);
272+
break;
273+
case 15:
274+
zEntPlayer_SNDPlayStream(0, 100, ePlayerStreamSnd_BigCombo2, 0x0);
275+
break;
276+
}
277+
278+
if (comboHUD != NULL)
279+
{
280+
comboHUD->w.add_motive(xhud::motive(NULL, 0.0f, comboDisplayTime, 0.0f,
281+
xhud::delay_motive_update,
282+
(void*)zComboHideMessage));
283+
}
298284
}
299285

300286
comboTimer = -1.0f;
@@ -303,8 +289,3 @@ void zCombo_Update(F32 dt)
303289
}
304290
}
305291
}
306-
307-
bool ztextbox::visible()
308-
{
309-
return this->flag.visible;
310-
}

src/SB/Game/zTextBox.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ struct ztextbox : xBase
9797
void clear_text();
9898
void refresh();
9999
void get_text(char* buffer, size_t buffer_size) const;
100-
bool visible();
100+
bool visible()
101+
{
102+
return this->flag.visible;
103+
}
101104
};
102105

103106
#endif

0 commit comments

Comments
 (0)