From 83a13a64c710e8a0e418ec469c2550ebfb9ca345 Mon Sep 17 00:00:00 2001 From: fig02 Date: Tue, 19 Sep 2023 13:23:56 -0400 Subject: [PATCH] Document niche magic spell bug (#1526) * document magic spell bug * Update src/overlays/actors/ovl_player_actor/z_player.c Co-authored-by: Dragorn421 * adjust comment * fix renamed func and reformat --------- Co-authored-by: Dragorn421 --- src/overlays/actors/ovl_player_actor/z_player.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index 39e9156956..7519787dea 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -5239,6 +5239,14 @@ void func_8083AF44(PlayState* play, Player* this, s32 magicSpell) { func_80835DE4(play, this, Player_Action_808507F4, 0); this->actionVar1 = magicSpell - 3; + + //! @bug `MAGIC_CONSUME_WAIT_PREVIEW` is not guaranteed to succeed. + //! Ideally, the return value of `Magic_RequestChange` should be checked before allowing the process of + //! using a spell to continue. If the magic state change request fails, `gSaveContext.magicTarget` will + //! never be set correctly. + //! When `MAGIC_STATE_CONSUME_SETUP` is set in `Player_Action_808507F4`, magic will eventually be + //! consumed to a stale target value. If that stale target value is higher than the current + //! magic value, it will be consumed to zero. Magic_RequestChange(play, sMagicSpellCosts[magicSpell], MAGIC_CONSUME_WAIT_PREVIEW); LinkAnimation_PlayOnceSetSpeed(play, &this->skelAnime, &gPlayerAnim_link_magic_tame, 0.83f);