Enhancements for equipping magic arrows (#1022)

Skip Magic Arrow Equip Animation, Equip Multiple Arrows at Once
This commit is contained in:
lilDavid 2022-11-07 02:05:56 -06:00 committed by GitHub
commit e170407517
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 60 additions and 15 deletions

View file

@ -127,8 +127,8 @@ s32 func_80834A2C(Player* this, PlayState* play);
s32 func_80834B5C(Player* this, PlayState* play);
s32 func_80834C74(Player* this, PlayState* play);
s32 func_8083501C(Player* this, PlayState* play);
s32 func_808351D4(Player* this, PlayState* play);
s32 func_808353D8(Player* this, PlayState* play);
s32 func_808351D4(Player* this, PlayState* play); // Arrow nocked
s32 func_808353D8(Player* this, PlayState* play); // Aiming in first person
s32 func_80835588(Player* this, PlayState* play);
s32 func_808356E8(Player* this, PlayState* play);
s32 func_80835800(Player* this, PlayState* play);
@ -2167,6 +2167,7 @@ void func_80834298(Player* this, PlayState* play) {
}
}
// Determine projectile type for bow or slingshot
s32 func_80834380(PlayState* play, Player* this, s32* itemPtr, s32* typePtr) {
if (LINK_IS_ADULT) {
*itemPtr = ITEM_BOW;
@ -2189,6 +2190,7 @@ s32 func_80834380(PlayState* play, Player* this, s32* itemPtr, s32* typePtr) {
}
}
// The player has pressed the bow or hookshot button
s32 func_8083442C(Player* this, PlayState* play) {
s32 item;
s32 arrowType;
@ -2502,6 +2504,7 @@ s32 func_8083501C(Player* this, PlayState* play) {
return 1;
}
// Fire the projectile
s32 func_808350A4(PlayState* play, Player* this) {
s32 item;
s32 arrowType;
@ -3012,7 +3015,10 @@ void func_80835F44(PlayState* play, Player* this, s32 item) {
if ((this->heldItemActionParam >= 0) && (Player_ActionToMagicSpell(this, actionParam) < 0) &&
(item != this->heldItemId) &&
(D_80854164[gPlayerModelTypes[this->modelGroup][PLAYER_MODELGROUPENTRY_ANIM]][nextAnimType] !=
PLAYER_D_808540F4_0)) {
PLAYER_D_808540F4_0) &&
(!CVar_GetS32("gSeparateArrows", 0) ||
actionParam < PLAYER_AP_BOW || actionParam > PLAYER_AP_BOW_0E ||
this->heldItemActionParam < PLAYER_AP_BOW || this->heldItemActionParam > PLAYER_AP_BOW_0E)) {
this->heldItemId = item;
this->stateFlags1 |= PLAYER_STATE1_8;
} else {

View file

@ -577,18 +577,22 @@ void KaleidoScope_SetupItemEquip(PlayState* play, u16 item, u16 slot, s16 animX,
sEquipMoveTimer = 10;
if ((pauseCtx->equipTargetItem == ITEM_ARROW_FIRE) || (pauseCtx->equipTargetItem == ITEM_ARROW_ICE) ||
(pauseCtx->equipTargetItem == ITEM_ARROW_LIGHT)) {
u16 index = 0;
if (pauseCtx->equipTargetItem == ITEM_ARROW_ICE) {
index = 1;
if (CVar_GetS32("gSkipArrowAnimation", 0)) {
Audio_PlaySoundGeneral(NA_SE_SY_DECIDE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
} else {
u16 index = 0;
if (pauseCtx->equipTargetItem == ITEM_ARROW_ICE) {
index = 1;
}
if (pauseCtx->equipTargetItem == ITEM_ARROW_LIGHT) {
index = 2;
}
Audio_PlaySoundGeneral(NA_SE_SY_SET_FIRE_ARROW + index, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
pauseCtx->equipTargetItem = 0xBF + index;
sEquipState = 0;
pauseCtx->equipAnimAlpha = 0;
sEquipMoveTimer = 6;
}
if (pauseCtx->equipTargetItem == ITEM_ARROW_LIGHT) {
index = 2;
}
Audio_PlaySoundGeneral(NA_SE_SY_SET_FIRE_ARROW + index, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
pauseCtx->equipTargetItem = 0xBF + index;
sEquipState = 0;
pauseCtx->equipAnimAlpha = 0;
sEquipMoveTimer = 6;
} else {
Audio_PlaySoundGeneral(NA_SE_SY_DECIDE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
}
@ -784,7 +788,9 @@ void KaleidoScope_UpdateItemEquip(PlayState* play) {
if (D_8082A488 == 0) {
pauseCtx->equipTargetItem -= 0xBF - ITEM_BOW_ARROW_FIRE;
pauseCtx->equipTargetSlot = SLOT_BOW;
if (!CVar_GetS32("gSeparateArrows", 0)) {
pauseCtx->equipTargetSlot = SLOT_BOW;
}
sEquipMoveTimer = 6;
WREG(90) = 320;
WREG(87) = WREG(91);
@ -853,6 +859,26 @@ void KaleidoScope_UpdateItemEquip(PlayState* play) {
osSyncPrintf("\n\n");
// Skipping the arrow animation: need to change the item's type and
// slot when it hits the button since it didn't get set earlier
if (pauseCtx->equipTargetItem == ITEM_ARROW_FIRE || pauseCtx->equipTargetItem == ITEM_ARROW_ICE ||
pauseCtx->equipTargetItem == ITEM_ARROW_LIGHT) {
switch (pauseCtx->equipTargetItem) {
case ITEM_ARROW_FIRE:
pauseCtx->equipTargetItem = ITEM_BOW_ARROW_FIRE;
break;
case ITEM_ARROW_ICE:
pauseCtx->equipTargetItem = ITEM_BOW_ARROW_ICE;
break;
case ITEM_ARROW_LIGHT:
pauseCtx->equipTargetItem = ITEM_BOW_ARROW_LIGHT;
break;
}
if (!CVar_GetS32("gSeparateArrows", 0)) {
pauseCtx->equipTargetSlot = SLOT_BOW;
}
}
// If the item is on another button already, swap the two
uint16_t targetButtonIndex = pauseCtx->equipTargetCBtn + 1;
for (uint16_t otherSlotIndex = 0; otherSlotIndex < ARRAY_COUNT(gSaveContext.equips.cButtonSlots);