Add Mulch effects

This commit is contained in:
Bassoonian 2023-12-03 13:17:34 +01:00
parent 4628af3d55
commit b02b3d074f
12 changed files with 132 additions and 4 deletions

View file

@ -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.$"

View file

@ -540,3 +540,6 @@ gSpecials::
def_special GetSprayId
def_special GetLastUsedSprayType
def_special TrySkyBattle
def_special PlayerHasMulch
def_special Bag_ChooseMulch
def_special ObjectEventInteractionApplyMulch

View file

@ -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);

View file

@ -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

View file

@ -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);

View file

@ -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,

View file

@ -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

View file

@ -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

View file

@ -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[] =

View file

@ -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)
{

View file

@ -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);
}

View file

@ -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");