summaryrefslogtreecommitdiff
path: root/src/map/npc.c
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-11-17 23:26:43 +0300
committerAndrei Karas <akaras@inbox.ru>2014-11-17 23:26:43 +0300
commit7966264fdf4271c8b247d572c2eadef88dcaf4b4 (patch)
treefd05e7c449d5ff883c19283f66a8e8e088a14fec /src/map/npc.c
parent83a2ec502bbe1a8a86ef6361eaf98f38f5d2a653 (diff)
downloadevol-hercules-7966264fdf4271c8b247d572c2eadef88dcaf4b4.tar.gz
evol-hercules-7966264fdf4271c8b247d572c2eadef88dcaf4b4.tar.bz2
evol-hercules-7966264fdf4271c8b247d572c2eadef88dcaf4b4.tar.xz
evol-hercules-7966264fdf4271c8b247d572c2eadef88dcaf4b4.zip
Allow continue npc script execution if distance to npc bigger than limit.
Diffstat (limited to 'src/map/npc.c')
-rw-r--r--src/map/npc.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/map/npc.c b/src/map/npc.c
new file mode 100644
index 0000000..054505d
--- /dev/null
+++ b/src/map/npc.c
@@ -0,0 +1,47 @@
+// Copyright (c) Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// Copyright (c) 2014 Evol developers
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "../../../common/HPMi.h"
+#include "../../../common/malloc.h"
+#include "../../../common/mmo.h"
+#include "../../../common/socket.h"
+#include "../../../common/strlib.h"
+#include "../../../map/npc.h"
+#include "../../../map/pc.h"
+
+#include "map/npc.h"
+
+struct npc_data* enpc_checknear(struct map_session_data* sd, struct block_list* bl)
+{
+ struct npc_data *nd;
+
+ hookStop();
+
+ if (!sd)
+ return NULL;
+
+ if (bl == NULL)
+ return NULL;
+ if (bl->type != BL_NPC)
+ return NULL;
+ nd = (TBL_NPC*)bl;
+
+ if (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)
+ {
+ return NULL;
+ }
+
+ return nd;
+}