From 101bc4a4e569903eedb463da9ee8b736d16ea6fb Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 21 May 2017 00:18:31 -0400 Subject: field_map_obj.c up to and including FieldObjectIsTrainerAndCloseToPlayer --- src/field_map_obj.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'src') diff --git a/src/field_map_obj.c b/src/field_map_obj.c index a7856ec07..61ec26365 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1601,3 +1601,44 @@ u8 sub_805C9D8(struct MapObject *mapObject, struct Sprite *sprite) return 1; } +u8 sub_805CA08(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite) != 0) + { + mapObject->mapobj_bit_1 = 0; + sprite->data1 = 1; + } + return 0; +} + +u8 FieldObjectIsTrainerAndCloseToPlayer(struct MapObject *mapObject) +{ + s16 x; + s16 y; + s16 objx; + s16 objy; + s16 minx; + s16 maxx; + s16 miny; + s16 maxy; + if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_DASH) == 0) + { + return 0; + } + if (mapObject->trainerType != 1 && mapObject->trainerType != 3) + { + return 0; + } + PlayerGetDestCoords(&x, &y); + objx = mapObject->coords2.x; + objy = mapObject->coords2.y; + minx = objx - mapObject->trainerRange_berryTreeId; + miny = objy - mapObject->trainerRange_berryTreeId; + maxx = objx + mapObject->trainerRange_berryTreeId; + maxy = objy + mapObject->trainerRange_berryTreeId; + if (minx > x || maxx < x || miny > y || maxy < y) + { + return 0; + } + return 1; +} -- cgit v1.2.3