瀏覽代碼

Fixed #884

Thanks to @mrjnumber1 and @csnv
Lemongrass3110 9 年之前
父節點
當前提交
9046e7ecf7
共有 1 個文件被更改,包括 12 次插入1 次删除
  1. 12 1
      src/map/unit.c

+ 12 - 1
src/map/unit.c

@@ -2319,6 +2319,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)
 {
+	struct walkpath_data wpd;
 	short dx, dy;
 
 	nullpo_retr(false, bl);
@@ -2357,7 +2358,17 @@ bool unit_can_reach_bl(struct block_list *bl,struct block_list *tbl, int range,
 	if (y)
 		*y = tbl->y-dy;
 
-	return path_search(NULL,bl->m,bl->x,bl->y,tbl->x-dx,tbl->y-dy,easy,CELL_CHKNOREACH);
+	if (!path_search(&wpd,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->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;
 }
 
 /**