Skip to content

Commit

Permalink
Added config option to keep direction for free cells
Browse files Browse the repository at this point in the history
Fixes bug making characters loop through busy cells
  • Loading branch information
csnv committed Oct 29, 2023
1 parent b097666 commit d8df290
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
8 changes: 8 additions & 0 deletions conf/map/battle/misc.conf
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ duel_only_on_same_map: false
official_cell_stack_limit: 1
custom_cell_stack_limit: 1

// Take into consideration the character's walking direction when searching for free cells?
// Set this to "true" to start searching for free cells in the same direction as the
// character came from
// Set this to "false" to always start searching from EAST (official behavior)
// Note: This setting also makes groups of mobs disperse in circular fashion
// instead of linear
keep_dir_free_cell: false

// Check occupied cells while walking? (Note 1)
check_occupied_cells: true

Expand Down
1 change: 1 addition & 0 deletions src/map/battle.c
Original file line number Diff line number Diff line change
Expand Up @@ -7573,6 +7573,7 @@ static const struct config_data_old battle_data[] = {
{ "official_cell_stack_limit", &battle_config.official_cell_stack_limit, 1, 0, 255, },
{ "custom_cell_stack_limit", &battle_config.custom_cell_stack_limit, 1, 1, 255, },
{ "dancing_weaponswitch_fix", &battle_config.dancing_weaponswitch_fix, 1, 0, 1, },
{ "keep_dir_free_cell", &battle_config.keep_dir_free_cell, 0, 0, 1, },
{ "check_occupied_cells", &battle_config.check_occupied_cells, 1, 0, 1, },

// eAthena additions
Expand Down
1 change: 1 addition & 0 deletions src/map/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ struct Battle_Config {
int bone_drop;
int buyer_name;
int dancing_weaponswitch_fix;
int keep_dir_free_cell;

// eAthena additions
int night_at_start; // added by [Yor]
Expand Down
9 changes: 7 additions & 2 deletions src/map/clif.c
Original file line number Diff line number Diff line change
Expand Up @@ -11831,9 +11831,14 @@ static void clif_parse_WalkToXY(int fd, struct map_session_data *sd)
if(sd->sc.data[SC_RUN] || sd->sc.data[SC_WUGDASH])
return;

pc->delinvincibletimer(sd);
RFIFOPOS(fd, packet_db[RFIFOW(fd, 0)].pos[0], &x, &y, NULL);

// Do not allow one cell move commands if the target cell is not free
if (battle_config.official_cell_stack_limit > 0
&& check_distance_blxy(&sd->bl, x, y, 1) && map->count_oncell(sd->bl.m, x, y, BL_CHAR | BL_NPC, 1))
return;

RFIFOPOS(fd, packet_db[RFIFOW(fd,0)].pos[0], &x, &y, NULL);
pc->delinvincibletimer(sd);

//Set last idle time... [Skotlex]
pc->update_idle_time(sd, BCIDLE_WALK);
Expand Down
2 changes: 1 addition & 1 deletion src/map/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -1749,7 +1749,7 @@ static int map_search_free_cell(struct block_list *src, int16 m, int16 *x, int16
*------------------------------------------*/
static bool map_closest_freecell(int16 m, const struct block_list *bl, int16 *x, int16 *y, int type, int flag)
{
enum unit_dir dir = UNIT_DIR_EAST;
enum unit_dir dir = battle_config.keep_dir_free_cell ? unit->getdir(bl) : UNIT_DIR_EAST;
int16 tx;
int16 ty;
int costrange = 10;
Expand Down

0 comments on commit d8df290

Please sign in to comment.