diff options
-rw-r--r-- | Changelog-Trunk.txt | 2 | ||||
-rw-r--r-- | src/map/unit.c | 16 |
2 files changed, 15 insertions, 3 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index ef546b860..334194d91 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,8 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2006/04/10
+ * Finished fixing the unit_data auto-chase update. Still need to do some
+ optimizations... but the current code-base should be usable. [Skotlex]
* Fixes to the unit_data update that lets characters auto-chase while
attacking. It seems to work mostly now, but there's still a few issues to
be resolved with ranged-attackers. [Skotlex]
diff --git a/src/map/unit.c b/src/map/unit.c index fe2b51b1f..dd3f1ef4c 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -59,13 +59,23 @@ int unit_walktoxy_sub(struct block_list *bl) if (ud->walktarget && ud->chaserange >0) {
//Trim the last part of the path to account for range.
- for (i = 1; i <= ud->chaserange && ud->walkpath.path_len>0; i++) {
+ for (i = ud->chaserange*10; i > 0 && ud->walkpath.path_len>0;) {
int dir;
ud->walkpath.path_len--;
dir = ud->walkpath.path[ud->walkpath.path_len];
+ if(dir&1)
+ i-=14;
+ else
+ i-=10;
ud->to_x -= dirx[dir];
ud->to_y -= diry[dir];
}
+ if (!ud->walkpath.path_len) {
+ //Already within requested range.
+ if (ud->attacktarget == ud->walktarget)
+ unit_attack(bl, ud->attacktarget, ud->state.attack_continue);
+ return 0;
+ }
}
ud->state.change_walk_target=0;
@@ -80,7 +90,7 @@ int unit_walktoxy_sub(struct block_list *bl) i = status_get_speed(bl)*14/10;
else
i = status_get_speed(bl);
- if( i > 0) {
+ if( i > 0) {
i = i>>1;
ud->walktimer = add_timer(gettick()+i,unit_walktoxy_timer,bl->id,0);
}
@@ -131,7 +141,7 @@ static int unit_walktoxy_timer(int tid,unsigned int tick,int id,int data) unit_walktoxy_sub(bl);
return 0;
}
- } else { // マス目境界へ到着
+ } else {
if(ud->walkpath.path[ud->walkpath.path_pos]>=8)
return 1;
x = bl->x;
|