Skip to content

Commit

Permalink
Merge pull request #3244 from csnv/fix/cell-nostack-path
Browse files Browse the repository at this point in the history
Fixed CELL_NOSTACK making mob ai not being able to reach target under certain conditions
  • Loading branch information
MishimaHaruna authored Nov 22, 2023
2 parents 95d8d08 + 7fa3dd6 commit 08790bc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/map/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -3242,14 +3242,18 @@ static int map_getcellp(struct map_data *m, const struct block_list *bl, int16 x
// special checks
case CELL_CHKPASS:
#ifdef CELL_NOSTACK
if (cell.cell_bl >= battle_config.custom_cell_stack_limit) return 0;
if (cell.cell_bl >= battle_config.custom_cell_stack_limit)
return 0;
FALLTHROUGH
#endif
case CELL_CHKREACH:
return (cell.walkable);

case CELL_CHKNOPASS:
#ifdef CELL_NOSTACK
if (cell.cell_bl >= battle_config.custom_cell_stack_limit) return 1;
if (cell.cell_bl >= battle_config.custom_cell_stack_limit)
return 1;
FALLTHROUGH
#endif
case CELL_CHKNOREACH:
return (!cell.walkable);
Expand Down
7 changes: 7 additions & 0 deletions src/map/mob.c
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,14 @@ static int mob_ai_sub_hard_activesearch(struct block_list *bl, va_list ap)
#ifdef ACTIVEPATHSEARCH
struct walkpath_data wpd;
bool is_standing = (md->ud.walktimer == INVALID_TIMER);
#ifdef CELL_NOSTACK
// Do not count target's cell
short x, y;
if ((unit->can_reach_bl(&md->bl, bl, distance_bl(&md->bl, bl) + 1, 1, &x, &y)
&& !path->search(&wpd, &md->bl, md->bl.m, md->bl.x, md->bl.y, x, y, 0, CELL_CHKNOPASS)) // Count walk path cells
#else
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
#endif
|| (is_standing && wpd.path_len > md->db->range2) //Standing monsters use range2, walking monsters use range3
|| (!is_standing && wpd.path_len > md->db->range3)) {
if (!check_distance_bl(&md->bl, bl, md->status.rhw.range)
Expand Down

0 comments on commit 08790bc

Please sign in to comment.