case WZ_STORMGUST: { //ordered by event probability
int dx = bl->x-skill_area_temp[4];
int dy = bl->y-skill_area_temp[5];
int range = skill_get_unit_range(skill_id,skill_lv);
if( abs(dx) < range && abs(dy) < range ){ //inner range X case
dir = rnd()%8; //make it random
}
else if(abs(dx) == range ^ abs(dy) == range){ //on edge but not corner //@FIXME check where is x and y for dir
if( dx == range) dir=rnd()%5; // left [0,1,2,3,4]
else if( dx == -range) dir=rnd()%5+4; if(dir>7) dir=0; //right [0,4,5,6,7] if 8
else if( dy == range) dir=rnd()%5; if(dir>2) dir+=3; //up [0,1,2,6,7] if 3,4
else if( dy == -range) dir=rnd()%5+2; //down [2,3,4,5,6]
}
else if(abs(dx) == (range+1) ^ abs(dy) == (range+1) ){ //spalsh after edge
if((abs(dx) == (range+1) && abs(dy) == range )
|| (abs(dx) == (range) && abs(dy) == (range+1) )){ //near corner
if( dx == range){
if(dy>0) dir=(rnd()%2)*7; // left [0,7]
if(dy<0) dir=rnd()%2+4; // left [4,5]
}
else if( dx == (range+1) ){
if(dy>0) dir=rnd()%2+6; // left [6,7]
if(dy<0) dir=rnd()%2+5; // left [5,6]
}
if( dx == -range){
if(dy>0) dir=rnd()%2; // left [0,1]
if(dy<0) dir=rnd()%2+3; // left [3,4]
}
else if( dx == -(range+1) ){
if(dy>0) dir=rnd()%2+1; // left [1,2]
if(dy<0) dir=rnd()%2+2; // left [2,3]
}
}
else if( dx == range) dir=rnd()%3+5; // left [5,6,7]
else if( dx == -range) dir=rnd()%3+5; //right [5,6,7]
else if( dy == range) dir=rnd()%3; if(dir>=2) dir=7; //up [0,1,7] if 2
else if( dy == -range) dir=rnd()%3+3; //down [3,4,5]
}
else if(abs(dx) == range && abs(dy) == range){ //on edge corner
if(dx>0 && dx == dy ) dir=rnd()%3+6; if(dir>7) dir=0; // right-up [0,6,7] if 8
else if(dx>0 && dx == -dy) dir=rnd()%3+4; //right-down [4,5,6]
else if( dy == dx) dir=rnd()%3+2; //left-down [2,3,4]
else if( dy == -dx) dir=rnd()%3; //left-up [0,1,2]
}
else //splah from edge push us away
dir = map_calc_dir(bl,skill_area_temp[4],skill_area_temp[5]);
ShowInfo("srcx=%d,srcy=%d, blx=%d,bly=%d, \n\tdx=%d, dy=%d => dir=%d\n",
skill_area_temp[4],skill_area_temp[5],bl->x,bl->y,
dx,dy,dir);
break;
}
http://rathena.org/board/index.php?app=core&module=attach§ion=attach&attach_rel_module=tracker&attach_id=6664