From 76eae8ed000c4cc55ae16d16a5b5c99907a41ddf Mon Sep 17 00:00:00 2001 From: Alex <93446519+AlexOn1ine@users.noreply.github.com> Date: Mon, 28 Oct 2024 18:03:15 +0100 Subject: [PATCH] Decouple Poke Ball ids from item ids (#5560) --- graphics/balls/strange.png | Bin 0 -> 358 bytes graphics/items/icon_palettes/strange_ball.pal | 19 ++ graphics/items/icons/strange_ball.png | Bin 0 -> 304 bytes include/battle_anim.h | 1 - include/constants/items.h | 10 +- include/graphics.h | 4 + include/item.h | 2 +- include/pokeball.h | 58 +++--- migration_scripts/README.md | 2 +- src/battle_anim_throw.c | 176 ++++++------------ src/battle_main.c | 22 +-- src/battle_script_commands.c | 62 +++--- src/data/graphics/items.h | 3 + src/data/graphics/pokeballs.h | 3 + src/data/items.h | 70 ++++--- src/daycare.c | 22 +-- src/debug.c | 8 +- src/egg_hatch.c | 3 +- src/event_object_movement.c | 4 +- src/item.c | 9 +- src/pokeball.c | 84 ++++++--- src/pokemon.c | 2 +- src/pokemon_summary_screen.c | 18 +- src/script_pokemon_util.c | 6 +- test/battle/trainer_control.c | 4 +- test/pokemon.c | 4 +- 26 files changed, 300 insertions(+), 296 deletions(-) create mode 100644 graphics/balls/strange.png create mode 100644 graphics/items/icon_palettes/strange_ball.pal create mode 100644 graphics/items/icons/strange_ball.png diff --git a/graphics/balls/strange.png b/graphics/balls/strange.png new file mode 100644 index 0000000000000000000000000000000000000000..a4d141bead9bd3714e7eb1cbd94eaad7c6b8e1f0 GIT binary patch literal 358 zcmeAS@N?(olHy`uVBq!ia0vp^0zhoQ!VDx|6+TY^QjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`bpw1tT>t<7@95~*cx6}Uxuuo2SM7a!F6!d^|Np-~`+aZg{cC(Z6Q4bQ zHfP<@?(Xj7eS58&jGh2Bau#?*7BevL9R^{>~VUO@=d$ zt`M5EMuj11$FyAyl1_Spx?WulZA-kadoAsBXuERe>hd%_79*9gwU%4CR1V#^xV1cd5a`e3SOe|Wn`0@woI5r~Vauci3xqn-m@>l|UNRXv>=JS0QJgTZ zyQyiDLTytyYa_>+XYXPiJ5DwU2x}JbGcz+>5;r>a#<`^p=o;^2UbTgz zu$W=)oUD6mG`H=II=3cj+ZGN62FHDSix2H(C~anFY-ZqLh_nCA2GlE1666>B9}S#U z+%yF!H{a96F+^kH)`E+tW$C=`h>Ao)+w|rJLf7-Y0 zw#CMh8G6&F2tHwcZNqONBW5Ann&{$XIJczl^D+_ZX{I(QY}~g}c*sTimer = 0; sprite->callback = SpriteCB_Ball_MonShrink; - ballId = ItemIdToBallId(gLastUsedItem); - switch (ballId) - { - case 0 ... POKEBALL_COUNT - 1: - AnimateBallOpenParticles(sprite->x, sprite->y - 5, 1, 28, ballId); - LaunchBallFadeMonTask(FALSE, gBattleAnimTarget, 14, ballId); - break; - } + enum PokeBall ballId = ItemIdToBallId(gLastUsedItem); + AnimateBallOpenParticles(sprite->x, sprite->y - 5, 1, 28, ballId); + LaunchBallFadeMonTask(FALSE, gBattleAnimTarget, 14, ballId); } } } @@ -1720,20 +1663,13 @@ static void SpriteCB_CaptureStar_Flicker(struct Sprite *sprite) // - Wild mon emerge from Poké Ball static void SpriteCB_Ball_Release_Step(struct Sprite *sprite) { - u8 ballId; - StartSpriteAnim(sprite, 1); StartSpriteAffineAnim(sprite, 0); sprite->callback = SpriteCB_Ball_Release_Wait; - ballId = ItemIdToBallId(gLastUsedItem); - switch (ballId) - { - case 0 ... POKEBALL_COUNT - 1: - AnimateBallOpenParticles(sprite->x, sprite->y - 5, 1, 28, ballId); - LaunchBallFadeMonTask(TRUE, gBattleAnimTarget, 14, ballId); - break; - } + enum PokeBall ballId = ItemIdToBallId(gLastUsedItem); + AnimateBallOpenParticles(sprite->x, sprite->y - 5, 1, 28, ballId); + LaunchBallFadeMonTask(TRUE, gBattleAnimTarget, 14, ballId); // Animate Pokémon emerging from Poké Ball gSprites[gBattlerSpriteIds[gBattleAnimTarget]].invisible = FALSE; diff --git a/src/battle_main.c b/src/battle_main.c index d60b239981..7b71b8449d 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -320,15 +320,15 @@ const struct TrainerClass gTrainerClasses[TRAINER_CLASS_COUNT] = TRAINER_CLASS(TRAINER_CLASS_HIKER, "HIKER", 10), TRAINER_CLASS(TRAINER_CLASS_TEAM_AQUA, "TEAM AQUA"), TRAINER_CLASS(TRAINER_CLASS_PKMN_BREEDER, "{PKMN} BREEDER", 10, B_TRAINER_CLASS_POKE_BALLS >= GEN_8 ? ITEM_HEAL_BALL : ITEM_FRIEND_BALL), - TRAINER_CLASS(TRAINER_CLASS_COOLTRAINER, "COOLTRAINER", 12, ITEM_ULTRA_BALL), + TRAINER_CLASS(TRAINER_CLASS_COOLTRAINER, "COOLTRAINER", 12, BALL_ULTRA), TRAINER_CLASS(TRAINER_CLASS_BIRD_KEEPER, "BIRD KEEPER", 8), - TRAINER_CLASS(TRAINER_CLASS_COLLECTOR, "COLLECTOR", 15, ITEM_PREMIER_BALL), - TRAINER_CLASS(TRAINER_CLASS_SWIMMER_M, "SWIMMER♂", 2, ITEM_DIVE_BALL), + TRAINER_CLASS(TRAINER_CLASS_COLLECTOR, "COLLECTOR", 15, BALL_PREMIER), + TRAINER_CLASS(TRAINER_CLASS_SWIMMER_M, "SWIMMER♂", 2, BALL_DIVE), TRAINER_CLASS(TRAINER_CLASS_TEAM_MAGMA, "TEAM MAGMA"), TRAINER_CLASS(TRAINER_CLASS_EXPERT, "EXPERT", 10), TRAINER_CLASS(TRAINER_CLASS_AQUA_ADMIN, "AQUA ADMIN", 10), - TRAINER_CLASS(TRAINER_CLASS_BLACK_BELT, "BLACK BELT", 8, ITEM_ULTRA_BALL), - TRAINER_CLASS(TRAINER_CLASS_AQUA_LEADER, "AQUA LEADER", 20, ITEM_MASTER_BALL), + TRAINER_CLASS(TRAINER_CLASS_BLACK_BELT, "BLACK BELT", 8, BALL_ULTRA), + TRAINER_CLASS(TRAINER_CLASS_AQUA_LEADER, "AQUA LEADER", 20, BALL_MASTER), TRAINER_CLASS(TRAINER_CLASS_HEX_MANIAC, "HEX MANIAC", 6), TRAINER_CLASS(TRAINER_CLASS_AROMA_LADY, "AROMA LADY", 10), TRAINER_CLASS(TRAINER_CLASS_RUIN_MANIAC, "RUIN MANIAC", 15), @@ -345,8 +345,8 @@ const struct TrainerClass gTrainerClasses[TRAINER_CLASS_COUNT] = TRAINER_CLASS(TRAINER_CLASS_PICNICKER, "PICNICKER", 4), TRAINER_CLASS(TRAINER_CLASS_BUG_MANIAC, "BUG MANIAC", 15), TRAINER_CLASS(TRAINER_CLASS_PSYCHIC, "PSYCHIC", 6), - TRAINER_CLASS(TRAINER_CLASS_GENTLEMAN, "GENTLEMAN", 20, ITEM_LUXURY_BALL), - TRAINER_CLASS(TRAINER_CLASS_ELITE_FOUR, "ELITE FOUR", 25, ITEM_ULTRA_BALL), + TRAINER_CLASS(TRAINER_CLASS_GENTLEMAN, "GENTLEMAN", 20, BALL_LUXURY), + TRAINER_CLASS(TRAINER_CLASS_ELITE_FOUR, "ELITE FOUR", 25, BALL_ULTRA), TRAINER_CLASS(TRAINER_CLASS_LEADER, "LEADER", 25), TRAINER_CLASS(TRAINER_CLASS_SCHOOL_KID, "SCHOOL KID"), TRAINER_CLASS(TRAINER_CLASS_SR_AND_JR, "SR. AND JR.", 4), @@ -354,21 +354,21 @@ const struct TrainerClass gTrainerClasses[TRAINER_CLASS_COUNT] = TRAINER_CLASS(TRAINER_CLASS_POKEFAN, "POKéFAN", 20), TRAINER_CLASS(TRAINER_CLASS_YOUNGSTER, "YOUNGSTER", 4), TRAINER_CLASS(TRAINER_CLASS_CHAMPION, "CHAMPION", 50), - TRAINER_CLASS(TRAINER_CLASS_FISHERMAN, "FISHERMAN", 10, B_TRAINER_CLASS_POKE_BALLS >= GEN_8 ? ITEM_DIVE_BALL : ITEM_LURE_BALL), + TRAINER_CLASS(TRAINER_CLASS_FISHERMAN, "FISHERMAN", 10, B_TRAINER_CLASS_POKE_BALLS >= GEN_8 ? BALL_DIVE : BALL_LURE), TRAINER_CLASS(TRAINER_CLASS_TRIATHLETE, "TRIATHLETE", 10), TRAINER_CLASS(TRAINER_CLASS_DRAGON_TAMER, "DRAGON TAMER", 12), TRAINER_CLASS(TRAINER_CLASS_NINJA_BOY, "NINJA BOY", 3), TRAINER_CLASS(TRAINER_CLASS_BATTLE_GIRL, "BATTLE GIRL", 6), TRAINER_CLASS(TRAINER_CLASS_PARASOL_LADY, "PARASOL LADY", 10), - TRAINER_CLASS(TRAINER_CLASS_SWIMMER_F, "SWIMMER♀", 2, ITEM_DIVE_BALL), + TRAINER_CLASS(TRAINER_CLASS_SWIMMER_F, "SWIMMER♀", 2, BALL_DIVE), TRAINER_CLASS(TRAINER_CLASS_TWINS, "TWINS", 3), TRAINER_CLASS(TRAINER_CLASS_SAILOR, "SAILOR", 8), - TRAINER_CLASS(TRAINER_CLASS_COOLTRAINER_2, "COOLTRAINER", 5, ITEM_ULTRA_BALL), + TRAINER_CLASS(TRAINER_CLASS_COOLTRAINER_2, "COOLTRAINER", 5, BALL_ULTRA), TRAINER_CLASS(TRAINER_CLASS_MAGMA_ADMIN, "MAGMA ADMIN", 10), TRAINER_CLASS(TRAINER_CLASS_RIVAL, "{PKMN} TRAINER", 15), TRAINER_CLASS(TRAINER_CLASS_BUG_CATCHER, "BUG CATCHER", 4), TRAINER_CLASS(TRAINER_CLASS_PKMN_RANGER, "{PKMN} RANGER", 12), - TRAINER_CLASS(TRAINER_CLASS_MAGMA_LEADER, "MAGMA LEADER", 20, ITEM_MASTER_BALL), + TRAINER_CLASS(TRAINER_CLASS_MAGMA_LEADER, "MAGMA LEADER", 20, BALL_MASTER), TRAINER_CLASS(TRAINER_CLASS_LASS, "LASS", 4), TRAINER_CLASS(TRAINER_CLASS_YOUNG_COUPLE, "YOUNG COUPLE", 8), TRAINER_CLASS(TRAINER_CLASS_OLD_COUPLE, "OLD COUPLE", 10), diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 005ee855a5..5424d1b499 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -15173,10 +15173,10 @@ static void Cmd_handleballthrow(void) else { u32 odds, i; - u8 catchRate; + u32 catchRate; + u32 ballId = ItemIdToBallId(gLastUsedItem); - gLastThrownBall = gLastUsedItem; - gBallToDisplay = gLastThrownBall; + gBallToDisplay = gLastThrownBall = gLastUsedItem; if (gBattleTypeFlags & BATTLE_TYPE_SAFARI) catchRate = gBattleStruct->safariCatchFactor * 1275 / 100; else @@ -15184,39 +15184,39 @@ static void Cmd_handleballthrow(void) if (gSpeciesInfo[gBattleMons[gBattlerTarget].species].isUltraBeast) { - if (gLastUsedItem == ITEM_BEAST_BALL) + if (ballId == BALL_BEAST) ballMultiplier = 500; else ballMultiplier = 10; } else { - switch (gLastUsedItem) + switch (ballId) { - case ITEM_ULTRA_BALL: + case BALL_ULTRA: ballMultiplier = 200; break; - case ITEM_SPORT_BALL: + case BALL_SPORT: if (B_SPORT_BALL_MODIFIER <= GEN_7) ballMultiplier = 150; break; - case ITEM_GREAT_BALL: + case BALL_GREAT: ballMultiplier = 150; break; - case ITEM_SAFARI_BALL: + case BALL_SAFARI: if (B_SAFARI_BALL_MODIFIER <= GEN_7) ballMultiplier = 150; break; - case ITEM_NET_BALL: + case BALL_NET: if (IS_BATTLER_OF_TYPE(gBattlerTarget, TYPE_WATER) || IS_BATTLER_OF_TYPE(gBattlerTarget, TYPE_BUG)) ballMultiplier = B_NET_BALL_MODIFIER >= GEN_7 ? 350 : 300; break; - case ITEM_DIVE_BALL: + case BALL_DIVE: if (GetCurrentMapType() == MAP_TYPE_UNDERWATER || (B_DIVE_BALL_MODIFIER >= GEN_4 && (gIsFishingEncounter || gIsSurfingEncounter))) ballMultiplier = 350; break; - case ITEM_NEST_BALL: + case BALL_NEST: if (B_NEST_BALL_MODIFIER >= GEN_6) { //((41 - Pokémon's level) ÷ 10)× if Pokémon's level is between 1 and 29, 1× otherwise. @@ -15237,25 +15237,25 @@ static void Cmd_handleballthrow(void) ballMultiplier = 100; } break; - case ITEM_REPEAT_BALL: + case BALL_REPEAT: if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(gBattleMons[gBattlerTarget].species), FLAG_GET_CAUGHT)) ballMultiplier = (B_REPEAT_BALL_MODIFIER >= GEN_7 ? 350 : 300); break; - case ITEM_TIMER_BALL: + case BALL_TIMER: ballMultiplier = 100 + (gBattleResults.battleTurnCounter * (B_TIMER_BALL_MODIFIER >= GEN_5 ? 30 : 10)); if (ballMultiplier > 400) ballMultiplier = 400; break; - case ITEM_DUSK_BALL: + case BALL_DUSK: i = GetTimeOfDay(); if (i == TIME_EVENING || i == TIME_NIGHT || gMapHeader.cave || gMapHeader.mapType == MAP_TYPE_UNDERGROUND) ballMultiplier = (B_DUSK_BALL_MODIFIER >= GEN_7 ? 300 : 350); break; - case ITEM_QUICK_BALL: + case BALL_QUICK: if (gBattleResults.battleTurnCounter == 0) ballMultiplier = (B_QUICK_BALL_MODIFIER >= GEN_5 ? 500 : 400); break; - case ITEM_LEVEL_BALL: + case BALL_LEVEL: if (gBattleMons[gBattlerAttacker].level >= 4 * gBattleMons[gBattlerTarget].level) ballMultiplier = 800; else if (gBattleMons[gBattlerAttacker].level > 2 * gBattleMons[gBattlerTarget].level) @@ -15263,7 +15263,7 @@ static void Cmd_handleballthrow(void) else if (gBattleMons[gBattlerAttacker].level > gBattleMons[gBattlerTarget].level) ballMultiplier = 200; break; - case ITEM_LURE_BALL: + case BALL_LURE: if (gIsFishingEncounter) { if (B_LURE_BALL_MODIFIER >= GEN_8) @@ -15274,7 +15274,7 @@ static void Cmd_handleballthrow(void) ballMultiplier = 300; } break; - case ITEM_MOON_BALL: + case BALL_MOON: { const struct Evolution *evolutions = GetSpeciesEvolutions(gBattleMons[gBattlerTarget].species); if (evolutions == NULL) @@ -15287,7 +15287,7 @@ static void Cmd_handleballthrow(void) } } break; - case ITEM_LOVE_BALL: + case BALL_LOVE: if (gBattleMons[gBattlerTarget].species == gBattleMons[gBattlerAttacker].species) { u8 gender1 = GetMonGender(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]]); @@ -15297,11 +15297,11 @@ static void Cmd_handleballthrow(void) ballMultiplier = 800; } break; - case ITEM_FAST_BALL: + case BALL_FAST: if (gSpeciesInfo[gBattleMons[gBattlerTarget].species].baseSpeed >= 100) ballMultiplier = 400; break; - case ITEM_HEAVY_BALL: + case BALL_HEAVY: i = GetSpeciesWeight(gBattleMons[gBattlerTarget].species); if (B_HEAVY_BALL_MODIFIER >= GEN_7) { @@ -15339,11 +15339,11 @@ static void Cmd_handleballthrow(void) ballAddition = 40; } break; - case ITEM_DREAM_BALL: + case BALL_DREAM: if (B_DREAM_BALL_MODIFIER >= GEN_8 && (gBattleMons[gBattlerTarget].status1 & STATUS1_SLEEP || GetBattlerAbility(gBattlerTarget) == ABILITY_COMATOSE)) ballMultiplier = 400; break; - case ITEM_BEAST_BALL: + case BALL_BEAST: ballMultiplier = 10; break; } @@ -15364,8 +15364,8 @@ static void Cmd_handleballthrow(void) if (gBattleMons[gBattlerTarget].status1 & (STATUS1_POISON | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON | STATUS1_FROSTBITE)) odds = (odds * 15) / 10; - if (gBattleResults.catchAttempts[gLastUsedItem - FIRST_BALL] < 255) - gBattleResults.catchAttempts[gLastUsedItem - FIRST_BALL]++; + if (gBattleResults.catchAttempts[ballId] < 255) + gBattleResults.catchAttempts[ballId]++; if (odds > 254) // mon caught { @@ -15373,14 +15373,14 @@ static void Cmd_handleballthrow(void) MarkBattlerForControllerExec(gBattlerAttacker); TryBattleFormChange(gBattlerTarget, FORM_CHANGE_END_BATTLE); gBattlescriptCurrInstr = BattleScript_SuccessBallThrow; - SetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_POKEBALL, &gLastUsedItem); + SetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_POKEBALL, &ballId); if (CalculatePlayerPartyCount() == PARTY_SIZE) gBattleCommunication[MULTISTRING_CHOOSER] = 0; else gBattleCommunication[MULTISTRING_CHOOSER] = 1; - if (gLastUsedItem == ITEM_HEAL_BALL) + if (gLastUsedItem == BALL_HEAL) { MonRestorePP(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]]); HealStatusConditions(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], STATUS1_ANY, gBattlerTarget); @@ -15406,7 +15406,7 @@ static void Cmd_handleballthrow(void) maxShakes = BALL_3_SHAKES_SUCCESS; } - if (gLastUsedItem == ITEM_MASTER_BALL) + if (ballId == BALL_MASTER) { shakes = maxShakes; } @@ -15427,14 +15427,14 @@ static void Cmd_handleballthrow(void) TryBattleFormChange(gBattlerTarget, FORM_CHANGE_END_BATTLE); gBattlescriptCurrInstr = BattleScript_SuccessBallThrow; - SetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_POKEBALL, &gLastUsedItem); + SetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_POKEBALL, &ballId); if (CalculatePlayerPartyCount() == PARTY_SIZE) gBattleCommunication[MULTISTRING_CHOOSER] = 0; else gBattleCommunication[MULTISTRING_CHOOSER] = 1; - if (gLastUsedItem == ITEM_HEAL_BALL) + if (ballId == BALL_HEAL) { MonRestorePP(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]]); HealStatusConditions(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], STATUS1_ANY, gBattlerTarget); diff --git a/src/data/graphics/items.h b/src/data/graphics/items.h index 45e3ec0e2c..b508df90a1 100644 --- a/src/data/graphics/items.h +++ b/src/data/graphics/items.h @@ -6,6 +6,9 @@ const u32 gItemIconPalette_ReturnToFieldArrow[] = INCBIN_U32("graphics/items/ico // Poké Balls +const u32 gItemIcon_StrangeBall[] = INCBIN_U32("graphics/items/icons/strange_ball.4bpp.lz"); +const u32 gItemIconPalette_StrangeBall[] = INCBIN_U32("graphics/items/icon_palettes/strange_ball.gbapal.lz"); + const u32 gItemIcon_PokeBall[] = INCBIN_U32("graphics/items/icons/poke_ball.4bpp.lz"); const u32 gItemIconPalette_PokeBall[] = INCBIN_U32("graphics/items/icon_palettes/poke_ball.gbapal.lz"); diff --git a/src/data/graphics/pokeballs.h b/src/data/graphics/pokeballs.h index 44f47cde48..f09d635d21 100644 --- a/src/data/graphics/pokeballs.h +++ b/src/data/graphics/pokeballs.h @@ -1,3 +1,6 @@ +const u32 gBallGfx_Strange[] = INCBIN_U32("graphics/balls/strange.4bpp.lz"); +const u32 gBallPal_Strange[] = INCBIN_U32("graphics/balls/strange.gbapal.lz"); + const u32 gBallGfx_Poke[] = INCBIN_U32("graphics/balls/poke.4bpp.lz"); const u32 gBallPal_Poke[] = INCBIN_U32("graphics/balls/poke.gbapal.lz"); diff --git a/src/data/items.h b/src/data/items.h index 88a46efd7d..2b560ad9d5 100644 --- a/src/data/items.h +++ b/src/data/items.h @@ -154,6 +154,22 @@ const struct Item gItemsInfo[] = // Poké Balls + [ITEM_STRANGE_BALL] = + { + .name = _("Strange Ball"), + .price = 0, + .description = COMPOUND_STRING( + "An unusual Ball\n" + "warped through\n" + "space and time."), + .pocket = POCKET_POKE_BALLS, + .type = ITEM_USE_BAG_MENU, + .battleUsage = EFFECT_ITEM_THROW_BALL, + .secondaryId = BALL_STRANGE, + .iconPic = gItemIcon_StrangeBall, + .iconPalette = gItemIconPalette_StrangeBall, + }, + [ITEM_POKE_BALL] = { .name = _("Poké Ball"), @@ -165,7 +181,7 @@ const struct Item gItemsInfo[] = .pocket = POCKET_POKE_BALLS, .type = ITEM_USE_BAG_MENU, .battleUsage = EFFECT_ITEM_THROW_BALL, - .secondaryId = ITEM_POKE_BALL - FIRST_BALL, + .secondaryId = BALL_POKE, .iconPic = gItemIcon_PokeBall, .iconPalette = gItemIconPalette_PokeBall, }, @@ -181,7 +197,7 @@ const struct Item gItemsInfo[] = .pocket = POCKET_POKE_BALLS, .type = ITEM_USE_BAG_MENU, .battleUsage = EFFECT_ITEM_THROW_BALL, - .secondaryId = ITEM_GREAT_BALL - FIRST_BALL, + .secondaryId = BALL_GREAT, .iconPic = gItemIcon_GreatBall, .iconPalette = gItemIconPalette_GreatBall, }, @@ -197,7 +213,7 @@ const struct Item gItemsInfo[] = .pocket = POCKET_POKE_BALLS, .type = ITEM_USE_BAG_MENU, .battleUsage = EFFECT_ITEM_THROW_BALL, - .secondaryId = ITEM_ULTRA_BALL - FIRST_BALL, + .secondaryId = BALL_ULTRA, .iconPic = gItemIcon_UltraBall, .iconPalette = gItemIconPalette_UltraBall, }, @@ -213,7 +229,7 @@ const struct Item gItemsInfo[] = .pocket = POCKET_POKE_BALLS, .type = ITEM_USE_BAG_MENU, .battleUsage = EFFECT_ITEM_THROW_BALL, - .secondaryId = ITEM_MASTER_BALL - FIRST_BALL, + .secondaryId = BALL_MASTER, .iconPic = gItemIcon_MasterBall, .iconPalette = gItemIconPalette_MasterBall, }, @@ -229,7 +245,7 @@ const struct Item gItemsInfo[] = .pocket = POCKET_POKE_BALLS, .type = ITEM_USE_BAG_MENU, .battleUsage = EFFECT_ITEM_THROW_BALL, - .secondaryId = ITEM_PREMIER_BALL - FIRST_BALL, + .secondaryId = BALL_PREMIER, .iconPic = gItemIcon_PremierBall, .iconPalette = gItemIconPalette_LuxuryBall, }, @@ -245,7 +261,7 @@ const struct Item gItemsInfo[] = .pocket = POCKET_POKE_BALLS, .type = ITEM_USE_BAG_MENU, .battleUsage = EFFECT_ITEM_THROW_BALL, - .secondaryId = ITEM_HEAL_BALL - FIRST_BALL, + .secondaryId = BALL_HEAL, .iconPic = gItemIcon_HealBall, .iconPalette = gItemIconPalette_HealBall, }, @@ -261,7 +277,7 @@ const struct Item gItemsInfo[] = .pocket = POCKET_POKE_BALLS, .type = ITEM_USE_BAG_MENU, .battleUsage = EFFECT_ITEM_THROW_BALL, - .secondaryId = ITEM_NET_BALL - FIRST_BALL, + .secondaryId = BALL_NET, .iconPic = gItemIcon_NetBall, .iconPalette = gItemIconPalette_NetBall, }, @@ -277,7 +293,7 @@ const struct Item gItemsInfo[] = .pocket = POCKET_POKE_BALLS, .type = ITEM_USE_BAG_MENU, .battleUsage = EFFECT_ITEM_THROW_BALL, - .secondaryId = ITEM_NEST_BALL - FIRST_BALL, + .secondaryId = BALL_NEST, .iconPic = gItemIcon_NestBall, .iconPalette = gItemIconPalette_NestBall, }, @@ -293,7 +309,7 @@ const struct Item gItemsInfo[] = .pocket = POCKET_POKE_BALLS, .type = ITEM_USE_BAG_MENU, .battleUsage = EFFECT_ITEM_THROW_BALL, - .secondaryId = ITEM_DIVE_BALL - FIRST_BALL, + .secondaryId = BALL_DIVE, .iconPic = gItemIcon_DiveBall, .iconPalette = gItemIconPalette_DiveBall, }, @@ -309,7 +325,7 @@ const struct Item gItemsInfo[] = .pocket = POCKET_POKE_BALLS, .type = ITEM_USE_BAG_MENU, .battleUsage = EFFECT_ITEM_THROW_BALL, - .secondaryId = ITEM_DUSK_BALL - FIRST_BALL, + .secondaryId = BALL_DUSK, .iconPic = gItemIcon_DuskBall, .iconPalette = gItemIconPalette_DuskBall, }, @@ -325,7 +341,7 @@ const struct Item gItemsInfo[] = .pocket = POCKET_POKE_BALLS, .type = ITEM_USE_BAG_MENU, .battleUsage = EFFECT_ITEM_THROW_BALL, - .secondaryId = ITEM_TIMER_BALL - FIRST_BALL, + .secondaryId = BALL_TIMER, .iconPic = gItemIcon_TimerBall, .iconPalette = gItemIconPalette_RepeatBall, }, @@ -341,7 +357,7 @@ const struct Item gItemsInfo[] = .pocket = POCKET_POKE_BALLS, .type = ITEM_USE_BAG_MENU, .battleUsage = EFFECT_ITEM_THROW_BALL, - .secondaryId = ITEM_QUICK_BALL - FIRST_BALL, + .secondaryId = BALL_QUICK, .iconPic = gItemIcon_QuickBall, .iconPalette = gItemIconPalette_QuickBall, }, @@ -357,7 +373,7 @@ const struct Item gItemsInfo[] = .pocket = POCKET_POKE_BALLS, .type = ITEM_USE_BAG_MENU, .battleUsage = EFFECT_ITEM_THROW_BALL, - .secondaryId = ITEM_REPEAT_BALL - FIRST_BALL, + .secondaryId = BALL_REPEAT, .iconPic = gItemIcon_RepeatBall, .iconPalette = gItemIconPalette_RepeatBall, }, @@ -373,7 +389,7 @@ const struct Item gItemsInfo[] = .pocket = POCKET_POKE_BALLS, .type = ITEM_USE_BAG_MENU, .battleUsage = EFFECT_ITEM_THROW_BALL, - .secondaryId = ITEM_LUXURY_BALL - FIRST_BALL, + .secondaryId = BALL_LUXURY, .iconPic = gItemIcon_LuxuryBall, .iconPalette = gItemIconPalette_LuxuryBall, }, @@ -389,7 +405,7 @@ const struct Item gItemsInfo[] = .pocket = POCKET_POKE_BALLS, .type = ITEM_USE_BAG_MENU, .battleUsage = EFFECT_ITEM_THROW_BALL, - .secondaryId = ITEM_LEVEL_BALL - FIRST_BALL, + .secondaryId = BALL_LEVEL, .iconPic = gItemIcon_LevelBall, .iconPalette = gItemIconPalette_LevelBall, }, @@ -405,7 +421,7 @@ const struct Item gItemsInfo[] = .pocket = POCKET_POKE_BALLS, .type = ITEM_USE_BAG_MENU, .battleUsage = EFFECT_ITEM_THROW_BALL, - .secondaryId = ITEM_LURE_BALL - FIRST_BALL, + .secondaryId = BALL_LURE, .iconPic = gItemIcon_LureBall, .iconPalette = gItemIconPalette_LureBall, }, @@ -421,7 +437,7 @@ const struct Item gItemsInfo[] = .pocket = POCKET_POKE_BALLS, .type = ITEM_USE_BAG_MENU, .battleUsage = EFFECT_ITEM_THROW_BALL, - .secondaryId = ITEM_MOON_BALL - FIRST_BALL, + .secondaryId = BALL_MOON, .iconPic = gItemIcon_MoonBall, .iconPalette = gItemIconPalette_MoonBall, }, @@ -437,7 +453,7 @@ const struct Item gItemsInfo[] = .pocket = POCKET_POKE_BALLS, .type = ITEM_USE_BAG_MENU, .battleUsage = EFFECT_ITEM_THROW_BALL, - .secondaryId = ITEM_FRIEND_BALL - FIRST_BALL, + .secondaryId = BALL_FRIEND, .iconPic = gItemIcon_FriendBall, .iconPalette = gItemIconPalette_FriendBall, }, @@ -453,7 +469,7 @@ const struct Item gItemsInfo[] = .pocket = POCKET_POKE_BALLS, .type = ITEM_USE_BAG_MENU, .battleUsage = EFFECT_ITEM_THROW_BALL, - .secondaryId = ITEM_LOVE_BALL - FIRST_BALL, + .secondaryId = BALL_LOVE, .iconPic = gItemIcon_LoveBall, .iconPalette = gItemIconPalette_LoveBall, }, @@ -469,7 +485,7 @@ const struct Item gItemsInfo[] = .pocket = POCKET_POKE_BALLS, .type = ITEM_USE_BAG_MENU, .battleUsage = EFFECT_ITEM_THROW_BALL, - .secondaryId = ITEM_FAST_BALL - FIRST_BALL, + .secondaryId = BALL_FAST, .iconPic = gItemIcon_FastBall, .iconPalette = gItemIconPalette_FastBall, }, @@ -485,7 +501,7 @@ const struct Item gItemsInfo[] = .pocket = POCKET_POKE_BALLS, .type = ITEM_USE_BAG_MENU, .battleUsage = EFFECT_ITEM_THROW_BALL, - .secondaryId = ITEM_HEAVY_BALL - FIRST_BALL, + .secondaryId = BALL_HEAVY, .iconPic = gItemIcon_HeavyBall, .iconPalette = gItemIconPalette_HeavyBall, }, @@ -506,7 +522,7 @@ const struct Item gItemsInfo[] = .pocket = POCKET_POKE_BALLS, .type = ITEM_USE_BAG_MENU, .battleUsage = EFFECT_ITEM_THROW_BALL, - .secondaryId = ITEM_DREAM_BALL - FIRST_BALL, + .secondaryId = BALL_DREAM, .iconPic = gItemIcon_DreamBall, .iconPalette = gItemIconPalette_DreamBall, }, @@ -522,7 +538,7 @@ const struct Item gItemsInfo[] = .pocket = POCKET_POKE_BALLS, .type = ITEM_USE_BAG_MENU, .battleUsage = EFFECT_ITEM_THROW_BALL, - .secondaryId = ITEM_SAFARI_BALL - FIRST_BALL, + .secondaryId = BALL_SAFARI, .iconPic = gItemIcon_SafariBall, .iconPalette = gItemIconPalette_SafariBall, }, @@ -538,7 +554,7 @@ const struct Item gItemsInfo[] = .pocket = POCKET_POKE_BALLS, .type = ITEM_USE_BAG_MENU, .battleUsage = EFFECT_ITEM_THROW_BALL, - .secondaryId = ITEM_SPORT_BALL - FIRST_BALL, + .secondaryId = BALL_SPORT, .iconPic = gItemIcon_SportBall, .iconPalette = gItemIconPalette_SportBall, }, @@ -553,7 +569,7 @@ const struct Item gItemsInfo[] = .pocket = POCKET_POKE_BALLS, .type = ITEM_USE_BAG_MENU, .battleUsage = EFFECT_ITEM_THROW_BALL, - .secondaryId = ITEM_PARK_BALL - FIRST_BALL, + .secondaryId = BALL_PARK, .iconPic = gItemIcon_ParkBall, .iconPalette = gItemIconPalette_ParkBall, }, @@ -568,7 +584,7 @@ const struct Item gItemsInfo[] = .pocket = POCKET_POKE_BALLS, .type = ITEM_USE_BAG_MENU, .battleUsage = EFFECT_ITEM_THROW_BALL, - .secondaryId = ITEM_BEAST_BALL - FIRST_BALL, + .secondaryId = BALL_BEAST, .iconPic = gItemIcon_BeastBall, .iconPalette = gItemIconPalette_BeastBall, }, @@ -584,7 +600,7 @@ const struct Item gItemsInfo[] = .pocket = POCKET_POKE_BALLS, .type = ITEM_USE_BAG_MENU, .battleUsage = EFFECT_ITEM_THROW_BALL, - .secondaryId = ITEM_CHERISH_BALL - FIRST_BALL, + .secondaryId = BALL_CHERISH, .iconPic = gItemIcon_CherishBall, .iconPalette = gItemIconPalette_CherishBall, }, diff --git a/src/daycare.c b/src/daycare.c index 780e69e44d..013e0b05ba 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -716,17 +716,17 @@ static void InheritIVs(struct Pokemon *egg, struct DayCare *daycare) static void InheritPokeball(struct Pokemon *egg, struct BoxPokemon *father, struct BoxPokemon *mother) { - u16 inheritBall = ITEM_POKE_BALL; - u16 fatherBall = GetBoxMonData(father, MON_DATA_POKEBALL); - u16 motherBall = GetBoxMonData(mother, MON_DATA_POKEBALL); + enum PokeBall inheritBall = BALL_POKE; + enum PokeBall fatherBall = GetBoxMonData(father, MON_DATA_POKEBALL); + enum PokeBall motherBall = GetBoxMonData(mother, MON_DATA_POKEBALL); u16 fatherSpecies = GetBoxMonData(father, MON_DATA_SPECIES); u16 motherSpecies = GetBoxMonData(mother, MON_DATA_SPECIES); - if (fatherBall == ITEM_MASTER_BALL || fatherBall == ITEM_CHERISH_BALL) - fatherBall = ITEM_POKE_BALL; + if (fatherBall == BALL_MASTER || fatherBall == BALL_CHERISH || fatherBall == BALL_STRANGE) + fatherBall = BALL_POKE; - if (motherBall == ITEM_MASTER_BALL || motherBall == ITEM_CHERISH_BALL) - motherBall = ITEM_POKE_BALL; + if (motherBall == BALL_MASTER || motherBall == BALL_CHERISH || motherBall == BALL_STRANGE) + motherBall = BALL_POKE; if (P_BALL_INHERITING >= GEN_7) { @@ -1087,14 +1087,14 @@ static void _GiveEggFromDaycare(struct DayCare *daycare) void CreateEgg(struct Pokemon *mon, u16 species, bool8 setHotSpringsLocation) { u8 metLevel; - u16 ball; + enum PokeBall ball; u8 language; u8 metLocation; u8 isEgg; CreateMon(mon, species, EGG_HATCH_LEVEL, USE_RANDOM_IVS, FALSE, 0, OT_ID_PLAYER_ID, 0); metLevel = 0; - ball = ITEM_POKE_BALL; + ball = BALL_POKE; language = LANGUAGE_JAPANESE; SetMonData(mon, MON_DATA_POKEBALL, &ball); SetMonData(mon, MON_DATA_NICKNAME, sJapaneseEggNickname); @@ -1114,14 +1114,14 @@ void CreateEgg(struct Pokemon *mon, u16 species, bool8 setHotSpringsLocation) static void SetInitialEggData(struct Pokemon *mon, u16 species, struct DayCare *daycare) { u32 personality; - u16 ball; + enum PokeBall ball; u8 metLevel; u8 language; personality = daycare->offspringPersonality; CreateMon(mon, species, EGG_HATCH_LEVEL, USE_RANDOM_IVS, TRUE, personality, OT_ID_PLAYER_ID, 0); metLevel = 0; - ball = ITEM_POKE_BALL; + ball = BALL_POKE; language = LANGUAGE_JAPANESE; SetMonData(mon, MON_DATA_POKEBALL, &ball); SetMonData(mon, MON_DATA_NICKNAME, sJapaneseEggNickname); diff --git a/src/debug.c b/src/debug.c index a3978fbd40..f1c403fc1e 100644 --- a/src/debug.c +++ b/src/debug.c @@ -4174,12 +4174,12 @@ static void DebugAction_PCBag_Fill_PocketItems(u8 taskId) static void DebugAction_PCBag_Fill_PocketPokeBalls(u8 taskId) { - u16 itemId; + u16 ballId; - for (itemId = FIRST_BALL; itemId < LAST_BALL; itemId++) + for (ballId = BALL_STRANGE; ballId < POKEBALL_COUNT; ballId++) { - if (CheckBagHasSpace(itemId, MAX_BAG_ITEM_CAPACITY)) - AddBagItem(itemId, MAX_BAG_ITEM_CAPACITY); + if (CheckBagHasSpace(ballId, MAX_BAG_ITEM_CAPACITY)) + AddBagItem(ballId, MAX_BAG_ITEM_CAPACITY); } } diff --git a/src/egg_hatch.c b/src/egg_hatch.c index 88f2b329e9..ee45635ce7 100644 --- a/src/egg_hatch.c +++ b/src/egg_hatch.c @@ -314,7 +314,8 @@ static void CreateHatchedMon(struct Pokemon *egg, struct Pokemon *temp) { u16 species; u32 personality, pokerus; - u8 i, friendship, language, gameMet, markings, isModernFatefulEncounter, ball; + enum PokeBall ball; + u8 i, friendship, language, gameMet, markings, isModernFatefulEncounter; u16 moves[MAX_MON_MOVES]; u32 ivs[NUM_STATS]; diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 9a4f9980f5..f1aefbb046 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -7344,12 +7344,12 @@ static u8 LoadFillColorPalette(u16 color, u16 paletteTag, struct Sprite *sprite) static void ObjectEventSetPokeballGfx(struct ObjectEvent *objEvent) { #if OW_FOLLOWERS_POKEBALLS - u32 ball = BALL_POKE; + enum PokeBall ball = BALL_STRANGE; if (objEvent->localId == OBJ_EVENT_ID_FOLLOWER) { struct Pokemon *mon = GetFirstLiveMon(); if (mon) - ball = ItemIdToBallId(GetMonData(mon, MON_DATA_POKEBALL)); + ball = GetMonData(mon, MON_DATA_POKEBALL); } if (ball != BALL_POKE && ball < POKEBALL_COUNT) diff --git a/src/item.c b/src/item.c index 36114e1591..b0135d8f83 100644 --- a/src/item.c +++ b/src/item.c @@ -1,6 +1,7 @@ #include "global.h" #include "item.h" #include "berry.h" +#include "pokeball.h" #include "string_util.h" #include "text.h" #include "event_data.h" @@ -166,11 +167,11 @@ bool8 HasAtLeastOneBerry(void) bool8 HasAtLeastOnePokeBall(void) { - u16 i; + u16 ballId; - for (i = FIRST_BALL; i <= LAST_BALL; i++) + for (ballId = BALL_STRANGE; ballId < POKEBALL_COUNT; ballId++) { - if (CheckBagHasItem(i, 1) == TRUE) + if (CheckBagHasItem(ballId, 1) == TRUE) return TRUE; } return FALSE; @@ -968,7 +969,7 @@ u8 ItemId_GetBattleUsage(u16 itemId) return gItemsInfo[item].battleUsage; } -u8 ItemId_GetSecondaryId(u16 itemId) +u32 ItemId_GetSecondaryId(u32 itemId) { return gItemsInfo[SanitizeItemId(itemId)].secondaryId; } diff --git a/src/pokeball.c b/src/pokeball.c index 21557d973a..2b168cd7e3 100644 --- a/src/pokeball.c +++ b/src/pokeball.c @@ -13,6 +13,7 @@ #include "trig.h" #include "util.h" #include "data.h" +#include "item.h" #include "constants/songs.h" static void Task_DoPokeballSendOutAnim(u8 taskId); @@ -47,36 +48,38 @@ static u16 GetBattlerPokeballItemId(u8 battlerId); // rom const data -#define GFX_TAG_POKE_BALL 55000 -#define GFX_TAG_GREAT_BALL 55001 -#define GFX_TAG_ULTRA_BALL 55002 -#define GFX_TAG_MASTER_BALL 55003 -#define GFX_TAG_PREMIER_BALL 55004 -#define GFX_TAG_HEAL_BALL 55005 -#define GFX_TAG_NET_BALL 55006 -#define GFX_TAG_NEST_BALL 55007 -#define GFX_TAG_DIVE_BALL 55008 -#define GFX_TAG_DUSK_BALL 55009 -#define GFX_TAG_TIMER_BALL 55010 -#define GFX_TAG_QUICK_BALL 55011 -#define GFX_TAG_REPEAT_BALL 55012 -#define GFX_TAG_LUXURY_BALL 55013 -#define GFX_TAG_LEVEL_BALL 55014 -#define GFX_TAG_LURE_BALL 55015 -#define GFX_TAG_MOON_BALL 55016 -#define GFX_TAG_FRIEND_BALL 55017 -#define GFX_TAG_LOVE_BALL 55018 -#define GFX_TAG_FAST_BALL 55019 -#define GFX_TAG_HEAVY_BALL 55020 -#define GFX_TAG_DREAM_BALL 55021 -#define GFX_TAG_SAFARI_BALL 55022 -#define GFX_TAG_SPORT_BALL 55023 -#define GFX_TAG_PARK_BALL 55024 -#define GFX_TAG_BEAST_BALL 55025 -#define GFX_TAG_CHERISH_BALL 55026 +#define GFX_TAG_STRANGE_BALL 55000 +#define GFX_TAG_POKE_BALL 55001 +#define GFX_TAG_GREAT_BALL 55002 +#define GFX_TAG_ULTRA_BALL 55003 +#define GFX_TAG_MASTER_BALL 55004 +#define GFX_TAG_PREMIER_BALL 55005 +#define GFX_TAG_HEAL_BALL 55006 +#define GFX_TAG_NET_BALL 55007 +#define GFX_TAG_NEST_BALL 55008 +#define GFX_TAG_DIVE_BALL 55009 +#define GFX_TAG_DUSK_BALL 55010 +#define GFX_TAG_TIMER_BALL 55011 +#define GFX_TAG_QUICK_BALL 55012 +#define GFX_TAG_REPEAT_BALL 55013 +#define GFX_TAG_LUXURY_BALL 55014 +#define GFX_TAG_LEVEL_BALL 55015 +#define GFX_TAG_LURE_BALL 55016 +#define GFX_TAG_MOON_BALL 55017 +#define GFX_TAG_FRIEND_BALL 55018 +#define GFX_TAG_LOVE_BALL 55019 +#define GFX_TAG_FAST_BALL 55020 +#define GFX_TAG_HEAVY_BALL 55021 +#define GFX_TAG_DREAM_BALL 55022 +#define GFX_TAG_SAFARI_BALL 55023 +#define GFX_TAG_SPORT_BALL 55024 +#define GFX_TAG_PARK_BALL 55025 +#define GFX_TAG_BEAST_BALL 55026 +#define GFX_TAG_CHERISH_BALL 55027 const struct CompressedSpriteSheet gBallSpriteSheets[POKEBALL_COUNT] = { + [BALL_STRANGE] = {gBallGfx_Strange, 384, GFX_TAG_STRANGE_BALL}, [BALL_POKE] = {gBallGfx_Poke, 384, GFX_TAG_POKE_BALL}, [BALL_GREAT] = {gBallGfx_Great, 384, GFX_TAG_GREAT_BALL}, [BALL_ULTRA] = {gBallGfx_Ultra, 384, GFX_TAG_ULTRA_BALL}, @@ -108,6 +111,7 @@ const struct CompressedSpriteSheet gBallSpriteSheets[POKEBALL_COUNT] = const struct CompressedSpritePalette gBallSpritePalettes[POKEBALL_COUNT] = { + [BALL_STRANGE] = {gBallPal_Strange, GFX_TAG_STRANGE_BALL}, [BALL_POKE] = {gBallPal_Poke, GFX_TAG_POKE_BALL}, [BALL_GREAT] = {gBallPal_Great, GFX_TAG_GREAT_BALL}, [BALL_ULTRA] = {gBallPal_Ultra, GFX_TAG_ULTRA_BALL}, @@ -252,6 +256,16 @@ static const union AffineAnimCmd *const sAffineAnim_BallRotate[] = const struct SpriteTemplate gBallSpriteTemplates[POKEBALL_COUNT] = { + [BALL_STRANGE] = + { + .tileTag = GFX_TAG_STRANGE_BALL, + .paletteTag = GFX_TAG_STRANGE_BALL, + .oam = &sBallOamData, + .anims = sBallAnimSequences, + .images = NULL, + .affineAnims = sAffineAnim_BallRotate, + .callback = SpriteCB_BallThrow, + }, [BALL_POKE] = { .tileTag = GFX_TAG_POKE_BALL, @@ -562,7 +576,7 @@ static void Task_DoPokeballSendOutAnim(u8 taskId) throwCaseId = gTasks[taskId].tThrowId; battlerId = gTasks[taskId].tBattler; - ballId = ItemIdToBallId(GetBattlerPokeballItemId(battlerId)); + ballId = GetBattlerPokeballItemId(battlerId); LoadBallGfx(ballId); ballSpriteId = CreateSprite(&gBallSpriteTemplates[ballId], 32, 80, 29); gSprites[ballSpriteId].data[0] = 0x80; @@ -651,7 +665,7 @@ static void SpriteCB_BallThrow(struct Sprite *sprite) sprite->x2 = 0; sprite->y2 = 0; sprite->data[5] = 0; - ballId = ItemIdToBallId(GetBattlerPokeballItemId(opponentBattler)); + ballId = GetBattlerPokeballItemId(opponentBattler); AnimateBallOpenParticles(sprite->x, sprite->y - 5, 1, 28, ballId); sprite->data[0] = LaunchBallFadeMonTask(FALSE, opponentBattler, 14, ballId); sprite->sBattler = opponentBattler; @@ -967,7 +981,7 @@ static void SpriteCB_ReleaseMonFromBall(struct Sprite *sprite) u32 ballId; StartSpriteAnim(sprite, 1); - ballId = ItemIdToBallId(GetBattlerPokeballItemId(battlerId)); + ballId = GetBattlerPokeballItemId(battlerId); AnimateBallOpenParticles(sprite->x, sprite->y - 5, 1, 28, ballId); sprite->data[0] = LaunchBallFadeMonTask(TRUE, sprite->sBattler, 14, ballId); sprite->callback = HandleBallAnimEnd; @@ -1580,3 +1594,13 @@ static u16 GetBattlerPokeballItemId(u8 battlerId) return GetMonData(mon, MON_DATA_POKEBALL); } + +enum PokeBall ItemIdToBallId(u32 ballItem) +{ + enum PokeBall secondaryId = ItemId_GetSecondaryId(ballItem); + + if (secondaryId <= BALL_STRANGE || secondaryId >= POKEBALL_COUNT) + return BALL_STRANGE; + + return secondaryId; +} diff --git a/src/pokemon.c b/src/pokemon.c index c5dcbb1903..242d28d664 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -1022,7 +1022,7 @@ STATIC_ASSERT(NUM_SPECIES < (1 << 11), PokemonSubstruct0_species_TooSmall); STATIC_ASSERT(NUMBER_OF_MON_TYPES + 1 <= (1 << 5), PokemonSubstruct0_teraType_TooSmall); STATIC_ASSERT(ITEMS_COUNT < (1 << 10), PokemonSubstruct0_heldItem_TooSmall); STATIC_ASSERT(MAX_LEVEL <= 100, PokemonSubstruct0_experience_PotentiallTooSmall); // Maximum of ~2 million exp. -STATIC_ASSERT(LAST_BALL < (1 << 6), PokemonSubstruct0_pokeball_TooSmall); +STATIC_ASSERT(POKEBALL_COUNT <= (1 << 6), PokemonSubstruct0_pokeball_TooSmall); STATIC_ASSERT(MOVES_COUNT_ALL < (1 << 11), PokemonSubstruct1_moves_TooSmall); STATIC_ASSERT(ARRAY_COUNT(sCompressedStatuses) <= (1 << 4), PokemonSubstruct3_compressedStatus_TooSmall); STATIC_ASSERT(MAX_LEVEL < (1 << 7), PokemonSubstruct3_metLevel_TooSmall); diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index d20e3299d2..4cfc17c707 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -1579,8 +1579,8 @@ static void SetDefaultTilemaps(void) SetBgTilemapBuffer(2, sMonSummaryScreen->bgTilemapBuffers[PSS_PAGE_BATTLE_MOVES][0]); SetBgAttribute(1, BG_ATTR_PRIORITY, 2); SetBgAttribute(2, BG_ATTR_PRIORITY, 1); - ChangeBgX(1, 0x10000, BG_COORD_ADD); - ChangeBgX(2, 0x10000, BG_COORD_ADD); + ChangeBgX(1, 0x10000, BG_COORD_ADD); + ChangeBgX(2, 0x10000, BG_COORD_ADD); ShowBg(1); ShowBg(2); } @@ -1591,8 +1591,8 @@ static void SetDefaultTilemaps(void) SetBgTilemapBuffer(2, sMonSummaryScreen->bgTilemapBuffers[PSS_PAGE_BATTLE_MOVES][0]); SetBgAttribute(1, BG_ATTR_PRIORITY, 1); SetBgAttribute(2, BG_ATTR_PRIORITY, 2); - ChangeBgX(1, 0x10000, BG_COORD_ADD); - ChangeBgX(2, 0x10000, BG_COORD_ADD); + ChangeBgX(1, 0x10000, BG_COORD_ADD); + ChangeBgX(2, 0x10000, BG_COORD_ADD); ShowBg(1); ShowBg(2); } @@ -4271,7 +4271,7 @@ static void RemoveAndCreateMonMarkingsSprite(struct Pokemon *mon) static void CreateCaughtBallSprite(struct Pokemon *mon) { - u8 ball = ItemIdToBallId(GetMonData(mon, MON_DATA_POKEBALL)); + enum PokeBall ball = GetMonData(mon, MON_DATA_POKEBALL); LoadBallGfx(ball); sMonSummaryScreen->spriteIds[SPRITE_ARR_ID_BALL] = CreateSprite(&gBallSpriteTemplates[ball], 16, 136, 0); @@ -4392,7 +4392,7 @@ static inline bool32 ShouldShowMoveRelearner(void) && sMonSummaryScreen->mode != SUMMARY_MODE_BOX && sMonSummaryScreen->mode != SUMMARY_MODE_BOX_CURSOR && sMonSummaryScreen->relearnableMovesNum > 0 - && !InBattleFactory() + && !InBattleFactory() && !InSlateportBattleTent()); } @@ -4403,7 +4403,7 @@ static inline bool32 ShouldShowRename(void) && !sMonSummaryScreen->summary.isEgg && sMonSummaryScreen->mode != SUMMARY_MODE_BOX && sMonSummaryScreen->mode != SUMMARY_MODE_BOX_CURSOR - && !InBattleFactory() + && !InBattleFactory() && !InSlateportBattleTent() && GetPlayerIDAsU32() == sMonSummaryScreen->summary.OTID); } @@ -4431,7 +4431,7 @@ static void CB2_PssChangePokemonNickname(void) { GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_NICKNAME, gStringVar3); GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_NICKNAME, gStringVar2); - DoNamingScreen(NAMING_SCREEN_NICKNAME, gStringVar2, GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_SPECIES, NULL), - GetMonGender(&gPlayerParty[gSpecialVar_0x8004]), GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_PERSONALITY, NULL), + DoNamingScreen(NAMING_SCREEN_NICKNAME, gStringVar2, GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_SPECIES, NULL), + GetMonGender(&gPlayerParty[gSpecialVar_0x8004]), GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_PERSONALITY, NULL), CB2_ReturnToSummaryScreenFromNamingScreen); } diff --git a/src/script_pokemon_util.c b/src/script_pokemon_util.c index 3d2c7d640c..020094389a 100644 --- a/src/script_pokemon_util.c +++ b/src/script_pokemon_util.c @@ -317,7 +317,7 @@ void SetTeraType(struct ScriptContext *ctx) * if side/slot are assigned, it will create the mon at the assigned party location * if slot == PARTY_SIZE, it will give the mon to first available party or storage slot */ -static u32 ScriptGiveMonParameterized(u8 side, u8 slot, u16 species, u8 level, u16 item, u8 ball, u8 nature, u8 abilityNum, u8 gender, u8 *evs, u8 *ivs, u16 *moves, bool8 isShiny, bool8 ggMaxFactor, u8 teraType) +static u32 ScriptGiveMonParameterized(u8 side, u8 slot, u16 species, u8 level, u16 item, enum PokeBall ball, u8 nature, u8 abilityNum, u8 gender, u8 *evs, u8 *ivs, u16 *moves, bool8 isShiny, bool8 ggMaxFactor, u8 teraType) { u16 nationalDexNum; int sentToPc; @@ -396,8 +396,8 @@ static u32 ScriptGiveMonParameterized(u8 side, u8 slot, u16 species, u8 level, u SetMonData(&mon, MON_DATA_ABILITY_NUM, &abilityNum); // ball - if (ball > LAST_BALL) - ball = ITEM_POKE_BALL; + if (ball > POKEBALL_COUNT) + ball = BALL_POKE; SetMonData(&mon, MON_DATA_POKEBALL, &ball); // held item diff --git a/test/battle/trainer_control.c b/test/battle/trainer_control.c index e31d281efe..5344a26596 100644 --- a/test/battle/trainer_control.c +++ b/test/battle/trainer_control.c @@ -24,8 +24,8 @@ TEST("CreateNPCTrainerPartyForTrainer generates customized Pokémon") EXPECT(IsMonShiny(&testParty[0])); EXPECT(!IsMonShiny(&testParty[1])); - EXPECT(GetMonData(&testParty[0], MON_DATA_POKEBALL, 0) == ITEM_MASTER_BALL); - EXPECT(GetMonData(&testParty[1], MON_DATA_POKEBALL, 0) == ITEM_POKE_BALL); + EXPECT(GetMonData(&testParty[0], MON_DATA_POKEBALL, 0) == BALL_MASTER); + EXPECT(GetMonData(&testParty[1], MON_DATA_POKEBALL, 0) == BALL_POKE); EXPECT(GetMonData(&testParty[0], MON_DATA_SPECIES, 0) == SPECIES_WOBBUFFET); EXPECT(GetMonData(&testParty[1], MON_DATA_SPECIES, 0) == SPECIES_WOBBUFFET); diff --git a/test/pokemon.c b/test/pokemon.c index 8419b9c7e1..f5431559ee 100644 --- a/test/pokemon.c +++ b/test/pokemon.c @@ -237,7 +237,7 @@ TEST("givemon [all]") EXPECT_EQ(GetMonData(&gPlayerParty[0], MON_DATA_SPECIES), SPECIES_WOBBUFFET); EXPECT_EQ(GetMonData(&gPlayerParty[0], MON_DATA_LEVEL), 100); EXPECT_EQ(GetMonData(&gPlayerParty[0], MON_DATA_HELD_ITEM), ITEM_LEFTOVERS); - EXPECT_EQ(GetMonData(&gPlayerParty[0], MON_DATA_POKEBALL), ITEM_MASTER_BALL); + EXPECT_EQ(GetMonData(&gPlayerParty[0], MON_DATA_POKEBALL), BALL_MASTER); EXPECT_EQ(GetNature(&gPlayerParty[0]), NATURE_BOLD); EXPECT_EQ(GetMonAbility(&gPlayerParty[0]), gSpeciesInfo[SPECIES_WOBBUFFET].abilities[2]); EXPECT_EQ(GetMonGender(&gPlayerParty[0]), MON_MALE); @@ -300,7 +300,7 @@ TEST("givemon [vars]") EXPECT_EQ(GetMonData(&gPlayerParty[0], MON_DATA_SPECIES), SPECIES_WOBBUFFET); EXPECT_EQ(GetMonData(&gPlayerParty[0], MON_DATA_LEVEL), 100); EXPECT_EQ(GetMonData(&gPlayerParty[0], MON_DATA_HELD_ITEM), ITEM_LEFTOVERS); - EXPECT_EQ(GetMonData(&gPlayerParty[0], MON_DATA_POKEBALL), ITEM_MASTER_BALL); + EXPECT_EQ(GetMonData(&gPlayerParty[0], MON_DATA_POKEBALL), BALL_MASTER); EXPECT_EQ(GetNature(&gPlayerParty[0]), NATURE_BOLD); EXPECT_EQ(GetMonAbility(&gPlayerParty[0]), gSpeciesInfo[SPECIES_WOBBUFFET].abilities[2]); EXPECT_EQ(GetMonGender(&gPlayerParty[0]), MON_MALE);