How to interrupt AIs movement

Other plugins for extending OpenKore's functionality. This forum is only for posting new plugins and commenting on existing plugins. For support, use the Support forum.

Moderator: Moderators

Message
Author
Tanatoo
Noob
Noob
Posts: 2
Joined: 30 Oct 2011, 15:20
Noob?: Yes

How to interrupt AIs movement

#1 Post by Tanatoo »

Good day.

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");
	}
}
This method works.
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();
				}
			}
		}	
	}
}
This does not work. "MapRoute" is not found. I must repeat that there is no "MapRoute" task (or any similar) in activeTasks, I checked that many times.

My question is - how to find the movement task? Or is it a dead end, and there is another method to interrupt movement behavior?

vitriol
Plain Yogurt
Plain Yogurt
Posts: 61
Joined: 19 Apr 2011, 23:26
Noob?: No

Re: How to interrupt AIs movement

#2 Post by vitriol »

getRouteString in CalcMapRoute.pm has the map-by-map route.

You can save the string and somehow re-apply it when resuming. But it appears that the exact steps through the map are only calculated by a limited number of steps at a time, defined as route_step in the config files. So even if you save the route and have the bot resume, he will still have to recalculate the exact step sequence each time the route_step has been exhausted

Post Reply