Skip to content

Fix magicFillTarget getting lowered if dying during refill#2577

Open
djevangelia wants to merge 4 commits into
OoTRandomizer:Devfrom
djevangelia:kaleidomagic
Open

Fix magicFillTarget getting lowered if dying during refill#2577
djevangelia wants to merge 4 commits into
OoTRandomizer:Devfrom
djevangelia:kaleidomagic

Conversation

@djevangelia
Copy link
Copy Markdown

Don't change magicFillTarget if player dies during magic fill. Fixes #1618.

When player dies, the magic fill target when respawning is set to current magic, and current magic is then set to 0. If player respawns and dies before magic is fully refilled, the fill target will be changed to player's current magic again, i.e. less than previous target.

This fix checks on game over if player is currently in a refill state: either FILL state, drawing the magic bar extending (STEP_CAPACITY), or has a magicLevel of 0 (set when dying, reset early when starting magic refill). If so, it does not overwrite the old fill target.

The assembly should roughly be equal to:

if (gSaveContext.magicState != MAGIC_STATE_FILL && gSaveContext.magicState != MAGIC_STATE_STEP_CAPACITY &&
    gSaveContext.save.info.playerData.magicLevel != 0) {
    gSaveContext.magicFillTarget = gSaveContext.save.info.playerData.magic;
}
gSaveContext.magicCapacity = 0;
gSaveContext.save.info.playerData.magicLevel = gSaveContext.save.info.playerData.magic = 0;

where the gSaveContext.magicFillTarget was previously always set.

Disassembly

Part of matching Kaleidoscope_Update disassembly here (it's 2500+ lines long in full)
Decomp C code here

Testing

Tested in Ares recently nightly build and Project64 3.0.1.
Looks like this: https://www.youtube.com/watch?v=s4WrGXN75-E

Instant death function for testing:

func_80837B18 = 0x8038e5b4;
extern int32_t func_80837B18(z64_game_t* play, z64_link_t* this, int32_t damage);
if (z64_game.common.input[0].raw.pad.dr) {
    func_80837B18(&z64_game, &z64_link, -200);
}

@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 May 16, 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.

Queued Ice traps on OHKO can lead to the Magic Meter not being refilled properly after death

2 participants