Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed CELL_NOSTACK making mob ai not being able to reach target under certain conditions #3244

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading