From b02b3d074f7d5f33be0093170906de33ad4ef3c5 Mon Sep 17 00:00:00 2001 From: Bassoonian Date: Sun, 3 Dec 2023 13:17:34 +0100 Subject: [PATCH] Add Mulch effects --- data/scripts/berry_tree.inc | 44 +++++++++++++++++++++++++++++++++ data/specials.inc | 3 +++ include/berry.h | 2 ++ include/constants/script_menu.h | 1 + include/item_menu.h | 2 ++ include/item_use.h | 1 + include/strings.h | 3 +++ src/berry.c | 34 +++++++++++++++++++++++++ src/data/script_menu.h | 8 ++++++ src/item_menu.c | 31 +++++++++++++++++++++-- src/item_use.c | 2 +- src/strings.c | 5 +++- 12 files changed, 132 insertions(+), 4 deletions(-) diff --git a/data/scripts/berry_tree.inc b/data/scripts/berry_tree.inc index c302f07eb0..f1ff5ba5a8 100644 --- a/data/scripts/berry_tree.inc +++ b/data/scripts/berry_tree.inc @@ -23,6 +23,8 @@ BerryTree_EventScript_CheckSoil:: faceplayer specialvar VAR_RESULT, PlayerHasBerries goto_if_eq VAR_RESULT, TRUE, BerryTree_EventScript_WantToPlant + specialvar VAR_RESULT, PlayerHasMulch + goto_if_eq VAR_RESULT, TRUE, BerryTree_EventScript_WantToMulch message BerryTree_Text_ItsSoftLoamySoil waitmessage waitbuttonpress @@ -30,11 +32,29 @@ BerryTree_EventScript_CheckSoil:: end BerryTree_EventScript_WantToPlant:: + specialvar VAR_RESULT, PlayerHasMulch + goto_if_eq VAR_RESULT, TRUE, BerryTree_EventScript_WantToPlantMulch msgbox BerryTree_Text_WantToPlant, MSGBOX_YESNO goto_if_eq VAR_RESULT, YES, BerryTree_EventScript_ChooseBerryToPlant goto_if_eq VAR_RESULT, NO, BerryTree_EventScript_CancelPlanting end +BerryTree_EventScript_WantToMulch:: + msgbox BerryTree_Text_WantToMulch, MSGBOX_YESNO + goto_if_eq VAR_RESULT, YES, BerryTree_EventScript_ChooseMulchToUse + goto_if_eq VAR_RESULT, NO, BerryTree_EventScript_CancelPlanting + end + +BerryTree_EventScript_WantToPlantMulch:: + message BerryTree_Text_ItsSoftLoamySoil + waitmessage + multichoice 0, 0, MULTI_BERRY_PLOT, FALSE + switch VAR_RESULT + case 0, BerryTree_EventScript_ChooseMulchToUse + case 1, BerryTree_EventScript_ChooseBerryToPlant + case 2, BerryTree_EventScript_CancelPlanting + case MULTI_B_PRESSED, BerryTree_EventScript_CancelPlanting + BerryTree_EventScript_ChooseBerryToPlant:: fadescreen FADE_TO_BLACK closemessage @@ -44,6 +64,15 @@ BerryTree_EventScript_ChooseBerryToPlant:: removeitem VAR_ITEM_ID call BerryTree_EventScript_PlantBerry +BerryTree_EventScript_ChooseMulchToUse:: + fadescreen FADE_TO_BLACK + closemessage + special Bag_ChooseMulch + waitstate + goto_if_eq VAR_ITEM_ID, 0, BerryTree_EventScript_CancelPlanting + removeitem VAR_ITEM_ID + call BerryTree_EventScript_UseMulch + BerryTree_EventScript_CancelPlanting:: release end @@ -194,6 +223,13 @@ BerryTree_EventScript_PlantBerry:: waitbuttonpress return +BerryTree_EventScript_UseMulch:: + special ObjectEventInteractionApplyMulch + message BerryTree_Text_ScatteredMulch + waitmessage + waitbuttonpress + return + BerryTree_Text_ItsSoftLoamySoil: .string "It's soft, loamy soil.$" @@ -201,10 +237,18 @@ BerryTree_Text_WantToPlant: .string "It's soft, loamy soil.\n" .string "Want to plant a BERRY?$" +BerryTree_Text_WantToMulch: + .string "It's soft, loamy soil.\n" + .string "Put down some fertilizer?$" + BerryTree_Text_PlantedOneBerry: .string "{PLAYER} planted one {STR_VAR_1} in\n" .string "the soft, loamy soil.$" +BerryTree_Text_ScatteredMulch: + .string "{PLAYER} scattered the {STR_VAR_1}\n" + .string "on the soft, loamy soil.$" + BerryTree_Text_BerryGrowthStage1: .string "One {STR_VAR_1} was planted here.$" diff --git a/data/specials.inc b/data/specials.inc index 34e86cad29..d001e44549 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -540,3 +540,6 @@ gSpecials:: def_special GetSprayId def_special GetLastUsedSprayType def_special TrySkyBattle + def_special PlayerHasMulch + def_special Bag_ChooseMulch + def_special ObjectEventInteractionApplyMulch diff --git a/include/berry.h b/include/berry.h index 22b9158ee2..68ac171370 100644 --- a/include/berry.h +++ b/include/berry.h @@ -19,10 +19,12 @@ u8 ItemIdToBerryType(u16 item); void GetBerryNameByBerryType(u8 berry, u8 *string); void ResetBerryTreeSparkleFlag(u8 id); void Bag_ChooseBerry(void); +void Bag_ChooseMulch(void); void ObjectEventInteractionGetBerryTreeData(void); void ObjectEventInteractionPlantBerryTree(void); void ObjectEventInteractionPickBerryTree(void); void ObjectEventInteractionRemoveBerryTree(void); +void ObjectEventInteractionApplyMulch(void); bool8 PlayerHasBerries(void); void SetBerryTreesSeen(void); diff --git a/include/constants/script_menu.h b/include/constants/script_menu.h index c58df7335f..d341a65403 100644 --- a/include/constants/script_menu.h +++ b/include/constants/script_menu.h @@ -122,6 +122,7 @@ #define MULTI_SLATEPORT_TENT_RULES 111 #define MULTI_FALLARBOR_TENT_RULES 112 #define MULTI_TAG_MATCH_TYPE 113 +#define MULTI_BERRY_PLOT 114 // Lilycove SS Tidal Multichoice Selections #define SSTIDAL_SELECTION_SLATEPORT 0 diff --git a/include/item_menu.h b/include/item_menu.h index d4ae5a4c5f..75912eca62 100644 --- a/include/item_menu.h +++ b/include/item_menu.h @@ -17,6 +17,7 @@ enum { ITEMMENULOCATION_APPRENTICE, ITEMMENULOCATION_WALLY, ITEMMENULOCATION_PCBOX, + ITEMMENULOCATION_BERRY_TREE_MULCH, ITEMMENULOCATION_LAST, }; @@ -101,6 +102,7 @@ void DoWallyTutorialBagMenu(void); void ResetBagScrollPositions(void); void ChooseBerryForMachine(void (*exitCallback)(void)); void CB2_ChooseBerry(void); +void CB2_ChooseMulch(void); void Task_FadeAndCloseBagMenu(u8 taskId); void BagMenu_YesNo(u8 taskId, u8 windowType, const struct YesNoFuncTable* funcTable); void UpdatePocketItemList(u8 pocketId); diff --git a/include/item_use.h b/include/item_use.h index 5abe87f057..22833f299d 100644 --- a/include/item_use.h +++ b/include/item_use.h @@ -41,6 +41,7 @@ void ItemUseInBattle_PartyMenuChooseMove(u8 taskId); void Task_UseDigEscapeRopeOnField(u8 taskId); u8 CanUseDigOrEscapeRopeOnCurMap(void); u8 CheckIfItemIsTMHMOrEvolutionStone(u16 itemId); +void DisplayDadsAdviceCannotUseItemMessage(u8 taskId, bool8 isUsingRegisteredKeyItemOnField); enum { BALL_THROW_UNABLE_TWO_MONS, diff --git a/include/strings.h b/include/strings.h index 9184b4663a..8a26819c5a 100644 --- a/include/strings.h +++ b/include/strings.h @@ -3055,4 +3055,7 @@ extern const u8 gText_ExpShareOff[]; extern const u8 gText_BasePointsResetToZero[]; +extern const u8 gText_Fertilize[]; +extern const u8 gText_PlantBerry[]; + #endif // GUARD_STRINGS_H diff --git a/src/berry.c b/src/berry.c index 93b1e1e21a..98f9cc3b17 100644 --- a/src/berry.c +++ b/src/berry.c @@ -1825,6 +1825,11 @@ void Bag_ChooseBerry(void) SetMainCallback2(CB2_ChooseBerry); } +void Bag_ChooseMulch(void) +{ + SetMainCallback2(CB2_ChooseMulch); +} + void ObjectEventInteractionPlantBerryTree(void) { u8 berry = ItemIdToBerryType(gSpecialVar_ItemId); @@ -1833,6 +1838,14 @@ void ObjectEventInteractionPlantBerryTree(void) ObjectEventInteractionGetBerryTreeData(); } +void ObjectEventInteractionApplyMulch(void) +{ + u8 mulch = ITEM_TO_MULCH(gSpecialVar_ItemId); + + gSaveBlock1Ptr->berryTrees[GetObjectEventBerryTreeId(gSelectedObjectEvent)].mulch = mulch; + StringExpandPlaceholders(gStringVar1, gItems[gSpecialVar_ItemId].name); +} + void ObjectEventInteractionPickBerryTree(void) { u8 id = GetObjectEventBerryTreeId(gSelectedObjectEvent); @@ -1892,6 +1905,27 @@ void SetBerryTreesSeen(void) } } +bool8 PlayerHasMulch(void) +{ + if (CheckBagHasItem(ITEM_GROWTH_MULCH, 1)) + return TRUE; + if (CheckBagHasItem(ITEM_DAMP_MULCH, 1)) + return TRUE; + if (CheckBagHasItem(ITEM_STABLE_MULCH, 1)) + return TRUE; + if (CheckBagHasItem(ITEM_GOOEY_MULCH, 1)) + return TRUE; + if (CheckBagHasItem(ITEM_RICH_MULCH, 1)) + return TRUE; + if (CheckBagHasItem(ITEM_SURPRISE_MULCH, 1)) + return TRUE; + if (CheckBagHasItem(ITEM_BOOST_MULCH, 1)) + return TRUE; + if (CheckBagHasItem(ITEM_AMAZE_MULCH, 1)) + return TRUE; + return FALSE; +} + // Berry mutations #if OW_BERRY_MUTATIONS == TRUE #define BERRY_MUTATION_CHANCE 25 diff --git a/src/data/script_menu.h b/src/data/script_menu.h index 79355748c7..c5afa87043 100644 --- a/src/data/script_menu.h +++ b/src/data/script_menu.h @@ -771,6 +771,13 @@ static const struct MenuAction MultichoiceList_TagMatchType[] = {gText_Exit}, }; +static const struct MenuAction MultichoiceList_BerryPlot[] = +{ + {gText_Fertilize}, + {gText_PlantBerry}, + {gText_Exit}, +}; + static const struct MenuAction MultichoiceList_Exit[] = { {gText_Exit}, @@ -898,6 +905,7 @@ static const struct MultichoiceListStruct sMultichoiceLists[] = [MULTI_SLATEPORT_TENT_RULES] = MULTICHOICE(MultichoiceList_SlateportTentRules), [MULTI_FALLARBOR_TENT_RULES] = MULTICHOICE(MultichoiceList_FallarborTentRules), [MULTI_TAG_MATCH_TYPE] = MULTICHOICE(MultichoiceList_TagMatchType), + [MULTI_BERRY_PLOT] = MULTICHOICE(MultichoiceList_BerryPlot), }; const u8 *const gStdStrings[] = diff --git a/src/item_menu.c b/src/item_menu.c index 8067742579..3753e4f2dc 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -210,6 +210,7 @@ static void ConfirmToss(u8); static void CancelToss(u8); static void ConfirmSell(u8); static void CancelSell(u8); +static void Task_FadeAndCloseBagMenuIfMulch(u8 taskId); static const struct BgTemplate sBgTemplates_ItemMenu[] = { @@ -351,7 +352,8 @@ static const TaskFunc sContextMenuFuncs[] = { [ITEMMENULOCATION_QUIZ_LADY] = Task_ItemContext_Normal, [ITEMMENULOCATION_APPRENTICE] = Task_ItemContext_Normal, [ITEMMENULOCATION_WALLY] = NULL, - [ITEMMENULOCATION_PCBOX] = Task_ItemContext_GiveToPC + [ITEMMENULOCATION_PCBOX] = Task_ItemContext_GiveToPC, + [ITEMMENULOCATION_BERRY_TREE_MULCH] = Task_FadeAndCloseBagMenuIfMulch, }; static const struct YesNoFuncTable sYesNoTossFunctions = {ConfirmToss, CancelToss}; @@ -577,6 +579,12 @@ void CB2_ChooseBerry(void) GoToBagMenu(ITEMMENULOCATION_BERRY_TREE, BERRIES_POCKET, CB2_ReturnToFieldContinueScript); } +// Choosing mulch to use +void CB2_ChooseMulch(void) +{ + GoToBagMenu(ITEMMENULOCATION_BERRY_TREE_MULCH, ITEMS_POCKET, CB2_ReturnToFieldContinueScript); +} + // Choosing berry for Berry Blender or Berry Crush void ChooseBerryForMachine(void (*exitCallback)(void)) { @@ -629,7 +637,8 @@ void GoToBagMenu(u8 location, u8 pocket, void ( *exitCallback)()) if (pocket < POCKETS_COUNT) gBagPosition.pocket = pocket; if (gBagPosition.location == ITEMMENULOCATION_BERRY_TREE || - gBagPosition.location == ITEMMENULOCATION_BERRY_BLENDER_CRUSH) + gBagPosition.location == ITEMMENULOCATION_BERRY_BLENDER_CRUSH || + gBagPosition.location == ITEMMENULOCATION_BERRY_TREE_MULCH) gBagMenu->pocketSwitchDisabled = TRUE; gBagMenu->newScreenCallback = NULL; gBagMenu->toSwapPos = NOT_SWAPPING; @@ -1078,6 +1087,23 @@ void Task_FadeAndCloseBagMenu(u8 taskId) gTasks[taskId].func = Task_CloseBagMenu; } +static void Task_FadeAndCloseBagMenuIfMulch(u8 taskId) +{ + if (gSpecialVar_ItemId == ITEM_GROWTH_MULCH || + gSpecialVar_ItemId == ITEM_DAMP_MULCH || + gSpecialVar_ItemId == ITEM_STABLE_MULCH || + gSpecialVar_ItemId == ITEM_GOOEY_MULCH || + gSpecialVar_ItemId == ITEM_RICH_MULCH || + gSpecialVar_ItemId == ITEM_SURPRISE_MULCH || + gSpecialVar_ItemId == ITEM_BOOST_MULCH || + gSpecialVar_ItemId == ITEM_AMAZE_MULCH) + { + Task_FadeAndCloseBagMenu(taskId); + return; + } + DisplayDadsAdviceCannotUseItemMessage(taskId, FALSE); +} + static void Task_CloseBagMenu(u8 taskId) { s16 *data = gTasks[taskId].data; @@ -1588,6 +1614,7 @@ static void OpenContextMenu(u8 taskId) case ITEMMENULOCATION_SHOP: case ITEMMENULOCATION_BERRY_TREE: case ITEMMENULOCATION_ITEMPC: + case ITEMMENULOCATION_BERRY_TREE_MULCH: default: if (MenuHelpers_IsLinkActive() == TRUE || InUnionRoom() == TRUE) { diff --git a/src/item_use.c b/src/item_use.c index 11d92e7427..25b5b988fb 100644 --- a/src/item_use.c +++ b/src/item_use.c @@ -158,7 +158,7 @@ static void DisplayCannotUseItemMessage(u8 taskId, bool8 isUsingRegisteredKeyIte DisplayItemMessageOnField(taskId, gStringVar4, Task_CloseCantUseKeyItemMessage); } -static void DisplayDadsAdviceCannotUseItemMessage(u8 taskId, bool8 isUsingRegisteredKeyItemOnField) +void DisplayDadsAdviceCannotUseItemMessage(u8 taskId, bool8 isUsingRegisteredKeyItemOnField) { DisplayCannotUseItemMessage(taskId, isUsingRegisteredKeyItemOnField, gText_DadsAdvice); } diff --git a/src/strings.c b/src/strings.c index f23ad3fca5..565f0a8f62 100644 --- a/src/strings.c +++ b/src/strings.c @@ -267,7 +267,8 @@ const u8 *const gBagMenu_ReturnToStrings[] = [ITEMMENULOCATION_QUIZ_LADY] = gText_TheField, [ITEMMENULOCATION_APPRENTICE] = gText_TheField, [ITEMMENULOCATION_WALLY] = gText_TheBattle, - [ITEMMENULOCATION_PCBOX] = gText_ThePC + [ITEMMENULOCATION_PCBOX] = gText_ThePC, + [ITEMMENULOCATION_BERRY_TREE_MULCH] = gText_TheField, }; const u8 *const gPyramidBagMenu_ReturnToStrings[] = @@ -1843,3 +1844,5 @@ const u8 gText_Berries[] = _("BERRIES"); const u8 gText_ExpShareOn[] = _("The Exp. Share has been turned on.{PAUSE_UNTIL_PRESS}"); const u8 gText_ExpShareOff[] = _("The Exp. Share has been turned off.{PAUSE_UNTIL_PRESS}"); const u8 gText_BasePointsResetToZero[] = _("{STR_VAR_1}'s base points\nwere all reset to zero!{PAUSE_UNTIL_PRESS}"); +const u8 gText_Fertilize[] = _("FERTILIZE"); +const u8 gText_PlantBerry[] = _("PLANT BERRY");