It's a side effect of certain skills, like Jupitel Thunder.
src - current position
ref - reference position
range - how much to push
dx - push increment for the x coordinate
dy - push increment for the y coordinate
The implementation can push in 8 directions.
The direction is determined by the position of ref relative to src.
if( abs(ref.y-src.y) >= 3*abs(ref.x-src.x) )
{// vertical
dx = 0;
dy = (ref.y > src.y ? 1 : -1);
}
else if( abs(ref.x-src.x) >= 3*abs(ref.y-src.y) )
{// horizontal
dx = (ref.x > src.x ? 1 : -1);
dy = 0;
}
else
{// diagonal
dx = (ref.x > src.x ? 1 : -1);
dy = (ref.y > src.y ? 1 : -1);
}
It pushes until the target range is reached or an unmovable cell is found.
for( ; range > 0; --range )
{
if( !is_movable(src.x+dx, src.y+dy) )
break;// not movable
src.x += dx;
src.y += dy;
}
Based on a 11.2 zone.
Sem comentários:
Enviar um comentário