Plan to walk in lock map !

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
crazydoy
Noob
Noob
Posts: 1
Joined: 17 Apr 2011, 06:55
Noob?: Yes

Re: Plan to walk in lock map !

#21 Post by crazydoy »

eee.... i noob in plugin those thg... so conclusion how to active the planWalk.pl, CoreLogic.pm and the planWalk.txt??
can someone send me pls... i see wat u all say n i try test but cant... pls help me... thanks

sofax222
Developers
Developers
Posts: 214
Joined: 24 Nov 2010, 03:08
Noob?: Yes

Re: Plan to walk in lock map !

#22 Post by sofax222 »

crazydoy wrote:eee.... i noob in plugin those thg... so conclusion how to active the planWalk.pl, CoreLogic.pm and the planWalk.txt??
can someone send me pls... i see wat u all say n i try test but cant... pls help me... thanks
Which one plugin you use ? planLockMapWalk.pl or planWalk.pl ?

If you use the "planLockMapWalk.pl" !

PS : "planLockMapWalk.pl" is the better one !
But, using the "planLockMapWalk.pl", You firstly have to modify the CoreLogic.pm program file.

If you use the "planLockMapWalk.pl", did you add the following setting in config.txt ?

Code: Select all

autoPlanLockMapWalk 1
planWalk_file planwalk.txt
planWalk_maxRouteTime 300
The following code is my new "planLockMapWalk.pl":

Code: Select all

# planLockMapWalk by Snoopy

package planLockMapWalk;

use strict;
#use warnings;

use Time::HiRes qw(time);

use Globals;
use Utils;
use Misc;
use AI;
use Log qw(debug message warning error);
use Translation;
#use encoding 'utf8';

my $nSpot = 0;
my $planMap = "";
my $cfID;
my $planwalk_file = "";
my @points = ();

Plugins::register('planLockMapWalk', 'Auto Plan to walk.', \&on_unload, \&on_reload);

my $hooks = Plugins::addHooks(
	['configModify', \&on_configModify, undef],
	['start3', \&on_start3, undef],
	['postloadfiles', \&on_loadfiles, undef],
	['pref_RandomWalk', \&pref_planWalk, undef],
	['post_RandomWalk', \&post_planWalk, undef]
);

my $chooks = Commands::register(
	['planwalk', "Plan Lock Map Walk plugin", \&commandHandler]
);

sub on_unload {
	Plugins::delHooks($hooks);
}

sub on_reload {
	message "planLockMapWalk plugin reloading\n";
	Plugins::delHooks($hooks);
	&on_start3
}

sub on_configModify {
	my (undef, $args) = @_;
	if ($args->{key} eq 'planWalk_file') {
		$planwalk_file = $args->{val};
		Settings::removeFile($cfID);
		$cfID = Settings::addControlFile($planwalk_file, loader => [ \&parsePlanWalk, undef]);
		Settings::loadByHandle($cfID);
	} elsif ($args->{key} eq 'lockMap') {
		if ($planMap ne $args->{val}) {
			$planMap = $args->{val};
			$nSpot = 0;
#			message T("..... change lockMap...\n");
			Settings::loadByHandle($cfID);
		}
	}
}

sub on_start3 {
	&checkFile;
	Settings::removeFile($cfID) if ($cfID);
	$cfID = Settings::addControlFile($planwalk_file, loader => [ \&parsePlanWalk]);
	Settings::loadByHandle($cfID);
}

sub on_loadfiles {
	if ($char && ($planMap ne $config{lockMap} || $planwalk_file ne $config{planWalk_file})) {
#		message TF("1. %s : %s , 2. %s : %s\n", $planMap, $config{lockMap}, $planwalk_file, $config{planWalk_file});
		$planMap = $config{lockMap};
		$planwalk_file = (defined $config{planWalk_file})? $config{planWalk_file} : "planwalk.txt";
		Settings::removeFile($cfID) if ($cfID);
		$cfID = Settings::addControlFile($planwalk_file, loader => [ \&parsePlanWalk]);
		Settings::loadByHandle($cfID);
	}
}

