From b8abf962fd079bc3cad4498aa968f2318d1f5fde Mon Sep 17 00:00:00 2001 From: Michieru Date: Mon, 3 Nov 2014 11:46:22 +0100 Subject: * No cell stacking implemented (official version) - Split config cell_stack_limit into custom_cell_stack_limit (previous feature) and official_cell_stack_limit (see below) - Expanded map_count_oncell by a flag parameter, currently only one flag is supported: only count standing units (needed for official cell stack feature) - Added a new function map_closest_freecell that will return the closest free cell using the same order that official servers use - Monsters will now actively search for a free cell when starting to walk randomly and when unlocking target - When any unit finishes walking (regularly) and is not on a free cell, it will now actively search for a free cell - Step actions will be delayed until a suitable cell was found, they will even be executed when the player walked slightly out of attack range - Monsters will now stop instantly if their target is completely non-existent * This is mainly for looters that had their loot taken * Hide and most other situations still use the configuration setting monster_chase_refresh Mega Thanks to Playtester --- src/map/mob.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/map/mob.c') diff --git a/src/map/mob.c b/src/map/mob.c index 23706d293..c05f4c4a2 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -1303,6 +1303,10 @@ int mob_unlocktarget(struct mob_data *md, int64 tick) { md->ud.target_to = 0; unit->set_target(&md->ud, 0); } + if(map->count_oncell(md->bl.m, md->bl.x, md->bl.y, BL_CHAR|BL_NPC, 1) > battle_config.official_cell_stack_limit) { + unit->walktoxy(&md->bl, md->bl.x, md->bl.y, 8); + } + return 0; } /*========================================== @@ -1330,7 +1334,7 @@ int mob_randomwalk(struct mob_data *md, int64 tick) { x+=md->bl.x; y+=md->bl.y; - if(((x != md->bl.x) || (y != md->bl.y)) && map->getcell(md->bl.m,x,y,CELL_CHKPASS) && unit->walktoxy(&md->bl,x,y,0)){ + if(((x != md->bl.x) || (y != md->bl.y)) && map->getcell(md->bl.m,x,y,CELL_CHKPASS) && unit->walktoxy(&md->bl,x,y,8)){ break; } } @@ -1429,8 +1433,9 @@ bool mob_ai_sub_hard(struct mob_data *md, int64 tick) { //No valid target if (mob->warpchase(md, tbl)) return true; //Chasing this target. - if(md->ud.walktimer != INVALID_TIMER && (!can_move || md->ud.walkpath.path_pos <= battle_config.mob_chase_refresh)) - return true; //Walk at least "mob_chase_refresh" cells before dropping the target + if(md->ud.walktimer != INVALID_TIMER && (!can_move || md->ud.walkpath.path_pos <= battle_config.mob_chase_refresh) + && (tbl || md->ud.walkpath.path_pos == 0)) + return true; //Walk at least "mob_chase_refresh" cells before dropping the target unless target is non-existent mob_unlocktarget(md, tick); //Unlock target tbl = NULL; } -- cgit v1.2.3-70-g09d2