Document rotating_tile_puzzle

This commit is contained in:
GriffinR 2019-10-16 04:09:30 -04:00
parent 90a05cf824
commit 0f15264595
10 changed files with 158 additions and 132 deletions

View File

@ -1468,22 +1468,25 @@
.byte \location
.endm
.macro mossdeepgym1 unknown:req
@ For the rotating tile puzzles in Mossdeep Gym/Trick House Room 7. Moves the objects on the colored puzzle specified by puzzleNumber one rotation
.macro moverotatingtileobjects puzzleNumber:req
.byte 0xd3
.2byte \unknown
.2byte \puzzleNumber
.endm
.macro mossdeepgym2
@ For the rotating tile puzzles in Mossdeep Gym/Trick House Room 7. Updates the facing direction of all objects on the puzzle tiles
.macro turnrotatingtileobjects
.byte 0xd4
.endm
@ In FireRed, this command is a nop.
@ For the rotating tile puzzles in Mossdeep Gym/Trick House Room 7. Allocates memory for the puzzle objects. isTrickHouse is needed to determine which of the two maps the puzzle is on, in order to know where in the tileset the puzzle tiles start. In FireRed, this command is a nop.
.macro initrotatingtilepuzzle isTrickHouse:req
.byte 0xd5
.2byte \isTrickHouse
.endm
.macro mossdeepgym4
@ For the rotating tile puzzles in Mossdeep Gym/Trick House Room 7. Frees the memory allocated for the puzzle objects.
.macro freerotatingtilepuzzle
.byte 0xd6
.endm

View File

@ -312,11 +312,11 @@ MossdeepCity_Gym_EventScript_YellowFloorSwitch:: @ 8220C67
waitse
playse SE_TU_SAA
initrotatingtilepuzzle FALSE
mossdeepgym1 0
moverotatingtileobjects 0
waitmovement 0
mossdeepgym2
turnrotatingtileobjects
waitmovement 0
mossdeepgym4
freerotatingtilepuzzle
end
MossdeepCity_Gym_EventScript_BlueFloorSwitch:: @ 8220C7D
@ -324,11 +324,11 @@ MossdeepCity_Gym_EventScript_BlueFloorSwitch:: @ 8220C7D
waitse
playse SE_TU_SAA
initrotatingtilepuzzle FALSE
mossdeepgym1 1
moverotatingtileobjects 1
waitmovement 0
mossdeepgym2
turnrotatingtileobjects
waitmovement 0
mossdeepgym4
freerotatingtilepuzzle
end
MossdeepCity_Gym_EventScript_GreenFloorSwitch:: @ 8220C93
@ -336,11 +336,11 @@ MossdeepCity_Gym_EventScript_GreenFloorSwitch:: @ 8220C93
waitse
playse SE_TU_SAA
initrotatingtilepuzzle FALSE
mossdeepgym1 2
moverotatingtileobjects 2
waitmovement 0
mossdeepgym2
turnrotatingtileobjects
waitmovement 0
mossdeepgym4
freerotatingtilepuzzle
end
MossdeepCity_Gym_EventScript_PurpleFloorSwitch:: @ 8220CA9
@ -348,11 +348,11 @@ MossdeepCity_Gym_EventScript_PurpleFloorSwitch:: @ 8220CA9
waitse
playse SE_TU_SAA
initrotatingtilepuzzle FALSE
mossdeepgym1 3
moverotatingtileobjects 3
waitmovement 0
mossdeepgym2
turnrotatingtileobjects
waitmovement 0
mossdeepgym4
freerotatingtilepuzzle
end
MossdeepCity_Gym_EventScript_RedFloorSwitch:: @ 8220CBF
@ -360,11 +360,11 @@ MossdeepCity_Gym_EventScript_RedFloorSwitch:: @ 8220CBF
waitse
playse SE_TU_SAA
initrotatingtilepuzzle FALSE
mossdeepgym1 4
moverotatingtileobjects 4
waitmovement 0
mossdeepgym2
turnrotatingtileobjects
waitmovement 0
mossdeepgym4
freerotatingtilepuzzle
end
MossdeepCity_Gym_Text_GymGuideAdvice: @ 8220CD5

