Added ability to use pokeballs on field

This commit is contained in:
Ninjdai 2023-11-10 00:53:14 +01:00
parent 87e2a5dc74
commit 5af3affc59
6 changed files with 66 additions and 1 deletions

View File

@ -37,6 +37,7 @@ void ItemUseInBattle_PartyMenuChooseMove(u8 taskId);
void Task_UseDigEscapeRopeOnField(u8 taskId); void Task_UseDigEscapeRopeOnField(u8 taskId);
u8 CanUseDigOrEscapeRopeOnCurMap(void); u8 CanUseDigOrEscapeRopeOnCurMap(void);
u8 CheckIfItemIsTMHMOrEvolutionStone(u16 itemId); u8 CheckIfItemIsTMHMOrEvolutionStone(u16 itemId);
void ItemUseOutOfBattle_PokeBall(u8);
enum { enum {
BALL_THROW_UNABLE_TWO_MONS, BALL_THROW_UNABLE_TWO_MONS,

View File

@ -96,5 +96,6 @@ void MoveDeleterForgetMove(void);
void BufferMoveDeleterNicknameAndMove(void); void BufferMoveDeleterNicknameAndMove(void);
void GetNumMovesSelectedMonHas(void); void GetNumMovesSelectedMonHas(void);
void MoveDeleterChooseMoveToForget(void); void MoveDeleterChooseMoveToForget(void);
void ItemUseCB_PokeBall(u8 taskId, TaskFunc task);
#endif // GUARD_PARTY_MENU_H #endif // GUARD_PARTY_MENU_H

View File

@ -41,6 +41,7 @@ const struct Item gItems[] =
.description = sPokeBallDesc, .description = sPokeBallDesc,
.pocket = POCKET_POKE_BALLS, .pocket = POCKET_POKE_BALLS,
.type = ITEM_USE_BAG_MENU, .type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_PokeBall,
.battleUsage = EFFECT_ITEM_THROW_BALL, .battleUsage = EFFECT_ITEM_THROW_BALL,
.secondaryId = ITEM_POKE_BALL - FIRST_BALL, .secondaryId = ITEM_POKE_BALL - FIRST_BALL,
}, },
@ -52,6 +53,7 @@ const struct Item gItems[] =
.description = sGreatBallDesc, .description = sGreatBallDesc,
.pocket = POCKET_POKE_BALLS, .pocket = POCKET_POKE_BALLS,
.type = ITEM_USE_BAG_MENU, .type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_PokeBall,
.battleUsage = EFFECT_ITEM_THROW_BALL, .battleUsage = EFFECT_ITEM_THROW_BALL,
.secondaryId = ITEM_GREAT_BALL - FIRST_BALL, .secondaryId = ITEM_GREAT_BALL - FIRST_BALL,
}, },
@ -63,6 +65,7 @@ const struct Item gItems[] =
.description = sUltraBallDesc, .description = sUltraBallDesc,
.pocket = POCKET_POKE_BALLS, .pocket = POCKET_POKE_BALLS,
.type = ITEM_USE_BAG_MENU, .type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_PokeBall,
.battleUsage = EFFECT_ITEM_THROW_BALL, .battleUsage = EFFECT_ITEM_THROW_BALL,
.secondaryId = ITEM_ULTRA_BALL - FIRST_BALL, .secondaryId = ITEM_ULTRA_BALL - FIRST_BALL,
}, },
@ -74,6 +77,7 @@ const struct Item gItems[] =
.description = sMasterBallDesc, .description = sMasterBallDesc,
.pocket = POCKET_POKE_BALLS, .pocket = POCKET_POKE_BALLS,
.type = ITEM_USE_BAG_MENU, .type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_PokeBall,
.battleUsage = EFFECT_ITEM_THROW_BALL, .battleUsage = EFFECT_ITEM_THROW_BALL,
.secondaryId = ITEM_MASTER_BALL - FIRST_BALL, .secondaryId = ITEM_MASTER_BALL - FIRST_BALL,
}, },
@ -85,6 +89,7 @@ const struct Item gItems[] =
.description = sPremierBallDesc, .description = sPremierBallDesc,
.pocket = POCKET_POKE_BALLS, .pocket = POCKET_POKE_BALLS,
.type = ITEM_USE_BAG_MENU, .type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_PokeBall,
.battleUsage = EFFECT_ITEM_THROW_BALL, .battleUsage = EFFECT_ITEM_THROW_BALL,
.secondaryId = ITEM_PREMIER_BALL - FIRST_BALL, .secondaryId = ITEM_PREMIER_BALL - FIRST_BALL,
}, },
@ -96,6 +101,7 @@ const struct Item gItems[] =
.description = sHealBallDesc, .description = sHealBallDesc,
.pocket = POCKET_POKE_BALLS, .pocket = POCKET_POKE_BALLS,
.type = ITEM_USE_BAG_MENU, .type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_PokeBall,
.battleUsage = EFFECT_ITEM_THROW_BALL, .battleUsage = EFFECT_ITEM_THROW_BALL,
.secondaryId = ITEM_HEAL_BALL - FIRST_BALL, .secondaryId = ITEM_HEAL_BALL - FIRST_BALL,
}, },
@ -107,6 +113,7 @@ const struct Item gItems[] =
.description = sNetBallDesc, .description = sNetBallDesc,
.pocket = POCKET_POKE_BALLS, .pocket = POCKET_POKE_BALLS,
.type = ITEM_USE_BAG_MENU, .type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_PokeBall,
.battleUsage = EFFECT_ITEM_THROW_BALL, .battleUsage = EFFECT_ITEM_THROW_BALL,
.secondaryId = ITEM_NET_BALL - FIRST_BALL, .secondaryId = ITEM_NET_BALL - FIRST_BALL,
}, },
@ -118,6 +125,7 @@ const struct Item gItems[] =
.description = sNestBallDesc, .description = sNestBallDesc,
.pocket = POCKET_POKE_BALLS, .pocket = POCKET_POKE_BALLS,
.type = ITEM_USE_BAG_MENU, .type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_PokeBall,
.battleUsage = EFFECT_ITEM_THROW_BALL, .battleUsage = EFFECT_ITEM_THROW_BALL,
.secondaryId = ITEM_NEST_BALL - FIRST_BALL, .secondaryId = ITEM_NEST_BALL - FIRST_BALL,
}, },
@ -129,6 +137,7 @@ const struct Item gItems[] =
.description = sDiveBallDesc, .description = sDiveBallDesc,
.pocket = POCKET_POKE_BALLS, .pocket = POCKET_POKE_BALLS,
.type = ITEM_USE_BAG_MENU, .type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_PokeBall,
.battleUsage = EFFECT_ITEM_THROW_BALL, .battleUsage = EFFECT_ITEM_THROW_BALL,
.secondaryId = ITEM_DIVE_BALL - FIRST_BALL, .secondaryId = ITEM_DIVE_BALL - FIRST_BALL,
}, },
@ -140,6 +149,7 @@ const struct Item gItems[] =
.description = sDuskBallDesc, .description = sDuskBallDesc,
.pocket = POCKET_POKE_BALLS, .pocket = POCKET_POKE_BALLS,
.type = ITEM_USE_BAG_MENU, .type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_PokeBall,
.battleUsage = EFFECT_ITEM_THROW_BALL, .battleUsage = EFFECT_ITEM_THROW_BALL,
.secondaryId = ITEM_DUSK_BALL - FIRST_BALL, .secondaryId = ITEM_DUSK_BALL - FIRST_BALL,
}, },
@ -151,6 +161,7 @@ const struct Item gItems[] =
.description = sTimerBallDesc, .description = sTimerBallDesc,
.pocket = POCKET_POKE_BALLS, .pocket = POCKET_POKE_BALLS,
.type = ITEM_USE_BAG_MENU, .type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_PokeBall,
.battleUsage = EFFECT_ITEM_THROW_BALL, .battleUsage = EFFECT_ITEM_THROW_BALL,
.secondaryId = ITEM_TIMER_BALL - FIRST_BALL, .secondaryId = ITEM_TIMER_BALL - FIRST_BALL,
}, },
@ -162,6 +173,7 @@ const struct Item gItems[] =
.description = sQuickBallDesc, .description = sQuickBallDesc,
.pocket = POCKET_POKE_BALLS, .pocket = POCKET_POKE_BALLS,
.type = ITEM_USE_BAG_MENU, .type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_PokeBall,
.battleUsage = EFFECT_ITEM_THROW_BALL, .battleUsage = EFFECT_ITEM_THROW_BALL,
.secondaryId = ITEM_QUICK_BALL - FIRST_BALL, .secondaryId = ITEM_QUICK_BALL - FIRST_BALL,
}, },
@ -173,6 +185,7 @@ const struct Item gItems[] =
.description = sRepeatBallDesc, .description = sRepeatBallDesc,
.pocket = POCKET_POKE_BALLS, .pocket = POCKET_POKE_BALLS,
.type = ITEM_USE_BAG_MENU, .type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_PokeBall,
.battleUsage = EFFECT_ITEM_THROW_BALL, .battleUsage = EFFECT_ITEM_THROW_BALL,
.secondaryId = ITEM_REPEAT_BALL - FIRST_BALL, .secondaryId = ITEM_REPEAT_BALL - FIRST_BALL,
}, },
@ -184,6 +197,7 @@ const struct Item gItems[] =
.description = sLuxuryBallDesc, .description = sLuxuryBallDesc,
.pocket = POCKET_POKE_BALLS, .pocket = POCKET_POKE_BALLS,
.type = ITEM_USE_BAG_MENU, .type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_PokeBall,
.battleUsage = EFFECT_ITEM_THROW_BALL, .battleUsage = EFFECT_ITEM_THROW_BALL,
.secondaryId = ITEM_LUXURY_BALL - FIRST_BALL, .secondaryId = ITEM_LUXURY_BALL - FIRST_BALL,
}, },
@ -195,6 +209,7 @@ const struct Item gItems[] =
.description = sLevelBallDesc, .description = sLevelBallDesc,
.pocket = POCKET_POKE_BALLS, .pocket = POCKET_POKE_BALLS,
.type = ITEM_USE_BAG_MENU, .type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_PokeBall,
.battleUsage = EFFECT_ITEM_THROW_BALL, .battleUsage = EFFECT_ITEM_THROW_BALL,
.secondaryId = ITEM_LEVEL_BALL - FIRST_BALL, .secondaryId = ITEM_LEVEL_BALL - FIRST_BALL,
}, },
@ -206,6 +221,7 @@ const struct Item gItems[] =
.description = sLureBallDesc, .description = sLureBallDesc,
.pocket = POCKET_POKE_BALLS, .pocket = POCKET_POKE_BALLS,
.type = ITEM_USE_BAG_MENU, .type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_PokeBall,
.battleUsage = EFFECT_ITEM_THROW_BALL, .battleUsage = EFFECT_ITEM_THROW_BALL,
.secondaryId = ITEM_LURE_BALL - FIRST_BALL, .secondaryId = ITEM_LURE_BALL - FIRST_BALL,
}, },
@ -217,6 +233,7 @@ const struct Item gItems[] =
.description = sMoonBallDesc, .description = sMoonBallDesc,
.pocket = POCKET_POKE_BALLS, .pocket = POCKET_POKE_BALLS,
.type = ITEM_USE_BAG_MENU, .type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_PokeBall,
.battleUsage = EFFECT_ITEM_THROW_BALL, .battleUsage = EFFECT_ITEM_THROW_BALL,
.secondaryId = ITEM_MOON_BALL - FIRST_BALL, .secondaryId = ITEM_MOON_BALL - FIRST_BALL,
}, },
@ -228,6 +245,7 @@ const struct Item gItems[] =
.description = sFriendBallDesc, .description = sFriendBallDesc,
.pocket = POCKET_POKE_BALLS, .pocket = POCKET_POKE_BALLS,
.type = ITEM_USE_BAG_MENU, .type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_PokeBall,
.battleUsage = EFFECT_ITEM_THROW_BALL, .battleUsage = EFFECT_ITEM_THROW_BALL,
.secondaryId = ITEM_FRIEND_BALL - FIRST_BALL, .secondaryId = ITEM_FRIEND_BALL - FIRST_BALL,
}, },
@ -239,6 +257,7 @@ const struct Item gItems[] =
.description = sLoveBallDesc, .description = sLoveBallDesc,
.pocket = POCKET_POKE_BALLS, .pocket = POCKET_POKE_BALLS,
.type = ITEM_USE_BAG_MENU, .type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_PokeBall,
.battleUsage = EFFECT_ITEM_THROW_BALL, .battleUsage = EFFECT_ITEM_THROW_BALL,
.secondaryId = ITEM_LOVE_BALL - FIRST_BALL, .secondaryId = ITEM_LOVE_BALL - FIRST_BALL,
}, },
@ -250,6 +269,7 @@ const struct Item gItems[] =
.description = sFastBallDesc, .description = sFastBallDesc,
.pocket = POCKET_POKE_BALLS, .pocket = POCKET_POKE_BALLS,
.type = ITEM_USE_BAG_MENU, .type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_PokeBall,
.battleUsage = EFFECT_ITEM_THROW_BALL, .battleUsage = EFFECT_ITEM_THROW_BALL,
.secondaryId = ITEM_FAST_BALL - FIRST_BALL, .secondaryId = ITEM_FAST_BALL - FIRST_BALL,
}, },
@ -261,6 +281,7 @@ const struct Item gItems[] =
.description = sHeavyBallDesc, .description = sHeavyBallDesc,
.pocket = POCKET_POKE_BALLS, .pocket = POCKET_POKE_BALLS,
.type = ITEM_USE_BAG_MENU, .type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_PokeBall,
.battleUsage = EFFECT_ITEM_THROW_BALL, .battleUsage = EFFECT_ITEM_THROW_BALL,
.secondaryId = ITEM_HEAVY_BALL - FIRST_BALL, .secondaryId = ITEM_HEAVY_BALL - FIRST_BALL,
}, },
@ -272,6 +293,7 @@ const struct Item gItems[] =
.description = sDreamBallDesc, .description = sDreamBallDesc,
.pocket = POCKET_POKE_BALLS, .pocket = POCKET_POKE_BALLS,
.type = ITEM_USE_BAG_MENU, .type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_PokeBall,
.battleUsage = EFFECT_ITEM_THROW_BALL, .battleUsage = EFFECT_ITEM_THROW_BALL,
.secondaryId = ITEM_DREAM_BALL - FIRST_BALL, .secondaryId = ITEM_DREAM_BALL - FIRST_BALL,
}, },
@ -283,6 +305,7 @@ const struct Item gItems[] =
.description = sSafariBallDesc, .description = sSafariBallDesc,
.pocket = POCKET_POKE_BALLS, .pocket = POCKET_POKE_BALLS,
.type = ITEM_USE_BAG_MENU, .type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_PokeBall,
.battleUsage = EFFECT_ITEM_THROW_BALL, .battleUsage = EFFECT_ITEM_THROW_BALL,
.secondaryId = ITEM_SAFARI_BALL - FIRST_BALL, .secondaryId = ITEM_SAFARI_BALL - FIRST_BALL,
}, },
@ -294,6 +317,7 @@ const struct Item gItems[] =
.description = sSportBallDesc, .description = sSportBallDesc,
.pocket = POCKET_POKE_BALLS, .pocket = POCKET_POKE_BALLS,
.type = ITEM_USE_BAG_MENU, .type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_PokeBall,
.battleUsage = EFFECT_ITEM_THROW_BALL, .battleUsage = EFFECT_ITEM_THROW_BALL,
.secondaryId = ITEM_SPORT_BALL - FIRST_BALL, .secondaryId = ITEM_SPORT_BALL - FIRST_BALL,
}, },
@ -305,6 +329,7 @@ const struct Item gItems[] =
.description = sParkBallDesc, .description = sParkBallDesc,
.pocket = POCKET_POKE_BALLS, .pocket = POCKET_POKE_BALLS,
.type = ITEM_USE_BAG_MENU, .type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_PokeBall,
.battleUsage = EFFECT_ITEM_THROW_BALL, .battleUsage = EFFECT_ITEM_THROW_BALL,
.secondaryId = ITEM_PARK_BALL - FIRST_BALL, .secondaryId = ITEM_PARK_BALL - FIRST_BALL,
}, },
@ -316,6 +341,7 @@ const struct Item gItems[] =
.description = sBeastBallDesc, .description = sBeastBallDesc,
.pocket = POCKET_POKE_BALLS, .pocket = POCKET_POKE_BALLS,
.type = ITEM_USE_BAG_MENU, .type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_PokeBall,
.battleUsage = EFFECT_ITEM_THROW_BALL, .battleUsage = EFFECT_ITEM_THROW_BALL,
.secondaryId = ITEM_BEAST_BALL - FIRST_BALL, .secondaryId = ITEM_BEAST_BALL - FIRST_BALL,
}, },
@ -327,6 +353,7 @@ const struct Item gItems[] =
.description = sCherishBallDesc, .description = sCherishBallDesc,
.pocket = POCKET_POKE_BALLS, .pocket = POCKET_POKE_BALLS,
.type = ITEM_USE_BAG_MENU, .type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_PokeBall,
.battleUsage = EFFECT_ITEM_THROW_BALL, .battleUsage = EFFECT_ITEM_THROW_BALL,
.secondaryId = ITEM_CHERISH_BALL - FIRST_BALL, .secondaryId = ITEM_CHERISH_BALL - FIRST_BALL,
}, },

