Advertisement
fig02

Infinite lens + Magic Spell Delay Glitch

Aug 24th, 2023
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.47 KB | None | 0 0
  1. `Player_UseItem` gets called when dins is used, which sets up stuff for `func_8083B040` to run, which handles cutscene items.
  2.  
  3. `func_8083B040` has a check for `BGCHECKFLAG_GROUND`, meaning the player has to be standing on the ground for cutscene items to play. If you have the hoverboots on and are hovering, you are considered to be in the air and your cs item usage will be delayed until you are on the ground.
  4.  
  5. Because a prerequisite to this glitch is having the infinite lens glitch active, `play->actorCtx.lensActive` is set to true. Because of the magic glitch, the magic state is `MAGIC_STATE_IDLE` which allows dins to be used even if lens is active.
  6.  
  7. Every frame that lens is active, the game is checking to see if a cutscene is running. Included in this list of conditions in `Player_InCsMode` is `this->unk_6AD == 4`, which means a cutscene item is queued. Since this unk_6AD value is set to 4 immediately when you press dins, `Actor_DisableLens` gets called on the same frame. When `Actor_DisableLens` runs it sets magic state to `MAGIC_STATE_RESET`.
  8.  
  9. If you press dins on the last frame you are airborn before you hit the ground, you delay the cs item from starting by one frame.
  10. `func_8083B040` will fail to start dins due to the player not standing on the ground. But the player is still in a cs item state. The check for player to be in a cutscene runs during the actor draw routine. So the player is in a cs item state now, but hasnt started the cutscene yet. `Actor_DisableLens` runs and sets the magic state to `MAGIC_STATE_RESET`. Now on the next frame, player is standing on the ground, and the cs item function can run.
  11.  
  12. `func_8083AF44` is called which spawns the magic spell actor and calls `Magic_RequestChange`. This normally sets the magic meter up to flash and show the decrement amount. If the current magic state is `MAGIC_STATE_IDLE` or `MAGIC_STATE_CONSUME_LENS`, `MAGIC_STATE_METER_FLASH_2` gets set, which flashes the magic meter and shows a preview of the magic being depleted. The magic decrement target is also set at this time.
  13.  
  14. HOWEVER, because of the timing of the cutscene item press, `Actor_DisableLens` just set the magic state to `MAGIC_STATE_RESET`. Since this state is not `MAGIC_STATE_IDLE` or `MAGIC_STATE_CONSUME_LENS`, the request to set `MAGIC_STATE_METER_FLASH_2` fails and an error sound is played.
  15.  
  16. However, player sets `MAGIC_STATE_CONSUME_SETUP` on his own regardless if this magic state change is successful or not. He is responsible for signaling when the magic consumption should happen while its flashing. He still does this, not knowing that `MAGIC_STATE_METER_FLASH_2` was never actually successfully set. Since `MAGIC_STATE_METER_FLASH_2` was never set, `gSaveContext.magicTarget` wasn't properly set either. This value is stale.
  17.  
  18. If you are doing this after a fresh reset, this value is 0 and you lose all your magic. It can theoretically be whatever your last magic target value was. If this value is higher than your current magic amount, you still lose all your magic (see the magic usage + pick up magic bug)
  19.  
  20.  
  21. Why this bug is frame perfect:
  22. If the player pressed dins multiple frames before reaching the ground, `Actor_DisableLens` would run too early and the `MAGIC_STATE_RESET` will have transitioned back to `MAGIC_STATE_IDLE` before the dins cutscene starts. If the player pressed dins any time after touching the ground, the cs item func can properly start the dins process before `Actor_DisableLens` ever has a chance to run and interrupt the process.
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement