Openkore.com

OpenKore Forums
It is currently 21 Sep 2014, 10:19

All times are UTC - 5 hours [ DST ]





Post new topic Reply to topic  [ 32 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
 Post subject: Re: Plan to walk in lock map !
PostPosted: 17 Apr 2011, 06:58 
Offline
Noob
Noob

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


Top
 Profile  
 
 Post subject: Re: Plan to walk in lock map !
PostPosted: 19 Apr 2011, 23:22 
Offline
Developers
Developers

Joined: 24 Nov 2010, 03:08
Posts: 201
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:
autoPlanLockMapWalk 1
planWalk_file planwalk.txt
planWalk_maxRouteTime 300


The following code is my new "planLockMapWalk.pl":
Code:
# 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;


Top
 Profile  
 
 Post subject: Re: Plan to walk in lock map !
PostPosted: 01 May 2011, 15:31 
Offline
Noob
Noob

Joined: 18 Feb 2009, 19:50
Posts: 8
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..


Top
 Profile  
 
 Post subject: Re: Plan to walk in lock map !
PostPosted: 02 May 2011, 03:43 
Offline
Developers
Developers

Joined: 24 Nov 2010, 03:08
Posts: 201
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.


Top
 Profile  
 
 Post subject: Re: Plan to walk in lock map !
PostPosted: 25 Aug 2011, 05:10 
Offline
Noob
Noob

Joined: 22 Jul 2010, 02:00
Posts: 1
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 ^^


Top
 Profile  
 
 Post subject: Re: Plan to walk in lock map !
PostPosted: 01 Oct 2011, 05:26 
Offline
Developers
Developers

Joined: 24 Nov 2010, 03:08
Posts: 201
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 ?


Top
 Profile  
 
 Post subject: Re: Plan to walk in lock map !
PostPosted: 19 Dec 2011, 08:03 
Offline
Noob
Noob

Joined: 19 Dec 2011, 07:56
Posts: 2
i was use this plugin
but does not work at all
its still random route


Top
 Profile  
 
 Post subject: Re: Plan to walk in lock map !
PostPosted: 22 Dec 2011, 20:54 
Offline
Developers
Developers

Joined: 24 Nov 2010, 03:08
Posts: 201
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 ??


Top
 Profile  
 
 Post subject: Re: Plan to walk in lock map !
PostPosted: 28 Dec 2011, 11:19 
Offline
Noob
Noob

Joined: 19 Dec 2011, 07:56
Posts: 2
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


Top
 Profile  
 
 Post subject: Re: Plan to walk in lock map !
PostPosted: 28 Apr 2012, 12:12 
Offline
Plain Yogurt
Plain Yogurt

Joined: 19 May 2011, 00:40
Posts: 62
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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 32 posts ]  Go to page Previous  1, 2, 3, 4  Next

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
[ Time : 0.048s | 14 Queries | GZIP : On ]