Skip to content

Fix ice traps locking magic if casting#2556

Open
djevangelia wants to merge 3 commits into
OoTRandomizer:Devfrom
djevangelia:mwmagic
Open

Fix ice traps locking magic if casting#2556
djevangelia wants to merge 3 commits into
OoTRandomizer:Devfrom
djevangelia:mwmagic

Conversation

@djevangelia

Copy link
Copy Markdown

Reset the magic state upon getting hit by something that freezes or electrifies. Fixes #752.

If Player_Action_CastMagicSpell is interrupted (with a change in action function) before magicState is changed from pre-consume state MAGIC_STATE_METER_FLASH_2 to MAGIC_STATE_CONSUME_SETUP, player is stuck in this magic pre-consume state which prevents using magic but also cannot continue to a consume state by itself.
This is vanilla, but not noticed because it's difficult or maybe impossible to get interrupted. By sending an ice trap to another player who is casting, the player gets interrupted and may get stuck in this magic state. This is also true for eletric hit.

It is solved here by adding a function to call vanilla function Magic_Reset upon receiving a frozen or eletric hit (under Player_SetupAction in https://github.com/djevangelia/oot/blob/oot-docu/src/overlays/actors/ovl_player_actor/z_player.c#L5135, lines 5164 and 5174). However, some extra notes:

  • Do not reset magic if magicState is MAGIC_STATE_METER_FLASH_1 because if it is Nayru's love, player will now be able to cast during Nayru and crash.
  • Theoretically, a player could receive an ice trap while getting magic refill, and other unlikely cases. Because of that I've chosen to only reset if state is MAGIC_STATE_METER_FLASH_2 because it's the problematic one here.
  • Farore's Wind has about a 10 frame delay between consuming magic and actually working (setting respawn data). This results in a window where interrupt leads to magic lost without effect. Therefore I have moved the magic consume forward to the same place where respawn point is set. This has no visual or gameplay impact and I believe it's a milder change than the opposite, in line with when players would expect magic to be consumed. It's still a change that would affect all Farore's Wind casts for seeds where this fix is applied, though. (See https://github.com/djevangelia/oot/blob/oot-docu/src/overlays/actors/ovl_player_actor/z_player.c#L16174 - the magicState change on line 16208 is now in the end of 16231 for Farore.)
  • If one wants to tailor individual cases, it's possible to do checks for player->actionFunc and then player->av1.actionVar1 for which spell and player->av2.actionVar2 to find out where the player is in the casting sequence. For that you would need to do the check before Player_SetupAction is called, however.

Testing

Tested in Ares 1.47, Project64 3.0.1 and Mupen64plus 2.8. Calling same function as ice trap on button press (z64_LinkDamage(&z64_game, &z64_link, 0x03, 0, 0, 0x14)).
https://www.youtube.com/watch?v=jToBDh4jGis (ignore that the Farore's pointer flies away, it's because I'm using the debug menu)
Also tested getting electrified. Spin attack doesn't seem affected by this in the first place but seems to work too.

@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 Apr 19, 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.

Multiworld: Recieving an Ice Trap while mid-cast of Farore's Wind breaks ability to use Magic

2 participants