diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/map/mercenary.h | 1 | ||||
-rw-r--r-- | src/map/unit.c | 40 |
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. |