diff options
author | scnorton <scnorton@biociphers.org> | 2017-05-22 19:31:47 -0400 |
---|---|---|
committer | scnorton <scnorton@biociphers.org> | 2017-05-24 16:14:50 -0400 |
commit | b087d8a909925baf772aa0d631318fb17667067c (patch) | |
tree | b10aadfcfe2a8444a2e624fec02619b706b1eae0 /src/field_map_obj.c | |
parent | abe5f5053624f876ea17c44370b203c0a4ace86b (diff) |
IsCoordOutsideFieldObjectMovementRect and others
Diffstat (limited to 'src/field_map_obj.c')
-rw-r--r-- | src/field_map_obj.c | 57 |
1 files changed, 53 insertions, 4 deletions
diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 7c332c505..755de7611 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -2972,19 +2972,20 @@ u8 sub_805FF20(struct MapObject *mapObject, u8 direction) return npc_block_way(mapObject, x, y, direction); } -bool8 IsCoordOutsideFieldObjectMovementRect(struct MapObject *mapObject, s16 x, s16 y); +bool8 IsCoordOutsideFieldObjectMovementRect(struct MapObject2 *mapObject, s16 x, s16 y); +bool8 CheckForCollisionBetweenFieldObjects(struct MapObject *mapObject, s16 x, s16 y); +bool8 IsMetatileDirectionallyImpassable(struct MapObject *mapObject, s16 x, s16 y, u8 direction); u8 npc_block_way(struct MapObject *mapObject, s16 x, s16 y, u8 direction) { - if (IsCoordOutsideFieldObjectMovementRect(mapObject, x, y)) + if (IsCoordOutsideFieldObjectMovementRect((struct MapObject2 *)mapObject, x, y)) { return 1; } if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == -1 || IsMetatileDirectionallyImpassable(mapObject, x, y, direction)) { return 2; - } - if (mapObject->mapobj_bit_15 && !CanCameraMoveInDirection(direction)) + } else if (mapObject->mapobj_bit_15 && !CanCameraMoveInDirection(direction)) { return 2; } @@ -2998,3 +2999,51 @@ u8 npc_block_way(struct MapObject *mapObject, s16 x, s16 y, u8 direction) } return 0; } + +u8 sub_8060024(struct MapObject *mapObject, s16 x, s16 y, u8 direction) +{ + u8 flags; + flags = 0; + if (IsCoordOutsideFieldObjectMovementRect((struct MapObject2 *)mapObject, x, y)) + { + flags |= 1; + } + if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == -1 || IsMetatileDirectionallyImpassable(mapObject, x, y, direction) || (mapObject->mapobj_bit_15 && !CanCameraMoveInDirection(direction))) + { + flags |= 2; + } + if (IsZCoordMismatchAt(mapObject->mapobj_unk_0B_0, x, y)) + { + flags |= 4; + } + if (CheckForCollisionBetweenFieldObjects(mapObject, x, y)) + { + flags |= 8; + } + return flags; +} + +bool8 IsCoordOutsideFieldObjectMovementRect(struct MapObject2 *mapObject, s16 x, s16 y) +{ + s16 minv; + s16 maxv; + if (mapObject->mapobj_unk_19 != 0) + { + minv = mapObject->coords1.x - (mapObject->mapobj_unk_19); + maxv = mapObject->coords1.x + (mapObject->mapobj_unk_19); + if (minv > x || maxv < x) + { + return 1; + } + } + if (mapObject->mapobj_unk_19b != 0) + { + minv = mapObject->coords1.y - (mapObject->mapobj_unk_19b); + maxv = mapObject->coords1.y + (mapObject->mapobj_unk_19b); + if (minv > y || maxv < y) + { + return 1; + } + } + return 0; +} |