# checks planwalk file
sub checkFile {
	$planMap = $config{lockMap};
	$planwalk_file = (defined $config{planWalk_file})? $config{planWalk_file} : "planwalk.txt";
}

# onFile(Re)load
sub parsePlanWalk {
	my $file = shift;
#	message TF("The plak walk on %s in file: %s\n", $planMap, $file);

	my $flag1 = 0;
	@points = ();
	if (-e $file && $planMap) {
#	if (-e $file) {
		open my $fp, "<:utf8", $file;
		while (<$fp>) {
			$. == 1 && s/^\x{FEFF}//; # utf bom
			s/(.*)[\s\t]+#.*$/$1/;	# remove last comments
			s/^\s*#.*$//;		# remove comments
			s/^\s*//;		# remove leading whitespaces
			s/\s*[\r\n]?$//g;	# remove trailing whitespaces and eol
			s/  +/ /g;		# trim down spaces - very cool for user's string data?
			next unless ($_);
			if (/^\[(.+)\]$/) {
				$flag1 = ($1 eq $planMap) ? 1 : 0;
#				$flag1 = ($1 eq $config{lockMap}) ? 1 : 0;
			} elsif ($flag1) {
				if (/^(\d+):(\d+)$/) {
					push @points, {'xPos' => $1, 'yPos' => $2};
				}
			}
		}
#		foreach my $pp (@points) {
#			message TF("Point : %s, %s\n", $pp->{xPos}, $pp->{yPos});
#		}
	}
}

sub pref_planWalk {
	return if (!$config{autoPlanLockMapWalk} || $config{lockMap} ne $field->baseName);

	my (undef, $args) = @_;
	my $ret = 1;
	my $maxRouteTime = $config{planWalk_maxRouteTime} ? $config{planWalk_maxRouteTime} :
		($config{route_randomWalk_maxRouteTime} ? $config{route_randomWalk_maxRouteTime} : 120);

	$nSpot = @points - 1 if ($nSpot >= @points);
	if ($nSpot >= 0) {
		my ($to_x, $to_y);
		$to_x = $points[$nSpot]->{xPos};
		$to_y = $points[$nSpot]->{yPos};

		if ($to_x eq "" || $to_y eq "") {
			error T("Empty coordinates setting for planLockMapWalk; planLockMapWalk disabled\n");
			$config{autoPlanLockMapWalk} = '0';
		} elsif ($field->isWalkable($to_x, $to_y)) {
			AI::clear(qw/move route mapRoute/);
			message TF("Do plan walking route to: %s: %s, %s\n", $field->descString(), $to_x, $to_y), "route";
			main::ai_route($field->baseName, $to_x, $to_y, 
				maxRouteTime => $maxRouteTime,
				attackOnRoute => 2,
				noMapRoute => ($config{route_randomWalk} == 2 ? 1 : 0));
			$ret = 0;
		} else {
			error TF("Invalid coordinates specified (%d, %d) for planLockMapWalk (coordinates are unwalkable); planLockMapWalk disabled\n", $to_x, $to_y);
			$config{autoPlanLockMapWalk} = '0';
		}
		$nSpot++;
		$nSpot = 0 if ($nSpot >= @points);
	}
	$args->{return} = $ret;
}

sub post_planWalk {
}

sub commandHandler {
	message TF("The Plan Lock Map is : %s (Step: %d)\n", ($planMap) ? $planMap : "???", $nSpot - 1);
	message TF("The configuration file is : %s \n", ($planwalk_file) ? $planwalk_file : "???");
	for(my $i = 0 ; $i < @points ; $i++) {
		message TF("Walk Point(%d) : %s, %s\n", $i, $points[$i]->{xPos}, $points[$i]->{yPos});
	}
}

1;

crowser
Noob
Noob
Posts: 8
Joined: 18 Feb 2009, 19:50
Noob?: No

Re: Plan to walk in lock map !

#23 Post by crowser »

sofax222 wrote:There is a problem for running of WayPoint plugin.
That is, the "sit" console command will be blocked !
Because in running of WayPoint, there always is an ai task "waypoint" in the ai queue !
would macro help? i never tried the sitting feature of the bot since there never was a need for any of my characters to sit..

