rework assignable tunic/boots to use shipinit and hooks (#4978)
* don't put away items when equipping tunics/boots * vb * don't need that return * ok i guess i'm going down the rabbit hole * more rabbit hole * shipinit and more hooks * clean up * use fewer params, add a missing condition * make the loops make sense
This commit is contained in:
@@ -2244,16 +2244,12 @@ void Player_InitItemActionWithAnim(PlayState* play, Player* this, s8 itemAction)
|
||||
}
|
||||
|
||||
s8 Player_ItemToItemAction(s32 item) {
|
||||
if (item >= ITEM_NONE_FE) {
|
||||
if (GameInteractor_Should(VB_ITEM_ACTION_BE_NONE, item >= ITEM_NONE_FE, item)) {
|
||||
return PLAYER_IA_NONE;
|
||||
} else if (item == ITEM_LAST_USED) {
|
||||
return PLAYER_IA_SWORD_CS;
|
||||
} else if (item == ITEM_FISHING_POLE) {
|
||||
return PLAYER_IA_FISHING_POLE;
|
||||
// #region SOH [Enhancement] Added to prevent crashes with assignable equipment
|
||||
} else if (item >= ITEM_TUNIC_KOKIRI && item <= ITEM_BOOTS_HOVER) {
|
||||
return PLAYER_IA_NONE;
|
||||
// #endregion
|
||||
} else {
|
||||
return sItemActions[item];
|
||||
}
|
||||
@@ -2572,7 +2568,7 @@ void Player_ProcessItemButtons(Player* this, PlayState* play) {
|
||||
if ((item < ITEM_NONE_FE) && (Player_ItemToItemAction(item) == this->heldItemAction)) {
|
||||
sHeldItemButtonIsHeldDown = true;
|
||||
}
|
||||
} else {
|
||||
} else if (GameInteractor_Should(VB_CHANGE_HELD_ITEM_AND_USE_ITEM, true, item)) {
|
||||
this->heldItemButton = i;
|
||||
Player_UseItem(play, this, item);
|
||||
}
|
||||
@@ -11883,45 +11879,6 @@ static Vec3f D_80854814 = { 0.0f, 0.0f, 200.0f };
|
||||
static f32 sWaterConveyorSpeeds[] = { 2.0f, 4.0f, 7.0f };
|
||||
static f32 sFloorConveyorSpeeds[] = { 0.5f, 1.0f, 3.0f };
|
||||
|
||||
void Player_UseTunicBoots(Player* this, PlayState* play) {
|
||||
// Boots and tunics equip despite state
|
||||
if (
|
||||
this->stateFlags1 & (PLAYER_STATE1_INPUT_DISABLED | PLAYER_STATE1_IN_ITEM_CS | PLAYER_STATE1_IN_CUTSCENE | PLAYER_STATE1_TALKING | PLAYER_STATE1_DEAD) ||
|
||||
this->stateFlags2 & PLAYER_STATE2_OCARINA_PLAYING
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
s32 i;
|
||||
for (i = 0; i < ARRAY_COUNT(sItemButtons); i++) {
|
||||
if (CHECK_BTN_ALL(sControlInput->press.button, sItemButtons[i])) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
s32 item = Player_GetItemOnButton(play, i);
|
||||
if (item >= ITEM_TUNIC_KOKIRI && item <= ITEM_BOOTS_HOVER) {
|
||||
if (item >= ITEM_BOOTS_KOKIRI) {
|
||||
u16 bootsValue = item - ITEM_BOOTS_KOKIRI + 1;
|
||||
if (CUR_EQUIP_VALUE(EQUIP_TYPE_BOOTS) == bootsValue) {
|
||||
Inventory_ChangeEquipment(EQUIP_TYPE_BOOTS, EQUIP_VALUE_BOOTS_KOKIRI);
|
||||
} else {
|
||||
Inventory_ChangeEquipment(EQUIP_TYPE_BOOTS, bootsValue);
|
||||
}
|
||||
Player_SetEquipmentData(play, this);
|
||||
func_808328EC(this, CUR_EQUIP_VALUE(EQUIP_TYPE_BOOTS) == EQUIP_VALUE_BOOTS_IRON ? NA_SE_PL_WALK_HEAVYBOOTS : NA_SE_PL_CHANGE_ARMS);
|
||||
} else {
|
||||
u16 tunicValue = item - ITEM_TUNIC_KOKIRI + 1;
|
||||
if (CUR_EQUIP_VALUE(EQUIP_TYPE_TUNIC) == tunicValue) {
|
||||
Inventory_ChangeEquipment(EQUIP_TYPE_TUNIC, EQUIP_VALUE_TUNIC_KOKIRI);
|
||||
} else {
|
||||
Inventory_ChangeEquipment(EQUIP_TYPE_TUNIC, tunicValue);
|
||||
}
|
||||
Player_SetEquipmentData(play, this);
|
||||
func_808328EC(this, NA_SE_PL_CHANGE_ARMS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Player_UpdateCommon(Player* this, PlayState* play, Input* input) {
|
||||
s32 pad;
|
||||
|
||||
@@ -12218,9 +12175,8 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) {
|
||||
sUseHeldItem = sHeldItemButtonIsHeldDown = 0;
|
||||
sSavedCurrentMask = this->currentMask;
|
||||
|
||||
if (!(this->stateFlags3 & PLAYER_STATE3_PAUSE_ACTION_FUNC)) {
|
||||
if (GameInteractor_Should(VB_EXECUTE_PLAYER_ACTION_FUNC, !(this->stateFlags3 & PLAYER_STATE3_PAUSE_ACTION_FUNC), input)) {
|
||||
this->actionFunc(this, play);
|
||||
Player_UseTunicBoots(this, play);
|
||||
}
|
||||
|
||||
Player_UpdateCamAndSeqModes(play, this);
|
||||
|
||||
Reference in New Issue
Block a user