Skip to content

Commit

Permalink
[Enhancement] Adds fix to play correct audio when collecting the 4th …
Browse files Browse the repository at this point in the history
…piece of a heart container (HarbourMasters#865)

* [Enhancement] Adds fix to play correct audio when collecting the 4th piece of a heart container

* Addresses review comments
  • Loading branch information
lscholte authored Nov 23, 2024
1 parent 8c8b9ad commit 7c222f9
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 3 deletions.
5 changes: 5 additions & 0 deletions mm/2s2h/BenGui/BenMenuBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,11 @@ void DrawEnhancementsMenu() {
{ .tooltip = "Fixes a bug that results in the Ikana Great Fairy fountain looking "
"green instead of yellow, this was fixed in the EU version" });

UIWidgets::CVarCheckbox("Fix Completed Heart Container Audio",
"gEnhancements.Fixes.CompletedHeartContainerAudio",
{ .tooltip = "Fixes a bug that results in the wrong audio playing upon "
"receiving a 4th piece of heart to fill a new heart container." });

if (UIWidgets::CVarCheckbox(
"Fix Texture overflow OOB", "gEnhancements.Fixes.FixTexturesOOB",
{ .tooltip = "Fixes textures that normally overflow to be patched with the correct size or format",
Expand Down
6 changes: 5 additions & 1 deletion mm/2s2h/BenGui/SearchableMenuItems.h
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,11 @@ void AddEnhancements() {
.widgetTooltip = "Fixes textures that normally overflow to be patched with the correct size or format",
.widgetType = WIDGET_CVAR_CHECKBOX,
.widgetOptions = { .defaultVariant = true },
.widgetCallback = [](widgetInfo& info) { GfxPatcher_ApplyOverflowTexturePatches(); } } } } });
.widgetCallback = [](widgetInfo& info) { GfxPatcher_ApplyOverflowTexturePatches(); } },
{ "Fix Completed Heart Container Audio", "gEnhancements.Fixes.CompletedHeartContainerAudio",
"Fixes a bug that results in the wrong audio playing upon receiving a 4th piece of heart to "
"fill a new heart container.",
WIDGET_CVAR_CHECKBOX } } } });
enhancementsSidebar.push_back(
{ "Restorations",
3,
Expand Down
1 change: 1 addition & 0 deletions mm/2s2h/Enhancements/Enhancements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ void InitEnhancements() {
// Fixes
RegisterFierceDeityZTargetMovement();
RegisterTwoHandedSwordSpinAttack();
RegisterCompletedHeartContainerAudio();

// Graphics
RegisterDisableBlackBars();
Expand Down
16 changes: 16 additions & 0 deletions mm/2s2h/Enhancements/Fixes/CompletedHeartContainerAudio.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <libultraship/bridge.h>
#include "2s2h/GameInteractor/GameInteractor.h"

extern "C" {
#include "variables.h"
}

void RegisterCompletedHeartContainerAudio() {
REGISTER_VB_SHOULD(VB_PLAY_HEART_CONTAINER_GET_FANFARE, {
GetItemId getItemId = (GetItemId)va_arg(args, int);
if (CVarGetInteger("gEnhancements.Fixes.CompletedHeartContainerAudio", 0) && getItemId == GI_HEART_PIECE &&
GET_QUEST_HEART_PIECE_COUNT == 0) {
*should = true;
}
});
}
1 change: 1 addition & 0 deletions mm/2s2h/Enhancements/Fixes/Fixes.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef ENHANCEMENTS_FIXES_H
#define ENHANCEMENTS_FIXES_H

void RegisterCompletedHeartContainerAudio();
void RegisterFierceDeityZTargetMovement();

#endif // ENHANCEMENTS_FIXES_H
1 change: 1 addition & 0 deletions mm/2s2h/GameInteractor/GameInteractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ typedef enum {
VB_CHECK_HELD_ITEM_BUTTON_PRESS,
VB_MAGIC_SPIN_ATTACK_CHECK_FORM,
VB_TRANSFORM_THUNDER_MATRIX,
VB_PLAY_HEART_CONTAINER_GET_FANFARE,
VB_BE_HOOKSHOT_SURFACE,
} GIVanillaBehavior;

Expand Down
5 changes: 3 additions & 2 deletions mm/src/overlays/actors/ovl_player_actor/z_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -13521,8 +13521,9 @@ s32 func_808482E0(PlayState* play, Player* this) {
} else {
s32 seqId;

if ((this->getItemId == GI_HEART_CONTAINER) ||
((this->getItemId == GI_HEART_PIECE) && EQ_MAX_QUEST_HEART_PIECE_COUNT)) {
bool vanillaCondition = (this->getItemId == GI_HEART_CONTAINER) ||
((this->getItemId == GI_HEART_PIECE) && EQ_MAX_QUEST_HEART_PIECE_COUNT);
if (GameInteractor_Should(VB_PLAY_HEART_CONTAINER_GET_FANFARE, vanillaCondition, this->getItemId)) {
seqId = NA_BGM_GET_HEART | 0x900;
} else {
s32 var_v1;
Expand Down

0 comments on commit 7c222f9

Please sign in to comment.