sofax222
Developers
Developers
Posts: 214
Joined: 24 Nov 2010, 03:08
Noob?: Yes

Re: Plan to walk in lock map !

#24 Post by sofax222 »

crowser wrote:
sofax222 wrote:There is a problem for running of WayPoint plugin.
That is, the "sit" console command will be blocked !
Because in running of WayPoint, there always is an ai task "waypoint" in the ai queue !
would macro help? i never tried the sitting feature of the bot since there never was a need for any of my characters to sit..
May be macro could help ! I don't know !
Sometime, I need to pause the bot by "sit", such as manual reviving HP/SP.

Oligo21
Noob
Noob
Posts: 1
Joined: 22 Jul 2010, 02:00
Noob?: No

Re: Plan to walk in lock map !

#25 Post by Oligo21 »

this is how i did it with only 2 small macro

macro maps {
$i = 0
$map = <maps>
$xpos = 10, 20, 30, 40, 50, 60 , 70, 80, 90, 100, stop
$ypos = 10, 20, 30, 40, 50, 60 , 70, 80, 90, 100
call route
}
macro route {
if ($xpos != stop) goto increment
$i = 1
:increment
$i++
log moving to $map @arg("$xpos",$i) @arg("$ypos",$i)
do eval ai_route($.map,@arg("$xpos",$i),@arg("$ypos",$i), attackOnRoute => 2)
call route
}

Problems are that i can't run other macro because macro route is looping. I am looking for a more elegant solution and i thing this topic will help me ^^

sofax222
Developers
Developers
Posts: 214
Joined: 24 Nov 2010, 03:08
Noob?: Yes

Re: Plan to walk in lock map !

#26 Post by sofax222 »

Oligo21 wrote:this is how i did it with only 2 small macro

macro maps {
$i = 0
$map = <maps>
$xpos = 10, 20, 30, 40, 50, 60 , 70, 80, 90, 100, stop
$ypos = 10, 20, 30, 40, 50, 60 , 70, 80, 90, 100
call route
}
macro route {
if ($xpos != stop) goto increment
$i = 1
:increment
$i++
log moving to $map @arg("$xpos",$i) @arg("$ypos",$i)
do eval ai_route($.map,@arg("$xpos",$i),@arg("$ypos",$i), attackOnRoute => 2)
call route
}

Problems are that i can't run other macro because macro route is looping. I am looking for a more elegant solution and i thing this topic will help me ^^
Did you try the "planLockMapWalk" plugin ?

Dzar
Noob
Noob
Posts: 2
Joined: 19 Dec 2011, 07:56
Noob?: Yes

Re: Plan to walk in lock map !

#27 Post by Dzar »

i was use this plugin
but does not work at all
its still random route

sofax222
Developers
Developers
Posts: 214
Joined: 24 Nov 2010, 03:08
Noob?: Yes

Re: Plan to walk in lock map !

#28 Post by sofax222 »

Dzar wrote:i was use this plugin
but does not work at all
its still random route
Did you modify the src/AI/CoreLogic.pm file ??

Dzar
Noob
Noob
Posts: 2
Joined: 19 Dec 2011, 07:56
Noob?: Yes

Re: Plan to walk in lock map !

#29 Post by Dzar »

sofax222 wrote:
Dzar wrote:i was use this plugin
but does not work at all
its still random route
Did you modify the src/AI/CoreLogic.pm file ??

ok nvm
its work to me

i see the plan walk must have a - g plan walk
cos before that i just only use 4 plan walk

glennlevi
Plain Yogurt
Plain Yogurt
Posts: 58
Joined: 19 May 2011, 00:40
Noob?: Yes

Re: Plan to walk in lock map !

#30 Post by glennlevi »

I keep getting the message:

Variable "%field" is not imported at src/AI/CoreLogic.pm line xxxx.
Global symbol "%field" requires explicit package name at src/AI/CoreLogic.pm line xxxx.

I already have the plugin.
I already have planwalk.txt with coordinates in config folder.
I have put the necessary block in config.txt
and I already copied over the Random Walk block in CoreLogic.pm

What am I doing wrong?

Post Reply