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

@@ -1687,6 +1687,10 @@ static bool mob_ai_sub_hard(struct mob_data *md, t_tick tick)
if(md->bl.prev == nullptr || md->status.hp == 0)
return false;
// Monsters force-walked by script commands should not be searching for targets.
if (md->ud.state.force_walk)
return false;
if (DIFF_TICK(tick, md->last_thinktime) < MIN_MOBTHINKTIME)
return false;
@@ -2005,6 +2009,10 @@ static int mob_ai_sub_lazy(struct mob_data *md, va_list args)
if(md->bl.prev == NULL)
return 0;
// Monsters force-walked by script commands should not be searching for targets.
if (md->ud.state.force_walk)
return false;
t_tick tick = va_arg(args,t_tick);
if (battle_config.mob_ai&0x20 && map_getmapdata(md->bl.m)->users>0)