From bb1860600e59dacef19e8fd3e24417a92fde5113 Mon Sep 17 00:00:00 2001 From: skotlex Date: Fri, 9 Feb 2007 19:50:57 +0000 Subject: - Updated the 'unit walk' to functions so they stop your attack if it's possible to walk. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9837 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/clif.c | 1 - src/map/unit.c | 22 ++++++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) (limited to 'src/map') diff --git a/src/map/clif.c b/src/map/clif.c index aa2091054..c8c021233 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -8359,7 +8359,6 @@ void clif_parse_WalkToXY(int fd, struct map_session_data *sd) { if(sd->sc.count && sd->sc.data[SC_RUN].timer != -1) return; - pc_stop_attack(sd); pc_delinvincibletimer(sd); cmd = RFIFOW(fd,0); diff --git a/src/map/unit.c b/src/map/unit.c index 2a360e6ab..18fffa7f5 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -43,6 +43,7 @@ struct unit_data* unit_bl2ud(struct block_list *bl) { return NULL; } +static int unit_attack_timer(int tid,unsigned int tick,int id,int data); static int unit_walktoxy_timer(int tid,unsigned int tick,int id,int data); int unit_walktoxy_sub(struct block_list *bl) @@ -309,9 +310,14 @@ int unit_walktoxy( struct block_list *bl, int x, int y, int flag) { // timer関数からunit_walktoxy_subを呼ぶようにする ud->state.change_walk_target = 1; return 1; - } else { - return unit_walktoxy_sub(bl); } + + if (ud->attacktimer != -1) { + delete_timer( ud->attacktimer, unit_attack_timer ); + ud->attacktimer = -1; + } + + return unit_walktoxy_sub(bl); } static int unit_walktobl_sub(int tid,unsigned int tick,int id,int data) @@ -366,13 +372,21 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int ud->state.change_walk_target = 1; return 1; } + if (DIFF_TICK(ud->canmove_tick, gettick()) > 0) { //Can't move, wait a bit before invoking the movement. add_timer(ud->canmove_tick+1, unit_walktobl_sub, bl->id, ud->target); return 1; - } else if (!unit_can_move(bl)) + } + + if (!unit_can_move(bl)) return 0; - + + if (ud->attacktimer != -1) { + delete_timer( ud->attacktimer, unit_attack_timer ); + ud->attacktimer = -1; + } + return unit_walktoxy_sub(bl); } -- cgit v1.2.3-70-g09d2