items tied to items rather than slots + dpad items now work (#2884)

This commit is contained in:
inspectredc 2023-11-06 04:33:51 +00:00 committed by GitHub
parent 8e00265ff8
commit 8b78cb832a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -510,58 +510,60 @@ void UseItem(uint8_t usedItem, u8 started, Actor* thisx, PlayState* play) {
if (this->usedItem != 0xFF && this->itemTimer <= 0) { if (this->usedItem != 0xFF && this->itemTimer <= 0) {
switch (usedItem) { switch (usedItem) {
case SLOT_STICK: case ITEM_STICK:
UseDekuStick(this, play, started); UseDekuStick(this, play, started);
break; break;
case SLOT_BOMB: case ITEM_BOMB:
UseBombs(this, play, started); UseBombs(this, play, started);
break; break;
case SLOT_BOMBCHU: case ITEM_BOMBCHU:
UseBombchus(this, play, started); UseBombchus(this, play, started);
break; break;
case SLOT_NUT: case ITEM_NUT:
UseNuts(this, play, started); UseNuts(this, play, started);
break; break;
case SLOT_BOW: case ITEM_BOW:
UseBow(this, play, started, 0); UseBow(this, play, started, 0);
break; break;
case SLOT_ARROW_FIRE: case ITEM_ARROW_FIRE:
UseBow(this, play, started, 1); UseBow(this, play, started, 1);
break; break;
case SLOT_ARROW_ICE: case ITEM_ARROW_ICE:
UseBow(this, play, started, 2); UseBow(this, play, started, 2);
break; break;
case SLOT_ARROW_LIGHT: case ITEM_ARROW_LIGHT:
UseBow(this, play, started, 3); UseBow(this, play, started, 3);
break; break;
case SLOT_SLINGSHOT: case ITEM_SLINGSHOT:
UseSlingshot(this, play, started); UseSlingshot(this, play, started);
break; break;
case SLOT_OCARINA: case ITEM_OCARINA_FAIRY:
case ITEM_OCARINA_TIME:
UseOcarina(this, play, started); UseOcarina(this, play, started);
break; break;
case SLOT_HOOKSHOT: case ITEM_HOOKSHOT:
case ITEM_LONGSHOT:
UseHookshot(this, play, started); UseHookshot(this, play, started);
break; break;
case SLOT_DINS_FIRE: case ITEM_DINS_FIRE:
UseSpell(this, play, started, 1); UseSpell(this, play, started, 1);
break; break;
case SLOT_NAYRUS_LOVE: case ITEM_NAYRUS_LOVE:
UseSpell(this, play, started, 2); UseSpell(this, play, started, 2);
break; break;
case SLOT_FARORES_WIND: case ITEM_FARORES_WIND:
UseSpell(this, play, started, 3); UseSpell(this, play, started, 3);
break; break;
case SLOT_HAMMER: case ITEM_HAMMER:
UseHammer(this, play, started); UseHammer(this, play, started);
break; break;
case SLOT_BOOMERANG: case ITEM_BOOMERANG:
UseBoomerang(this, play, started); UseBoomerang(this, play, started);
break; break;
case SLOT_LENS: case ITEM_LENS:
UseLens(this, play, started); UseLens(this, play, started);
break; break;
case SLOT_BEAN: case ITEM_BEAN:
UseBeans(this, play, started); UseBeans(this, play, started);
break; break;
} }
@ -685,41 +687,37 @@ void EnPartner_Update(Actor* thisx, PlayState* play) {
uint8_t released = 0; uint8_t released = 0;
uint8_t current = 0; uint8_t current = 0;
uint16_t partnerButtons[7] = { BTN_CLEFT, BTN_CDOWN, BTN_CRIGHT, BTN_DUP, BTN_DDOWN, BTN_DLEFT, BTN_DRIGHT};
uint8_t buttonMax = 3;
if (CVarGetInteger("gDpadEquips", 0) != 0) {
buttonMax = ARRAY_COUNT(gSaveContext.equips.cButtonSlots);
}
if (this->usedItem == 0xFF && this->itemTimer <= 0) { if (this->usedItem == 0xFF && this->itemTimer <= 0) {
if (CHECK_BTN_ALL(sControlInput.press.button, BTN_CLEFT)) { for (uint8_t i = 0; i < buttonMax; i++) {
this->usedItem = gSaveContext.equips.cButtonSlots[0]; if (CHECK_BTN_ALL(sControlInput.press.button, partnerButtons[i])) {
this->usedItemButton = 0; this->usedItem = gSaveContext.equips.buttonItems[i+1];
pressed = 1; this->usedItemButton = i;
} else if (CHECK_BTN_ALL(sControlInput.press.button, BTN_CDOWN)) {
this->usedItem = gSaveContext.equips.cButtonSlots[1];
this->usedItemButton = 1;
pressed = 1;
} else if (CHECK_BTN_ALL(sControlInput.press.button, BTN_CRIGHT)) {
this->usedItem = gSaveContext.equips.cButtonSlots[2];
this->usedItemButton = 2;
pressed = 1; pressed = 1;
} }
} }
}
if (this->usedItem != 0xFF) { if (this->usedItem != 0xFF) {
if (CHECK_BTN_ALL(sControlInput.cur.button, BTN_CLEFT) && this->usedItemButton == 0) { for (uint8_t i = 0; i < buttonMax; i++) {
current = 1; if (CHECK_BTN_ALL(sControlInput.cur.button, partnerButtons[i]) && this->usedItemButton == i) {
} else if (CHECK_BTN_ALL(sControlInput.cur.button, BTN_CDOWN) && this->usedItemButton == 1) {
current = 1;
} else if (CHECK_BTN_ALL(sControlInput.cur.button, BTN_CRIGHT) && this->usedItemButton == 2) {
current = 1; current = 1;
} }
} }
}
if (this->usedItem != 0xFF) { if (this->usedItem != 0xFF) {
if (CHECK_BTN_ALL(sControlInput.rel.button, BTN_CLEFT) && this->usedItemButton == 0) { for (uint8_t i = 0; i < buttonMax; i++) {
released = 1; if (CHECK_BTN_ALL(sControlInput.rel.button, partnerButtons[i]) && this->usedItemButton == i) {
} else if (CHECK_BTN_ALL(sControlInput.rel.button, BTN_CDOWN) && this->usedItemButton == 1) {
released = 1;
} else if (CHECK_BTN_ALL(sControlInput.rel.button, BTN_CRIGHT) && this->usedItemButton == 2) {
released = 1; released = 1;
} }
} }
}
if (pressed == 1) { if (pressed == 1) {
UseItem(this->usedItem, 1, this, play); UseItem(this->usedItem, 1, this, play);