From 6e8102e46929bfc73048ede2a5a0595ba584f3cc Mon Sep 17 00:00:00 2001 From: Josh Sanchez Date: Mon, 3 Mar 2025 21:53:20 -0600 Subject: [PATCH 1/6] zCombo: Include zEntPickup to use zEntPickup_SpawnNRewards method --- src/SB/Game/zCombo.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SB/Game/zCombo.h b/src/SB/Game/zCombo.h index f6c00beef..3b1f3173b 100644 --- a/src/SB/Game/zCombo.h +++ b/src/SB/Game/zCombo.h @@ -4,6 +4,7 @@ #include #include "xFont.h" #include "xHud.h" +#include "zEntPickup.h" void zCombo_Setup(); void zCombo_Add(int); From b5af1ac1be2dd3f6362880411ad46e4163c5b9dd Mon Sep 17 00:00:00 2001 From: Josh Sanchez Date: Mon, 3 Mar 2025 21:53:44 -0600 Subject: [PATCH 2/6] xHud: Add delay_motive_update to header --- src/SB/Core/x/xHud.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SB/Core/x/xHud.h b/src/SB/Core/x/xHud.h index 368e0f72a..9b6b015ba 100644 --- a/src/SB/Core/x/xHud.h +++ b/src/SB/Core/x/xHud.h @@ -198,6 +198,7 @@ namespace xhud bool linear_motive_update(widget& w, motive& m, F32); bool accelerate_motive_update(widget& w, motive& m, F32); + bool delay_motive_update(widget& w, motive& m, F32); xModelInstance* load_model(U32); }; // namespace xhud From 21d7fc688adf1e557945647b48dd29dbb837ec84 Mon Sep 17 00:00:00 2001 From: Josh Sanchez Date: Mon, 3 Mar 2025 21:54:34 -0600 Subject: [PATCH 3/6] zCombo: Fix incorrect static data types --- src/SB/Game/zCombo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SB/Game/zCombo.cpp b/src/SB/Game/zCombo.cpp index 9aa396069..fc81a5903 100644 --- a/src/SB/Game/zCombo.cpp +++ b/src/SB/Game/zCombo.cpp @@ -32,11 +32,11 @@ struct widget_chunk : xBase /* .bss */ static xVec3 sUnderCamPos; -static xtextbox * sHideText[5]; +static ztextbox* sHideText[5]; /* .sbss */ static widget_chunk* comboHUD; -static zUIFont* sHideUIF[1]; +static zUIFont* sHideUIF; static S32 comboPending; static S32 comboLastCounter; static S32 comboCounter; From e5e6c28152add656c87607756271a91c968a986e Mon Sep 17 00:00:00 2001 From: Josh Sanchez Date: Mon, 3 Mar 2025 21:54:53 -0600 Subject: [PATCH 4/6] zCombo: 94% objdiff match on comboReward static data init --- src/SB/Game/zCombo.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/SB/Game/zCombo.cpp b/src/SB/Game/zCombo.cpp index fc81a5903..c07f1d45a 100644 --- a/src/SB/Game/zCombo.cpp +++ b/src/SB/Game/zCombo.cpp @@ -46,7 +46,14 @@ static F32 comboTimer; static F32 comboMaxTime = 1.0f; static F32 comboDisplayTime = 2.0f; -extern zComboReward comboReward[16]; +static zComboReward comboReward[16] = { + { 0, "", {}, 0, NULL }, { 0, "", {}, 0, NULL }, { 2, "", {}, 0, NULL }, + { 3, "", {}, 0, NULL }, { 3, "", {}, 0, NULL }, { 5, "", {}, 0, NULL }, + { 10, "", {}, 0, NULL }, { 15, "", {}, 0, NULL }, { 20, "", {}, 0, NULL }, + { 25, "", {}, 0, NULL }, { 30, "", {}, 0, NULL }, { 40, "", {}, 0, NULL }, + { 50, "", {}, 0, NULL }, { 60, "", {}, 0, NULL }, { 75, "", {}, 0, NULL }, + { 100, "", {}, 0, NULL }, +}; void fillCombo(zComboReward* reward) { From b889e21657b1c83aa9e142736070e77b864e20fa Mon Sep 17 00:00:00 2001 From: Josh Sanchez Date: Mon, 3 Mar 2025 21:55:46 -0600 Subject: [PATCH 5/6] zCombo: zCombo_Update 94% code match --- src/SB/Game/zCombo.cpp | 117 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) diff --git a/src/SB/Game/zCombo.cpp b/src/SB/Game/zCombo.cpp index c07f1d45a..7c3f20ff4 100644 --- a/src/SB/Game/zCombo.cpp +++ b/src/SB/Game/zCombo.cpp @@ -224,6 +224,123 @@ void zCombo_HideImmediately() } } +void zCombo_Update(F32 dt) +{ + F32 temp_f0; + S32 var_r31; + S32 var_r28; + zComboReward* temp_r5; + zComboReward* temp_r3; + zComboReward* temp_r0; + + xVec3Copy(&sUnderCamPos, &globals.camera.mat.pos); + + xVec3AddScaled(&sUnderCamPos, &globals.camera.mat.up, -3.0f); + + var_r31 = comboCounter; + if (comboCounter >= 0x10) + { + var_r31 = 0xf; + } + + temp_r3 = comboReward; + temp_r5 = &temp_r3[var_r31]; + if (comboLastCounter != comboCounter && temp_r5->reward != 0) + { + if (comboHUD != NULL) + { + strcpy(comboHUD->w.text, xTextAssetGetText(temp_r5->textAsset)); + comboHUD->w.show(); + } + comboLastCounter = comboCounter; + } + + var_r28 = 0; + do + { + if (sHideText[var_r28] != NULL && sHideText[var_r28]->visible()) + { + // null-terminating character + comboHUD->w.text[0] = '\x00'; + break; + } + + var_r28 += 1; + } while (var_r28 < 5); + + if (sHideUIF != NULL && xEntIsVisible(sHideUIF)) + { + // null-terminating character + comboHUD->w.text[0] = '\x00'; + } + + if (comboTimer >= 0.0f) + { + temp_f0 = comboTimer - dt; + comboTimer = temp_f0; + + temp_r0 = &comboReward[0]; + + if (comboTimer < 0.0f && temp_r0->reward > 0) + { + zEntPickup_SpawnNRewards(comboReward->rewardList, comboReward->rewardNum, &sUnderCamPos); + + switch (var_r31) + { + case 5: + zEntPlayer_SNDPlayStreamRandom(0, 1, ePlayerStreamSnd_Combo1, ePlayerStreamSnd_Combo2, + 0.1f); + break; + case 6: + case 7: + zEntPlayer_SNDPlayStreamRandom(0, 2, ePlayerStreamSnd_Combo1, ePlayerStreamSnd_Combo2, + 0.1f); + break; + case 8: + case 9: + zEntPlayer_SNDPlayStreamRandom(0, 3, ePlayerStreamSnd_Combo1, ePlayerStreamSnd_Combo2, + 0.1f); + break; + case 10: + zEntPlayer_SNDPlayStreamRandom(0, 4, ePlayerStreamSnd_Combo1, ePlayerStreamSnd_Combo2, + 0.1f); + break; + case 11: + case 12: + zEntPlayer_SNDPlayStreamRandom(0, 5, ePlayerStreamSnd_Combo1, ePlayerStreamSnd_Combo2, + 0.1f); + zEntPlayer_SNDPlayStreamRandom(6, 50, ePlayerStreamSnd_Combo1, ePlayerStreamSnd_Combo5, + 0.1f); + break; + case 13: + zEntPlayer_SNDPlayStreamRandom(0, 10, ePlayerStreamSnd_BigCombo1, + ePlayerStreamSnd_BigCombo2, 0.1f); + zEntPlayer_SNDPlayStream(11, 100, ePlayerStreamSnd_BigCombo1, 0x0); + break; + case 14: + zEntPlayer_SNDPlayStreamRandom(0, 10, ePlayerStreamSnd_BigCombo1, + ePlayerStreamSnd_BigCombo2, 0.1f); + zEntPlayer_SNDPlayStream(21, 100, ePlayerStreamSnd_BigCombo1, 0x0); + break; + case 15: + zEntPlayer_SNDPlayStream(0, 100, ePlayerStreamSnd_BigCombo2, 0x0); + break; + } + + if (comboHUD != NULL) + { + comboHUD->w.add_motive(xhud::motive(NULL, comboDisplayTime, (F32)0.0f, (F32)0.0f, + xhud::delay_motive_update, (void*)zComboHideMessage)); + } + + comboTimer = -1.0f; + comboCounter = 0; + comboLastCounter = 0; + } + + } +} + bool ztextbox::visible() { return this->flag.visible; From a1e6f6299571d4e00136b413a9658e24f79fd27f Mon Sep 17 00:00:00 2001 From: Josh Sanchez Date: Mon, 3 Mar 2025 21:56:04 -0600 Subject: [PATCH 6/6] zCombo: Clang-format pass --- src/SB/Game/zCombo.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SB/Game/zCombo.cpp b/src/SB/Game/zCombo.cpp index 7c3f20ff4..55ed15227 100644 --- a/src/SB/Game/zCombo.cpp +++ b/src/SB/Game/zCombo.cpp @@ -92,9 +92,9 @@ void fillCombo(zComboReward* reward) reward->rewardNum = j; } -void zCombo_Add(S32 arg0) +void zCombo_Add(S32 arg0) { - if (comboTimer < 0.0f) + if (comboTimer < 0.0f) { comboTimer = comboMaxTime; comboPending = arg0 - 1; @@ -102,7 +102,7 @@ void zCombo_Add(S32 arg0) } comboTimer = comboMaxTime; comboCounter += arg0; - if ((S32) comboPending != 0) + if ((S32)comboPending != 0) { comboCounter += comboPending; comboPending = 0;