Eliminate goto in ItemUseCB_Medicine
This commit is contained in:
parent
585f313c64
commit
2239f3aa60
1 changed files with 45 additions and 42 deletions
|
@ -4325,9 +4325,13 @@ void ItemUseCB_Medicine(u8 taskId, TaskFunc task)
|
||||||
u16 hp = 0;
|
u16 hp = 0;
|
||||||
struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId];
|
struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId];
|
||||||
u16 item = gSpecialVar_ItemId;
|
u16 item = gSpecialVar_ItemId;
|
||||||
bool8 canHeal;
|
bool8 canHeal, cannotUse;
|
||||||
|
|
||||||
if (NotUsingHPEVItemOnShedinja(mon, item))
|
if (NotUsingHPEVItemOnShedinja(mon, item) == FALSE)
|
||||||
|
{
|
||||||
|
cannotUse = TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
canHeal = IsHPRecoveryItem(item);
|
canHeal = IsHPRecoveryItem(item);
|
||||||
if (canHeal == TRUE)
|
if (canHeal == TRUE)
|
||||||
|
@ -4336,51 +4340,50 @@ void ItemUseCB_Medicine(u8 taskId, TaskFunc task)
|
||||||
if (hp == GetMonData(mon, MON_DATA_MAX_HP))
|
if (hp == GetMonData(mon, MON_DATA_MAX_HP))
|
||||||
canHeal = FALSE;
|
canHeal = FALSE;
|
||||||
}
|
}
|
||||||
if (ExecuteTableBasedItemEffect_(gPartyMenu.slotId, item, 0))
|
cannotUse = ExecuteTableBasedItemEffect_(gPartyMenu.slotId, item, 0);
|
||||||
{
|
|
||||||
iTriedHonestlyIDid:
|
|
||||||
gPartyMenuUseExitCallback = FALSE;
|
|
||||||
PlaySE(SE_SELECT);
|
|
||||||
DisplayPartyMenuMessage(gText_WontHaveEffect, TRUE);
|
|
||||||
ScheduleBgCopyTilemapToVram(2);
|
|
||||||
gTasks[taskId].func = task;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (cannotUse != FALSE)
|
||||||
{
|
{
|
||||||
goto iTriedHonestlyIDid; //TODO: resolve this goto
|
gPartyMenuUseExitCallback = FALSE;
|
||||||
}
|
PlaySE(SE_SELECT);
|
||||||
gPartyMenuUseExitCallback = TRUE;
|
DisplayPartyMenuMessage(gText_WontHaveEffect, TRUE);
|
||||||
if (!IsItemFlute(item))
|
|
||||||
{
|
|
||||||
PlaySE(SE_USE_ITEM);
|
|
||||||
if (gPartyMenu.action != PARTY_ACTION_REUSABLE_ITEM)
|
|
||||||
RemoveBagItem(item, 1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PlaySE(SE_GLASS_FLUTE);
|
|
||||||
}
|
|
||||||
SetPartyMonAilmentGfx(mon, &sPartyMenuBoxes[gPartyMenu.slotId]);
|
|
||||||
if (gSprites[sPartyMenuBoxes[gPartyMenu.slotId].statusSpriteId].invisible)
|
|
||||||
DisplayPartyPokemonLevelCheck(mon, &sPartyMenuBoxes[gPartyMenu.slotId], 1);
|
|
||||||
if (canHeal == TRUE)
|
|
||||||
{
|
|
||||||
if (hp == 0)
|
|
||||||
AnimatePartySlot(gPartyMenu.slotId, 1);
|
|
||||||
PartyMenuModifyHP(taskId, gPartyMenu.slotId, 1, GetMonData(mon, MON_DATA_HP) - hp, Task_DisplayHPRestoredMessage);
|
|
||||||
ResetHPTaskData(taskId, 0, hp);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GetMonNickname(mon, gStringVar1);
|
|
||||||
GetMedicineItemEffectMessage(item);
|
|
||||||
DisplayPartyMenuMessage(gStringVar4, TRUE);
|
|
||||||
ScheduleBgCopyTilemapToVram(2);
|
ScheduleBgCopyTilemapToVram(2);
|
||||||
gTasks[taskId].func = task;
|
gTasks[taskId].func = task;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gPartyMenuUseExitCallback = TRUE;
|
||||||
|
if (!IsItemFlute(item))
|
||||||
|
{
|
||||||
|
PlaySE(SE_USE_ITEM);
|
||||||
|
if (gPartyMenu.action != PARTY_ACTION_REUSABLE_ITEM)
|
||||||
|
RemoveBagItem(item, 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PlaySE(SE_GLASS_FLUTE);
|
||||||
|
}
|
||||||
|
SetPartyMonAilmentGfx(mon, &sPartyMenuBoxes[gPartyMenu.slotId]);
|
||||||
|
if (gSprites[sPartyMenuBoxes[gPartyMenu.slotId].statusSpriteId].invisible)
|
||||||
|
DisplayPartyPokemonLevelCheck(mon, &sPartyMenuBoxes[gPartyMenu.slotId], 1);
|
||||||
|
if (canHeal == TRUE)
|
||||||
|
{
|
||||||
|
if (hp == 0)
|
||||||
|
AnimatePartySlot(gPartyMenu.slotId, 1);
|
||||||
|
PartyMenuModifyHP(taskId, gPartyMenu.slotId, 1, GetMonData(mon, MON_DATA_HP) - hp, Task_DisplayHPRestoredMessage);
|
||||||
|
ResetHPTaskData(taskId, 0, hp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GetMonNickname(mon, gStringVar1);
|
||||||
|
GetMedicineItemEffectMessage(item);
|
||||||
|
DisplayPartyMenuMessage(gStringVar4, TRUE);
|
||||||
|
ScheduleBgCopyTilemapToVram(2);
|
||||||
|
gTasks[taskId].func = task;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Task_DisplayHPRestoredMessage(u8 taskId)
|
static void Task_DisplayHPRestoredMessage(u8 taskId)
|
||||||
|
|
Loading…
Reference in a new issue