From cf5b21464d5a1490d860e4567e2d197d7f62cecb Mon Sep 17 00:00:00 2001 From: kittenchilly Date: Tue, 12 Sep 2023 19:03:54 -0500 Subject: [PATCH 1/6] Implement Pokemon Box Link functionality --- data/scripts/pc.inc | 8 ++++++++ include/event_scripts.h | 1 + include/item_use.h | 1 + src/data/items.h | 4 ++-- src/item_use.c | 16 ++++++++++++++++ 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/data/scripts/pc.inc b/data/scripts/pc.inc index 1993aaf63f86..e4e37f5b4309 100644 --- a/data/scripts/pc.inc +++ b/data/scripts/pc.inc @@ -64,3 +64,11 @@ EventScript_AccessHallOfFame:: waitstate goto EventScript_AccessPC end + +EventScript_AccessPokemonBoxLink:: + playse SE_PC_LOGIN + msgbox gText_StorageSystemOpened, MSGBOX_DEFAULT + special ShowPokemonStorageSystemPC + waitstate + goto EventScript_TurnOffPC + end diff --git a/include/event_scripts.h b/include/event_scripts.h index 4e0a88f82ac1..690171a1b974 100644 --- a/include/event_scripts.h +++ b/include/event_scripts.h @@ -515,6 +515,7 @@ extern const u8 MauvilleCity_PokemonCenter_1F_Text_HotSpringsStory[]; extern const u8 LittlerootTown_BrendansHouse_2F_EventScript_PC[]; extern const u8 LittlerootTown_MaysHouse_2F_EventScript_PC[]; extern const u8 EventScript_PC[]; +extern const u8 EventScript_AccessPokemonBoxLink[]; extern const u8 EventScript_TestSignpostMsg[]; extern const u8 EventScript_HiddenItemScript[]; extern const u8 EventScript_TV[]; diff --git a/include/item_use.h b/include/item_use.h index 6b3d0c590e22..827e1a26338d 100644 --- a/include/item_use.h +++ b/include/item_use.h @@ -7,6 +7,7 @@ void ItemUseOutOfBattle_Rod(u8); void ItemUseOutOfBattle_Itemfinder(u8); void ItemUseOutOfBattle_PokeblockCase(u8); void ItemUseOutOfBattle_CoinCase(u8); +void ItemUseOutOfBattle_PokemonBoxLink(u8); void ItemUseOutOfBattle_PowderJar(u8); void ItemUseOutOfBattle_SSTicket(u8); void ItemUseOutOfBattle_WailmerPail(u8); diff --git a/src/data/items.h b/src/data/items.h index 842dae6bd20f..996e27161cec 100644 --- a/src/data/items.h +++ b/src/data/items.h @@ -8758,8 +8758,8 @@ const struct Item gItems[] = .description = sPokemonBoxLinkDesc, .importance = 1, .pocket = POCKET_KEY_ITEMS, - .type = ITEM_USE_BAG_MENU, - .fieldUseFunc = ItemUseOutOfBattle_CannotUse, // Todo + .type = ITEM_USE_FIELD, + .fieldUseFunc = ItemUseOutOfBattle_PokemonBoxLink, }, [ITEM_COIN_CASE] = diff --git a/src/item_use.c b/src/item_use.c index b3b5c066a499..3e974051e559 100644 --- a/src/item_use.c +++ b/src/item_use.c @@ -56,6 +56,7 @@ static u8 GetDirectionToHiddenItem(s16, s16); static void PlayerFaceHiddenItem(u8); static void CheckForHiddenItemsInMapConnection(u8); static void Task_OpenRegisteredPokeblockCase(u8); +static void Task_WaitFadeAccessPC(u8); static void ItemUseOnFieldCB_Bike(u8); static void ItemUseOnFieldCB_Rod(u8); static void ItemUseOnFieldCB_Itemfinder(u8); @@ -678,6 +679,21 @@ static void Task_OpenRegisteredPokeblockCase(u8 taskId) } } +void ItemUseOutOfBattle_PokemonBoxLink(u8 taskId) +{ + sItemUseOnFieldCB = Task_WaitFadeAccessPC; + SetUpItemUseOnFieldCallback(taskId); +} + +static void Task_WaitFadeAccessPC(u8 taskId) +{ + if (!gPaletteFade.active) + { + ScriptContext_SetupScript(EventScript_AccessPokemonBoxLink); + DestroyTask(taskId); + } +} + void ItemUseOutOfBattle_CoinCase(u8 taskId) { ConvertIntToDecimalStringN(gStringVar1, GetCoins(), STR_CONV_MODE_LEFT_ALIGN, 4); From 4c3b6109db515f3ae98c6d9a517b283b90a79455 Mon Sep 17 00:00:00 2001 From: kittenchilly Date: Tue, 12 Sep 2023 19:05:24 -0500 Subject: [PATCH 2/6] Update item_use.c --- src/item_use.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/item_use.c b/src/item_use.c index 3e974051e559..151d17e8267a 100644 --- a/src/item_use.c +++ b/src/item_use.c @@ -681,11 +681,11 @@ static void Task_OpenRegisteredPokeblockCase(u8 taskId) void ItemUseOutOfBattle_PokemonBoxLink(u8 taskId) { - sItemUseOnFieldCB = Task_WaitFadeAccessPC; + sItemUseOnFieldCB = Task_WaitFadeAccessPokemonBoxLink; SetUpItemUseOnFieldCallback(taskId); } -static void Task_WaitFadeAccessPC(u8 taskId) +static void Task_WaitFadeAccessPokemonBoxLink(u8 taskId) { if (!gPaletteFade.active) { From 4dbb6011b616952f58a6a58cb97f81a8e519d86b Mon Sep 17 00:00:00 2001 From: kittenchilly Date: Tue, 12 Sep 2023 19:05:38 -0500 Subject: [PATCH 3/6] Update item_use.c --- src/item_use.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/item_use.c b/src/item_use.c index 151d17e8267a..c65aaa095fc0 100644 --- a/src/item_use.c +++ b/src/item_use.c @@ -56,7 +56,7 @@ static u8 GetDirectionToHiddenItem(s16, s16); static void PlayerFaceHiddenItem(u8); static void CheckForHiddenItemsInMapConnection(u8); static void Task_OpenRegisteredPokeblockCase(u8); -static void Task_WaitFadeAccessPC(u8); +static void Task_WaitFadeAccessPokemonBoxLink(u8); static void ItemUseOnFieldCB_Bike(u8); static void ItemUseOnFieldCB_Rod(u8); static void ItemUseOnFieldCB_Itemfinder(u8); From be5b46b6c4420cd350ac1932d4c3562f7bfbebe5 Mon Sep 17 00:00:00 2001 From: kittenchilly Date: Tue, 12 Sep 2023 19:17:01 -0500 Subject: [PATCH 4/6] Can only use box link if the map allows escape --- src/item_use.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/item_use.c b/src/item_use.c index c65aaa095fc0..f28718436c76 100644 --- a/src/item_use.c +++ b/src/item_use.c @@ -56,7 +56,7 @@ static u8 GetDirectionToHiddenItem(s16, s16); static void PlayerFaceHiddenItem(u8); static void CheckForHiddenItemsInMapConnection(u8); static void Task_OpenRegisteredPokeblockCase(u8); -static void Task_WaitFadeAccessPokemonBoxLink(u8); +static void Task_AccessPokemonBoxLink(u8); static void ItemUseOnFieldCB_Bike(u8); static void ItemUseOnFieldCB_Rod(u8); static void ItemUseOnFieldCB_Itemfinder(u8); @@ -681,17 +681,20 @@ static void Task_OpenRegisteredPokeblockCase(u8 taskId) void ItemUseOutOfBattle_PokemonBoxLink(u8 taskId) { - sItemUseOnFieldCB = Task_WaitFadeAccessPokemonBoxLink; - SetUpItemUseOnFieldCallback(taskId); + if (CanUseDigOrEscapeRopeOnCurMap) + { + sItemUseOnFieldCB = Task_AccessPokemonBoxLink; + SetUpItemUseOnFieldCallback(taskId); + } + else + DisplayDadsAdviceCannotUseItemMessage(taskId, gTasks[taskId].tUsingRegisteredKeyItem); + } -static void Task_WaitFadeAccessPokemonBoxLink(u8 taskId) +static void Task_AccessPokemonBoxLink(u8 taskId) { - if (!gPaletteFade.active) - { - ScriptContext_SetupScript(EventScript_AccessPokemonBoxLink); - DestroyTask(taskId); - } + ScriptContext_SetupScript(EventScript_AccessPokemonBoxLink); + DestroyTask(taskId); } void ItemUseOutOfBattle_CoinCase(u8 taskId) From edabad9fa004f4aa7b753c6a3c9ad096030db20b Mon Sep 17 00:00:00 2001 From: kittenchilly Date: Tue, 12 Sep 2023 19:30:41 -0500 Subject: [PATCH 5/6] Revert "Can only use box link if the map allows escape" This reverts commit be5b46b6c4420cd350ac1932d4c3562f7bfbebe5. --- src/item_use.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/item_use.c b/src/item_use.c index f28718436c76..c65aaa095fc0 100644 --- a/src/item_use.c +++ b/src/item_use.c @@ -56,7 +56,7 @@ static u8 GetDirectionToHiddenItem(s16, s16); static void PlayerFaceHiddenItem(u8); static void CheckForHiddenItemsInMapConnection(u8); static void Task_OpenRegisteredPokeblockCase(u8); -static void Task_AccessPokemonBoxLink(u8); +static void Task_WaitFadeAccessPokemonBoxLink(u8); static void ItemUseOnFieldCB_Bike(u8); static void ItemUseOnFieldCB_Rod(u8); static void ItemUseOnFieldCB_Itemfinder(u8); @@ -681,20 +681,17 @@ static void Task_OpenRegisteredPokeblockCase(u8 taskId) void ItemUseOutOfBattle_PokemonBoxLink(u8 taskId) { - if (CanUseDigOrEscapeRopeOnCurMap) - { - sItemUseOnFieldCB = Task_AccessPokemonBoxLink; - SetUpItemUseOnFieldCallback(taskId); - } - else - DisplayDadsAdviceCannotUseItemMessage(taskId, gTasks[taskId].tUsingRegisteredKeyItem); - + sItemUseOnFieldCB = Task_WaitFadeAccessPokemonBoxLink; + SetUpItemUseOnFieldCallback(taskId); } -static void Task_AccessPokemonBoxLink(u8 taskId) +static void Task_WaitFadeAccessPokemonBoxLink(u8 taskId) { - ScriptContext_SetupScript(EventScript_AccessPokemonBoxLink); - DestroyTask(taskId); + if (!gPaletteFade.active) + { + ScriptContext_SetupScript(EventScript_AccessPokemonBoxLink); + DestroyTask(taskId); + } } void ItemUseOutOfBattle_CoinCase(u8 taskId) From 13498abe4ade990c144f558491c85b4c5ee5975e Mon Sep 17 00:00:00 2001 From: kittenchilly Date: Tue, 12 Sep 2023 19:31:46 -0500 Subject: [PATCH 6/6] Overworld_IsEscapingAllowed --- src/item_use.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/item_use.c b/src/item_use.c index c65aaa095fc0..ff07ca49a159 100644 --- a/src/item_use.c +++ b/src/item_use.c @@ -56,7 +56,7 @@ static u8 GetDirectionToHiddenItem(s16, s16); static void PlayerFaceHiddenItem(u8); static void CheckForHiddenItemsInMapConnection(u8); static void Task_OpenRegisteredPokeblockCase(u8); -static void Task_WaitFadeAccessPokemonBoxLink(u8); +static void Task_AccessPokemonBoxLink(u8); static void ItemUseOnFieldCB_Bike(u8); static void ItemUseOnFieldCB_Rod(u8); static void ItemUseOnFieldCB_Itemfinder(u8); @@ -681,17 +681,14 @@ static void Task_OpenRegisteredPokeblockCase(u8 taskId) void ItemUseOutOfBattle_PokemonBoxLink(u8 taskId) { - sItemUseOnFieldCB = Task_WaitFadeAccessPokemonBoxLink; + sItemUseOnFieldCB = Task_AccessPokemonBoxLink; SetUpItemUseOnFieldCallback(taskId); } -static void Task_WaitFadeAccessPokemonBoxLink(u8 taskId) +static void Task_AccessPokemonBoxLink(u8 taskId) { - if (!gPaletteFade.active) - { - ScriptContext_SetupScript(EventScript_AccessPokemonBoxLink); - DestroyTask(taskId); - } + ScriptContext_SetupScript(EventScript_AccessPokemonBoxLink); + DestroyTask(taskId); } void ItemUseOutOfBattle_CoinCase(u8 taskId)