Fixes script commands unitwalkto/unitwalk (#7007)

* Fixes #5340.
* Resolves an issue where monsters may tend to lose their target if they are too slow and the destination is too far when using script commands unitwalkto/unitwalk.
* Allow script command unitstopwalk to remove the state tracking for script commands unitwalk/unitwalkto.
* Print a warning to the console if a unit is forced to walk again and hasn't yet reached its initial destination.
Thanks to @NeutralDev and @Lemongrass3110!
This commit is contained in:
Aleos
2022-06-07 15:07:51 -04:00
committed by GitHub
parent 2bb79d0200
commit aad3a70bbc
5 changed files with 44 additions and 7 deletions

View File

@@ -435,7 +435,7 @@ static TIMER_FUNC(unit_walktoxy_timer)
//Monsters can only leave icewalls to the west and south
//But if movement fails more than icewall_walk_block times, they can ignore this rule
if(md && md->walktoxy_fail_count < icewall_walk_block && map_getcell(bl->m,x,y,CELL_CHKICEWALL) && (dx > 0 || dy > 0)) {
if(md && !ud->state.force_walk && md->walktoxy_fail_count < icewall_walk_block && map_getcell(bl->m,x,y,CELL_CHKICEWALL) && (dx > 0 || dy > 0)) {
//Needs to be done here so that rudeattack skills are invoked
md->walktoxy_fail_count++;
clif_fixpos(bl);
@@ -472,6 +472,8 @@ static TIMER_FUNC(unit_walktoxy_timer)
}
#endif
ud->state.force_walk = false;
if (ud->walk_done_event[0]){
char walk_done_event[EVENT_NAME_LENGTH];
@@ -526,7 +528,7 @@ static TIMER_FUNC(unit_walktoxy_timer)
md->min_chase--;
// Walk skills are triggered regardless of target due to the idle-walk mob state.
// But avoid triggering on stop-walk calls.
if(tid != INVALID_TIMER &&
if(!ud->state.force_walk && tid != INVALID_TIMER &&
!(ud->walk_count%WALK_SKILL_INTERVAL) &&
map[bl->m].users > 0 &&
mobskill_use(md, tick, -1)) {