Remove special IAs (#3453)

* Remove special IAs

* Add clarifying comment
This commit is contained in:
Pepe20129 2024-01-02 06:29:47 +01:00 committed by GitHub
parent 03d907b843
commit 1699eea009
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 91 deletions

View File

@ -132,16 +132,6 @@ typedef enum {
/* 0x40 */ PLAYER_IA_MASK_GERUDO, /* 0x40 */ PLAYER_IA_MASK_GERUDO,
/* 0x41 */ PLAYER_IA_MASK_TRUTH, /* 0x41 */ PLAYER_IA_MASK_TRUTH,
/* 0x42 */ PLAYER_IA_LENS_OF_TRUTH, /* 0x42 */ PLAYER_IA_LENS_OF_TRUTH,
// Upstream TODO: Document why these entries were added
/* 0x43 */ PLAYER_IA_SHIELD_DEKU,
/* 0x44 */ PLAYER_IA_SHIELD_HYLIAN,
/* 0x45 */ PLAYER_IA_SHIELD_MIRROR,
/* 0x46 */ PLAYER_IA_TUNIC_KOKIRI,
/* 0x47 */ PLAYER_IA_TUNIC_GORON,
/* 0x48 */ PLAYER_IA_TUNIC_ZORA,
/* 0x49 */ PLAYER_IA_BOOTS_KOKIRI,
/* 0x4A */ PLAYER_IA_BOOTS_IRON,
/* 0x4B */ PLAYER_IA_BOOTS_HOVER,
/* 0x4C */ PLAYER_IA_MAX /* 0x4C */ PLAYER_IA_MAX
} PlayerItemAction; } PlayerItemAction;

View File

