summaryrefslogtreecommitdiff
path: root/src
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
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')
-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;