Advertisement
fig02

using a new held item

Aug 19th, 2023
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.63 KB | None | 0 0
  1. Starting from the very top of an update cycle: Player_UpdateCommon -> actionFunc (func674) -> maybe subActionFunc (D_80854448)
  2.  
  3. Within specific actions (main or sub) , they will call Player_UpdateUpperBody in contexts where links upper body is allowed to do something else from the main body.
  4.  
  5. Player_UpdateUpperBody is constantly calling Player_CanUpdateItems which checks baseline conditions that allow the player to change or use items.
  6. If the player is allowed to change an item on this frame, Player_UpdateItems is called.
  7.  
  8. Player_UpdateItems has even more conditions that can block using or changing items. If all of the conditions here are met, Player_ItemHandler is called. Player_UpdateItems will be important again later for the item change process.
  9.  
  10. Player_ItemHandler mainly listens for the player to press the B or C buttons, and properly respond. It also checks the item and masks currently in use and sees if they are on a C button. If an item is in use but not on a C button, it is automatically put away.
  11. If a item button is pressed, Player_UseItem is called.
  12.  
  13. Player_UseItem is a large and complicated function. This has a lot of checks to see if you are able to use certain items. It will handle blocking an item usage if its not appropriate and will play the error sound. Many item id ranges are used to handle items in different ways.
  14. If an item is a held item, it makes it to the bottom of this function where there are two paths.
  15.  
  16. If an item is not currently in links hand, the heldItemId is updated and PLAYER_STATE1_START_CHANGING_HELD_ITEM is set. This will jump-start the item change process on the next frame.
  17.  
  18. On the next frame when Player_UpdateItems runs (assuming it can), if PLAYER_STATE1_START_CHANGING_HELD_ITEM is set, it will skip calling Player_ItemHandler on this frame and run Player_StartChangingHeldItem instead.
  19.  
  20. Player_StartChangingHeldItem sets the correct item change anim to play based on the model group that corresponds to the item. It also sets Player_IA_ChangeHeldItem as the current item action function.
  21.  
  22. Player_IA_ChangeHeldItem updates the upper body skelanime to play the putaway/takeout animation. Player_WaitToFinishItemChange is also called every frame in this action, checking for the item change frame in sItemChangeInfo. When it hits the right frame, Player_FinishItemChange is run.
  23.  
  24. Player_FinishItemChange handles playing the sword takeout/putaway sound, or the generic item takeout/putaway sound. It also calls Player_UseItem for the new item that was just taken out.
  25.  
  26. This time in Player_UseItem, since the item id of the requested item matches heldItemid, the item is ready to be initialized. Player_InitItemActionWithAnim is called which changes links current animation to match the animgroup that belongs to the new item. Then that calls Player_InitItemAction which initializes related variables and calls the ItemActionInitFunc.
  27.  
  28. At this point the upper body change animation has not finished. Player_IA_ChangeHeldItem is still the current itemActionFunc. When the change animation is done, Player_SetItemActionFunc is called with the correct update func for the new item action. The update func is called on this frame to let it update on the first frame its out.
  29. At this point, the item may or may not be used instantly when it is pulled out. This depends on sUseHeldItem. If sUseHeldItem is set to true before the item change is done or if the model animtype is not 3 (stick/bgs/hammer), the item will be used right away.
  30.  
  31. After this point, the item update process is done and Player_UpdateUpperBody will call the itemActionFunc to update for the item until a new item is taken out or the current item is put away.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement