diff options
author | PikalaxALT <pikalaxalt@gmail.com> | 2017-09-16 18:42:35 -0400 |
---|---|---|
committer | PikalaxALT <pikalaxalt@gmail.com> | 2017-09-16 18:42:35 -0400 |
commit | fedbcd7bb7202f37f4a3a017a2f4c1fe296a6ae3 (patch) | |
tree | 2351c1805fc03c2c08a7b564f7b8607d317e90b3 /src/field_map_obj.c | |
parent | 5812bc4ebe83bb80294bbb40846ae6fb1c76e5bf (diff) |
npc_block_way
Diffstat (limited to 'src/field_map_obj.c')
-rwxr-xr-x | src/field_map_obj.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 93baccf36..5ec5e68f4 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -121,6 +121,10 @@ void DoGroundEffects_OnFinishStep(struct MapObject *, struct Sprite *); void npc_obj_transfer_image_anim_pause_flag(struct MapObject *, struct Sprite *); void FieldObjectUpdateSubpriority(struct MapObject *, struct Sprite *); +bool8 IsCoordOutsideFieldObjectMovementRect(struct MapObject *fieldObject, s16 x, s16 y); +bool8 IsMetatileDirectionallyImpassable(struct MapObject *, s16, s16, u8); +bool8 CheckForCollisionBetweenFieldObjects(struct MapObject *, s16, s16); + // ROM data void (*const gUnknown_08505438[NUM_FIELD_MAP_OBJECT_TEMPLATES])(struct Sprite *); @@ -3637,7 +3641,7 @@ void npc_set_running_behaviour_etc(struct MapObject *mapObject, u8 animPattern) dirn2anim(npc_running_behaviour_by_direction, gUnknown_0850DB53) -bool8 npc_block_way__next_tile(struct MapObject *mapObject, u8 direction) +u8 npc_block_way__next_tile(struct MapObject *mapObject, u8 direction) { s16 x; s16 y; @@ -3648,6 +3652,24 @@ bool8 npc_block_way__next_tile(struct MapObject *mapObject, u8 direction) return npc_block_way(mapObject, x, y, direction); } +u8 npc_block_way(struct MapObject *mapObject, s16 x, s16 y, u32 dirn) +{ + u8 direction; + + direction = dirn; + if (IsCoordOutsideFieldObjectMovementRect(mapObject, x, y)) + return 1; + else if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == -1 || IsMetatileDirectionallyImpassable(mapObject, x, y, direction)) + return 2; + else if (mapObject->mapobj_bit_15 && !CanCameraMoveInDirection(direction)) + return 2; + else if (IsZCoordMismatchAt(mapObject->mapobj_unk_0B_0, x, y)) + return 3; + else if (CheckForCollisionBetweenFieldObjects(mapObject, x, y)) + return 4; + return 0; +} + asm(".section .text.get_face_direction_anim_id"); void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); |