From 2a27d5fccc9316594edcedefb7ad01ea6f33e8da Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@54d463be-8e91-2dee-dedb-b68131a5f0ec> Date: Sat, 12 Feb 2005 14:04:21 +0000 Subject: * Removed old code for Sharp Shooting * Merged Shinomori's code into map_foreachinpath git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1089 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-SVN.txt | 4 +++ src/map/map.c | 77 +++++++++++++++++++++++-------------------------------- src/map/map.h | 2 +- src/map/skill.c | 56 +--------------------------------------- 4 files changed, 38 insertions(+), 101 deletions(-) diff --git a/Changelog-SVN.txt b/Changelog-SVN.txt index a8c272a4f..b383c0d02 100644 --- a/Changelog-SVN.txt +++ b/Changelog-SVN.txt @@ -1,5 +1,9 @@ Date Added +02/12 + * Removed old code for Sharp Shooting (still a little buggy) [celest] + * Merged Shinomori's code into map_foreachinpath [celest] + 02/11 * mob.c fixed doubling entries in DROPS LOG, optimized [Lupus] * item_noequip.txt now you can disable named consumable items diff --git a/src/map/map.c b/src/map/map.c index 6cab9afba..110c70850 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -8,6 +8,7 @@ #else #include #endif +#include #include "core.h" #include "timer.h" @@ -656,14 +657,15 @@ void map_foreachincell(int (*func)(struct block_list*,va_list),int m,int x,int y * For checking a path between two points (x0, y0) and (x1, y1) *------------------------------------------------------------ */ -void map_foreachinpath(int (*func)(struct block_list*,va_list),int m,int x0,int y0,int x1,int y1,int range,int length,int type,...) { +void map_foreachinpath(int (*func)(struct block_list*,va_list),int m,int x0,int y0,int x1,int y1,int type,...) { va_list ap; - int bx,by; - struct block_list *bl=NULL; - int blockcount=bl_list_count,i,c; - double s; - int in; // slope, interception - + double deltax = 0.0; + double deltay = 0.0; + int t, bx, by; + int *xs, *ys; + int blockcount = bl_list_count, i, c; + struct block_list *bl = NULL; + if(m < 0) return; va_start(ap,type); @@ -672,31 +674,20 @@ void map_foreachinpath(int (*func)(struct block_list*,va_list),int m,int x0,int if (x1 >= map[m].xs) x1 = map[m].xs-1; if (y1 >= map[m].ys) y1 = map[m].ys-1; -// y = ax + c // ugh, algebra! xp -// x = (y - c) / a - if (x0 == x1) { - s = 999; in = 0; - } else if (y0 == y1) { - s = 0; in = y0; - } else { - s = (double)(y1 - y0)/(double)(x1 - x0); - in = y0 - s * x0; - } - //printf ("%lf %d\n", s, in); -// I'm not finished thinking on it -// but first it might better use a parameter equation -// x=(x1-x0)*t+x0; y=(y1-y0)*t+y0; t=[0,1] -// would not need special case aproximating for infinity/zero slope -// so maybe this way: -/* - double deltax = 0.0; - double deltay = 0.0; - int t; + // I'm not finished thinking on it + // but first it might better use a parameter equation + // x=(x1-x0)*t+x0; y=(y1-y0)*t+y0; t=[0,1] + // would not need special case aproximating for infinity/zero slope + // so maybe this way: + // find maximum runindex int tmax = abs(y1-y0); - if(tmax < abs(x1-x0)) + if(tmax < abs(x1-x0)) tmax = abs(x1-x0); + xs = (int *)aCallocA(tmax + 1, sizeof(int)); + ys = (int *)aCallocA(tmax + 1, sizeof(int)); + // pre-calculate delta values for x and y destination // should speed up cause you don't need to divide in the loop if(tmax>0) @@ -711,9 +702,9 @@ void map_foreachinpath(int (*func)(struct block_list*,va_list),int m,int x0,int int y = (int)floor(deltay * (double)t +0.5)+y0; // the xy pairs of points in line between x0y0 and x1y1 // including start and end point - printf("%i\t%i\n",x,y); + xs[t] = x; + ys[t] = y; } - */ if (type == 0 || type != BL_MOB) for (by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++) { @@ -721,15 +712,12 @@ void map_foreachinpath(int (*func)(struct block_list*,va_list),int m,int x0,int bl = map[m].block[bx+by*map[m].bxs]; c = map[m].block_count[bx+by*map[m].bxs]; for(i=0;inext){ - if(bl && type && bl->type!=type) - continue; if(bl) { - if (((s == 999 && bl->x == x0) || - (s == 0 && in == y0 && bl->y == y0) || - abs(s * bl->x + in - bl->y) <= range || - abs((bl->y - in)/s - bl->x) <= range) && - bl_list_counttype!=type) + continue; + for(t=0; t<=tmax; t++) + if(bl->x==xs[t] && bl->y==ys[t] && bl_list_countnext){ if(bl) { - if (((s == 999 && bl->x == x0) || - (s == 0 && in == y0 && bl->y == y0) || - abs(s * bl->x + in - bl->y) <= range || - abs((bl->y - in)/s - bl->x) <= range) && - bl_list_countx==xs[t] && bl->y==ys[t] && bl_list_countx, y1 = src->y; - int x0 = bl->x, y0 = bl->y; - int *xs, *ys; - - dx = (x1 - x0); - if (dx < 0) { - swap(x0, x1); - swap(y0, y1); - dx = -dx; - } - dy = (y1 - y0); - weight = dx > abs(dy) ? dx : abs(y1 - y0); - xs = (int *)aCallocA(weight, sizeof(int)); - ys = (int *)aCallocA(weight, sizeof(int)); - while ((x0 != x1 || y0 != y1) && num < skill_get_range(skillid,skilllv)) { // fixed [Shinomori] - wx += dx; - wy += dy; - if (wx >= weight) { - wx -= weight; x0 ++; - } - if (wy >= weight) { - wy -= weight; y0 ++; - } else if (wy < 0) { - wy += weight; y0 --; - } - if (x0 == x1) { - if (dy > 0) { y0++; } - else { y0--; } - } - //xs[number] = x0; - //ys[number] = y0 - printf ("%d - %d %d\n", weight, x0, y0); - //map_foreachinarea (skill_attack_area,src->m,x0,y0,x0,y0,0, - //BF_WEAPON,src,src,skillid,skilllv,tick,flag,BCT_ENEMY); - num++; // make sure it doesn't run infinitely - } - //for num = 0; num < weight; num++ - //map_foreach skill attack area - //if last of xs || ys != x y, manually skill attack - clif_skill_nodamage(src,bl,skillid,skilllv,1); - aFree (xs); - aFree (ys);*/ - #endif - - #if 0 // change 0 to 1 to switch to the this system [celest] - skill_attack(BF_WEAPON,src,src,bl,skillid,skilllv,tick,flag); - #else - map_foreachinpath (skill_attack_area,src->m,src->x,src->y,bl->x,bl->y, - 2,skill_get_range(skillid,skilllv),0, + map_foreachinpath (skill_attack_area,src->m,src->x,src->y,bl->x,bl->y,0, BF_WEAPON,src,src,skillid,skilllv,tick,flag,BCT_ENEMY); - #endif - } break; case PA_PRESSURE: /* プレッシャ? */ -- cgit v1.2.3-70-g09d2