summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorgreenboxal2 <greenboxal2@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-06-21 10:41:37 +0000
committergreenboxal2 <greenboxal2@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-06-21 10:41:37 +0000
commit31ad1a39db0aa488dd5a96e54d842b89a46eb129 (patch)
treebb7d053556c661ecb60c9728b84e08fc966d818d /src/map
parent7cb15efd94f0b12cd269862888be653def1e3633 (diff)
downloadhercules-31ad1a39db0aa488dd5a96e54d842b89a46eb129.tar.gz
hercules-31ad1a39db0aa488dd5a96e54d842b89a46eb129.tar.bz2
hercules-31ad1a39db0aa488dd5a96e54d842b89a46eb129.tar.xz
hercules-31ad1a39db0aa488dd5a96e54d842b89a46eb129.zip
Fixed bugreport:6044 mercenaries should warp after being far from the master after 3 seconds.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16327 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r--src/map/mercenary.h1
-rw-r--r--src/map/unit.c40
2 files changed, 36 insertions, 5 deletions
diff --git a/src/map/mercenary.h b/src/map/mercenary.h
index f63ffad86..402a4e0ab 100644
--- a/src/map/mercenary.h
+++ b/src/map/mercenary.h
@@ -46,6 +46,7 @@ struct mercenary_data {
int contract_timer;
unsigned devotion_flag : 1;
+ unsigned int masterteleport_timer;
};
bool merc_class(int class_);
diff --git a/src/map/unit.c b/src/map/unit.c
index 6d4c9b9cf..e85849283 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -182,8 +182,22 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data
sd->areanpc_id=0;
if( sd->md && !check_distance_bl(&sd->bl, &sd->md->bl, MAX_MER_DISTANCE) )
- {// mercenary is too far from the master so warp the master's position
- unit_warp( &sd->md->bl, sd->bl.m, sd->bl.x, sd->bl.y, CLR_TELEPORT );
+ {
+ // mercenary should be warped after being 3 seconds too far from the master [greenbox]
+ if (sd->md->masterteleport_timer == 0)
+ {
+ sd->md->masterteleport_timer = gettick();
+ }
+ else if (DIFF_TICK(gettick(), sd->md->masterteleport_timer) > 3000)
+ {
+ sd->md->masterteleport_timer = 0;
+ unit_warp( &sd->md->bl, sd->bl.m, sd->bl.x, sd->bl.y, CLR_TELEPORT );
+ }
+ }
+ else
+ {
+ // reset the tick, he is not far anymore
+ sd->md->masterteleport_timer = 0;
}
} else if (md) {
if( map_getcell(bl->m,x,y,CELL_CHKNPC) ) {
@@ -206,9 +220,25 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data
clif_move(ud);
}
}
- else if( mrd && mrd->master && !check_distance_bl(&mrd->master->bl, bl, MAX_MER_DISTANCE) )
- {// mercenary is too far from the master so warp the master's position
- unit_warp( bl, mrd->master->bl.id, mrd->master->bl.x, mrd->master->bl.y, CLR_TELEPORT );
+ else if( mrd && mrd->master )
+ {
+ if (!check_distance_bl(&mrd->master->bl, bl, MAX_MER_DISTANCE))
+ {
+ // mercenary should be warped after being 3 seconds too far from the master [greenbox]
+ if (mrd->masterteleport_timer == 0)
+ {
+ mrd->masterteleport_timer = gettick();
+ }
+ else if (DIFF_TICK(gettick(), mrd->masterteleport_timer) > 3000)
+ {
+ mrd->masterteleport_timer = 0;
+ unit_warp( bl, mrd->master->bl.id, mrd->master->bl.x, mrd->master->bl.y, CLR_TELEPORT );
+ }
+ }
+ else
+ {
+ mrd->masterteleport_timer = 0;
+ }
}
if(tid == INVALID_TIMER) //A directly invoked timer is from battle_stop_walking, therefore the rest is irrelevant.