Fix decorations metatile attribute names

This commit is contained in:
GriffinR 2022-01-19 10:56:54 -05:00
parent a8b466dc80
commit 8200fda14e
4 changed files with 23 additions and 17 deletions

View File

@ -179,8 +179,8 @@
#define MB_UNUSED_AF 0xAF #define MB_UNUSED_AF 0xAF
#define MB_SECRET_BASE_PC 0xB0 #define MB_SECRET_BASE_PC 0xB0
#define MB_SECRET_BASE_REGISTER_PC 0xB1 #define MB_SECRET_BASE_REGISTER_PC 0xB1
#define MB_SECRET_BASE_UNUSED 0xB2 #define MB_SECRET_BASE_OBSTACLE 0xB2
#define MB_BLOCK_DECORATION 0xB3 #define MB_SECRET_BASE_TRAINER_SPOT 0xB3
#define MB_SECRET_BASE_DECORATION 0xB4 #define MB_SECRET_BASE_DECORATION 0xB4
#define MB_HOLDS_SMALL_DECORATION 0xB5 #define MB_HOLDS_SMALL_DECORATION 0xB5
#define MB_UNUSED_B6 0xB6 #define MB_UNUSED_B6 0xB6

View File

@ -57,7 +57,7 @@ bool8 MetatileBehavior_IsSecretBaseTree(u8);
bool8 MetatileBehavior_IsSecretBaseShrub(u8); bool8 MetatileBehavior_IsSecretBaseShrub(u8);
bool8 MetatileBehavior_IsSecretBasePC(u8); bool8 MetatileBehavior_IsSecretBasePC(u8);
bool8 MetatileBehavior_IsRecordMixingSecretBasePC(u8); bool8 MetatileBehavior_IsRecordMixingSecretBasePC(u8);
bool8 MetatileBehavior_IsBlockDecoration(u8); bool8 MetatileBehavior_IsSecretBaseTrainerSpot(u8);
bool8 MetatileBehavior_IsSecretBaseImpassable(u8); bool8 MetatileBehavior_IsSecretBaseImpassable(u8);
bool8 MetatileBehavior_IsSecretBaseDecorationBase(u8); bool8 MetatileBehavior_IsSecretBaseDecorationBase(u8);
bool8 MetatileBehavior_IsSecretBasePoster(u8); bool8 MetatileBehavior_IsSecretBasePoster(u8);

View File