@ -101,15 +101,6 @@ u8 sActionModelGroups[] = {
PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_GERUDO PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_GERUDO
PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_TRUTH PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_TRUTH
PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_LENS_OF_TRUTH PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_LENS_OF_TRUTH
PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_SHIELD_DEKU
PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_SHIELD_HYLIAN
PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_SHIELD_MIRROR
PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_TUNIC_KOKIRI
PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_TUNIC_GORON
PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_TUNIC_ZORA
PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_BOOTS_KOKIRI
PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_BOOTS_IRON
PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_BOOTS_HOVER
}; };
TextTriggerEntry sTextTriggers[] = { TextTriggerEntry sTextTriggers[] = {

View File

@ -1074,15 +1074,6 @@ static s8 sItemActions[] = {
PLAYER_IA_SWORD_KOKIRI, // ITEM_SWORD_KOKIRI PLAYER_IA_SWORD_KOKIRI, // ITEM_SWORD_KOKIRI
PLAYER_IA_SWORD_MASTER, // ITEM_SWORD_MASTER PLAYER_IA_SWORD_MASTER, // ITEM_SWORD_MASTER
PLAYER_IA_SWORD_BIGGORON, // ITEM_SWORD_BIGGORON PLAYER_IA_SWORD_BIGGORON, // ITEM_SWORD_BIGGORON
PLAYER_IA_SHIELD_DEKU, // ITEM_SHIELD_DEKU
PLAYER_IA_SHIELD_HYLIAN, // ITEM_SHIELD_HYLIAN
PLAYER_IA_SHIELD_MIRROR, // ITEM_SHIELD_MIRROR
PLAYER_IA_TUNIC_KOKIRI, // ITEM_TUNIC_KOKIRI
PLAYER_IA_TUNIC_GORON, // ITEM_TUNIC_GORON
PLAYER_IA_TUNIC_ZORA, // ITEM_TUNIC_ZORA
PLAYER_IA_BOOTS_KOKIRI, // ITEM_BOOTS_KOKIRI
PLAYER_IA_BOOTS_IRON, // ITEM_BOOTS_IRON
PLAYER_IA_BOOTS_HOVER, // ITEM_BOOTS_HOVER
}; };
static u8 sMaskMemory; static u8 sMaskMemory;
@ -1157,15 +1148,6 @@ static s32 (*sItemActionUpdateFuncs[])(Player* this, PlayState* play) = {
func_8083485C, // PLAYER_IA_MASK_GERUDO func_8083485C, // PLAYER_IA_MASK_GERUDO
func_8083485C, // PLAYER_IA_MASK_TRUTH func_8083485C, // PLAYER_IA_MASK_TRUTH
func_8083485C, // PLAYER_IA_LENS_OF_TRUTH func_8083485C, // PLAYER_IA_LENS_OF_TRUTH
func_8083485C, // PLAYER_IA_SHIELD_DEKU
func_8083485C, // PLAYER_IA_SHIELD_HYLIAN
func_8083485C, // PLAYER_IA_SHIELD_MIRROR
func_8083485C, // PLAYER_IA_TUNIC_KOKIRI
func_8083485C, // PLAYER_IA_TUNIC_GORON
func_8083485C, // PLAYER_IA_TUNIC_ZORA
func_8083485C, // PLAYER_IA_BOOTS_KOKIRI
func_8083485C, // PLAYER_IA_BOOTS_IRON
func_8083485C, // PLAYER_IA_BOOTS_HOVER
}; };
static void (*sItemActionInitFuncs[])(PlayState* play, Player* this) = { static void (*sItemActionInitFuncs[])(PlayState* play, Player* this) = {
@ -1236,15 +1218,6 @@ static void (*sItemActionInitFuncs[])(PlayState* play, Player* this) = {
func_80833770, // PLAYER_IA_MASK_GERUDO func_80833770, // PLAYER_IA_MASK_GERUDO
func_80833770, // PLAYER_IA_MASK_TRUTH func_80833770, // PLAYER_IA_MASK_TRUTH
func_80833770, // PLAYER_IA_LENS_OF_TRUTH func_80833770, // PLAYER_IA_LENS_OF_TRUTH
func_80833770, // PLAYER_IA_SHIELD_DEKU
func_80833770, // PLAYER_IA_SHIELD_HYLIAN
func_80833770, // PLAYER_IA_SHIELD_MIRROR
func_80833770, // PLAYER_IA_TUNIC_KOKIRI
func_80833770, // PLAYER_IA_TUNIC_GORON
func_80833770, // PLAYER_IA_TUNIC_ZORA
func_80833770, // PLAYER_IA_BOOTS_KOKIRI
func_80833770, // PLAYER_IA_BOOTS_IRON
func_80833770, // PLAYER_IA_BOOTS_HOVER
}; };
typedef enum { typedef enum {
@ -2037,6 +2010,10 @@ s8 Player_ItemToItemAction(s32 item) {
return PLAYER_IA_LAST_USED; return PLAYER_IA_LAST_USED;
} else if (item == ITEM_FISHING_POLE) { } else if (item == ITEM_FISHING_POLE) {
return PLAYER_IA_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 { } else {
return sItemActions[item]; return sItemActions[item];
} }
@ -3167,8 +3144,7 @@ void Player_UseItem(PlayState* play, Player* this, s32 item) {
if ((itemAction == PLAYER_IA_NONE) || !(this->stateFlags1 & PLAYER_STATE1_IN_WATER) || if ((itemAction == PLAYER_IA_NONE) || !(this->stateFlags1 & PLAYER_STATE1_IN_WATER) ||
((this->actor.bgCheckFlags & 1) && ((this->actor.bgCheckFlags & 1) &&
((itemAction == PLAYER_IA_HOOKSHOT) || (itemAction == PLAYER_IA_LONGSHOT))) || ((itemAction == PLAYER_IA_HOOKSHOT) || (itemAction == PLAYER_IA_LONGSHOT)))) {
((itemAction >= PLAYER_IA_SHIELD_DEKU) && (itemAction <= PLAYER_IA_BOOTS_HOVER))) {
if ((play->bombchuBowlingStatus == 0) && if ((play->bombchuBowlingStatus == 0) &&
(((itemAction == PLAYER_IA_DEKU_STICK) && (AMMO(ITEM_STICK) == 0)) || (((itemAction == PLAYER_IA_DEKU_STICK) && (AMMO(ITEM_STICK) == 0)) ||
@ -3180,12 +3156,6 @@ void Player_UseItem(PlayState* play, Player* this, s32 item) {
return; return;
} }
if (itemAction >= PLAYER_IA_SHIELD_DEKU) {
// Changing shields through action commands is unimplemented
// Boots and tunics handled previously
return;
}
if (itemAction == PLAYER_IA_LENS_OF_TRUTH) { if (itemAction == PLAYER_IA_LENS_OF_TRUTH) {
if (Magic_RequestChange(play, 0, MAGIC_CONSUME_LENS)) { if (Magic_RequestChange(play, 0, MAGIC_CONSUME_LENS)) {
if (play->actorCtx.lensActive) { if (play->actorCtx.lensActive) {
@ -11000,46 +10970,39 @@ static f32 D_8085482C[] = { 0.5f, 1.0f, 3.0f };
void Player_UseTunicBoots(Player* this, PlayState* play) { void Player_UseTunicBoots(Player* this, PlayState* play) {
// Boots and tunics equip despite state // Boots and tunics equip despite state
s32 i; if (
s32 item; this->stateFlags1 & (PLAYER_STATE1_INPUT_DISABLED | PLAYER_STATE1_IN_ITEM_CS | PLAYER_STATE1_IN_CUTSCENE | PLAYER_STATE1_TEXT_ON_SCREEN | PLAYER_STATE1_DEAD) ||
s32 itemAction;
if (!(
this->stateFlags1 & PLAYER_STATE1_INPUT_DISABLED ||
this->stateFlags1 & PLAYER_STATE1_IN_ITEM_CS ||
this->stateFlags1 & PLAYER_STATE1_IN_CUTSCENE ||
this->stateFlags1 & PLAYER_STATE1_TEXT_ON_SCREEN ||
this->stateFlags1 & PLAYER_STATE1_DEAD ||
this->stateFlags2 & PLAYER_STATE2_OCARINA_PLAYING this->stateFlags2 & PLAYER_STATE2_OCARINA_PLAYING
)) { ) {
for (i = 0; i < ARRAY_COUNT(sItemButtons); i++) { return;
if (CHECK_BTN_ALL(sControlInput->press.button, sItemButtons[i])) { }
break;
} s32 i;
for (i = 0; i < ARRAY_COUNT(sItemButtons); i++) {
if (CHECK_BTN_ALL(sControlInput->press.button, sItemButtons[i])) {
break;
} }
item = Player_GetItemOnButton(play, i); }
if (item >= ITEM_TUNIC_KOKIRI && item <= ITEM_BOOTS_HOVER) { s32 item = Player_GetItemOnButton(play, i);
this->heldItemButton = i; if (item >= ITEM_TUNIC_KOKIRI && item <= ITEM_BOOTS_HOVER) {
itemAction = Player_ItemToItemAction(item); if (item >= ITEM_BOOTS_KOKIRI) {
if (itemAction >= PLAYER_IA_BOOTS_KOKIRI) { u16 bootsValue = item - ITEM_BOOTS_KOKIRI + 1;
u16 bootsValue = itemAction - PLAYER_IA_BOOTS_KOKIRI + 1; if (CUR_EQUIP_VALUE(EQUIP_TYPE_BOOTS) == bootsValue) {
if (CUR_EQUIP_VALUE(EQUIP_TYPE_BOOTS) == bootsValue) { Inventory_ChangeEquipment(EQUIP_TYPE_BOOTS, EQUIP_VALUE_BOOTS_KOKIRI);
Inventory_ChangeEquipment(EQUIP_TYPE_BOOTS, EQUIP_VALUE_BOOTS_KOKIRI); } else {
} else { Inventory_ChangeEquipment(EQUIP_TYPE_BOOTS, bootsValue);
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 if (itemAction >= PLAYER_IA_TUNIC_KOKIRI) {
u16 tunicValue = itemAction - PLAYER_IA_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);
} }
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);
} }
} }
} }