diff --git a/data/maps/IslandCave/scripts.inc b/data/maps/IslandCave/scripts.inc index d15802aaa..1bfadb9f2 100644 --- a/data/maps/IslandCave/scripts.inc +++ b/data/maps/IslandCave/scripts.inc @@ -51,10 +51,10 @@ IslandCave_EventScript_OpenRegiEntrance:: IslandCave_EventScript_CaveEntranceMiddle:: lockall - call_if_set FLAG_TEMP_3, IslandCave_EventScript_ClearSteps + call_if_set FLAG_TEMP_REGICE_PUZZLE_FAILED, IslandCave_EventScript_ClearSteps goto_if_set FLAG_SYS_BRAILLE_REGICE_COMPLETED, IslandCave_EventScript_BigHoleInWall braillemessage IslandCave_Braille_RunLapAroundWall - setflag FLAG_TEMP_2 + setflag FLAG_TEMP_REGICE_PUZZLE_STARTED special ShouldDoBrailleRegicePuzzle goto IslandCave_EventScript_CloseBrailleMsg end @@ -66,10 +66,10 @@ IslandCave_EventScript_BigHoleInWall:: IslandCave_EventScript_CaveEntranceSide:: lockall - call_if_set FLAG_TEMP_3, IslandCave_EventScript_ClearSteps + call_if_set FLAG_TEMP_REGICE_PUZZLE_FAILED, IslandCave_EventScript_ClearSteps braillemessage IslandCave_Braille_RunLapAroundWall goto_if_set FLAG_SYS_BRAILLE_REGICE_COMPLETED, IslandCave_EventScript_CloseBrailleMsg - setflag FLAG_TEMP_2 + setflag FLAG_TEMP_REGICE_PUZZLE_STARTED special ShouldDoBrailleRegicePuzzle goto IslandCave_EventScript_CloseBrailleMsg end @@ -84,7 +84,7 @@ IslandCave_EventScript_ClearSteps:: setvar VAR_REGICE_STEPS_1, 0 setvar VAR_REGICE_STEPS_2, 0 setvar VAR_REGICE_STEPS_3, 0 - clearflag FLAG_TEMP_3 + clearflag FLAG_TEMP_REGICE_PUZZLE_FAILED return IslandCave_EventScript_Regice:: diff --git a/data/maps/Route130/map.json b/data/maps/Route130/map.json index 7b37a10ed..bb79a2bb4 100644 --- a/data/maps/Route130/map.json +++ b/data/maps/Route130/map.json @@ -62,7 +62,7 @@ "trainer_type": "TRAINER_TYPE_NONE", "trainer_sight_or_berry_tree_id": "BERRY_TREE_ROUTE_130_LIECHI", "script": "BerryTreeScript", - "flag": "FLAG_TEMP_11" + "flag": "FLAG_TEMP_HIDE_MIRAGE_ISLAND_BERRY_TREE" }, { "graphics_id": "OBJ_EVENT_GFX_SWIMMER_M", diff --git a/data/maps/Route130/scripts.inc b/data/maps/Route130/scripts.inc index 7e0ecc8bd..b5b9227e8 100644 --- a/data/maps/Route130/scripts.inc +++ b/data/maps/Route130/scripts.inc @@ -6,7 +6,8 @@ Route130_OnTransition: call_if_ge VAR_SOOTOPOLIS_CITY_STATE, 4, Route130_EventScript_CheckSetAbnormalWeather specialvar VAR_RESULT, IsMirageIslandPresent goto_if_eq VAR_RESULT, TRUE, Route130_EventScript_SetMirageIslandLayout - setflag FLAG_TEMP_11 +@ Mirage Island isn't currently visible, hide any objects on the island. Only the first flag is actually associated with anything. + setflag FLAG_TEMP_HIDE_MIRAGE_ISLAND_BERRY_TREE setflag FLAG_TEMP_12 setflag FLAG_TEMP_13 setflag FLAG_TEMP_14 diff --git a/data/maps/ShoalCave_LowTideEntranceRoom/scripts.inc b/data/maps/ShoalCave_LowTideEntranceRoom/scripts.inc index 905a9a77a..80368b148 100644 --- a/data/maps/ShoalCave_LowTideEntranceRoom/scripts.inc +++ b/data/maps/ShoalCave_LowTideEntranceRoom/scripts.inc @@ -33,9 +33,9 @@ ShoalCave_LowTideEntranceRoom_EventScript_ShellBellExpert:: removeitem ITEM_SHOAL_SALT, 4 removeitem ITEM_SHOAL_SHELL, 4 giveitem ITEM_SHELL_BELL - goto_if_eq VAR_RESULT, FALSE, Common_EventScript_ShowBagIsFull + goto_if_eq VAR_RESULT, FALSE, Common_EventScript_ShowBagIsFull @ Never FALSE, we already made sure there will be room in the bag. msgbox ShoalCave_LowTideEntranceRoom_Text_ExplainShellBell, MSGBOX_DEFAULT - setflag FLAG_TEMP_2 + setflag FLAG_TEMP_2 @ Not read. Perhaps meant to stop him from re-explaining the Shell Bell if multiple are received in one sitting. release end diff --git a/data/scripts/gabby_and_ty.inc b/data/scripts/gabby_and_ty.inc index e3dbdfd66..260526c4b 100644 --- a/data/scripts/gabby_and_ty.inc +++ b/data/scripts/gabby_and_ty.inc @@ -202,7 +202,7 @@ GabbyAndTy_EventScript_FirstInterview:: call_if_eq VAR_FACING, DIR_NORTH, GabbyAndTy_EventScript_FacePlayerNorth call_if_eq VAR_FACING, DIR_SOUTH, GabbyAndTy_EventScript_FacePlayerSouth call_if_eq VAR_FACING, DIR_EAST, GabbyAndTy_EventScript_FacePlayerEast - goto_if_set FLAG_TEMP_1, GabbyAndTy_EventScript_KeepingAnEyeOutForYou + goto_if_set FLAG_TEMP_SKIP_GABBY_INTERVIEW, GabbyAndTy_EventScript_KeepingAnEyeOutForYou msgbox GabbyAndTy_Text_WhoAreYouInterview, MSGBOX_YESNO goto GabbyAndTy_EventScript_Interview end @@ -230,7 +230,7 @@ GabbyAndTy_EventScript_RequestInterview:: call_if_eq VAR_FACING, DIR_NORTH, GabbyAndTy_EventScript_FacePlayerNorth call_if_eq VAR_FACING, DIR_SOUTH, GabbyAndTy_EventScript_FacePlayerSouth call_if_eq VAR_FACING, DIR_EAST, GabbyAndTy_EventScript_FacePlayerEast - goto_if_set FLAG_TEMP_1, GabbyAndTy_EventScript_KeepingAnEyeOutForYou + goto_if_set FLAG_TEMP_SKIP_GABBY_INTERVIEW, GabbyAndTy_EventScript_KeepingAnEyeOutForYou specialvar VAR_RESULT, GabbyAndTyGetLastQuote goto_if_eq VAR_RESULT, 0, GabbyAndTy_EventScript_DidntInterviewLastTime msgbox GabbyAndTy_Text_QuoteFromLastInterview, MSGBOX_DEFAULT @@ -295,13 +295,13 @@ GabbyAndTy_EventScript_Interview:: goto_if_eq VAR_RESULT, 0, GabbyAndTy_EventScript_DontGiveUpKeepingEyeOut msgbox GabbyAndTy_Text_PerfectWellBeSeeingYou, MSGBOX_DEFAULT special GabbyAndTyAfterInterview - setflag FLAG_TEMP_1 + setflag FLAG_TEMP_SKIP_GABBY_INTERVIEW release end GabbyAndTy_EventScript_DontGiveUpKeepingEyeOut:: msgbox GabbyAndTy_Text_DontGiveUpKeepingEyeOut, MSGBOX_DEFAULT - setflag FLAG_TEMP_1 + setflag FLAG_TEMP_SKIP_GABBY_INTERVIEW release end diff --git a/include/constants/flags.h b/include/constants/flags.h index 59bde846c..5761fb0ed 100644 --- a/include/constants/flags.h +++ b/include/constants/flags.h @@ -1644,4 +1644,10 @@ // FLAG_SPECIAL_FLAG_0x4005 - 0x407F also exist and are unused #define SPECIAL_FLAGS_END (SPECIAL_FLAGS_START + 0x7F) +// Temp flag aliases +#define FLAG_TEMP_SKIP_GABBY_INTERVIEW FLAG_TEMP_1 +#define FLAG_TEMP_REGICE_PUZZLE_STARTED FLAG_TEMP_2 +#define FLAG_TEMP_REGICE_PUZZLE_FAILED FLAG_TEMP_3 +#define FLAG_TEMP_HIDE_MIRAGE_ISLAND_BERRY_TREE FLAG_TEMP_11 + #endif // GUARD_CONSTANTS_FLAGS_H diff --git a/src/braille_puzzles.c b/src/braille_puzzles.c index 348742849..49f73dd6b 100644 --- a/src/braille_puzzles.c +++ b/src/braille_puzzles.c @@ -278,6 +278,8 @@ bool8 FldEff_UsePuzzleEffect(void) return FALSE; } +// The puzzle to unlock Regice's cave requires the player to interact with the braille message on the back wall, +// step on every space on the perimeter of the cave (and only those spaces) then return to the back wall. bool8 ShouldDoBrailleRegicePuzzle(void) { u8 i; @@ -287,9 +289,11 @@ bool8 ShouldDoBrailleRegicePuzzle(void) { if (FlagGet(FLAG_SYS_BRAILLE_REGICE_COMPLETED)) return FALSE; - if (FlagGet(FLAG_TEMP_2) == FALSE) + // Set when the player interacts with the braille message + if (FlagGet(FLAG_TEMP_REGICE_PUZZLE_STARTED) == FALSE) return FALSE; - if (FlagGet(FLAG_TEMP_3) == TRUE) + // Cleared when the player interacts with the braille message + if (FlagGet(FLAG_TEMP_REGICE_PUZZLE_FAILED) == TRUE) return FALSE; for (i = 0; i < ARRAY_COUNT(sRegicePathCoords); i++) @@ -298,8 +302,7 @@ bool8 ShouldDoBrailleRegicePuzzle(void) u8 yPos = sRegicePathCoords[i][1]; if (gSaveBlock1Ptr->pos.x == xPos && gSaveBlock1Ptr->pos.y == yPos) { - u16 varValue; - + // Player is standing on a correct space, set the corresponding bit if (i < 16) { u16 val = VarGet(VAR_REGICE_STEPS_1); @@ -319,11 +322,11 @@ bool8 ShouldDoBrailleRegicePuzzle(void) VarSet(VAR_REGICE_STEPS_3, val); } - varValue = VarGet(VAR_REGICE_STEPS_1); - if (varValue != 0xFFFF || VarGet(VAR_REGICE_STEPS_2) != 0xFFFF || VarGet(VAR_REGICE_STEPS_3) != 0xF) + // Make sure a full lap has been completed. There are 36 steps in a lap, so 16+16+4 bits to check across the 3 vars. + if (VarGet(VAR_REGICE_STEPS_1) != 0xFFFF || VarGet(VAR_REGICE_STEPS_2) != 0xFFFF || VarGet(VAR_REGICE_STEPS_3) != 0xF) return FALSE; - // This final check is redundant. + // A lap has been completed, the puzzle is complete when the player returns to the braille message. if (gSaveBlock1Ptr->pos.x == 8 && gSaveBlock1Ptr->pos.y == 21) return TRUE; else @@ -331,8 +334,9 @@ bool8 ShouldDoBrailleRegicePuzzle(void) } } - FlagSet(FLAG_TEMP_3); - FlagClear(FLAG_TEMP_2); + // Player stepped on an incorrect space, puzzle failed. + FlagSet(FLAG_TEMP_REGICE_PUZZLE_FAILED); + FlagClear(FLAG_TEMP_REGICE_PUZZLE_STARTED); } return FALSE; diff --git a/src/tv.c b/src/tv.c index 85819a7a1..696e0519b 100644 --- a/src/tv.c +++ b/src/tv.c @@ -941,9 +941,8 @@ void GabbyAndTyBeforeInterview(void) gSaveBlock1Ptr->gabbyAndTyData.mon2 = gBattleResults.playerMon2Species; gSaveBlock1Ptr->gabbyAndTyData.lastMove = gBattleResults.lastUsedMovePlayer; if (gSaveBlock1Ptr->gabbyAndTyData.battleNum != 0xFF) - { gSaveBlock1Ptr->gabbyAndTyData.battleNum++; - } + gSaveBlock1Ptr->gabbyAndTyData.battleTookMoreThanOneTurn = gBattleResults.playerMonWasDamaged; if (gBattleResults.playerFaintCounter != 0) @@ -975,9 +974,7 @@ void GabbyAndTyBeforeInterview(void) TakeGabbyAndTyOffTheAir(); if (gSaveBlock1Ptr->gabbyAndTyData.lastMove == MOVE_NONE) - { - FlagSet(FLAG_TEMP_1); - } + FlagSet(FLAG_TEMP_SKIP_GABBY_INTERVIEW); } void GabbyAndTyAfterInterview(void)