I am making my first plugin. Its quite simple yet, but gonna be a complex party management plugin in future.
For right now I am stuck in one problem. I cannot find out how to pause the bots movement, and resume it later. I mean only movement should be paused, all other behaviors should be working as usual.
Possible solutions I tried:
1. Console command "move stop".
Code: Select all
my $aiHook = Plugins::addHook("AI_pre", \&on_AI);
sub on_AI {
if (isStopRequired())
{
Commands::run("move stop");
}
}
But, it spams "Stopped all movement" messages on the screen, and, which is more important, it forces the AI to recalculate the route. I need to resume the old route, which was before movement stopped.
2. taskManager.
I found that there is an object called taskManager, which contains activeTasks array. I thought I should find a task responsible for movement (it should be called "MapRoute" or smth like that), then deactivate that task and activate it later. But, when I looked through all the activeTasks, there only 2 of them: RaiseSkill, RaiseStat. That's it. No MapRoute task!
Code: Select all
my $aiHook = Plugins::addHook("AI_pre", \&on_AI);
sub on_AI {
if (isStopRequired())
{
foreach ($taskManager->{activeTasks})
{
for my $i (0 .. $_->size() - 1)
{
my $task = $_->get($i);
if ($task->getName() eq "MapRoute")
{
$task->interrupt();
}
}
}
}
}
My question is - how to find the movement task? Or is it a dead end, and there is another method to interrupt movement behavior?