View File

@ -295,7 +295,7 @@ static const u8 sContextMenuItems_KeyItemsPocket[] = {
}; };
static const u8 sContextMenuItems_BallsPocket[] = { static const u8 sContextMenuItems_BallsPocket[] = {
ACTION_GIVE, ACTION_DUMMY, ACTION_USE, ACTION_GIVE,
ACTION_TOSS, ACTION_CANCEL ACTION_TOSS, ACTION_CANCEL
}; };

View File

@ -1351,3 +1351,10 @@ void ItemUseOutOfBattle_CannotUse(u8 taskId)
} }
#undef tUsingRegisteredKeyItem #undef tUsingRegisteredKeyItem
void ItemUseOutOfBattle_PokeBall(u8 taskId)
{
gItemUseCB = ItemUseCB_PokeBall;
gBagMenu->newScreenCallback = CB2_ShowPartyMenuForItemUse;
Task_FadeAndCloseBagMenu(taskId);
}

View File

@ -6964,3 +6964,32 @@ void IsLastMonThatKnowsSurf(void)
gSpecialVar_Result = TRUE; gSpecialVar_Result = TRUE;
} }
} }
void ItemUseCB_PokeBall(u8 taskId, TaskFunc task)
{
struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId];
u16 currBall = GetMonData(mon, MON_DATA_POKEBALL);
u16 newBall = gSpecialVar_ItemId;
static const u8 sText_MonBallWasChanged[] = _("{STR_VAR_1} was put in the {STR_VAR_2}.{PAUSE_UNTIL_PRESS}");
if (currBall == newBall)
{
gPartyMenuUseExitCallback = FALSE;
DisplayPartyMenuMessage(gText_WontHaveEffect, TRUE);
ScheduleBgCopyTilemapToVram(2);
gTasks[taskId].func = task;
}
else
{
GetMonNickname(mon, gStringVar1);
CopyItemName(newBall, gStringVar2);
PlaySE(SE_SELECT);
gPartyMenuUseExitCallback = TRUE;
SetMonData(mon, MON_DATA_POKEBALL, &newBall);
StringExpandPlaceholders(gStringVar4, sText_MonBallWasChanged);
DisplayPartyMenuMessage(gStringVar4, TRUE);
ScheduleBgCopyTilemapToVram(2);
gTasks[taskId].func = task;
RemoveBagItem(newBall, 1);
}
}