@ -1211,7 +1211,8 @@ static void ShowDecorationOnMap_(u16 mapX, u16 mapY, u8 decWidth, u8 decHeight,
{ {
x = mapX + i; x = mapX + i;
attributes = GetMetatileAttributesById(NUM_TILES_IN_PRIMARY + gDecorations[decoration].tiles[j * decWidth + i]); attributes = GetMetatileAttributesById(NUM_TILES_IN_PRIMARY + gDecorations[decoration].tiles[j * decWidth + i]);
if (MetatileBehavior_IsSecretBaseImpassable(attributes) == TRUE || (gDecorations[decoration].permission != DECORPERM_PASS_FLOOR && (attributes >> METATILE_ATTR_LAYER_SHIFT))) if (MetatileBehavior_IsSecretBaseImpassable(attributes & METATILE_ATTR_BEHAVIOR_MASK) == TRUE
|| (gDecorations[decoration].permission != DECORPERM_PASS_FLOOR && (attributes >> METATILE_ATTR_LAYER_SHIFT) != METATILE_LAYER_TYPE_NORMAL))
impassableFlag = MAPGRID_COLLISION_MASK; impassableFlag = MAPGRID_COLLISION_MASK;
else else
impassableFlag = 0; impassableFlag = 0;
@ -1471,23 +1472,26 @@ static void AttemptCancelPlaceDecoration(u8 taskId)
DisplayItemMessageOnField(taskId, gStringVar4, CancelDecoratingPrompt); DisplayItemMessageOnField(taskId, gStringVar4, CancelDecoratingPrompt);
} }
static bool8 IsNonBlockNonElevated(u8 behaviorAt, u16 layerType) static bool8 IsSecretBaseTrainerSpot(u8 behaviorAt, u16 layerType)
{ {
if (MetatileBehavior_IsBlockDecoration(behaviorAt) != TRUE || layerType != 0) if (!(MetatileBehavior_IsSecretBaseTrainerSpot(behaviorAt) == TRUE && layerType == METATILE_LAYER_TYPE_NORMAL))
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
// Can't place decoration where the player was standing when they interacted with the PC
static bool8 IsntInitialPosition(u8 taskId, s16 x, s16 y, u16 layerType) static bool8 IsntInitialPosition(u8 taskId, s16 x, s16 y, u16 layerType)
{ {
if (x == gTasks[taskId].tInitialX + MAP_OFFSET && y == gTasks[taskId].tInitialY + MAP_OFFSET && layerType != 0) if (x == gTasks[taskId].tInitialX + MAP_OFFSET
&& y == gTasks[taskId].tInitialY + MAP_OFFSET
&& layerType != METATILE_LAYER_TYPE_NORMAL)
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
static bool8 IsFloorOrBoardAndHole(u16 behaviorAt, const struct Decoration *decoration) static bool8 IsFloorOrBoardAndHole(u16 behaviorAt, const struct Decoration *decoration)
{ {
if (MetatileBehavior_IsBlockDecoration(behaviorAt) != TRUE) if (MetatileBehavior_IsSecretBaseTrainerSpot(behaviorAt) != TRUE)
{ {
if (decoration->id == DECOR_SOLID_BOARD && MetatileBehavior_IsSecretBaseHole(behaviorAt) == TRUE) if (decoration->id == DECOR_SOLID_BOARD && MetatileBehavior_IsSecretBaseHole(behaviorAt) == TRUE)
return TRUE; return TRUE;
@ -1545,7 +1549,7 @@ static bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration)
curX = gTasks[taskId].tCursorX + j; curX = gTasks[taskId].tCursorX + j;
behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY); behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY);
layerType = GetMetatileAttributesById(NUM_TILES_IN_PRIMARY + decoration->tiles[(mapY - 1 - i) * mapX + j]) & METATILE_ATTR_LAYER_MASK; layerType = GetMetatileAttributesById(NUM_TILES_IN_PRIMARY + decoration->tiles[(mapY - 1 - i) * mapX + j]) & METATILE_ATTR_LAYER_MASK;
if (!MetatileBehavior_IsNormal(behaviorAt) && !IsNonBlockNonElevated(behaviorAt, layerType)) if (!MetatileBehavior_IsNormal(behaviorAt) && !IsSecretBaseTrainerSpot(behaviorAt, layerType))
return FALSE; return FALSE;
if (!IsntInitialPosition(taskId, curX, curY, layerType)) if (!IsntInitialPosition(taskId, curX, curY, layerType))

View File

@ -188,8 +188,8 @@ static const u8 sTileBitAttributes[] =
[MB_UNUSED_AF] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), [MB_UNUSED_AF] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
[MB_SECRET_BASE_PC] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), [MB_SECRET_BASE_PC] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
[MB_SECRET_BASE_REGISTER_PC] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), [MB_SECRET_BASE_REGISTER_PC] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
[MB_SECRET_BASE_UNUSED] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE), [MB_SECRET_BASE_OBSTACLE] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
[MB_BLOCK_DECORATION] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE), [MB_SECRET_BASE_TRAINER_SPOT] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
[MB_SECRET_BASE_DECORATION] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), [MB_SECRET_BASE_DECORATION] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
[MB_HOLDS_SMALL_DECORATION] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE), [MB_HOLDS_SMALL_DECORATION] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
[MB_UNUSED_B6] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), [MB_UNUSED_B6] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
@ -687,17 +687,19 @@ bool8 MetatileBehavior_IsRecordMixingSecretBasePC(u8 metatileBehavior)
return FALSE; return FALSE;
} }
bool8 Unref_MetatileBehavior_IsSecretBaseUnused_B2(u8 metatileBehavior) // Used by the rock/grass floor spaces that the secret base trainer is not standing on
bool8 MetatileBehavior_IsSecretBaseObstacle1(u8 metatileBehavior)
{ {
if (metatileBehavior == MB_SECRET_BASE_UNUSED) if (metatileBehavior == MB_SECRET_BASE_OBSTACLE)
return TRUE; return TRUE;
else else
return FALSE; return FALSE;
} }
bool8 MetatileBehavior_IsBlockDecoration(u8 metatileBehavior) // Used by the rock/grass floor space that the secret base trainer stands on
bool8 MetatileBehavior_IsSecretBaseTrainerSpot(u8 metatileBehavior)
{ {
if (metatileBehavior == MB_BLOCK_DECORATION) if (metatileBehavior == MB_SECRET_BASE_TRAINER_SPOT)
return TRUE; return TRUE;
else else
return FALSE; return FALSE;
@ -743,9 +745,9 @@ bool8 MetatileBehavior_IsSecretBaseNorthWall(u8 metatileBehavior)
return FALSE; return FALSE;
} }
bool8 Unref_MetatileBehavior_IsSecretBaseUnused_B2_2(u8 metatileBehavior) bool8 MetatileBehavior_IsSecretBaseObstacle2(u8 metatileBehavior)
{ {
if (metatileBehavior == MB_SECRET_BASE_UNUSED) if (metatileBehavior == MB_SECRET_BASE_OBSTACLE)
return TRUE; return TRUE;
else else
return FALSE; return FALSE;