fixed learning moves

This commit is contained in:
AgustinGDLV 2022-05-16 13:12:41 -07:00
parent 03c21c3b71
commit 793e8ef5a4
3 changed files with 74 additions and 47 deletions

View File

@ -1381,7 +1381,7 @@ const struct Item gItems[] =
.description = sExpCandyXSDesc,
.pocket = POCKET_ITEMS,
.type = ITEM_USE_PARTY_MENU,
.fieldUseFunc = ItemUseOutOfBattle_RareCandy, // Todo
.fieldUseFunc = ItemUseOutOfBattle_RareCandy,
.flingPower = 30,
},
@ -1394,7 +1394,7 @@ const struct Item gItems[] =
.description = sExpCandyXSDesc,
.pocket = POCKET_ITEMS,
.type = ITEM_USE_PARTY_MENU,
.fieldUseFunc = ItemUseOutOfBattle_RareCandy, // Todo
.fieldUseFunc = ItemUseOutOfBattle_RareCandy,
.flingPower = 30,
},
@ -1407,7 +1407,7 @@ const struct Item gItems[] =
.description = sExpCandyMDesc,
.pocket = POCKET_ITEMS,
.type = ITEM_USE_PARTY_MENU,
.fieldUseFunc = ItemUseOutOfBattle_RareCandy, // Todo
.fieldUseFunc = ItemUseOutOfBattle_RareCandy,
.flingPower = 30,
},
@ -1420,7 +1420,7 @@ const struct Item gItems[] =
.description = sExpCandyLDesc,
.pocket = POCKET_ITEMS,
.type = ITEM_USE_PARTY_MENU,
.fieldUseFunc = ItemUseOutOfBattle_RareCandy, // Todo
.fieldUseFunc = ItemUseOutOfBattle_RareCandy,
.flingPower = 30,
},
@ -1433,7 +1433,7 @@ const struct Item gItems[] =
.description = sExpCandyXLDesc,
.pocket = POCKET_ITEMS,
.type = ITEM_USE_PARTY_MENU,
.fieldUseFunc = ItemUseOutOfBattle_RareCandy, // Todo
.fieldUseFunc = ItemUseOutOfBattle_RareCandy,
.flingPower = 30,
},
@ -1445,7 +1445,7 @@ const struct Item gItems[] =
.description = sDynamaxCandyDesc,
.pocket = POCKET_ITEMS,
.type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_CannotUse, // Todo
.fieldUseFunc = ItemUseOutOfBattle_CannotUse,
.flingPower = 30,
},

View File

