From fd69ef339c5ea1578e52f22cc51ff338cb77abb1 Mon Sep 17 00:00:00 2001 From: pkmnsnfrn Date: Thu, 25 Jul 2024 19:33:07 -0700 Subject: [PATCH] Got pokemart and pokecenter changes working --- include/constants/metatile_behaviors.h | 4 +++- include/event_scripts.h | 3 +++ include/metatile_behavior.h | 2 ++ src/field_control_avatar.c | 18 +++++++----------- src/menu.c | 1 - src/metatile_behavior.c | 18 ++++++++++++++++++ 6 files changed, 33 insertions(+), 13 deletions(-) diff --git a/include/constants/metatile_behaviors.h b/include/constants/metatile_behaviors.h index 56df442bb8..808fa49df7 100755 --- a/include/constants/metatile_behaviors.h +++ b/include/constants/metatile_behaviors.h @@ -32,11 +32,13 @@ #define MB_SHOAL_CAVE_ENTRANCE 0x1C #if OW_AUTO_SIGNPOST == TRUE #define MB_SIGNPOST 0x1D +#define MB_SIGNPOST_POKECENTER 0x1E +#define MB_SIGNPOST_POKEMART 0x1F #else #define MB_UNUSED_1D 0x1D -#endif #define MB_UNUSED_1E 0x1E #define MB_UNUSED_1F 0x1F +#endif #define MB_ICE 0x20 #define MB_SAND 0x21 #define MB_SEAWEED 0x22 diff --git a/include/event_scripts.h b/include/event_scripts.h index f66e52866d..f23f52cb12 100644 --- a/include/event_scripts.h +++ b/include/event_scripts.h @@ -648,4 +648,7 @@ extern const u8 VSSeeker_Text_TrainersNotReady[]; extern const u8 EventScript_VsSeekerChargingDone[]; extern const u8 EventScript_CancelMessageBox[]; +extern const u8 Common_EventScript_ShowPokemonCenterSign[]; +extern const u8 Common_EventScript_ShowPokemartSign[]; + #endif // GUARD_EVENT_SCRIPTS_H diff --git a/include/metatile_behavior.h b/include/metatile_behavior.h index 74f0beca74..0c4622adaf 100644 --- a/include/metatile_behavior.h +++ b/include/metatile_behavior.h @@ -149,5 +149,7 @@ bool8 MetatileBehavior_IsLongGrass_Duplicate(u8); bool8 MetatileBehavior_IsLongGrassSouthEdge(u8); bool8 MetatileBehavior_IsTrainerHillTimer(u8); bool8 MetatileBehavior_IsSignpost(u8 mb); +bool8 MetatileBehavior_IsPokemonCenterSign(u8 mb); +bool8 MetatileBehavior_IsPokeMartSign(u8 mb); #endif // GUARD_METATILE_BEHAVIOR_H diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index df77f798ce..880eb8d59e 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -1112,13 +1112,12 @@ static bool8 TrySetUpWalkIntoSignpostScript(struct MapPosition *position, u16 me switch (GetFacingSignpostType(metatileBehavior, playerDirection)) { - /* leaving this commented out for examples of custom signpost types case SIGNPOST_POKECENTER: - SetUpWalkIntoSignScript(EventScript_PokecenterSign, playerDirection); + SetUpWalkIntoSignScript(Common_EventScript_ShowPokemonCenterSign, playerDirection); return TRUE; case SIGNPOST_POKEMART: - SetUpWalkIntoSignScript(EventScript_PokemartSign, playerDirection); - return TRUE;*/ + SetUpWalkIntoSignScript(Common_EventScript_ShowPokemartSign, playerDirection); + return TRUE; case SIGNPOST_SCRIPTED: script = GetSignpostScriptAtMapPosition(position); if (script == NULL) @@ -1132,12 +1131,10 @@ static bool8 TrySetUpWalkIntoSignpostScript(struct MapPosition *position, u16 me static u8 GetFacingSignpostType(u16 metatileBehavior, u8 playerDirection) { - /*if (MetatileBehavior_IsPlayerFacingPokemonCenterSign(metatileBehavior, playerDirection) == TRUE) + if (MetatileBehavior_IsPokemonCenterSign(metatileBehavior) == TRUE) return SIGNPOST_POKECENTER; - if (MetatileBehavior_IsPlayerFacingPokeMartSign(metatileBehavior, playerDirection) == TRUE) - return SIGNPOST_POKEMART;*/ - - DebugPrintf("behavior is %d",metatileBehavior); + if (MetatileBehavior_IsPokeMartSign(metatileBehavior) == TRUE) + return SIGNPOST_POKEMART; if (MetatileBehavior_IsSignpost(metatileBehavior) == TRUE) return SIGNPOST_SCRIPTED; @@ -1147,7 +1144,7 @@ static u8 GetFacingSignpostType(u16 metatileBehavior, u8 playerDirection) static void SetMsgSignPostAndVarFacing(u32 playerDirection) { - DebugPrintf("test"); + SetWalkingIntoSignVars(); MsgSetSignPost(); gSpecialVar_Facing = playerDirection; } @@ -1155,7 +1152,6 @@ static void SetMsgSignPostAndVarFacing(u32 playerDirection) static void SetUpWalkIntoSignScript(const u8 *script, u8 playerDirection) { ScriptContext_SetupScript(script); - SetWalkingIntoSignVars(); SetMsgSignPostAndVarFacing(playerDirection); } diff --git a/src/menu.c b/src/menu.c index 620c4d13e1..2679e0a336 100644 --- a/src/menu.c +++ b/src/menu.c @@ -327,7 +327,6 @@ static void WindowFunc_DrawSignFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 wi static inline void *GetWindowFunc_DialogueFrame(void) { - DebugPrintf("test %d",IsMsgSignPost()); return (IsMsgSignPost() ? WindowFunc_DrawSignFrame : WindowFunc_DrawDialogueFrame); } diff --git a/src/metatile_behavior.c b/src/metatile_behavior.c index e5c72b127c..601e2660af 100644 --- a/src/metatile_behavior.c +++ b/src/metatile_behavior.c @@ -1413,3 +1413,21 @@ bool8 MetatileBehavior_IsSignpost(u8 mb) #endif } +bool8 MetatileBehavior_IsPokemonCenterSign(u8 mb) +{ +#if OW_AUTO_SIGNPOST == TRUE + return (mb == MB_SIGNPOST_POKECENTER); +#else + return FALSE; +#endif +} + +bool8 MetatileBehavior_IsPokeMartSign(u8 mb) +{ +#if OW_AUTO_SIGNPOST == TRUE + return (mb == MB_SIGNPOST_POKEMART); +#else + return FALSE; +#endif +} +