View File

@ -223,11 +223,11 @@ Route110_TrickHousePuzzle7_EventScript_26E31B:: @ 826E31B
waitse
playse SE_TU_SAA
initrotatingtilepuzzle TRUE
mossdeepgym1 0
moverotatingtileobjects 0
waitmovement 0
mossdeepgym2
turnrotatingtileobjects
waitmovement 0
mossdeepgym4
freerotatingtilepuzzle
end
Route110_TrickHousePuzzle7_EventScript_26E331:: @ 826E331
@ -235,11 +235,11 @@ Route110_TrickHousePuzzle7_EventScript_26E331:: @ 826E331
waitse
playse SE_TU_SAA
initrotatingtilepuzzle TRUE
mossdeepgym1 1
moverotatingtileobjects 1
waitmovement 0
mossdeepgym2
turnrotatingtileobjects
waitmovement 0
mossdeepgym4
freerotatingtilepuzzle
end
Route110_TrickHousePuzzle7_EventScript_26E347:: @ 826E347
@ -247,11 +247,11 @@ Route110_TrickHousePuzzle7_EventScript_26E347:: @ 826E347
waitse
playse SE_TU_SAA
initrotatingtilepuzzle TRUE
mossdeepgym1 2
moverotatingtileobjects 2
waitmovement 0
mossdeepgym2
turnrotatingtileobjects
waitmovement 0
mossdeepgym4
freerotatingtilepuzzle
end
Route110_TrickHousePuzzle7_EventScript_26E35D:: @ 826E35D
@ -259,11 +259,11 @@ Route110_TrickHousePuzzle7_EventScript_26E35D:: @ 826E35D
waitse
playse SE_TU_SAA
initrotatingtilepuzzle TRUE
mossdeepgym1 3
moverotatingtileobjects 3
waitmovement 0
mossdeepgym2
turnrotatingtileobjects
waitmovement 0
mossdeepgym4
freerotatingtilepuzzle
end
Route110_TrickHousePuzzle7_EventScript_26E373:: @ 826E373
@ -271,11 +271,11 @@ Route110_TrickHousePuzzle7_EventScript_26E373:: @ 826E373
waitse
playse SE_TU_SAA
initrotatingtilepuzzle TRUE
mossdeepgym1 4
moverotatingtileobjects 4
waitmovement 0
mossdeepgym2
turnrotatingtileobjects
waitmovement 0
mossdeepgym4
freerotatingtilepuzzle
end
Route110_TrickHousePuzzle7_EventScript_26E389:: @ 826E389

View File

@ -2,42 +2,42 @@
.section .rodata
gUnknown_08612698:: @ 8612698
RotatingTilePuzzle_Movement_ShiftRight:: @ 8612698
store_lock_anim
walk_right
free_unlock_anim
step_end
gUnknown_0861269C:: @ 861269C
RotatingTilePuzzle_Movement_ShiftDown:: @ 861269C
store_lock_anim
walk_down
free_unlock_anim
step_end
gUnknown_086126A0:: @ 86126A0
RotatingTilePuzzle_Movement_ShiftLeft:: @ 86126A0
store_lock_anim
walk_left
free_unlock_anim
step_end
gUnknown_086126A4:: @ 86126A4
RotatingTilePuzzle_Movement_ShiftUp:: @ 86126A4
store_lock_anim
walk_up
free_unlock_anim
step_end
MossdeepGym_Movement_FaceRight:: @ 86126A8
RotatingTilePuzzle_Movement_FaceRight:: @ 86126A8
face_right
step_end
MossdeepGym_Movement_FaceDown:: @ 86126AA
RotatingTilePuzzle_Movement_FaceDown:: @ 86126AA
face_down
step_end
MossdeepGym_Movement_FaceLeft:: @ 86126AC
RotatingTilePuzzle_Movement_FaceLeft:: @ 86126AC
face_left
step_end
MossdeepGym_Movement_FaceUp:: @ 86126AE
RotatingTilePuzzle_Movement_FaceUp:: @ 86126AE
face_up
step_end