@ -151,6 +151,8 @@ EWRAM_DATA u8 gSelectedOrderFromParty[MAX_FRONTIER_PARTY_SIZE] = {0};
static EWRAM_DATA u16 sPartyMenuItemId = 0;
static EWRAM_DATA u16 sUnused = 0;
EWRAM_DATA u8 gBattlePartyCurrentOrder[PARTY_SIZE / 2] = {0}; // bits 0-3 are the current pos of Slot 1, 4-7 are Slot 2, and so on
static EWRAM_DATA u8 sInitialLevel = 0;
static EWRAM_DATA u8 sFinalLevel = 0;
// IWRAM common
void (*gItemUseCB)(u8, TaskFunc);
@ -4822,7 +4824,10 @@ static void Task_LearnNextMoveOrClosePartyMenu(u8 taskId)
if (IsFanfareTaskInactive() && ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON))))
{
if (gPartyMenu.learnMoveState == 1)
Task_TryLearningNextMove(taskId);
if (sInitialLevel < sFinalLevel)
Task_TryLearnNewMoves(taskId);
else
Task_TryLearningNextMove(taskId);
else
{
if (gPartyMenu.learnMoveState == 2) // never occurs
@ -4874,6 +4879,7 @@ static void CB2_ShowSummaryScreenToForgetMove(void)
static void CB2_ReturnToPartyMenuWhileLearningMove(void)
{
SetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_LEVEL, &sFinalLevel); // to avoid displaying incorrect level
InitPartyMenu(PARTY_MENU_TYPE_FIELD, PARTY_LAYOUT_SINGLE, PARTY_ACTION_CHOOSE_MON, TRUE, PARTY_MSG_NONE, Task_ReturnToPartyMenuWhileLearningMove, gPartyMenu.exitCallback);
}
@ -4979,8 +4985,9 @@ void ItemUseCB_RareCandy(u8 taskId, TaskFunc task)
s16 *arrayPtr = ptr->data;
u16 *itemPtr = &gSpecialVar_ItemId;
bool8 cannotUseEffect;
sInitialLevel = GetMonData(mon, MON_DATA_LEVEL);
if (GetMonData(mon, MON_DATA_LEVEL) != MAX_LEVEL)
if (sInitialLevel != MAX_LEVEL)
{
BufferMonStatsToTaskData(mon, arrayPtr);
cannotUseEffect = ExecuteTableBasedItemEffect_(gPartyMenu.slotId, *itemPtr, 0);
@ -5009,6 +5016,7 @@ void ItemUseCB_RareCandy(u8 taskId, TaskFunc task)
StringExpandPlaceholders(gStringVar4, gText_PkmnElevatedToLvVar2);
DisplayPartyMenuMessage(gStringVar4, TRUE);
ScheduleBgCopyTilemapToVram(2);
sFinalLevel = GetMonData(mon, MON_DATA_LEVEL, NULL);
gTasks[taskId].func = Task_DisplayLevelUpStatsPg1;
}
}
@ -5067,49 +5075,68 @@ static void DisplayLevelUpStatsPg2(u8 taskId)
static void Task_TryLearnNewMoves(u8 taskId)
{
u8 i;
u16 learnMove;
if (WaitFanfare(0) && ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON))))
{
RemoveLevelUpStatsWindow();
learnMove = MonTryLearningNewMove(&gPlayerParty[gPartyMenu.slotId], TRUE);
gPartyMenu.learnMoveState = 1;
switch (learnMove)
for (; sInitialLevel < sFinalLevel; sInitialLevel++)
{
case 0: // No moves to learn
PartyMenuTryEvolution(taskId);
break;
case MON_HAS_MAX_MOVES:
DisplayMonNeedsToReplaceMove(taskId);
break;
case MON_ALREADY_KNOWS_MOVE:
gTasks[taskId].func = Task_TryLearningNextMove;
break;
default:
DisplayMonLearnedMove(taskId, learnMove);
break;
SetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_LEVEL, &sInitialLevel);
learnMove = MonTryLearningNewMove(&gPlayerParty[gPartyMenu.slotId], TRUE);
gPartyMenu.learnMoveState = 1;
switch (learnMove)
{
case 0: // No moves to learn
if(sInitialLevel >= sFinalLevel)
PartyMenuTryEvolution(taskId);
break;
case MON_HAS_MAX_MOVES:
DisplayMonNeedsToReplaceMove(taskId);
break;
case MON_ALREADY_KNOWS_MOVE:
gTasks[taskId].func = Task_TryLearningNextMove;
break;
default:
DisplayMonLearnedMove(taskId, learnMove);
break;
}
if (learnMove)
break;
}
}
}
static void Task_TryLearningNextMove(u8 taskId)
{
u16 result = MonTryLearningNewMove(&gPlayerParty[gPartyMenu.slotId], FALSE);
switch (result)
u8 i;
u16 result;
for (; sInitialLevel < sFinalLevel; sInitialLevel++)
{
case 0: // No moves to learn
PartyMenuTryEvolution(taskId);
break;
case MON_HAS_MAX_MOVES:
DisplayMonNeedsToReplaceMove(taskId);
break;
case MON_ALREADY_KNOWS_MOVE:
return;
default:
DisplayMonLearnedMove(taskId, result);
break;
SetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_LEVEL, &sInitialLevel);
result = MonTryLearningNewMove(&gPlayerParty[gPartyMenu.slotId], FALSE);
gPartyMenu.learnMoveState = 1;
switch (result)
{
case 0: // No moves to learn
if(sInitialLevel >= sFinalLevel)
PartyMenuTryEvolution(taskId);
break;
case MON_HAS_MAX_MOVES:
DisplayMonNeedsToReplaceMove(taskId);
break;
case MON_ALREADY_KNOWS_MOVE:
return;
default:
DisplayMonLearnedMove(taskId, result);
break;
}
if (result)
break;
}
if(sInitialLevel >= sFinalLevel)
PartyMenuTryEvolution(taskId);
}
static void PartyMenuTryEvolution(u8 taskId)

View File

@ -4708,6 +4708,11 @@ bool8 ExecuteTableBasedItemEffect(struct Pokemon *mon, u16 item, u8 partyIndex,
} \
}
#define ONE_HUNDRED 1 << 4
#define ONE_THOUSAND 1 << 5
#define TEN_THOUSAND 1 << 6
#define FULL_LEVEL 1 << 7
// Returns TRUE if the item has no effect on the Pokémon, FALSE otherwise
bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 moveIndex, bool8 usedByAI)
{
@ -4873,11 +4878,6 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov
retVal = FALSE;
}
#define ONE_HUNDRED 1 << 4
#define ONE_THOUSAND 1 << 5
#define TEN_THOUSAND 1 << 6
#define FULL_LEVEL 1 << 7
// Rare Candy
if ((itemEffect[i] & ITEM3_LEVEL_UP)
&& GetMonData(mon, MON_DATA_LEVEL, NULL) != MAX_LEVEL)
@ -4902,11 +4902,6 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov
retVal = FALSE;
}
#undef ONE_HUNDRED
#undef ONE_THOUSAND
#undef TEN_THOUSAND
#undef FULL_LEVEL
// Cure status
if ((itemEffect[i] & ITEM3_SLEEP)
&& HealStatusConditions(mon, partyIndex, STATUS1_SLEEP, battlerId) == 0)
@ -5301,6 +5296,11 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov
return retVal;
}
#undef ONE_HUNDRED
#undef ONE_THOUSAND
#undef TEN_THOUSAND
#undef FULL_LEVEL
bool8 HealStatusConditions(struct Pokemon *mon, u32 battlePartyId, u32 healMask, u8 battlerId)
{
u32 status = GetMonData(mon, MON_DATA_STATUS, 0);