mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2025-01-06 01:23:15 +01:00
fixed learning moves
This commit is contained in:
parent
03c21c3b71
commit
793e8ef5a4
@ -1381,7 +1381,7 @@ const struct Item gItems[] =
|
|||||||
.description = sExpCandyXSDesc,
|
.description = sExpCandyXSDesc,
|
||||||
.pocket = POCKET_ITEMS,
|
.pocket = POCKET_ITEMS,
|
||||||
.type = ITEM_USE_PARTY_MENU,
|
.type = ITEM_USE_PARTY_MENU,
|
||||||
.fieldUseFunc = ItemUseOutOfBattle_RareCandy, // Todo
|
.fieldUseFunc = ItemUseOutOfBattle_RareCandy,
|
||||||
.flingPower = 30,
|
.flingPower = 30,
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1394,7 +1394,7 @@ const struct Item gItems[] =
|
|||||||
.description = sExpCandyXSDesc,
|
.description = sExpCandyXSDesc,
|
||||||
.pocket = POCKET_ITEMS,
|
.pocket = POCKET_ITEMS,
|
||||||
.type = ITEM_USE_PARTY_MENU,
|
.type = ITEM_USE_PARTY_MENU,
|
||||||
.fieldUseFunc = ItemUseOutOfBattle_RareCandy, // Todo
|
.fieldUseFunc = ItemUseOutOfBattle_RareCandy,
|
||||||
.flingPower = 30,
|
.flingPower = 30,
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1407,7 +1407,7 @@ const struct Item gItems[] =
|
|||||||
.description = sExpCandyMDesc,
|
.description = sExpCandyMDesc,
|
||||||
.pocket = POCKET_ITEMS,
|
.pocket = POCKET_ITEMS,
|
||||||
.type = ITEM_USE_PARTY_MENU,
|
.type = ITEM_USE_PARTY_MENU,
|
||||||
.fieldUseFunc = ItemUseOutOfBattle_RareCandy, // Todo
|
.fieldUseFunc = ItemUseOutOfBattle_RareCandy,
|
||||||
.flingPower = 30,
|
.flingPower = 30,
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1420,7 +1420,7 @@ const struct Item gItems[] =
|
|||||||
.description = sExpCandyLDesc,
|
.description = sExpCandyLDesc,
|
||||||
.pocket = POCKET_ITEMS,
|
.pocket = POCKET_ITEMS,
|
||||||
.type = ITEM_USE_PARTY_MENU,
|
.type = ITEM_USE_PARTY_MENU,
|
||||||
.fieldUseFunc = ItemUseOutOfBattle_RareCandy, // Todo
|
.fieldUseFunc = ItemUseOutOfBattle_RareCandy,
|
||||||
.flingPower = 30,
|
.flingPower = 30,
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1433,7 +1433,7 @@ const struct Item gItems[] =
|
|||||||
.description = sExpCandyXLDesc,
|
.description = sExpCandyXLDesc,
|
||||||
.pocket = POCKET_ITEMS,
|
.pocket = POCKET_ITEMS,
|
||||||
.type = ITEM_USE_PARTY_MENU,
|
.type = ITEM_USE_PARTY_MENU,
|
||||||
.fieldUseFunc = ItemUseOutOfBattle_RareCandy, // Todo
|
.fieldUseFunc = ItemUseOutOfBattle_RareCandy,
|
||||||
.flingPower = 30,
|
.flingPower = 30,
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1445,7 +1445,7 @@ const struct Item gItems[] =
|
|||||||
.description = sDynamaxCandyDesc,
|
.description = sDynamaxCandyDesc,
|
||||||
.pocket = POCKET_ITEMS,
|
.pocket = POCKET_ITEMS,
|
||||||
.type = ITEM_USE_BAG_MENU,
|
.type = ITEM_USE_BAG_MENU,
|
||||||
.fieldUseFunc = ItemUseOutOfBattle_CannotUse, // Todo
|
.fieldUseFunc = ItemUseOutOfBattle_CannotUse,
|
||||||
.flingPower = 30,
|
.flingPower = 30,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -151,6 +151,8 @@ EWRAM_DATA u8 gSelectedOrderFromParty[MAX_FRONTIER_PARTY_SIZE] = {0};
|
|||||||
static EWRAM_DATA u16 sPartyMenuItemId = 0;
|
static EWRAM_DATA u16 sPartyMenuItemId = 0;
|
||||||
static EWRAM_DATA u16 sUnused = 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
|
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
|
// IWRAM common
|
||||||
void (*gItemUseCB)(u8, TaskFunc);
|
void (*gItemUseCB)(u8, TaskFunc);
|
||||||
@ -4822,6 +4824,9 @@ static void Task_LearnNextMoveOrClosePartyMenu(u8 taskId)
|
|||||||
if (IsFanfareTaskInactive() && ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON))))
|
if (IsFanfareTaskInactive() && ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON))))
|
||||||
{
|
{
|
||||||
if (gPartyMenu.learnMoveState == 1)
|
if (gPartyMenu.learnMoveState == 1)
|
||||||
|
if (sInitialLevel < sFinalLevel)
|
||||||
|
Task_TryLearnNewMoves(taskId);
|
||||||
|
else
|
||||||
Task_TryLearningNextMove(taskId);
|
Task_TryLearningNextMove(taskId);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -4874,6 +4879,7 @@ static void CB2_ShowSummaryScreenToForgetMove(void)
|
|||||||
|
|
||||||
static void CB2_ReturnToPartyMenuWhileLearningMove(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);
|
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;
|
s16 *arrayPtr = ptr->data;
|
||||||
u16 *itemPtr = &gSpecialVar_ItemId;
|
u16 *itemPtr = &gSpecialVar_ItemId;
|
||||||
bool8 cannotUseEffect;
|
bool8 cannotUseEffect;
|
||||||
|
sInitialLevel = GetMonData(mon, MON_DATA_LEVEL);
|
||||||
|
|
||||||
if (GetMonData(mon, MON_DATA_LEVEL) != MAX_LEVEL)
|
if (sInitialLevel != MAX_LEVEL)
|
||||||
{
|
{
|
||||||
BufferMonStatsToTaskData(mon, arrayPtr);
|
BufferMonStatsToTaskData(mon, arrayPtr);
|
||||||
cannotUseEffect = ExecuteTableBasedItemEffect_(gPartyMenu.slotId, *itemPtr, 0);
|
cannotUseEffect = ExecuteTableBasedItemEffect_(gPartyMenu.slotId, *itemPtr, 0);
|
||||||
@ -5009,6 +5016,7 @@ void ItemUseCB_RareCandy(u8 taskId, TaskFunc task)
|
|||||||
StringExpandPlaceholders(gStringVar4, gText_PkmnElevatedToLvVar2);
|
StringExpandPlaceholders(gStringVar4, gText_PkmnElevatedToLvVar2);
|
||||||
DisplayPartyMenuMessage(gStringVar4, TRUE);
|
DisplayPartyMenuMessage(gStringVar4, TRUE);
|
||||||
ScheduleBgCopyTilemapToVram(2);
|
ScheduleBgCopyTilemapToVram(2);
|
||||||
|
sFinalLevel = GetMonData(mon, MON_DATA_LEVEL, NULL);
|
||||||
gTasks[taskId].func = Task_DisplayLevelUpStatsPg1;
|
gTasks[taskId].func = Task_DisplayLevelUpStatsPg1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5067,16 +5075,21 @@ static void DisplayLevelUpStatsPg2(u8 taskId)
|
|||||||
|
|
||||||
static void Task_TryLearnNewMoves(u8 taskId)
|
static void Task_TryLearnNewMoves(u8 taskId)
|
||||||
{
|
{
|
||||||
|
u8 i;
|
||||||
u16 learnMove;
|
u16 learnMove;
|
||||||
|
|
||||||
if (WaitFanfare(0) && ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON))))
|
if (WaitFanfare(0) && ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON))))
|
||||||
{
|
{
|
||||||
RemoveLevelUpStatsWindow();
|
RemoveLevelUpStatsWindow();
|
||||||
|
for (; sInitialLevel < sFinalLevel; sInitialLevel++)
|
||||||
|
{
|
||||||
|
SetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_LEVEL, &sInitialLevel);
|
||||||
learnMove = MonTryLearningNewMove(&gPlayerParty[gPartyMenu.slotId], TRUE);
|
learnMove = MonTryLearningNewMove(&gPlayerParty[gPartyMenu.slotId], TRUE);
|
||||||
gPartyMenu.learnMoveState = 1;
|
gPartyMenu.learnMoveState = 1;
|
||||||
switch (learnMove)
|
switch (learnMove)
|
||||||
{
|
{
|
||||||
case 0: // No moves to learn
|
case 0: // No moves to learn
|
||||||
|
if(sInitialLevel >= sFinalLevel)
|
||||||
PartyMenuTryEvolution(taskId);
|
PartyMenuTryEvolution(taskId);
|
||||||
break;
|
break;
|
||||||
case MON_HAS_MAX_MOVES:
|
case MON_HAS_MAX_MOVES:
|
||||||
@ -5089,16 +5102,25 @@ static void Task_TryLearnNewMoves(u8 taskId)
|
|||||||
DisplayMonLearnedMove(taskId, learnMove);
|
DisplayMonLearnedMove(taskId, learnMove);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (learnMove)
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Task_TryLearningNextMove(u8 taskId)
|
static void Task_TryLearningNextMove(u8 taskId)
|
||||||
{
|
{
|
||||||
u16 result = MonTryLearningNewMove(&gPlayerParty[gPartyMenu.slotId], FALSE);
|
u8 i;
|
||||||
|
u16 result;
|
||||||
|
for (; sInitialLevel < sFinalLevel; sInitialLevel++)
|
||||||
|
{
|
||||||
|
SetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_LEVEL, &sInitialLevel);
|
||||||
|
result = MonTryLearningNewMove(&gPlayerParty[gPartyMenu.slotId], FALSE);
|
||||||
|
gPartyMenu.learnMoveState = 1;
|
||||||
switch (result)
|
switch (result)
|
||||||
{
|
{
|
||||||
case 0: // No moves to learn
|
case 0: // No moves to learn
|
||||||
|
if(sInitialLevel >= sFinalLevel)
|
||||||
PartyMenuTryEvolution(taskId);
|
PartyMenuTryEvolution(taskId);
|
||||||
break;
|
break;
|
||||||
case MON_HAS_MAX_MOVES:
|
case MON_HAS_MAX_MOVES:
|
||||||
@ -5110,6 +5132,11 @@ static void Task_TryLearningNextMove(u8 taskId)
|
|||||||
DisplayMonLearnedMove(taskId, result);
|
DisplayMonLearnedMove(taskId, result);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (result)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(sInitialLevel >= sFinalLevel)
|
||||||
|
PartyMenuTryEvolution(taskId);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PartyMenuTryEvolution(u8 taskId)
|
static void PartyMenuTryEvolution(u8 taskId)
|
||||||
|
@ -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
|
// 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)
|
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;
|
retVal = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ONE_HUNDRED 1 << 4
|
|
||||||
#define ONE_THOUSAND 1 << 5
|
|
||||||
#define TEN_THOUSAND 1 << 6
|
|
||||||
#define FULL_LEVEL 1 << 7
|
|
||||||
|
|
||||||
// Rare Candy
|
// Rare Candy
|
||||||
if ((itemEffect[i] & ITEM3_LEVEL_UP)
|
if ((itemEffect[i] & ITEM3_LEVEL_UP)
|
||||||
&& GetMonData(mon, MON_DATA_LEVEL, NULL) != MAX_LEVEL)
|
&& 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;
|
retVal = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef ONE_HUNDRED
|
|
||||||
#undef ONE_THOUSAND
|
|
||||||
#undef TEN_THOUSAND
|
|
||||||
#undef FULL_LEVEL
|
|
||||||
|
|
||||||
// Cure status
|
// Cure status
|
||||||
if ((itemEffect[i] & ITEM3_SLEEP)
|
if ((itemEffect[i] & ITEM3_SLEEP)
|
||||||
&& HealStatusConditions(mon, partyIndex, STATUS1_SLEEP, battlerId) == 0)
|
&& HealStatusConditions(mon, partyIndex, STATUS1_SLEEP, battlerId) == 0)
|
||||||
@ -5301,6 +5296,11 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov
|
|||||||
return retVal;
|
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)
|
bool8 HealStatusConditions(struct Pokemon *mon, u32 battlePartyId, u32 healMask, u8 battlerId)
|
||||||
{
|
{
|
||||||
u32 status = GetMonData(mon, MON_DATA_STATUS, 0);
|
u32 status = GetMonData(mon, MON_DATA_STATUS, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user