View File

@ -211,10 +211,10 @@ gScriptCmdTable:: @ 81DB67C
.4byte ScrCmd_nop1
.4byte ScrCmd_warpD1
.4byte ScrCmd_setmonmetlocation
.4byte ScrCmd_mossdeepgym1
.4byte ScrCmd_mossdeepgym2
.4byte ScrCmd_moverotatingtileobjects
.4byte ScrCmd_turnrotatingtileobjects
.4byte ScrCmd_initrotatingtilepuzzle
.4byte ScrCmd_mossdeepgym4
.4byte ScrCmd_freerotatingtilepuzzle
.4byte ScrCmd_warpmossdeepgym
.4byte ScrCmd_cmdD8
.4byte ScrCmd_cmdD9

View File

@ -109,7 +109,7 @@
#define FLAG_MET_TEAM_AQUA_HARBOR 0x61
#define FLAG_TV_EXPLAINED 0x62
#define FLAG_MAUVILLE_GYM_BARRIERS_STATE 0x63
#define FLAG_MOSSDEEP_GYM_SWITCH_1 0x64 // Leftover from the RS version of Mossdeep Gym, functionally always zero
#define FLAG_MOSSDEEP_GYM_SWITCH_1 0x64 // Leftover from the RS version of Mossdeep Gym, functionally unused
#define FLAG_MOSSDEEP_GYM_SWITCH_2 0x65 //
#define FLAG_MOSSDEEP_GYM_SWITCH_3 0x66 //
#define FLAG_MOSSDEEP_GYM_SWITCH_4 0x67 //

View File

@ -77,7 +77,7 @@
#define METATILE_RS_MossdeepGym_Switch_Down 0x239
// gTileset_MossdeepGym from Emerald
#define METATILE_MossdeepGym_YellowRightArrow 0x250
#define METATILE_MossdeepGym_YellowArrow_Right 0x250
// gTileset_BrendansMaysHouse
#define METATILE_BrendansMaysHouse_BrendanPC_Off 0x25A

View File

@ -2,8 +2,8 @@
#define GUARD_ROTATING_TILE_PUZZLE_H
void InitRotatingTilePuzzle(bool8 isTrickHouse);
void FinishMossdeepGymTiles(void);
u16 MossdeepGym_MoveEvents(u8 puzzleNumber);
void MossdeepGym_TurnEvents(void);
void FreeRotatingTilePuzzle(void);
u16 MoveRotatingTileObjects(u8 puzzleNumber);
void TurnRotatingTileObjects(void);
#endif // GUARD_ROTATING_TILE_PUZZLE_H

View File

