summaryrefslogtreecommitdiff
path: root/src/map/npc.c
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-12-04 01:02:42 +0300
committerAndrei Karas <akaras@inbox.ru>2014-12-15 10:52:37 +0300
commit5736970973fefa2a1e10a1847c9bb12bd2cb0719 (patch)
tree20534e59778236f112ed91385371aff2b65d5a6b /src/map/npc.c
parentc7df86cc2442c29649ae44b629b05818a1742c08 (diff)
downloadhercules-5736970973fefa2a1e10a1847c9bb12bd2cb0719.tar.gz
hercules-5736970973fefa2a1e10a1847c9bb12bd2cb0719.tar.bz2
hercules-5736970973fefa2a1e10a1847c9bb12bd2cb0719.tar.xz
hercules-5736970973fefa2a1e10a1847c9bb12bd2cb0719.zip
add npc area size field.
Diffstat (limited to 'src/map/npc.c')
-rw-r--r--src/map/npc.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/map/npc.c b/src/map/npc.c
index 8c2f61d58..9731250f3 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -1086,22 +1086,28 @@ int npc_check_areanpc(int flag, int16 m, int16 x, int16 y, int16 range) {
struct npc_data* npc_checknear(struct map_session_data* sd, struct block_list* bl)
{
struct npc_data *nd;
+ int distance = AREA_SIZE + 1;
nullpo_retr(NULL, sd);
- if(bl == NULL) return NULL;
- if(bl->type != BL_NPC) return NULL;
+ if (bl == NULL) return NULL;
+ if (bl->type != BL_NPC) return NULL;
nd = (TBL_NPC*)bl;
- if(sd->state.using_fake_npc && sd->npc_id == bl->id)
+ if (sd->state.using_fake_npc && sd->npc_id == bl->id)
return nd;
if (nd->class_<0) //Class-less npc, enable click from anywhere.
return nd;
- if (bl->m!=sd->bl.m ||
- bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 ||
- bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1)
+ if (distance > nd->area_size)
+ distance = nd->area_size;
+
+ if (bl->m != sd->bl.m ||
+ bl->x < sd->bl.x - distance || bl->x > sd->bl.x + distance ||
+ bl->y < sd->bl.y - distance || bl->y > sd->bl.y + distance)
+ {
return NULL;
+ }
return nd;
}
@@ -2505,6 +2511,7 @@ struct npc_data* npc_create_npc(int m, int x, int y)
nd->bl.m = m;
nd->bl.x = x;
nd->bl.y = y;
+ nd->area_size = AREA_SIZE + 1;
return nd;
}