From 531c41a41d40857359bda2f35ce3d51539d9fee8 Mon Sep 17 00:00:00 2001 From: ultramage Date: Fri, 6 Jul 2007 20:51:01 +0000 Subject: * Cleaned up some nasty code related to skill_blown - split 'direction' value from flags - moved (almost) entire direction calculating code to the outside - bowling bash now has the 'suck-in' effect (knockback is now done in the direction you were last facing, not in your-target direction) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10861 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/map.c | 64 ++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 27 deletions(-) (limited to 'src/map/map.c') diff --git a/src/map/map.c b/src/map/map.c index 89494a65d..cac652ae8 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -2146,36 +2146,46 @@ int map_check_dir(int s_dir,int t_dir) } /*========================================== - * Returns the direction of the given cell in absolute relation to the char - * (regardless of where the char is facing) + * Returns the direction of the given cell, relative to 'src' *------------------------------------------*/ -int map_calc_dir( struct block_list *src,int x,int y) +int map_calc_dir(struct block_list* src, int x, int y) { - int dir=0; - int dx,dy; - + int dir = 0; + int dx, dy; + nullpo_retr(0, src); - - dx=x-src->x; - dy=y-src->y; - if( dx==0 && dy==0 ){ // 彼我の場所一致 - dir=0; // 上 - }else if( dx>=0 && dy>=0 ){ // 方向的に右上 - dir=7; // 右上 - if( dx*2-1dy*2 ) dir=6; // 右 - }else if( dx>=0 && dy<=0 ){ // 方向的に右下 - dir=5; // 右下 - if( dx*2-1<-dy ) dir=4; // 下 - if( dx>-dy*2 ) dir=6; // 右 - }else if( dx<=0 && dy<=0 ){ // 方向的に左下 - dir=3; // 左下 - if( dx*2+1>dy ) dir=4; // 下 - if( dxdy*2 ) dir=2; // 左 + + dx = x-src->x; + dy = y-src->y; + if( dx == 0 && dy == 0 ) + { // both are standing on the same spot + //dir = 6; // aegis-style, causes knockback to the left + dir = unit_getdir(src); // athena-style, causes knockback opposite to src's current direction + } + else if( dx >= 0 && dy >=0 ) + { // upper-right + if( dx*2-1 < dy ) dir = 0; // up + else if( dx > dy*2 ) dir = 6; // right + else dir = 7; // up-right + } + else if( dx >= 0 && dy <= 0 ) + { // lower-right + if( dx*2-1 < -dy ) dir = 4; // down + else if( dx > -dy*2 ) dir = 6; // right + else dir = 5; // down-right + } + else if( dx <= 0 && dy <= 0 ) + { // lower-left + if( dx*2+1 > dy ) dir = 4; // down + else if( dx < dy*2 ) dir = 2; // left + else dir = 3; // down-left + } + else + { // upper-left + if( -dx*2-1 < dy ) dir = 0; // up + else if( -dx > dy*2 ) dir = 2; // left + else dir = 1; // up-left + } return dir; } -- cgit v1.2.3-70-g09d2