Skip to content

Prevent magic add during spellcast from consuming all magic#2589

Open
djevangelia wants to merge 2 commits into
OoTRandomizer:Devfrom
djevangelia:magicadd
Open

Prevent magic add during spellcast from consuming all magic#2589
djevangelia wants to merge 2 commits into
OoTRandomizer:Devfrom
djevangelia:magicadd

Conversation

@djevangelia

Copy link
Copy Markdown

When adding magic, check current magic state and adjust both magic and magicTarget if needed. Fixes #2106.

See issue for further information. This checks for current magic state (or previous, if current is fill) and if applicable state - just instantly add the requested add amount to both magic and magicTarget, adjusting if necessary if result > capacity.

When consuming, it will also check if current magic - 2 = target, which is only possible if current magic was equal to target when starting the consume. Then, it will re-add those two points. This is a bit ugly and I can't remember if there was a specific reason why I checked this after the consume.

Testing

Tested in Ares recent nightly build. Tested together with previous fix for magic getting locked if frozen during spellcast.
Looks like this: https://www.youtube.com/watch?v=HbBx_z9MJ_I
Testing using button binds because I couldn't recreate the original bug report (magic jar picked up during cast). Also tested drinking potion and Great Fairy refill.

extern void Magic_Fill(z64_game_t* play);
extern int32_t Magic_RequestChange(z64_game_t* play, int16_t amount, int16_t type);

Magic_RequestChange = 0x80072588;
Magic_Fill = 0x80072500;

if (z64_game.common.input[0].pad_pressed.cu) {
    Magic_Fill(play);
    Magic_RequestChange(play, 12, 5);
}
if (z64_game.common.input[0].pad_pressed.cd) {
    z64_file.magic -= 12;
}

@fenhl fenhl added Type: Bug Something isn't working Component: ASM/C Changes some internals of the ASM/C libraries Status: Needs Review Someone should be looking at it labels Jun 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: ASM/C Changes some internals of the ASM/C libraries Status: Needs Review Someone should be looking at it Type: Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using a magic item (e.g. spells) on the same frame you collect a magic refill will completely drain the magic meter

2 participants