summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/map/npc.c19
-rw-r--r--src/map/npc.h1
2 files changed, 14 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;
}
diff --git a/src/map/npc.h b/src/map/npc.h
index fba14d485..0825faf10 100644
--- a/src/map/npc.h
+++ b/src/map/npc.h
@@ -61,6 +61,7 @@ struct npc_data {
int touching_id;
int64 next_walktime;
uint8 dir;
+ uint8 area_size;
unsigned size : 2;