summaryrefslogtreecommitdiff
path: root/src/map/unit.c
diff options
context:
space:
mode:
authorJorge C <ctt@csnv.es>2016-01-09 02:41:54 +0100
committerJorge C <ctt@csnv.es>2016-01-09 02:41:54 +0100
commit75d273c052cb46e74c8e5a39dfd68624add091d9 (patch)
tree2c1398483c625829b715ee8a45ee510e47cb691c /src/map/unit.c
parent2af2132c3fd39af714eb9819bbdd8d857e651915 (diff)
downloadhercules-75d273c052cb46e74c8e5a39dfd68624add091d9.tar.gz
hercules-75d273c052cb46e74c8e5a39dfd68624add091d9.tar.bz2
hercules-75d273c052cb46e74c8e5a39dfd68624add091d9.tar.xz
hercules-75d273c052cb46e74c8e5a39dfd68624add091d9.zip
Fixes monsters not taking rude attack when OFFICIAL_WALKPATH is used.
Rude attack was not checking for this setting.
Diffstat (limited to 'src/map/unit.c')
-rw-r--r--src/map/unit.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/map/unit.c b/src/map/unit.c
index 03334f7f3..b00aadf4b 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -1976,6 +1976,7 @@ bool unit_can_reach_pos(struct block_list *bl,int x,int y, int easy)
bool unit_can_reach_bl(struct block_list *bl,struct block_list *tbl, int range, int easy, short *x, short *y)
{
short dx,dy;
+ struct walkpath_data wpd;
nullpo_retr(false, bl);
nullpo_retr(false, tbl);
@@ -2005,7 +2006,20 @@ bool unit_can_reach_bl(struct block_list *bl,struct block_list *tbl, int range,
if (x) *x = tbl->x-dx;
if (y) *y = tbl->y-dy;
- return path->search(NULL,bl,bl->m,bl->x,bl->y,tbl->x-dx,tbl->y-dy,easy,CELL_CHKNOREACH);
+
+ if (!path->search(&wpd,bl,bl->m,bl->x,bl->y,tbl->x-dx,tbl->y-dy,easy,CELL_CHKNOREACH))
+ return false;
+
+#ifdef OFFICIAL_WALKPATH
+ if( !path->search_long(NULL, bl, bl->m, bl->x, bl->y, tbl->x-dx, tbl->y-dy, CELL_CHKNOPASS) // Check if there is an obstacle between
+ && wpd.path_len > 14 // Official number of walkable cells is 14 if and only if there is an obstacle between. [malufett]
+ && (bl->type != BL_NPC) ) // If type is a NPC, please disregard.
+ return false;
+#endif
+
+ return true;
+
+
}
/*==========================================
* Calculates position of Pet/Mercenary/Homunculus/Elemental