diff options
author | Haruna <haru@dotalux.com> | 2013-07-23 09:26:01 -0700 |
---|---|---|
committer | Haruna <haru@dotalux.com> | 2013-07-23 09:26:01 -0700 |
commit | 356a3ab31d7569eac9b2fa996c8d641eba7c9f99 (patch) | |
tree | c553cbaeee540c4836d70d86c0da9ebbda00a5d7 /src/map/unit.c | |
parent | 8d14a2e979fa7aab75b38a2c92e617de9c2e5f2e (diff) | |
parent | 78028c8b652a4edf761b6f250c2fca4b6c576dee (diff) | |
download | hercules-356a3ab31d7569eac9b2fa996c8d641eba7c9f99.tar.gz hercules-356a3ab31d7569eac9b2fa996c8d641eba7c9f99.tar.bz2 hercules-356a3ab31d7569eac9b2fa996c8d641eba7c9f99.tar.xz hercules-356a3ab31d7569eac9b2fa996c8d641eba7c9f99.zip |
Merge pull request #65 from piotrhalaczkiewicz/pathfinding
Pathfinding code cleanup.
Diffstat (limited to 'src/map/unit.c')
-rw-r--r-- | src/map/unit.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/map/unit.c b/src/map/unit.c index 4a8a87920..7c65594ca 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -107,9 +107,9 @@ int unit_walktoxy_sub(struct block_list *bl) ud->walkpath.path_len--; dir = ud->walkpath.path[ud->walkpath.path_len]; if(dir&1) - i-=14; + i -= MOVE_DIAGONAL_COST; else - i-=10; + i -= MOVE_COST; ud->to_x -= dirx[dir]; ud->to_y -= diry[dir]; } @@ -126,7 +126,7 @@ int unit_walktoxy_sub(struct block_list *bl) if(ud->walkpath.path_pos>=ud->walkpath.path_len) i = -1; else if(ud->walkpath.path[ud->walkpath.path_pos]&1) - i = iStatus->get_speed(bl)*14/10; + i = iStatus->get_speed(bl)*MOVE_DIAGONAL_COST/MOVE_COST; else i = iStatus->get_speed(bl); if( i > 0) @@ -346,14 +346,16 @@ int unit_walktoxy( struct block_list *bl, short x, short y, int flag) if( ud == NULL) return 0; - path_search(&wpd, bl->m, bl->x, bl->y, x, y, flag&1, CELL_CHKNOPASS); // Count walk path cells + if (!path_search(&wpd, bl->m, bl->x, bl->y, x, y, flag&1, CELL_CHKNOPASS)) // Count walk path cells + return 0; + #ifdef OFFICIAL_WALKPATH if( !path_search_long(NULL, bl->m, bl->x, bl->y, x, y, CELL_CHKNOPASS) // Check if there is an obstacle between && (wpd.path_len > (battle_config.max_walk_path/17)*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 0; #endif - if( (battle_config.max_walk_path < wpd.path_len) && (bl->type != BL_NPC) ) + if ((wpd.path_len > battle_config.max_walk_path) && (bl->type != BL_NPC)) return 0; if (flag&4 && DIFF_TICK(ud->canmove_tick, iTimer->gettick()) > 0 && |