diff --git a/include/fldeff.h b/include/fldeff.h index 0ad0e3d60..bed235a1b 100644 --- a/include/fldeff.h +++ b/include/fldeff.h @@ -35,6 +35,7 @@ bool8 FldEff_UseStrength(void); // sweet scent bool8 SetUpFieldMove_SweetScent(void); bool8 FldEff_SweetScent(void); +void StartSweetScentFieldEffect(void); // teleport bool8 SetUpFieldMove_Teleport(void); diff --git a/include/item_use.h b/include/item_use.h index bdbf2cdea..812e984ec 100644 --- a/include/item_use.h +++ b/include/item_use.h @@ -28,6 +28,7 @@ void ItemUseOutOfBattle_Berry(u8); void ItemUseOutOfBattle_EnigmaBerry(u8); void ItemUseOutOfBattle_FormChange(u8); void ItemUseOutOfBattle_FormChange_ConsumedOnUse(u8); +void ItemUseOutOfBattle_Honey(u8); void ItemUseOutOfBattle_CannotUse(u8); void ItemUseInBattle_PokeBall(u8); void ItemUseInBattle_StatIncrease(u8); diff --git a/src/data/items.h b/src/data/items.h index 5087ca03b..513099d18 100644 --- a/src/data/items.h +++ b/src/data/items.h @@ -2035,8 +2035,8 @@ const struct Item gItems[] = .price = 300, .description = sHoneyDesc, .pocket = POCKET_ITEMS, - .type = ITEM_USE_BAG_MENU, - .fieldUseFunc = ItemUseOutOfBattle_CannotUse, + .type = ITEM_USE_FIELD, + .fieldUseFunc = ItemUseOutOfBattle_Honey, .flingPower = 30, }, diff --git a/src/fldeff_sweetscent.c b/src/fldeff_sweetscent.c index 7e9352609..5ed133e5d 100644 --- a/src/fldeff_sweetscent.c +++ b/src/fldeff_sweetscent.c @@ -19,7 +19,6 @@ #include "constants/songs.h" static void FieldCallback_SweetScent(void); -static void StartSweetScentFieldEffect(void); static void TrySweetScentEncounter(u8 taskId); static void FailSweetScentEncounter(u8 taskId); @@ -47,14 +46,15 @@ bool8 FldEff_SweetScent(void) return FALSE; } -static void StartSweetScentFieldEffect(void) +void StartSweetScentFieldEffect(void) { u8 taskId; + u32 palettes = ~(1 << (gSprites[GetPlayerAvatarSpriteId()].oam.paletteNum + 16) | (1 << 13) | (1 << 14) | (1 << 15)); PlaySE(SE_M_SWEET_SCENT); CpuFastSet(gPlttBufferUnfaded, gPaletteDecompressionBuffer, 0x100); CpuFastSet(gPlttBufferFaded, gPlttBufferUnfaded, 0x100); - BeginNormalPaletteFade(~(1 << (gSprites[GetPlayerAvatarSpriteId()].oam.paletteNum + 16)), 4, 0, 8, RGB_RED); + BeginNormalPaletteFade(palettes, 4, 0, 8, RGB_RED); taskId = CreateTask(TrySweetScentEncounter, 0); gTasks[taskId].data[0] = 0; FieldEffectActiveListRemove(FLDEFF_SWEET_SCENT); diff --git a/src/item_use.c b/src/item_use.c index fee00853f..dbdcc16d6 100644 --- a/src/item_use.c +++ b/src/item_use.c @@ -18,6 +18,7 @@ #include "field_player_avatar.h" #include "field_screen_effect.h" #include "field_weather.h" +#include "fldeff.h" #include "item.h" #include "item_menu.h" #include "item_use.h" @@ -73,6 +74,7 @@ static void Task_UseLure(u8 taskId); static void Task_CloseCantUseKeyItemMessage(u8); static void SetDistanceOfClosestHiddenItem(u8, s16, s16); static void CB2_OpenPokeblockFromBag(void); +static void ItemUseOnFieldCB_Honey(u8 taskId); // EWRAM variables EWRAM_DATA static void(*sItemUseOnFieldCB)(u8 taskId) = NULL; @@ -1258,6 +1260,29 @@ void ItemUseOutOfBattle_FormChange_ConsumedOnUse(u8 taskId) SetUpItemUseCallback(taskId); } +void Task_UseHoneyOnField(u8 taskId) +{ + //ResetInitialPlayerAvatarState(); + StartSweetScentFieldEffect(); + DestroyTask(taskId); +} + +static void ItemUseOnFieldCB_Honey(u8 taskId) +{ + Overworld_ResetStateAfterDigEscRope(); + RemoveUsedItem(); + gTasks[taskId].data[0] = 0; + DisplayItemMessageOnField(taskId, gStringVar4, Task_UseHoneyOnField); +} + +void ItemUseOutOfBattle_Honey(u8 taskId) +{ + sItemUseOnFieldCB = ItemUseOnFieldCB_Honey; + gFieldCallback = FieldCB_UseItemOnField; + gBagMenu->newScreenCallback = CB2_ReturnToField; + Task_FadeAndCloseBagMenu(taskId); +} + void ItemUseOutOfBattle_CannotUse(u8 taskId) { DisplayDadsAdviceCannotUseItemMessage(taskId, gTasks[taskId].tUsingRegisteredKeyItem);