* Removed old code for Sharp Shooting
* Merged Shinomori's code into map_foreachinpath git-svn-id: https://svn.code.sf.net/p/rathena/svn/branches/stable@1089 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
parent
98351a8dd8
commit
5365aefea8
@ -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
|
||||
|
@ -8,6 +8,7 @@
|
||||
#else
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
#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;i<c && bl;i++,bl=bl->next){
|
||||
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_count<BL_LIST_MAX)
|
||||
bl_list[bl_list_count++]=bl;
|
||||
if (type && bl->type!=type)
|
||||
continue;
|
||||
for(t=0; t<=tmax; t++)
|
||||
if(bl->x==xs[t] && bl->y==ys[t] && bl_list_count<BL_LIST_MAX)
|
||||
bl_list[bl_list_count++]=bl;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -741,12 +729,9 @@ void map_foreachinpath(int (*func)(struct block_list*,va_list),int m,int x0,int
|
||||
c = map[m].block_mob_count[bx+by*map[m].bxs];
|
||||
for(i=0;i<c && bl;i++,bl=bl->next){
|
||||
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_count<BL_LIST_MAX)
|
||||
bl_list[bl_list_count++]=bl;
|
||||
for(t=0; t<=tmax; t++)
|
||||
if(bl->x==xs[t] && bl->y==ys[t] && bl_list_count<BL_LIST_MAX)
|
||||
bl_list[bl_list_count++]=bl;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -765,8 +750,10 @@ void map_foreachinpath(int (*func)(struct block_list*,va_list),int m,int x0,int
|
||||
|
||||
map_freeblock_unlock(); // ‰ð•ú‚ð‹–‰Â‚·‚é
|
||||
|
||||
va_end(ap);
|
||||
bl_list_count = blockcount;
|
||||
aFree (xs);
|
||||
aFree (ys);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
/*==========================================
|
||||
|
@ -689,7 +689,7 @@ void map_foreachinarea(int (*)(struct block_list*,va_list),int,int,int,int,int,i
|
||||
// -- moonsoul (added map_foreachincell)
|
||||
void map_foreachincell(int (*)(struct block_list*,va_list),int,int,int,int,...);
|
||||
void map_foreachinmovearea(int (*)(struct block_list*,va_list),int,int,int,int,int,int,int,int,...);
|
||||
void map_foreachinpath(int (*)(struct block_list*,va_list),int,int,int,int,int,int,int,int,...); // Celest
|
||||
void map_foreachinpath(int (*)(struct block_list*,va_list),int,int,int,int,int,int,...); // Celest
|
||||
int map_countnearpc(int,int,int);
|
||||
//block関連に追加
|
||||
int map_count_oncell(int m,int x,int y);
|
||||
|
@ -2297,62 +2297,8 @@ int skill_castend_damage_id( struct block_list* src, struct block_list *bl,int s
|
||||
break;
|
||||
|
||||
case SN_SHARPSHOOTING: /* シャ?プシュ?ティング */
|
||||
{
|
||||
#if 0 // temporarily keeping this block for future reference [celest]
|
||||
/*int dx, dy, wx = 0, wy = 0;
|
||||
int weight, num = 0;
|
||||
int x1 = src->x, 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: /* プレッシャ? */
|
||||
|
Loading…
x
Reference in New Issue
Block a user