summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2016-01-17 19:15:42 +0100
committerHaru <haru@dotalux.com>2016-01-17 19:15:42 +0100
commit1cf48187538e6012329c7b24a7e651947d524df0 (patch)
treeafc1ad9725805433354287929afabd926911ccca /src
parentc156322ded28c695c17871d98abe071bb73dadd4 (diff)
parent75d273c052cb46e74c8e5a39dfd68624add091d9 (diff)
downloadhercules-1cf48187538e6012329c7b24a7e651947d524df0.tar.gz
hercules-1cf48187538e6012329c7b24a7e651947d524df0.tar.bz2
hercules-1cf48187538e6012329c7b24a7e651947d524df0.tar.xz
hercules-1cf48187538e6012329c7b24a7e651947d524df0.zip
Merge pull request #1077 from csnv/master
Fixes monsters not taking rude attack when OFFICIAL_WALKPATH is used.
Diffstat (limited to 'src')
-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 26104e4e0..bea0913d2 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