Skip to content

Commit

Permalink
Implement Pokemon Box Link functionality (rh-hideout#3837)
Browse files Browse the repository at this point in the history
* Implement Pokemon Box Link functionality

* Update item_use.c

* Update item_use.c

* Can only use box link if the map allows escape

* Revert "Can only use box link if the map allows escape"

This reverts commit be5b46b.

* Overworld_IsEscapingAllowed

---------

Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com>
  • Loading branch information
kittenchilly and AlexOn1ine authored Dec 28, 2023
1 parent c57b154 commit 28f1777
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 2 deletions.
8 changes: 8 additions & 0 deletions data/scripts/pc.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions include/event_scripts.h
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down
1 change: 1 addition & 0 deletions include/item_use.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/data/items.h
Original file line number Diff line number Diff line change
Expand Up @@ -10186,8 +10186,8 @@ const struct Item gItems[] =
"Storage System."),
.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] =
Expand Down
13 changes: 13 additions & 0 deletions src/item_use.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,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 ItemUseOnFieldCB_Bike(u8);
static void ItemUseOnFieldCB_Rod(u8);
static void ItemUseOnFieldCB_Itemfinder(u8);
Expand Down Expand Up @@ -680,6 +681,18 @@ static void Task_OpenRegisteredPokeblockCase(u8 taskId)
}
}

void ItemUseOutOfBattle_PokemonBoxLink(u8 taskId)
{
sItemUseOnFieldCB = Task_AccessPokemonBoxLink;
SetUpItemUseOnFieldCallback(taskId);
}

static void Task_AccessPokemonBoxLink(u8 taskId)
{
ScriptContext_SetupScript(EventScript_AccessPokemonBoxLink);
DestroyTask(taskId);
}

void ItemUseOutOfBattle_CoinCase(u8 taskId)
{
ConvertIntToDecimalStringN(gStringVar1, GetCoins(), STR_CONV_MODE_LEFT_ALIGN, 4);
Expand Down

0 comments on commit 28f1777

Please sign in to comment.