@ -8,32 +8,35 @@
#include "constants/event_objects.h"
#include "constants/metatile_labels.h"
// Movement scripts.
extern const u8 gUnknown_08612698[];
extern const u8 gUnknown_0861269C[];
extern const u8 gUnknown_086126A0[];
extern const u8 gUnknown_086126A4[];
extern const u8 MossdeepGym_Movement_FaceRight[];
extern const u8 MossdeepGym_Movement_FaceDown[];
extern const u8 MossdeepGym_Movement_FaceLeft[];
extern const u8 MossdeepGym_Movement_FaceUp[];
extern const u8 RotatingTilePuzzle_Movement_ShiftRight[];
extern const u8 RotatingTilePuzzle_Movement_ShiftDown[];
extern const u8 RotatingTilePuzzle_Movement_ShiftLeft[];
extern const u8 RotatingTilePuzzle_Movement_ShiftUp[];
extern const u8 RotatingTilePuzzle_Movement_FaceRight[];
extern const u8 RotatingTilePuzzle_Movement_FaceDown[];
extern const u8 RotatingTilePuzzle_Movement_FaceLeft[];
extern const u8 RotatingTilePuzzle_Movement_FaceUp[];
struct MossdeepSubStruct
#define ROTATE_COUNTERCLOCKWISE 0
#define ROTATE_CLOCKWISE 1
#define ROTATE_NONE 2
struct RotatingTileObject
{
u8 unk0;
u8 prevPuzzleTileNum;
u8 eventTemplateId;
};
struct RotatingTilePuzzle
{
struct MossdeepSubStruct objects[EVENT_OBJECTS_COUNT];
u8 count;
struct RotatingTileObject objects[EVENT_OBJECTS_COUNT];
u8 numObjects;
bool8 isTrickHouse;
};
// This file's functions.
static void AddEventObject(u8 eventTemplateId, u8 arg1);
static void sub_81A8D94(u8 eventTemplateId, u8 arg1);
static void SaveRotatingTileObject(u8 eventTemplateId, u8 arg1);
static void TurnUnsavedRotatingTileObject(u8 eventTemplateId, u8 arg1);
// EWRAM vars
EWRAM_DATA static struct RotatingTilePuzzle *sRotatingTilePuzzle = NULL;
@ -47,7 +50,7 @@ void InitRotatingTilePuzzle(bool8 isTrickHouse)
sRotatingTilePuzzle->isTrickHouse = isTrickHouse;
}
void FinishMossdeepGymTiles(void)
void FreeRotatingTilePuzzle(void)
{
u8 id;
@ -59,7 +62,7 @@ void FinishMossdeepGymTiles(void)
ScriptMovement_UnfreezeEventObjects();
}
u16 MossdeepGym_MoveEvents(u8 puzzleNumber)
u16 MoveRotatingTileObjects(u8 puzzleNumber)
{
u8 i;
struct EventObjectTemplate *eventObjects = gSaveBlock1Ptr->eventObjectTemplates;
@ -68,47 +71,54 @@ u16 MossdeepGym_MoveEvents(u8 puzzleNumber)
for (i = 0; i < EVENT_OBJECT_TEMPLATES_COUNT; i++)
{
s32 puzzleTileStart;
u8 r5;
u8 puzzleTileNum;
s16 x = eventObjects[i].x + 7;
s16 y = eventObjects[i].y + 7;
u16 metatile = MapGridGetMetatileIdAt(x, y);
if (!sRotatingTilePuzzle->isTrickHouse)
puzzleTileStart = METATILE_MossdeepGym_YellowRightArrow;
puzzleTileStart = METATILE_MossdeepGym_YellowArrow_Right;
else
puzzleTileStart = METATILE_TrickHousePuzzle_Arrow_YellowOnWhite_Right;
if (metatile < METATILE_MossdeepGym_YellowRightArrow)
// Object is on a metatile before the puzzle tile section
// UB: Because this is not if (metatile < puzzleTileStart), for the trick house (metatile - puzzleTileStart) below can result in casting a negative value to u8
if (metatile < METATILE_MossdeepGym_YellowArrow_Right)
continue;
// Object is on a metatile after the puzzle tile section (never occurs, in both cases the puzzle tiles are last)
if ((u8)((metatile - puzzleTileStart) / 8) >= 5)
continue;
// Object is on a metatile in puzzle tile section, but not one of the currently rotating color
if ((u8)((metatile - puzzleTileStart) / 8) != puzzleNumber)
continue;
r5 = (u8)((metatile - puzzleTileStart) % 8);
if (r5 < 4)
puzzleTileNum = (u8)((metatile - puzzleTileStart) % 8);
// First 4 puzzle tiles are the colored arrows
if (puzzleTileNum < 4)
{
s8 x = 0;
s8 y = 0;
const u8 *movementScript;
switch (r5)
switch (puzzleTileNum)
{
case 0:
movementScript = gUnknown_08612698;
case 0: // Right Arrow
movementScript = RotatingTilePuzzle_Movement_ShiftRight;
x = 1;
break;
case 1:
movementScript = gUnknown_0861269C;
case 1: // Down Arrow
movementScript = RotatingTilePuzzle_Movement_ShiftDown;
y = 1;
break;
case 2:
movementScript = gUnknown_086126A0;
case 2: // Left Arrow
movementScript = RotatingTilePuzzle_Movement_ShiftLeft;
x = -1;
break;
case 3:
movementScript = gUnknown_086126A4;
case 3: // Up Arrow
movementScript = RotatingTilePuzzle_Movement_ShiftUp;
y = -1;
break;
default:
@ -119,13 +129,14 @@ u16 MossdeepGym_MoveEvents(u8 puzzleNumber)
eventObjects[i].y += y;
if (GetEventObjectIdByLocalIdAndMap(eventObjects[i].localId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup) != EVENT_OBJECTS_COUNT)
{
AddEventObject(i, r5);
SaveRotatingTileObject(i, puzzleTileNum);
localId = eventObjects[i].localId;
ScriptMovement_StartObjectMovementScript(localId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, movementScript);
}
// Never reached in normal gameplay
else
{
sub_81A8D94(i, r5);
TurnUnsavedRotatingTileObject(i, puzzleTileNum);
}
}
}
@ -133,7 +144,7 @@ u16 MossdeepGym_MoveEvents(u8 puzzleNumber)
return localId;
}
void MossdeepGym_TurnEvents(void)
void TurnRotatingTileObjects(void)
{
u8 i;
s32 puzzleTileStart;
@ -143,35 +154,44 @@ void MossdeepGym_TurnEvents(void)
return;
if (!sRotatingTilePuzzle->isTrickHouse)
puzzleTileStart = METATILE_MossdeepGym_YellowRightArrow;
puzzleTileStart = METATILE_MossdeepGym_YellowArrow_Right;
else
puzzleTileStart = METATILE_TrickHousePuzzle_Arrow_YellowOnWhite_Right;
eventObjects = gSaveBlock1Ptr->eventObjectTemplates;
for (i = 0; i < sRotatingTilePuzzle->count; i++)
for (i = 0; i < sRotatingTilePuzzle->numObjects; i++)
{
s32 r6;
s8 r0;
s32 rotation;
s8 tileDifference;
u8 eventObjectId;
s16 x = eventObjects[sRotatingTilePuzzle->objects[i].eventTemplateId].x + 7;
s16 y = eventObjects[sRotatingTilePuzzle->objects[i].eventTemplateId].y + 7;
u16 metatile = MapGridGetMetatileIdAt(x, y);
r0 = (u8)((metatile - puzzleTileStart) % 8);
r0 -= (sRotatingTilePuzzle->objects[i].unk0);
if (r0 < 0 || r0 == 3)
// NOTE: The following 2 assignments and if else could all be replaced with rotation = ROTATE_COUNTERCLOCKWISE
// For an object to be saved in sRotatingTilePuzzle->objects, it must have been on a colored arrow tile
// After the first assignment, tileDifference will always be a number [0-3] representing which arrow tile the object is on now (0: right, 1: down, 2: left, 3: up)
// prevPuzzleTileNum will similarly be a number [0-3] representing the arrow tile the object just moved from
// All the puzzles are oriented counter-clockwise and can only move 1 step at a time, so the difference between the current tile and the previous tile will always either be -1 or 3 (0-1, 1-2, 2-3, 3-0)
// Which means tileDifference will always either be -1 or 3 after the below subtraction, and rotation will always be ROTATE_COUNTERCLOCKWISE after the following conditionals
tileDifference = (u8)((metatile - puzzleTileStart) % 8);
tileDifference -= (sRotatingTilePuzzle->objects[i].prevPuzzleTileNum);
// Always true, see above
if (tileDifference < 0 || tileDifference == 3)
{
if (r0 == -3)
r6 = 1;
// Always false, see above
if (tileDifference == -3)
rotation = ROTATE_CLOCKWISE;
else
r6 = 0;
rotation = ROTATE_COUNTERCLOCKWISE;
}
else
{
if (r0 > 0)
r6 = 1;
if (tileDifference > 0)
rotation = ROTATE_CLOCKWISE;
else
r6 = 2;
rotation = ROTATE_NONE;
}
eventObjectId = GetEventObjectIdByLocalIdAndMap(eventObjects[sRotatingTilePuzzle->objects[i].eventTemplateId].localId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
@ -179,24 +199,24 @@ void MossdeepGym_TurnEvents(void)
{
const u8 *movementScript;
u8 direction = gEventObjects[eventObjectId].facingDirection;
if (r6 == 0)
if (rotation == ROTATE_COUNTERCLOCKWISE)
{
switch (direction)
{
case DIR_EAST:
movementScript = MossdeepGym_Movement_FaceUp;
movementScript = RotatingTilePuzzle_Movement_FaceUp;
eventObjects[sRotatingTilePuzzle->objects[i].eventTemplateId].movementType = MOVEMENT_TYPE_FACE_UP;
break;
case DIR_SOUTH:
movementScript = MossdeepGym_Movement_FaceRight;
movementScript = RotatingTilePuzzle_Movement_FaceRight;
eventObjects[sRotatingTilePuzzle->objects[i].eventTemplateId].movementType = MOVEMENT_TYPE_FACE_RIGHT;
break;
case DIR_WEST:
movementScript = MossdeepGym_Movement_FaceDown;
movementScript = RotatingTilePuzzle_Movement_FaceDown;
eventObjects[sRotatingTilePuzzle->objects[i].eventTemplateId].movementType = MOVEMENT_TYPE_FACE_DOWN;
break;
case DIR_NORTH:
movementScript = MossdeepGym_Movement_FaceLeft;
movementScript = RotatingTilePuzzle_Movement_FaceLeft;
eventObjects[sRotatingTilePuzzle->objects[i].eventTemplateId].movementType = MOVEMENT_TYPE_FACE_LEFT;
break;
default:
@ -207,24 +227,25 @@ void MossdeepGym_TurnEvents(void)
gSaveBlock1Ptr->location.mapGroup,
movementScript);
}
else if (r6 == 1)
// Never reached
else if (rotation == ROTATE_CLOCKWISE)
{
switch (direction)
{
case DIR_EAST:
movementScript = MossdeepGym_Movement_FaceDown;
movementScript = RotatingTilePuzzle_Movement_FaceDown;
eventObjects[sRotatingTilePuzzle->objects[i].eventTemplateId].movementType = MOVEMENT_TYPE_FACE_DOWN;
break;
case DIR_SOUTH:
movementScript = MossdeepGym_Movement_FaceLeft;
movementScript = RotatingTilePuzzle_Movement_FaceLeft;
eventObjects[sRotatingTilePuzzle->objects[i].eventTemplateId].movementType = MOVEMENT_TYPE_FACE_LEFT;
break;
case DIR_WEST:
movementScript = MossdeepGym_Movement_FaceUp;
movementScript = RotatingTilePuzzle_Movement_FaceUp;
eventObjects[sRotatingTilePuzzle->objects[i].eventTemplateId].movementType = MOVEMENT_TYPE_FACE_UP;
break;
case DIR_NORTH:
movementScript = MossdeepGym_Movement_FaceRight;
movementScript = RotatingTilePuzzle_Movement_FaceRight;
eventObjects[sRotatingTilePuzzle->objects[i].eventTemplateId].movementType = MOVEMENT_TYPE_FACE_RIGHT;
break;
default:
@ -239,17 +260,18 @@ void MossdeepGym_TurnEvents(void)
}
}
static void AddEventObject(u8 eventTemplateId, u8 arg1)
static void SaveRotatingTileObject(u8 eventTemplateId, u8 puzzleTileNum)
{
sRotatingTilePuzzle->objects[sRotatingTilePuzzle->count].eventTemplateId = eventTemplateId;
sRotatingTilePuzzle->objects[sRotatingTilePuzzle->count].unk0 = arg1;
sRotatingTilePuzzle->count++;
sRotatingTilePuzzle->objects[sRotatingTilePuzzle->numObjects].eventTemplateId = eventTemplateId;
sRotatingTilePuzzle->objects[sRotatingTilePuzzle->numObjects].prevPuzzleTileNum = puzzleTileNum;
sRotatingTilePuzzle->numObjects++;
}
static void sub_81A8D94(u8 eventTemplateId, u8 arg1)
// Functionally unused
static void TurnUnsavedRotatingTileObject(u8 eventTemplateId, u8 puzzleTileNum)
{
s8 r0;
s32 r6;
s8 tileDifference;
s32 rotation;
s32 puzzleTileStart;
u16 movementType;
struct EventObjectTemplate *eventObjects = gSaveBlock1Ptr->eventObjectTemplates;
@ -258,21 +280,22 @@ static void sub_81A8D94(u8 eventTemplateId, u8 arg1)
u16 metatile = MapGridGetMetatileIdAt(x, y);
if (!sRotatingTilePuzzle->isTrickHouse)
puzzleTileStart = METATILE_MossdeepGym_YellowRightArrow;
puzzleTileStart = METATILE_MossdeepGym_YellowArrow_Right;
else
puzzleTileStart = METATILE_TrickHousePuzzle_Arrow_YellowOnWhite_Right;
r0 = (u8)((metatile - puzzleTileStart) % 8);
r0 -= arg1;
if (r0 < 0 || r0 == 3)
r6 = 0;
else if (r0 > 0 || r0 == -3)
r6 = 1;
tileDifference = (u8)((metatile - puzzleTileStart) % 8);
tileDifference -= puzzleTileNum;
if (tileDifference < 0 || tileDifference == 3)
rotation = ROTATE_COUNTERCLOCKWISE;
else if (tileDifference > 0 || tileDifference == -3)
rotation = ROTATE_CLOCKWISE;
else
r6 = 2;
rotation = ROTATE_NONE;
movementType = eventObjects[eventTemplateId].movementType;
if (r6 == 0)
if (rotation == ROTATE_COUNTERCLOCKWISE)
{
switch (movementType)
{
@ -292,7 +315,7 @@ static void sub_81A8D94(u8 eventTemplateId, u8 arg1)
break;
}
}
else if (r6 == 1)
else if (rotation == ROTATE_CLOCKWISE)
{
switch (movementType)
{

View File

@ -27,13 +27,13 @@
#include "event_obj_lock.h"
#include "menu.h"
#include "money.h"
#include "mossdeep_gym.h"
#include "mystery_event_script.h"
#include "palette.h"
#include "party_menu.h"
#include "pokemon_storage_system.h"
#include "random.h"
#include "overworld.h"
#include "rotating_tile_puzzle.h"
#include "rtc.h"
#include "script.h"
#include "script_menu.h"
@ -2149,17 +2149,17 @@ bool8 ScrCmd_takecoins(struct ScriptContext *ctx)
return FALSE;
}
bool8 ScrCmd_mossdeepgym1(struct ScriptContext *ctx)
bool8 ScrCmd_moverotatingtileobjects(struct ScriptContext *ctx)
{
u16 puzzleNumber = VarGet(ScriptReadHalfword(ctx));
sMovingNpcId = MossdeepGym_MoveEvents(puzzleNumber);
sMovingNpcId = MoveRotatingTileObjects(puzzleNumber);
return FALSE;
}
bool8 ScrCmd_mossdeepgym2(struct ScriptContext *ctx)
bool8 ScrCmd_turnrotatingtileobjects(struct ScriptContext *ctx)
{
MossdeepGym_TurnEvents();
TurnRotatingTileObjects();
return FALSE;
}
@ -2171,9 +2171,9 @@ bool8 ScrCmd_initrotatingtilepuzzle(struct ScriptContext *ctx)
return FALSE;
}
bool8 ScrCmd_mossdeepgym4(struct ScriptContext *ctx)
bool8 ScrCmd_freerotatingtilepuzzle(struct ScriptContext *ctx)
{
FinishMossdeepGymTiles();
FreeRotatingTilePuzzle();
return FALSE;
}