diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-09-10 19:12:45 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-09-10 19:23:17 +0300 |
commit | dc45b9c29cfcf7c64f95dc9f81b1612dda68341d (patch) | |
tree | 194eb0b7f881d436cca129ece3c69bd75e68fc24 /src | |
parent | c76aa5f4843a521b1839875bf6c139f4658bd6d1 (diff) | |
download | hercules-dc45b9c29cfcf7c64f95dc9f81b1612dda68341d.tar.gz hercules-dc45b9c29cfcf7c64f95dc9f81b1612dda68341d.tar.bz2 hercules-dc45b9c29cfcf7c64f95dc9f81b1612dda68341d.tar.xz hercules-dc45b9c29cfcf7c64f95dc9f81b1612dda68341d.zip |
Add to path search functions source bl for plugins usage.
Diffstat (limited to 'src')
-rw-r--r-- | src/map/battle.c | 2 | ||||
-rw-r--r-- | src/map/map.c | 6 | ||||
-rw-r--r-- | src/map/mob.c | 2 | ||||
-rw-r--r-- | src/map/path.c | 6 | ||||
-rw-r--r-- | src/map/path.h | 6 | ||||
-rw-r--r-- | src/map/skill.c | 20 | ||||
-rw-r--r-- | src/map/unit.c | 20 |
7 files changed, 31 insertions, 31 deletions
diff --git a/src/map/battle.c b/src/map/battle.c index 6536e54c4..6a6924aa3 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -6689,7 +6689,7 @@ bool battle_check_range(struct block_list *src, struct block_list *bl, int range if( d > AREA_SIZE ) return false; // Avoid targeting objects beyond your range of sight. - return path->search_long(NULL,src->m,src->x,src->y,bl->x,bl->y,CELL_CHKWALL); + return path->search_long(NULL,src,src->m,src->x,src->y,bl->x,bl->y,CELL_CHKWALL); } static const struct battle_data { diff --git a/src/map/map.c b/src/map/map.c index 6e35e6bb6..ab34799ee 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -840,7 +840,7 @@ static int bl_vgetall_inshootrange(struct block_list *bl, va_list args) if (!check_distance_bl(center, bl, range)) return 0; #endif - if (!path->search_long(NULL, center->m, center->x, center->y, bl->x, bl->y, CELL_CHKWALL)) + if (!path->search_long(NULL, center, center->m, center->x, center->y, bl->x, bl->y, CELL_CHKWALL)) return 0; return 1; } @@ -1195,7 +1195,7 @@ static int bl_vgetall_inpath(struct block_list *bl, va_list args) if ( k < 0 || k > len_limit ) //Since more skills use this, check for ending point as well. return 0; - if ( k > magnitude2 && !path->search_long(NULL, m, x0, y0, xi, yi, CELL_CHKWALL) ) + if ( k > magnitude2 && !path->search_long(NULL, NULL, m, x0, y0, xi, yi, CELL_CHKWALL) ) return 0; //Targets beyond the initial ending point need the wall check. //All these shifts are to increase the precision of the intersection point and distance considering how it's @@ -2567,7 +2567,7 @@ int map_random_dir(struct block_list *bl, int16 *x, int16 *y) xi = bl->x + segment*dirx[j]; segment = (short)sqrt((float)(dist2 - segment*segment)); //The complement of the previously picked segment yi = bl->y + segment*diry[j]; - } while ( (map->getcell(bl->m,xi,yi,CELL_CHKNOPASS) || !path->search(NULL,bl->m,bl->x,bl->y,xi,yi,1,CELL_CHKNOREACH)) + } while ( (map->getcell(bl->m,xi,yi,CELL_CHKNOPASS) || !path->search(NULL,bl,bl->m,bl->x,bl->y,xi,yi,1,CELL_CHKNOREACH)) && (++i)<100 ); if (i < 100) { diff --git a/src/map/mob.c b/src/map/mob.c index f64c7e582..8c5e398b7 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -1079,7 +1079,7 @@ int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap) ) { //Pick closest target? #ifdef ACTIVEPATHSEARCH struct walkpath_data wpd; - if (!path->search(&wpd, md->bl.m, md->bl.x, md->bl.y, bl->x, bl->y, 0, CELL_CHKNOPASS)) // Count walk path cells + if (!path->search(&wpd, &md->bl, md->bl.m, md->bl.x, md->bl.y, bl->x, bl->y, 0, CELL_CHKNOPASS)) // Count walk path cells return 0; //Standing monsters use range2, walking monsters use range3 if ((md->ud.walktimer == INVALID_TIMER && wpd.path_len > md->db->range2) diff --git a/src/map/path.c b/src/map/path.c index 723fd8e8f..d56994fb4 100644 --- a/src/map/path.c +++ b/src/map/path.c @@ -69,7 +69,7 @@ static const unsigned char walk_choices [3][3] = * Find the closest reachable cell, 'count' cells away from (x0,y0) in direction (dx,dy). * Income after the coordinates of the blow *------------------------------------------*/ -int path_blownpos(int16 m,int16 x0,int16 y0,int16 dx,int16 dy,int count) +int path_blownpos(struct block_list *bl, int16 m,int16 x0,int16 y0,int16 dx,int16 dy,int count) { struct map_data *md; @@ -102,7 +102,7 @@ int path_blownpos(int16 m,int16 x0,int16 y0,int16 dx,int16 dy,int count) /*========================================== * is ranged attack from (x0,y0) to (x1,y1) possible? *------------------------------------------*/ -bool path_search_long(struct shootpath_data *spd,int16 m,int16 x0,int16 y0,int16 x1,int16 y1,cell_chk cell) +bool path_search_long(struct shootpath_data *spd,struct block_list *bl,int16 m,int16 x0,int16 y0,int16 x1,int16 y1,cell_chk cell) { int dx, dy; int wx = 0, wy = 0; @@ -236,7 +236,7 @@ static int add_path(struct node_heap *heap, struct path_node *tp, int16 x, int16 * flag: &1 = easy path search only * cell: type of obstruction to check for *------------------------------------------*/ -bool path_search(struct walkpath_data *wpd, int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int flag, cell_chk cell) +bool path_search(struct walkpath_data *wpd, struct block_list *bl, int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int flag, cell_chk cell) { register int i, j, x, y, dx, dy; struct map_data *md; diff --git a/src/map/path.h b/src/map/path.h index 2ece8f84b..14885d566 100644 --- a/src/map/path.h +++ b/src/map/path.h @@ -42,11 +42,11 @@ struct shootpath_data { struct path_interface { // calculates destination cell for knockback - int (*blownpos) (int16 m, int16 x0, int16 y0, int16 dx, int16 dy, int count); + int (*blownpos) (struct block_list *bl, int16 m, int16 x0, int16 y0, int16 dx, int16 dy, int count); // tries to find a walkable path - bool (*search) (struct walkpath_data *wpd, int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int flag, cell_chk cell); + bool (*search) (struct walkpath_data *wpd, struct block_list *bl, int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int flag, cell_chk cell); // tries to find a shootable path - bool (*search_long) (struct shootpath_data *spd, int16 m, int16 x0, int16 y0, int16 x1, int16 y1, cell_chk cell); + bool (*search_long) (struct shootpath_data *spd, struct block_list *bl, int16 m, int16 x0, int16 y0, int16 x1, int16 y1, cell_chk cell); bool (*check_distance) (int dx, int dy, int distance); unsigned int (*distance) (int dx, int dy); bool (*check_distance_client) (int dx, int dy, int distance); diff --git a/src/map/skill.c b/src/map/skill.c index 2582ca2b6..6e50a3116 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -3374,13 +3374,13 @@ int skill_timerskill(int tid, int64 tick, int id, intptr_t data) { case WZ_METEOR: if( skl->type >= 0 ) { int x = skl->type>>16, y = skl->type&0xFFFF; - if( path->search_long(NULL, src->m, src->x, src->y, x, y, CELL_CHKWALL) ) + if( path->search_long(NULL, src, src->m, src->x, src->y, x, y, CELL_CHKWALL) ) skill->unitsetting(src,skl->skill_id,skl->skill_lv,x,y,skl->flag); - if( path->search_long(NULL, src->m, src->x, src->y, skl->x, skl->y, CELL_CHKWALL) + if( path->search_long(NULL, src, src->m, src->x, src->y, skl->x, skl->y, CELL_CHKWALL) && !map->getcell(src->m, skl->x, skl->y, CELL_CHKLANDPROTECTOR) ) clif->skill_poseffect(src,skl->skill_id,skl->skill_lv,skl->x,skl->y,tick); } - else if( path->search_long(NULL, src->m, src->x, src->y, skl->x, skl->y, CELL_CHKWALL) ) + else if( path->search_long(NULL, src, src->m, src->x, src->y, skl->x, skl->y, CELL_CHKWALL) ) skill->unitsetting(src,skl->skill_id,skl->skill_lv,skl->x,skl->y,skl->flag); break; case GN_CRAZYWEED_ATK: { @@ -3724,7 +3724,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 break; case KN_CHARGEATK: { - bool path_exists = path->search_long(NULL, src->m, src->x, src->y, bl->x, bl->y,CELL_CHKWALL); + bool path_exists = path->search_long(NULL, src, src->m, src->x, src->y, bl->x, bl->y,CELL_CHKWALL); unsigned int dist = distance_bl(src, bl); uint8 dir = map->calc_dir(bl, src->x, src->y); @@ -4492,7 +4492,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 break; case WL_FROSTMISTY: // Doesn't deal damage through non-shootable walls. - if( path->search(NULL,src->m,src->x,src->y,bl->x,bl->y,1,CELL_CHKWALL) ) + if( path->search(NULL,src,src->m,src->x,src->y,bl->x,bl->y,1,CELL_CHKWALL) ) skill->attack(BF_MAGIC,src,src,bl,skill_id,skill_lv,tick,flag|SD_ANIMATION); break; case WL_HELLINFERNO: @@ -4514,7 +4514,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 break; } case RA_WUGBITE: - if( path->search(NULL,src->m,src->x,src->y,bl->x,bl->y,1,CELL_CHKNOREACH) ) { + if( path->search(NULL,src,src->m,src->x,src->y,bl->x,bl->y,1,CELL_CHKNOREACH) ) { skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag); }else if( sd && skill_id == RA_WUGBITE ) // Only RA_WUGBITE has the skill fail message. clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0); @@ -4945,7 +4945,7 @@ int skill_castend_id(int tid, int64 tick, int id, intptr_t data) { } if( ud->skill_id == RA_WUGSTRIKE ){ - if( !path->search(NULL,src->m,src->x,src->y,target->x,target->y,1,CELL_CHKNOREACH)) + if( !path->search(NULL,src,src->m,src->x,src->y,target->x,target->y,1,CELL_CHKNOREACH)) break; } @@ -5037,7 +5037,7 @@ int skill_castend_id(int tid, int64 tick, int id, intptr_t data) { skill->consume_requirement(sd,ud->skill_id,ud->skill_lv,1); } #ifdef OFFICIAL_WALKPATH - if( !path->search_long(NULL, src->m, src->x, src->y, target->x, target->y, CELL_CHKWALL) ) + if( !path->search_long(NULL, src, src->m, src->x, src->y, target->x, target->y, CELL_CHKWALL) ) break; #endif if( (src->type == BL_MER || src->type == BL_HOM) && !skill->check_condition_mercenary(src, ud->skill_id, ud->skill_lv, 1) ) @@ -10460,7 +10460,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui tmpx = x - area + rnd()%(area * 2 + 1); tmpy = y - area + rnd()%(area * 2 + 1); - if( i == 0 && path->search_long(NULL, src->m, src->x, src->y, tmpx, tmpy, CELL_CHKWALL) + if( i == 0 && path->search_long(NULL, src, src->m, src->x, src->y, tmpx, tmpy, CELL_CHKWALL) && !map->getcell(src->m, tmpx, tmpy, CELL_CHKLANDPROTECTOR)) clif->skill_poseffect(src,skill_id,skill_lv,tmpx,tmpy,tick); @@ -11453,7 +11453,7 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_ if( !group->state.song_dance && !map->getcell(src->m,ux,uy,CELL_CHKREACH) ) continue; // don't place skill units on walls (except for songs/dances/encores) - if( battle_config.skill_wall_check && skill->get_unit_flag(skill_id)&UF_PATHCHECK && !path->search_long(NULL,src->m,ux,uy,x,y,CELL_CHKWALL) ) + if( battle_config.skill_wall_check && skill->get_unit_flag(skill_id)&UF_PATHCHECK && !path->search_long(NULL,src,src->m,ux,uy,x,y,CELL_CHKWALL) ) continue; // no path between cell and center of casting. switch( skill_id ) { diff --git a/src/map/unit.c b/src/map/unit.c index 33360584a..02d1f4c1a 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -98,11 +98,11 @@ int unit_walktoxy_sub(struct block_list *bl) memset(&wpd, 0, sizeof(wpd)); - if( !path->search(&wpd,bl->m,bl->x,bl->y,ud->to_x,ud->to_y,ud->state.walk_easy,CELL_CHKNOPASS) ) + if( !path->search(&wpd,bl,bl->m,bl->x,bl->y,ud->to_x,ud->to_y,ud->state.walk_easy,CELL_CHKNOPASS) ) return 0; #ifdef OFFICIAL_WALKPATH - if( !path->search_long(NULL, bl->m, bl->x, bl->y, ud->to_x, ud->to_y, CELL_CHKNOPASS) // Check if there is an obstacle between + if( !path->search_long(NULL, bl, bl->m, bl->x, bl->y, ud->to_x, ud->to_y, CELL_CHKNOPASS) // Check if there is an obstacle between && wpd.path_len > 14 // Official number of walkable cells is 14 if and only if there is an obstacle between. [malufett] && (bl->type != BL_NPC) ) // If type is a NPC, please disregard. return 0; @@ -497,11 +497,11 @@ int unit_walktoxy( struct block_list *bl, short x, short y, int flag) if (battle_config.check_occupied_cells && (flag&8) && !map->closest_freecell(bl->m, &x, &y, BL_CHAR|BL_NPC, 1)) //This might change x and y return 0; - if (!path->search(&wpd, bl->m, bl->x, bl->y, x, y, flag&1, CELL_CHKNOPASS)) // Count walk path cells + if (!path->search(&wpd, bl, bl->m, bl->x, bl->y, x, y, flag&1, CELL_CHKNOPASS)) // Count walk path cells return 0; #ifdef OFFICIAL_WALKPATH - if( !path->search_long(NULL, bl->m, bl->x, bl->y, x, y, CELL_CHKNOPASS) // Check if there is an obstacle between + if( !path->search_long(NULL, bl, bl->m, bl->x, bl->y, x, y, CELL_CHKNOPASS) // Check if there is an obstacle between && (wpd.path_len > (battle_config.max_walk_path/17)*14) // Official number of walkable cells is 14 if and only if there is an obstacle between. [malufett] && (bl->type != BL_NPC) ) // If type is a NPC, please disregard. return 0; @@ -741,7 +741,7 @@ int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool unit->stop_walking(bl, STOPWALKING_FLAG_FIXPOS); unit->stop_attack(bl); - if( checkpath && (map->getcell(bl->m,dst_x,dst_y,CELL_CHKNOPASS) || !path->search(NULL,bl->m,bl->x,bl->y,dst_x,dst_y,easy,CELL_CHKNOREACH)) ) + if( checkpath && (map->getcell(bl->m,dst_x,dst_y,CELL_CHKNOPASS) || !path->search(NULL,bl,bl->m,bl->x,bl->y,dst_x,dst_y,easy,CELL_CHKNOREACH)) ) return 0; // unreachable ud->to_x = dst_x; @@ -775,7 +775,7 @@ int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool { // Check if pet needs to be teleported. [Skotlex] int flag = 0; struct block_list* pbl = &sd->pd->bl; - if( !checkpath && !path->search(NULL,pbl->m,pbl->x,pbl->y,dst_x,dst_y,0,CELL_CHKNOPASS) ) + if( !checkpath && !path->search(NULL,pbl,pbl->m,pbl->x,pbl->y,dst_x,dst_y,0,CELL_CHKNOPASS) ) flag = 1; else if (!check_distance_bl(&sd->bl, pbl, AREA_SIZE)) //Too far, teleport. flag = 2; @@ -829,7 +829,7 @@ int unit_blown(struct block_list* bl, int dx, int dy, int count, int flag) sd = BL_CAST(BL_PC, bl); su = BL_CAST(BL_SKILL, bl); - result = path->blownpos(bl->m, bl->x, bl->y, dx, dy, count); + result = path->blownpos(bl, bl->m, bl->x, bl->y, dx, dy, count); nx = result>>16; ny = result&0xffff; @@ -1940,7 +1940,7 @@ bool unit_can_reach_pos(struct block_list *bl,int x,int y, int easy) if (bl->x == x && bl->y == y) //Same place return true; - return path->search(NULL,bl->m,bl->x,bl->y,x,y,easy,CELL_CHKNOREACH); + return path->search(NULL,bl,bl->m,bl->x,bl->y,x,y,easy,CELL_CHKNOREACH); } /*========================================== @@ -1978,7 +1978,7 @@ bool unit_can_reach_bl(struct block_list *bl,struct block_list *tbl, int range, if (x) *x = tbl->x-dx; if (y) *y = tbl->y-dy; - return path->search(NULL,bl->m,bl->x,bl->y,tbl->x-dx,tbl->y-dy,easy,CELL_CHKNOREACH); + return path->search(NULL,bl,bl->m,bl->x,bl->y,tbl->x-dx,tbl->y-dy,easy,CELL_CHKNOREACH); } /*========================================== * Calculates position of Pet/Mercenary/Homunculus/Elemental @@ -2064,7 +2064,7 @@ int unit_attack_timer_sub(struct block_list* src, int tid, int64 tick) { if( status->isdead(src) || status->isdead(target) || battle->check_target(src,target,BCT_ENEMY) <= 0 || !status->check_skilluse(src, target, 0, 0) #ifdef OFFICIAL_WALKPATH - || !path->search_long(NULL, src->m, src->x, src->y, target->x, target->y, CELL_CHKWALL) + || !path->search_long(NULL, src, src->m, src->x, src->y, target->x, target->y, CELL_CHKWALL) #endif || (sd && !pc->can_attack(sd, ud->target) ) ) |