From c06029bc721119b0efd6e26c24a3f77772dfd77b Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Fri, 25 Jun 2021 13:37:59 -0600 Subject: [PATCH 01/14] add last used ball --- graphics/battle_interface/ability_pop_up.pal | 19 ++ graphics/battle_interface/last_used_ball.png | Bin 0 -> 223 bytes include/battle.h | 2 + include/battle_interface.h | 4 + include/battle_util.h | 1 + include/constants/battle_config.h | 4 + include/global.h | 3 +- include/item_use.h | 1 + src/battle_controller_player.c | 16 +- src/battle_interface.c | 181 +++++++++++++++++++ src/battle_main.c | 4 + src/battle_script_commands.c | 3 +- src/battle_util.c | 11 ++ src/item_use.c | 54 ++++-- src/new_game.c | 2 + 15 files changed, 283 insertions(+), 22 deletions(-) create mode 100644 graphics/battle_interface/ability_pop_up.pal create mode 100644 graphics/battle_interface/last_used_ball.png diff --git a/graphics/battle_interface/ability_pop_up.pal b/graphics/battle_interface/ability_pop_up.pal new file mode 100644 index 000000000..19895d0bc --- /dev/null +++ b/graphics/battle_interface/ability_pop_up.pal @@ -0,0 +1,19 @@ +JASC-PAL +0100 +16 +1 177 91 +143 129 149 +103 91 111 +79 65 85 +59 31 81 +103 89 109 +231 239 245 +249 253 255 +0 0 0 +0 0 0 +107 115 115 +74 66 82 +0 0 0 +214 214 206 +132 140 140 +0 0 0 diff --git a/graphics/battle_interface/last_used_ball.png b/graphics/battle_interface/last_used_ball.png new file mode 100644 index 0000000000000000000000000000000000000000..581569cf1bf4ce3f5cee78fcd83a7a34b149d012 GIT binary patch literal 223 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnF3?v&v(vJfvg8-ipSH_Le)y2(0UQw2Yj+z{f zK*sa;Uw{7n50nRj?BZfCCy?fA*Uq){^Z*&j&Z>)mRF^unv_P&x8 zS#yg)?8er2d6p7uYPU)$efU;Y`E%9Nr%yw_D=__j$HY1FVdQ&MBb@0Cx9FNdN!< literal 0 HcmV?d00001 diff --git a/include/battle.h b/include/battle.h index f009cbe7f..9a10ae77d 100644 --- a/include/battle.h +++ b/include/battle.h @@ -37,6 +37,7 @@ #define B_ACTION_CANCEL_PARTNER 12 // when choosing an action #define B_ACTION_NOTHING_FAINTED 13 // when choosing an action #define B_ACTION_DEBUG 20 +#define B_ACTION_THROW_BALL 21 // R to throw last used ball #define B_ACTION_NONE 0xFF #define MAX_TRAINER_ITEMS 4 @@ -586,6 +587,7 @@ struct BattleStruct u16 moveEffect2; // For Knock Off u16 changedSpecies[PARTY_SIZE]; // For Zygarde or future forms when multiple mons can change into the same pokemon. u8 quickClawBattlerId; + u8 ballSpriteIds[2]; // item gfx, window gfx }; #define GET_MOVE_TYPE(move, typeArg) \ diff --git a/include/battle_interface.h b/include/battle_interface.h index 0bcadaaac..c852b776a 100644 --- a/include/battle_interface.h +++ b/include/battle_interface.h @@ -93,5 +93,9 @@ u8 GetScaledHPFraction(s16 hp, s16 maxhp, u8 scale); u8 GetHPBarLevel(s16 hp, s16 maxhp); void CreateAbilityPopUp(u8 battlerId, u32 ability, bool32 isDoubleBattle); void DestroyAbilityPopUp(u8 battlerId); +bool32 CanThrowLastUsedBall(void); +void TryHideLastUsedBall(void); +void TryRestoreLastUsedBall(void); +void TryAddLastUsedBallItemSprites(void); #endif // GUARD_BATTLE_INTERFACE_H diff --git a/include/battle_util.h b/include/battle_util.h index 0bf49dadf..717017c06 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -46,6 +46,7 @@ struct TypePower extern const struct TypePower gNaturalGiftTable[]; +void HandleAction_ThrowBall(void); void HandleAction_UseMove(void); void HandleAction_Switch(void); void HandleAction_UseItem(void); diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index fe376da8d..0f878d3af 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -151,6 +151,10 @@ #define B_CRITICAL_CAPTURE TRUE // If set to TRUE, Critical Capture will be enabled. #define B_CATCHING_CHARM_BOOST 20 // % boost in Critical Capture odds if player has the Catching Charm. +// Last Used Ball +#define B_LAST_USED_BALL TRUE // If TRUE, the "last used ball" feature from Gen 7 will be implemented +#define B_LAST_USED_BALL_BUTTON R_BUTTON // If last used ball is implemented, this button (or button combo) will trigger throwing the last used ball. + // Other #define B_DOUBLE_WILD_CHANCE 0 // % chance of encountering two Pokémon in a Wild Encounter. #define B_SLEEP_TURNS GEN_7 // In Gen5+, sleep lasts for 1-3 turns instead of 2-5 turns. diff --git a/include/global.h b/include/global.h index e6b0797e7..a5d720eda 100644 --- a/include/global.h +++ b/include/global.h @@ -490,7 +490,8 @@ struct SaveBlock2 u16 optionsBattleSceneOff:1; // whether battle animations are disabled u16 regionMapZoom:1; // whether the map is zoomed in /*0x18*/ struct Pokedex pokedex; - /*0x90*/ u8 filler_90[0x8]; + /*0x90*/ u16 lastUsedBall; + /*0x92*/ u8 filler_90[0x6]; /*0x98*/ struct Time localTimeOffset; /*0xA0*/ struct Time lastBerryTreeUpdate; /*0xA8*/ u32 gcnLinkFlags; // Read by Pokemon Colosseum/XD diff --git a/include/item_use.h b/include/item_use.h index f577f8d46..42db6ff10 100644 --- a/include/item_use.h +++ b/include/item_use.h @@ -33,5 +33,6 @@ void ItemUseInBattle_EnigmaBerry(u8); void Task_UseDigEscapeRopeOnField(u8 taskId); u8 CanUseDigOrEscapeRopeOnCurMap(void); u8 CheckIfItemIsTMHMOrEvolutionStone(u16 itemId); +u32 CanThrowBall(void); #endif // GUARD_ITEM_USE_H diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index 89f73ffc4..89a044275 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -249,7 +249,8 @@ static void HandleInputChooseAction(void) if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); - + TryHideLastUsedBall(); + switch (gActionSelectionCursor[gActiveBattler]) { case 0: @@ -336,6 +337,15 @@ static void HandleInputChooseAction(void) BtlController_EmitTwoReturnValues(1, B_ACTION_DEBUG, 0); PlayerBufferExecCompleted(); } + #if B_LAST_USED_BALL == TRUE + else if (JOY_NEW(B_LAST_USED_BALL_BUTTON) && CanThrowLastUsedBall()) + { + PlaySE(SE_SELECT); + TryHideLastUsedBall(); + BtlController_EmitTwoReturnValues(1, B_ACTION_THROW_BALL, 0); + PlayerBufferExecCompleted(); + } + #endif } static void UnusedEndBounceEffect(void) @@ -372,6 +382,7 @@ static void HandleInputChooseTarget(void) else BtlController_EmitTwoReturnValues(1, 10, gMoveSelectionCursor[gActiveBattler] | (gMultiUsePlayerCursor << 8)); EndBounceEffect(gMultiUsePlayerCursor, BOUNCE_HEALTHBOX); + TryHideLastUsedBall(); HideMegaTriggerSprite(); PlayerBufferExecCompleted(); } @@ -514,6 +525,7 @@ static void HandleInputShowTargets(void) else BtlController_EmitTwoReturnValues(1, 10, gMoveSelectionCursor[gActiveBattler] | (gMultiUsePlayerCursor << 8)); HideMegaTriggerSprite(); + TryHideLastUsedBall(); PlayerBufferExecCompleted(); } else if (gMain.newKeys & B_BUTTON || gPlayerDpadHoldFrames > 59) @@ -606,6 +618,7 @@ static void HandleInputChooseMove(void) else BtlController_EmitTwoReturnValues(1, 10, gMoveSelectionCursor[gActiveBattler] | (gMultiUsePlayerCursor << 8)); HideMegaTriggerSprite(); + TryHideLastUsedBall(); PlayerBufferExecCompleted(); } else if (canSelectTarget == 1) @@ -2691,6 +2704,7 @@ static void PlayerHandleChooseAction(void) for (i = 0; i < 4; i++) ActionSelectionDestroyCursorAt(i); + TryRestoreLastUsedBall(); ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0); BattleStringExpandPlaceholdersToDisplayedString(gText_WhatWillPkmnDo); BattlePutTextOnWindow(gDisplayedStringBattle, 1); diff --git a/src/battle_interface.c b/src/battle_interface.c index 128f342df..828b57a2f 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -27,6 +27,9 @@ #include "constants/battle_config.h" #include "data.h" #include "pokemon_summary_screen.h" +#include "item_icon.h" +#include "item_use.h" +#include "item.h" enum { // Corresponds to gHealthboxElementsGfxTable (and the tables after it) in graphics.c @@ -196,6 +199,9 @@ static u8 CalcBarFilledPixels(s32 maxValue, s32 oldValue, s32 receivedValue, s32 static void SpriteCb_AbilityPopUp(struct Sprite *sprite); static void Task_FreeAbilityPopUpGfx(u8 taskId); +static void SpriteCB_LastUsedBall(struct Sprite *sprite); +static void SpriteCB_LastUsedBallWin(struct Sprite *sprite); + // const rom data static const struct OamData sUnknown_0832C138 = { @@ -812,6 +818,9 @@ u8 CreateBattlerHealthboxSprites(u8 battlerId) gSprites[megaIndicatorSpriteId].invisible = TRUE; } + gBattleStruct->ballSpriteIds[0] = MAX_SPRITES; + gBattleStruct->ballSpriteIds[1] = MAX_SPRITES; + return healthboxLeftSpriteId; } @@ -3128,3 +3137,175 @@ static void Task_FreeAbilityPopUpGfx(u8 taskId) DestroyTask(taskId); } } + +// last used ball +#define LAST_BALL_WINDOW_TAG 0xD721 + +static const struct OamData sOamData_LastUsedBall = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = SPRITE_SHAPE(32x32), + .x = 0, + .matrixNum = 0, + .size = SPRITE_SIZE(32x32), + .tileNum = 0, + .priority = 1, + .paletteNum = 0, + .affineParam = 0, +}; + +static const struct SpriteTemplate sSpriteTemplate_LastUsedBallWindow = +{ + .tileTag = LAST_BALL_WINDOW_TAG, + .paletteTag = ABILITY_POP_UP_TAG, + .oam = &sOamData_LastUsedBall, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCB_LastUsedBallWin +}; + +static const u8 sLastUsedBallWindowGfx[] = INCBIN_U8("graphics/battle_interface/last_used_ball.4bpp"); +static const struct SpriteSheet sSpriteSheet_LastUsedBallWindow = +{ + sLastUsedBallWindowGfx, sizeof(sLastUsedBallWindowGfx), LAST_BALL_WINDOW_TAG +}; + +#define LAST_USED_BALL_X_F 15 +#define LAST_USED_BALL_X_0 -15 +#define LAST_USED_BALL_Y 68 + +#define LAST_BALL_WIN_X_F (LAST_USED_BALL_X_F - 1) +#define LAST_BALL_WIN_X_0 (LAST_USED_BALL_X_0 - 0) +#define LAST_USED_WIN_Y (LAST_USED_BALL_Y - 8) + +#define sHide data[0] + +bool32 CanThrowLastUsedBall(void) +{ + return (!(CanThrowBall() != 0 + || (gBattleTypeFlags & BATTLE_TYPE_TRAINER) + || !CheckBagHasItem(gSaveBlock2Ptr->lastUsedBall, 1))); +} + + +void TryAddLastUsedBallItemSprites(void) +{ + if (CanThrowBall() != 0 + || (gBattleTypeFlags & BATTLE_TYPE_TRAINER) + || !CheckBagHasItem(gSaveBlock2Ptr->lastUsedBall, 1)) + return; + + // ball + if (gBattleStruct->ballSpriteIds[0] == MAX_SPRITES) + { + gBattleStruct->ballSpriteIds[0] = AddItemIconSprite(102, 102, gSaveBlock2Ptr->lastUsedBall); + gSprites[gBattleStruct->ballSpriteIds[0]].pos1.x = LAST_USED_BALL_X_0; + gSprites[gBattleStruct->ballSpriteIds[0]].pos1.y = LAST_USED_BALL_Y; + gSprites[gBattleStruct->ballSpriteIds[0]].sHide = FALSE; // restore + gSprites[gBattleStruct->ballSpriteIds[0]].callback = SpriteCB_LastUsedBall; + } + + // window + LoadSpritePalette(&sSpritePalette_AbilityPopUp); + if (GetSpriteTileStartByTag(LAST_BALL_WINDOW_TAG) == 0xFFFF) + LoadSpriteSheet(&sSpriteSheet_LastUsedBallWindow); + + if (gBattleStruct->ballSpriteIds[1] == MAX_SPRITES) + { + gBattleStruct->ballSpriteIds[1] = CreateSprite(&sSpriteTemplate_LastUsedBallWindow, + LAST_BALL_WIN_X_0, + LAST_USED_WIN_Y, 5); + gSprites[gBattleStruct->ballSpriteIds[0]].sHide = FALSE; // restore + } +} + +static void DestroyLastUsedBallWinGfx(struct Sprite *sprite) +{ + FreeSpriteTilesByTag(LAST_BALL_WINDOW_TAG); + FreeSpritePaletteByTag(ABILITY_POP_UP_TAG); + DestroySprite(sprite); + gBattleStruct->ballSpriteIds[1] = MAX_SPRITES; +} + +static void DestroyLastUsedBallGfx(struct Sprite *sprite) +{ + FreeSpriteTilesByTag(102); + FreeSpritePaletteByTag(102); + DestroySprite(sprite); + gBattleStruct->ballSpriteIds[0] = MAX_SPRITES; +} + +static void SpriteCB_LastUsedBallWin(struct Sprite *sprite) +{ + if (sprite->sHide) + { + if (sprite->pos1.x != LAST_BALL_WIN_X_0) + sprite->pos1.x--; + + if (sprite->pos1.x == LAST_BALL_WIN_X_0) + DestroyLastUsedBallWinGfx(sprite); + } + else + { + if (sprite->pos1.x != LAST_BALL_WIN_X_F) + sprite->pos1.x++; + } +} + +static void SpriteCB_LastUsedBall(struct Sprite *sprite) +{ + if (sprite->sHide) + { + if (sprite->pos1.x != LAST_USED_BALL_X_0) + sprite->pos1.x--; + + if (sprite->pos1.x == LAST_USED_BALL_X_0) + DestroyLastUsedBallGfx(sprite); + } + else + { + if (sprite->pos1.x != LAST_USED_BALL_X_F) + sprite->pos1.x++; + } +} + +static void TryHideOrRestoreLastUsedBall(u8 caseId) +{ + if (gBattleStruct->ballSpriteIds[0] == MAX_SPRITES) + return; + + switch (caseId) + { + case 0: // hide + if (gBattleStruct->ballSpriteIds[0] != MAX_SPRITES) + gSprites[gBattleStruct->ballSpriteIds[0]].sHide = TRUE; // hide + if (gBattleStruct->ballSpriteIds[1] != MAX_SPRITES) + gSprites[gBattleStruct->ballSpriteIds[1]].sHide = TRUE; // hide + break; + case 1: // restore + if (gBattleStruct->ballSpriteIds[0] != MAX_SPRITES) + gSprites[gBattleStruct->ballSpriteIds[0]].sHide = FALSE; // restore + if (gBattleStruct->ballSpriteIds[1] != MAX_SPRITES) + gSprites[gBattleStruct->ballSpriteIds[1]].sHide = FALSE; // restore + break; + } +} + +void TryHideLastUsedBall(void) +{ + TryHideOrRestoreLastUsedBall(0); +} + +void TryRestoreLastUsedBall(void) +{ + if (gBattleStruct->ballSpriteIds[0] != MAX_SPRITES) + TryHideOrRestoreLastUsedBall(1); + else + TryAddLastUsedBallItemSprites(); +} + diff --git a/src/battle_main.c b/src/battle_main.c index 9cf56abf7..2d4dfa16f 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -401,6 +401,7 @@ static void (* const sTurnActionsFuncsTable[])(void) = [B_ACTION_TRY_FINISH] = HandleAction_TryFinish, [B_ACTION_FINISHED] = HandleAction_ActionFinished, [B_ACTION_NOTHING_FAINTED] = HandleAction_NothingIsFainted, + [B_ACTION_THROW_BALL] = HandleAction_ThrowBall, }; static void (* const sEndTurnFuncsTable[])(void) = @@ -4053,6 +4054,9 @@ static void HandleTurnActionSelectionState(void) case B_ACTION_SAFARI_BALL: gBattleCommunication[gActiveBattler]++; break; + case B_ACTION_THROW_BALL: + gBattleCommunication[gActiveBattler]++; + break; case B_ACTION_SAFARI_POKEBLOCK: if ((gBattleResources->bufferB[gActiveBattler][1] | (gBattleResources->bufferB[gActiveBattler][2] << 8)) != 0) { diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index c8a393da3..f5f093cc5 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -12017,7 +12017,8 @@ static void Cmd_handleballthrow(void) { u32 odds; u8 catchRate; - + + gSaveBlock2Ptr->lastUsedBall = gLastUsedItem; if (gLastUsedItem == ITEM_SAFARI_BALL) catchRate = gBattleStruct->safariCatchFactor * 1275 / 100; else diff --git a/src/battle_util.c b/src/battle_util.c index 87f9003e0..7a86b659f 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -742,6 +742,17 @@ void HandleAction_SafariZoneBallThrow(void) gCurrentActionFuncId = B_ACTION_EXEC_SCRIPT; } +void HandleAction_ThrowBall(void) +{ + gBattlerAttacker = gBattlerByTurnOrder[gCurrentTurnActionNumber]; + gBattle_BG0_X = 0; + gBattle_BG0_Y = 0; + gLastUsedItem = gSaveBlock2Ptr->lastUsedBall; + RemoveBagItem(gLastUsedItem, 1); + gBattlescriptCurrInstr = BattleScript_BallThrow; + gCurrentActionFuncId = B_ACTION_EXEC_SCRIPT; +} + void HandleAction_ThrowPokeblock(void) { gBattlerAttacker = gBattlerByTurnOrder[gCurrentTurnActionNumber]; diff --git a/src/item_use.c b/src/item_use.c index 6b1519e9b..ad7a46499 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -936,42 +936,58 @@ void ItemUseOutOfBattle_EvolutionStone(u8 taskId) SetUpItemUseCallback(taskId); } -void ItemUseInBattle_PokeBall(u8 taskId) +u32 CanThrowBall(void) { if (IsBattlerAlive(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT)) - && IsBattlerAlive(GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT))) // There are two present pokemon. + && IsBattlerAlive(GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT))) { - static const u8 textCantThrowPokeBall[] = _("Cannot throw a ball!\nThere are two pokemon out there!\p"); - - if (!InBattlePyramid()) - DisplayItemMessage(taskId, 1, textCantThrowPokeBall, BagMenu_InitListsMenu); - else - DisplayItemMessageInBattlePyramid(taskId, textCantThrowPokeBall, Task_CloseBattlePyramidBagMessage); + return 1; // There are two present pokemon. } else if (gBattlerInMenuId == GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT) - && IsBattlerAlive(GetBattlerAtPosition(B_POSITION_PLAYER_LEFT))) // Attempting to throw a ball with the second pokemon while both are alive. + && IsBattlerAlive(GetBattlerAtPosition(B_POSITION_PLAYER_LEFT))) { - static const u8 textCantThrowPokeBall[] = _("Cannot throw a ball!\p"); - - if (!InBattlePyramid()) - DisplayItemMessage(taskId, 1, textCantThrowPokeBall, BagMenu_InitListsMenu); - else - DisplayItemMessageInBattlePyramid(taskId, textCantThrowPokeBall, Task_CloseBattlePyramidBagMessage); + return 2; // Attempting to throw a ball with the second pokemon while both are alive. } - else if (IsPlayerPartyAndPokemonStorageFull() == FALSE) // have room for mon? + else if (IsPlayerPartyAndPokemonStorageFull() == TRUE) { + return 3; // No room for mon + } + + return 0; // usable +} + +static const u8 sText_CantThrowPokeBall_TwoMons[] = _("Cannot throw a ball!\nThere are two pokemon out there!\p"); +static const u8 sText_CantThrowPokeBall[] = _("Cannot throw a ball!\p"); +void ItemUseInBattle_PokeBall(u8 taskId) +{ + switch (CanThrowBall()) + { + case 0: // usable + default: RemoveBagItem(gSpecialVar_ItemId, 1); if (!InBattlePyramid()) Task_FadeAndCloseBagMenu(taskId); else CloseBattlePyramidBag(taskId); - } - else - { + break; + case 1: // There are two present pokemon. + if (!InBattlePyramid()) + DisplayItemMessage(taskId, 1, sText_CantThrowPokeBall_TwoMons, BagMenu_InitListsMenu); + else + DisplayItemMessageInBattlePyramid(taskId, sText_CantThrowPokeBall_TwoMons, Task_CloseBattlePyramidBagMessage); + break; + case 2: // Attempting to throw a ball with the second pokemon while both are alive. + if (!InBattlePyramid()) + DisplayItemMessage(taskId, 1, sText_CantThrowPokeBall_TwoMons, BagMenu_InitListsMenu); + else + DisplayItemMessageInBattlePyramid(taskId, sText_CantThrowPokeBall_TwoMons, Task_CloseBattlePyramidBagMessage); + break; + case 3: // No room for mon if (!InBattlePyramid()) DisplayItemMessage(taskId, 1, gText_BoxFull, BagMenu_InitListsMenu); else DisplayItemMessageInBattlePyramid(taskId, gText_BoxFull, Task_CloseBattlePyramidBagMessage); + break; } } diff --git a/src/new_game.c b/src/new_game.c index 2a950efbc..c1dd85e90 100644 --- a/src/new_game.c +++ b/src/new_game.c @@ -45,6 +45,7 @@ #include "berry_powder.h" #include "mevent.h" #include "union_room_chat.h" +#include "constants/items.h" extern const u8 EventScript_ResetAllMapFlags[]; @@ -204,6 +205,7 @@ void NewGameInitData(void) WipeTrainerNameRecords(); ResetTrainerHillResults(); ResetContestLinkResults(); + gSaveBlock2Ptr->lastUsedBall = ITEM_POKE_BALL; } static void ResetMiniGamesRecords(void) From d28ac33b0e8f350d49511257d0d5df10ae2c8352 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Sun, 4 Jul 2021 09:28:59 -0600 Subject: [PATCH 02/14] fix throw last used ball action turn order checks --- src/battle_main.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/battle_main.c b/src/battle_main.c index 2d4dfa16f..6befbfbf5 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -4485,7 +4485,9 @@ static void SetActionsAndBattlersTurnOrder(void) { for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) { - if (gChosenActionByBattler[gActiveBattler] == B_ACTION_USE_ITEM || gChosenActionByBattler[gActiveBattler] == B_ACTION_SWITCH) + if (gChosenActionByBattler[gActiveBattler] == B_ACTION_USE_ITEM + || gChosenActionByBattler[gActiveBattler] == B_ACTION_SWITCH + || gChosenActionByBattler[gActiveBattler] == B_ACTION_THROW_BALL) { gActionsByTurnOrder[turnOrderId] = gChosenActionByBattler[gActiveBattler]; gBattlerByTurnOrder[turnOrderId] = gActiveBattler; @@ -4494,7 +4496,9 @@ static void SetActionsAndBattlersTurnOrder(void) } for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) { - if (gChosenActionByBattler[gActiveBattler] != B_ACTION_USE_ITEM && gChosenActionByBattler[gActiveBattler] != B_ACTION_SWITCH) + if (gChosenActionByBattler[gActiveBattler] != B_ACTION_USE_ITEM + && gChosenActionByBattler[gActiveBattler] != B_ACTION_SWITCH + && gChosenActionByBattler[gActiveBattler] != B_ACTION_THROW_BALL) { gActionsByTurnOrder[turnOrderId] = gChosenActionByBattler[gActiveBattler]; gBattlerByTurnOrder[turnOrderId] = gActiveBattler; @@ -4510,7 +4514,9 @@ static void SetActionsAndBattlersTurnOrder(void) if (gActionsByTurnOrder[i] != B_ACTION_USE_ITEM && gActionsByTurnOrder[j] != B_ACTION_USE_ITEM && gActionsByTurnOrder[i] != B_ACTION_SWITCH - && gActionsByTurnOrder[j] != B_ACTION_SWITCH) + && gActionsByTurnOrder[j] != B_ACTION_SWITCH + && gActionsByTurnOrder[i] != B_ACTION_THROW_BALL + && gActionsByTurnOrder[j] != B_ACTION_THROW_BALL) { if (GetWhoStrikesFirst(battler1, battler2, FALSE)) SwapTurnOrder(i, j); From 542f0accf5a4f0c3dde59e6e76dca98c7ab08db6 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Sun, 4 Jul 2021 10:09:57 -0600 Subject: [PATCH 03/14] fix updating last used ball when run out of item id --- src/battle_interface.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/battle_interface.c b/src/battle_interface.c index 828b57a2f..b233627d8 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -729,6 +729,12 @@ u8 GetMegaIndicatorSpriteId(u32 healthboxSpriteId) return gSprites[spriteId].hOther_IndicatorSpriteId; } +static void InitLastUsedBallAssets(void) +{ + gBattleStruct->ballSpriteIds[0] = MAX_SPRITES; + gBattleStruct->ballSpriteIds[1] = MAX_SPRITES; +} + u8 CreateBattlerHealthboxSprites(u8 battlerId) { s16 data6 = 0; @@ -3195,6 +3201,14 @@ bool32 CanThrowLastUsedBall(void) void TryAddLastUsedBallItemSprites(void) { + if (gSaveBlock2Ptr->lastUsedBall != ITEM_NONE && !CheckBagHasItem(gSaveBlock2Ptr->lastUsedBall, 1)) + { + // we're out of the last used ball, so just set it to the first ball in the bag + // we have to compact the bag first bc it is typically only compacted when you open it + CompactItemsInBagPocket(&gBagPockets[BALLS_POCKET]); + gSaveBlock2Ptr->lastUsedBall = gBagPockets[BALLS_POCKET].itemSlots[0].itemId; + } + if (CanThrowBall() != 0 || (gBattleTypeFlags & BATTLE_TYPE_TRAINER) || !CheckBagHasItem(gSaveBlock2Ptr->lastUsedBall, 1)) From 07e3e73372eb6d625a198e07fd4a2360c5d25031 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Sun, 18 Jul 2021 11:20:51 -0600 Subject: [PATCH 04/14] fix ITEM_NONE to 0 for compilation reasons --- src/battle_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_interface.c b/src/battle_interface.c index b233627d8..1564881e4 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -3201,7 +3201,7 @@ bool32 CanThrowLastUsedBall(void) void TryAddLastUsedBallItemSprites(void) { - if (gSaveBlock2Ptr->lastUsedBall != ITEM_NONE && !CheckBagHasItem(gSaveBlock2Ptr->lastUsedBall, 1)) + if (gSaveBlock2Ptr->lastUsedBall != 0 && !CheckBagHasItem(gSaveBlock2Ptr->lastUsedBall, 1)) { // we're out of the last used ball, so just set it to the first ball in the bag // we have to compact the bag first bc it is typically only compacted when you open it From d3446123461ee5ccfdf803934189244b351b459f Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Thu, 12 Aug 2021 14:49:17 -0600 Subject: [PATCH 05/14] fix last used ball window in wild doubles --- src/battle_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_interface.c b/src/battle_interface.c index 1564881e4..28d6bc97c 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -3183,7 +3183,7 @@ static const struct SpriteSheet sSpriteSheet_LastUsedBallWindow = #define LAST_USED_BALL_X_F 15 #define LAST_USED_BALL_X_0 -15 -#define LAST_USED_BALL_Y 68 +#define LAST_USED_BALL_Y ((IsDoubleBattle()) ? 78 : 68) #define LAST_BALL_WIN_X_F (LAST_USED_BALL_X_F - 1) #define LAST_BALL_WIN_X_0 (LAST_USED_BALL_X_0 - 0) From e4fb9c4593c8f37700005376b55c6e14c7a3a63d Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Tue, 31 Aug 2021 12:51:03 -0400 Subject: [PATCH 06/14] fix throwing ball in wild doubles --- src/battle_main.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/battle_main.c b/src/battle_main.c index c728ae266..9e08fbbbc 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -4055,6 +4055,7 @@ static void HandleTurnActionSelectionState(void) gBattleCommunication[gActiveBattler]++; break; case B_ACTION_THROW_BALL: + gBattleStruct->throwingPokeBall = TRUE; gBattleCommunication[gActiveBattler]++; break; case B_ACTION_SAFARI_POKEBLOCK: @@ -4170,6 +4171,13 @@ static void HandleTurnActionSelectionState(void) if (gBattleCommunication[ACTIONS_CONFIRMED_COUNT] == gBattlersCount) { sub_818603C(1); + + if (WILD_DOUBLE_BATTLE && gBattleStruct->throwingPokeBall) { + // if we choose to throw a ball with our second mon, skip the action of the first + // (if we have chosen throw ball with first, second's is already skipped) + gChosenActionByBattler[B_POSITION_PLAYER_LEFT] = B_ACTION_NOTHING_FAINTED; + } + gBattleMainFunc = SetActionsAndBattlersTurnOrder; if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) From 88476e0ac27c7fe44450a3f27feebc588ea95090 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Tue, 31 Aug 2021 12:59:20 -0400 Subject: [PATCH 07/14] remove 2nd case in CanThrowBall --- src/item_use.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/item_use.c b/src/item_use.c index ad7a46499..5a5cd6a52 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -943,11 +943,14 @@ u32 CanThrowBall(void) { return 1; // There are two present pokemon. } - else if (gBattlerInMenuId == GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT) + /*else if (gBattlerInMenuId == GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT) && IsBattlerAlive(GetBattlerAtPosition(B_POSITION_PLAYER_LEFT))) { + /* * this is removed. instead, selecting a ball to throw with the second mon just clears the action of your first mon. + * see the end of HandleTurnActionSelectionState in battle_main.c + */ return 2; // Attempting to throw a ball with the second pokemon while both are alive. - } + }*/ else if (IsPlayerPartyAndPokemonStorageFull() == TRUE) { return 3; // No room for mon From 39a254f80d240243f6e3a0568d0ae98f3ba0d5a5 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Wed, 1 Sep 2021 07:45:41 -0400 Subject: [PATCH 08/14] fix sprite pos changes --- src/battle_interface.c | 24 ++++++++++++------------ src/item_use.c | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/battle_interface.c b/src/battle_interface.c index e17036faa..5f3eecaac 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -3218,8 +3218,8 @@ void TryAddLastUsedBallItemSprites(void) if (gBattleStruct->ballSpriteIds[0] == MAX_SPRITES) { gBattleStruct->ballSpriteIds[0] = AddItemIconSprite(102, 102, gSaveBlock2Ptr->lastUsedBall); - gSprites[gBattleStruct->ballSpriteIds[0]].pos1.x = LAST_USED_BALL_X_0; - gSprites[gBattleStruct->ballSpriteIds[0]].pos1.y = LAST_USED_BALL_Y; + gSprites[gBattleStruct->ballSpriteIds[0]].x = LAST_USED_BALL_X_0; + gSprites[gBattleStruct->ballSpriteIds[0]].y = LAST_USED_BALL_Y; gSprites[gBattleStruct->ballSpriteIds[0]].sHide = FALSE; // restore gSprites[gBattleStruct->ballSpriteIds[0]].callback = SpriteCB_LastUsedBall; } @@ -3258,16 +3258,16 @@ static void SpriteCB_LastUsedBallWin(struct Sprite *sprite) { if (sprite->sHide) { - if (sprite->pos1.x != LAST_BALL_WIN_X_0) - sprite->pos1.x--; + if (sprite->x != LAST_BALL_WIN_X_0) + sprite->x--; - if (sprite->pos1.x == LAST_BALL_WIN_X_0) + if (sprite->x == LAST_BALL_WIN_X_0) DestroyLastUsedBallWinGfx(sprite); } else { - if (sprite->pos1.x != LAST_BALL_WIN_X_F) - sprite->pos1.x++; + if (sprite->x != LAST_BALL_WIN_X_F) + sprite->x++; } } @@ -3275,16 +3275,16 @@ static void SpriteCB_LastUsedBall(struct Sprite *sprite) { if (sprite->sHide) { - if (sprite->pos1.x != LAST_USED_BALL_X_0) - sprite->pos1.x--; + if (sprite->x != LAST_USED_BALL_X_0) + sprite->x--; - if (sprite->pos1.x == LAST_USED_BALL_X_0) + if (sprite->x == LAST_USED_BALL_X_0) DestroyLastUsedBallGfx(sprite); } else { - if (sprite->pos1.x != LAST_USED_BALL_X_F) - sprite->pos1.x++; + if (sprite->x != LAST_USED_BALL_X_F) + sprite->x++; } } diff --git a/src/item_use.c b/src/item_use.c index d0aa82b85..63854a1ac 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -966,7 +966,7 @@ void ItemUseInBattle_PokeBall(u8 taskId) break; case 1: // There are two present pokemon. if (!InBattlePyramid()) - DisplayItemMessage(taskId, 1, sText_CantThrowPokeBall_TwoMons, BagMenu_InitListsMenu); + DisplayItemMessage(taskId, 1, sText_CantThrowPokeBall_TwoMons, CloseItemMessage); else DisplayItemMessageInBattlePyramid(taskId, sText_CantThrowPokeBall_TwoMons, Task_CloseBattlePyramidBagMessage); break; From 3f34fec42fb3aa55173e207c384e3b40f1e46591 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Thu, 23 Sep 2021 12:03:01 -0400 Subject: [PATCH 09/14] change last ball graphic based on config. replace saveblock field with ewram field --- .../battle_interface/last_used_ball_l.png | Bin 0 -> 214 bytes ...ast_used_ball.png => last_used_ball_r.png} | Bin include/battle.h | 1 + src/battle_interface.c | 36 ++++++++++++++---- src/battle_main.c | 1 + src/battle_script_commands.c | 2 +- src/battle_util.c | 2 +- 7 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 graphics/battle_interface/last_used_ball_l.png rename graphics/battle_interface/{last_used_ball.png => last_used_ball_r.png} (100%) diff --git a/graphics/battle_interface/last_used_ball_l.png b/graphics/battle_interface/last_used_ball_l.png new file mode 100644 index 0000000000000000000000000000000000000000..90fcef37398ed2b8bef3c2cc0649bc4ad9a8fac1 GIT binary patch literal 214 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnF3?v&v(vJfvg8-ipSH_Le)y2(0UQw2Yj+z{f zK*sa;Uw{7n50nRj?BZfCCy?fA*Uq){^Z*&j&Z>)mRHCPgV~EDY^unv_P&x8 zS#yg)?8er2d6p7uYPU)$efU;Y`Lk$&!&Tdk1N(LxH11ySDHySpEAoNZk!hg?jk{ML zNYHg+U~^;L!1<<%`?2$5R*B*OhF;5_9Y;HAOBfhR1(d!8PtREbw2Z;i)z4*}Q$iB} D1m#Ns literal 0 HcmV?d00001 diff --git a/graphics/battle_interface/last_used_ball.png b/graphics/battle_interface/last_used_ball_r.png similarity index 100% rename from graphics/battle_interface/last_used_ball.png rename to graphics/battle_interface/last_used_ball_r.png diff --git a/include/battle.h b/include/battle.h index 54693a33b..0becc4dd4 100644 --- a/include/battle.h +++ b/include/battle.h @@ -890,5 +890,6 @@ extern u8 gNumberOfMovesToChoose; extern u8 gBattleControllerData[MAX_BATTLERS_COUNT]; extern bool8 gHasFetchedBall; extern u8 gLastUsedBall; +extern u16 gLastThrownBall; #endif // GUARD_BATTLE_H diff --git a/src/battle_interface.c b/src/battle_interface.c index 5f3eecaac..4a3d1eaec 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -30,6 +30,7 @@ #include "item_icon.h" #include "item_use.h" #include "item.h" +#include "constants/items.h" enum { // Corresponds to gHealthboxElementsGfxTable (and the tables after it) in graphics.c @@ -3175,7 +3176,11 @@ static const struct SpriteTemplate sSpriteTemplate_LastUsedBallWindow = .callback = SpriteCB_LastUsedBallWin }; -static const u8 sLastUsedBallWindowGfx[] = INCBIN_U8("graphics/battle_interface/last_used_ball.4bpp"); +#if B_LAST_USED_BALL_BUTTON == R_BUTTON + static const u8 sLastUsedBallWindowGfx[] = INCBIN_U8("graphics/battle_interface/last_used_ball_r.4bpp"); +#else + static const u8 sLastUsedBallWindowGfx[] = INCBIN_U8("graphics/battle_interface/last_used_ball_r.4bpp"); +#endif static const struct SpriteSheet sSpriteSheet_LastUsedBallWindow = { sLastUsedBallWindowGfx, sizeof(sLastUsedBallWindowGfx), LAST_BALL_WINDOW_TAG @@ -3193,31 +3198,39 @@ static const struct SpriteSheet sSpriteSheet_LastUsedBallWindow = bool32 CanThrowLastUsedBall(void) { - return (!(CanThrowBall() != 0 - || (gBattleTypeFlags & BATTLE_TYPE_TRAINER) - || !CheckBagHasItem(gSaveBlock2Ptr->lastUsedBall, 1))); + #if B_LAST_USED_BALL == FALSE + return FALSE; + #else + return (!(CanThrowBall() != 0 + || (gBattleTypeFlags & BATTLE_TYPE_TRAINER) + || !CheckBagHasItem(gLastThrownBall, 1))); + #endif } void TryAddLastUsedBallItemSprites(void) { - if (gSaveBlock2Ptr->lastUsedBall != 0 && !CheckBagHasItem(gSaveBlock2Ptr->lastUsedBall, 1)) + #if B_LAST_USED_BALL == TRUE + if (gLastThrownBall == 0) + gLastThrownBall = ITEM_POKE_BALL; + + if (gLastThrownBall != 0 && !CheckBagHasItem(gLastThrownBall, 1)) { // we're out of the last used ball, so just set it to the first ball in the bag // we have to compact the bag first bc it is typically only compacted when you open it CompactItemsInBagPocket(&gBagPockets[BALLS_POCKET]); - gSaveBlock2Ptr->lastUsedBall = gBagPockets[BALLS_POCKET].itemSlots[0].itemId; + gLastThrownBall = gBagPockets[BALLS_POCKET].itemSlots[0].itemId; } if (CanThrowBall() != 0 || (gBattleTypeFlags & BATTLE_TYPE_TRAINER) - || !CheckBagHasItem(gSaveBlock2Ptr->lastUsedBall, 1)) + || !CheckBagHasItem(gLastThrownBall, 1)) return; // ball if (gBattleStruct->ballSpriteIds[0] == MAX_SPRITES) { - gBattleStruct->ballSpriteIds[0] = AddItemIconSprite(102, 102, gSaveBlock2Ptr->lastUsedBall); + gBattleStruct->ballSpriteIds[0] = AddItemIconSprite(102, 102, gLastThrownBall); gSprites[gBattleStruct->ballSpriteIds[0]].x = LAST_USED_BALL_X_0; gSprites[gBattleStruct->ballSpriteIds[0]].y = LAST_USED_BALL_Y; gSprites[gBattleStruct->ballSpriteIds[0]].sHide = FALSE; // restore @@ -3236,6 +3249,7 @@ void TryAddLastUsedBallItemSprites(void) LAST_USED_WIN_Y, 5); gSprites[gBattleStruct->ballSpriteIds[0]].sHide = FALSE; // restore } + #endif } static void DestroyLastUsedBallWinGfx(struct Sprite *sprite) @@ -3290,6 +3304,7 @@ static void SpriteCB_LastUsedBall(struct Sprite *sprite) static void TryHideOrRestoreLastUsedBall(u8 caseId) { + #if B_LAST_USED_BALL == TRUE if (gBattleStruct->ballSpriteIds[0] == MAX_SPRITES) return; @@ -3308,18 +3323,23 @@ static void TryHideOrRestoreLastUsedBall(u8 caseId) gSprites[gBattleStruct->ballSpriteIds[1]].sHide = FALSE; // restore break; } + #endif } void TryHideLastUsedBall(void) { + #if B_LAST_USED_BALL == TRUE TryHideOrRestoreLastUsedBall(0); + #endif } void TryRestoreLastUsedBall(void) { + #if B_LAST_USED_BALL == TRUE if (gBattleStruct->ballSpriteIds[0] != MAX_SPRITES) TryHideOrRestoreLastUsedBall(1); else TryAddLastUsedBallItemSprites(); + #endif } diff --git a/src/battle_main.c b/src/battle_main.c index b1cc8bbc4..b8b013635 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -230,6 +230,7 @@ EWRAM_DATA u16 gPartnerSpriteId = 0; EWRAM_DATA struct TotemBoost gTotemBoosts[MAX_BATTLERS_COUNT] = {0}; EWRAM_DATA bool8 gHasFetchedBall = FALSE; EWRAM_DATA u8 gLastUsedBall = 0; +EWRAM_DATA u16 gLastThrownBall = 0; // IWRAM common vars void (*gPreBattleCallback1)(void); diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index cd64a2497..313f47878 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -12021,7 +12021,7 @@ static void Cmd_handleballthrow(void) u32 odds; u8 catchRate; - gSaveBlock2Ptr->lastUsedBall = gLastUsedItem; + gLastThrownBall = gLastUsedItem; if (gLastUsedItem == ITEM_SAFARI_BALL) catchRate = gBattleStruct->safariCatchFactor * 1275 / 100; else diff --git a/src/battle_util.c b/src/battle_util.c index 04070bf7e..f482d40dd 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -759,7 +759,7 @@ void HandleAction_ThrowBall(void) gBattlerAttacker = gBattlerByTurnOrder[gCurrentTurnActionNumber]; gBattle_BG0_X = 0; gBattle_BG0_Y = 0; - gLastUsedItem = gSaveBlock2Ptr->lastUsedBall; + gLastUsedItem = gLastThrownBall; RemoveBagItem(gLastUsedItem, 1); gBattlescriptCurrInstr = BattleScript_BallThrow; gCurrentActionFuncId = B_ACTION_EXEC_SCRIPT; From 768598b1545b361a3a5f3e312a2d66c2d510f1a3 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Thu, 23 Sep 2021 12:22:36 -0400 Subject: [PATCH 10/14] fix bad merge --- include/battle_util.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/battle_util.h b/include/battle_util.h index d01ca3411..15b238b17 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -48,7 +48,6 @@ struct TypePower extern const struct TypePower gNaturalGiftTable[]; void HandleAction_ThrowBall(void); -bool32 IsAffectedByFollowMe(u32 battlerAtk, u32 defSide); bool32 IsAffectedByFollowMe(u32 battlerAtk, u32 defSide, u32 move); void HandleAction_UseMove(void); void HandleAction_Switch(void); From 3925c07c1a2e7c6b3803e66f49f4af316fe26aec Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Thu, 23 Sep 2021 13:20:32 -0400 Subject: [PATCH 11/14] fix l graphic --- src/battle_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_interface.c b/src/battle_interface.c index 4a3d1eaec..63a05860d 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -3179,7 +3179,7 @@ static const struct SpriteTemplate sSpriteTemplate_LastUsedBallWindow = #if B_LAST_USED_BALL_BUTTON == R_BUTTON static const u8 sLastUsedBallWindowGfx[] = INCBIN_U8("graphics/battle_interface/last_used_ball_r.4bpp"); #else - static const u8 sLastUsedBallWindowGfx[] = INCBIN_U8("graphics/battle_interface/last_used_ball_r.4bpp"); + static const u8 sLastUsedBallWindowGfx[] = INCBIN_U8("graphics/battle_interface/last_used_ball_l.4bpp"); #endif static const struct SpriteSheet sSpriteSheet_LastUsedBallWindow = { From 1ad8448532c33f0962e1bfe8c6838ccc22b23686 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Wed, 6 Oct 2021 13:54:33 -0400 Subject: [PATCH 12/14] remove saveblock field --- include/global.h | 3 +-- src/new_game.c | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/include/global.h b/include/global.h index a0aa45d3d..53a6175a2 100644 --- a/include/global.h +++ b/include/global.h @@ -485,8 +485,7 @@ struct SaveBlock2 u16 optionsBattleSceneOff:1; // whether battle animations are disabled u16 regionMapZoom:1; // whether the map is zoomed in /*0x18*/ struct Pokedex pokedex; - /*0x90*/ u16 lastUsedBall; - /*0x92*/ u8 filler_90[0x6]; + /*0x90*/ u8 filler_90[0x8]; /*0x98*/ struct Time localTimeOffset; /*0xA0*/ struct Time lastBerryTreeUpdate; /*0xA8*/ u32 gcnLinkFlags; // Read by Pokemon Colosseum/XD diff --git a/src/new_game.c b/src/new_game.c index c1dd85e90..e0453c9ad 100644 --- a/src/new_game.c +++ b/src/new_game.c @@ -205,7 +205,6 @@ void NewGameInitData(void) WipeTrainerNameRecords(); ResetTrainerHillResults(); ResetContestLinkResults(); - gSaveBlock2Ptr->lastUsedBall = ITEM_POKE_BALL; } static void ResetMiniGamesRecords(void) From 3d24fd5f3094a20cf1325607148323e397a6f00c Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Wed, 6 Oct 2021 13:56:04 -0400 Subject: [PATCH 13/14] last ball defaults to first bag pocket item --- src/battle_interface.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/battle_interface.c b/src/battle_interface.c index c1f76c6ce..b3bb981c7 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -3206,10 +3206,8 @@ bool32 CanThrowLastUsedBall(void) void TryAddLastUsedBallItemSprites(void) { #if B_LAST_USED_BALL == TRUE - if (gLastThrownBall == 0) - gLastThrownBall = ITEM_POKE_BALL; - - if (gLastThrownBall != 0 && !CheckBagHasItem(gLastThrownBall, 1)) + if ((gLastThrownBall == 0 + || (gLastThrownBall != 0 && !CheckBagHasItem(gLastThrownBall, 1))) { // we're out of the last used ball, so just set it to the first ball in the bag // we have to compact the bag first bc it is typically only compacted when you open it From 33d19d4e348a5bdf0009ebe488e61a78684ca00a Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Wed, 6 Oct 2021 14:19:15 -0400 Subject: [PATCH 14/14] syntax fix --- src/battle_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_interface.c b/src/battle_interface.c index b3bb981c7..0e33455ac 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -3206,7 +3206,7 @@ bool32 CanThrowLastUsedBall(void) void TryAddLastUsedBallItemSprites(void) { #if B_LAST_USED_BALL == TRUE - if ((gLastThrownBall == 0 + if (gLastThrownBall == 0 || (gLastThrownBall != 0 && !CheckBagHasItem(gLastThrownBall, 1))) { // we're out of the last used ball, so just set it to the first ball in the bag