Openkore.com

OpenKore Forums
It is currently 24 Aug 2019, 20:44

All times are UTC - 5 hours [ DST ]





Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: buscommand update party
PostPosted: 31 Dec 2014, 01:55 
Offline
Human
Human

Joined: 17 Oct 2013, 12:45
Posts: 38
Before you can send bus command player name|all| map

Add party|party name

bus party <comand> - all bots that are in the same party bot you wrote the command receive that
bus <party name> <command> - all bots in party name receive the command

code:
Code:
#############################################################################
# busCommands revision 03 plugin by imikelance/marcelofoxes/licielg                           
#                                                         
# Openkore: http://openkore.com/                                 
# Openkore Brazil: http://openkore.com.br/      
#
# 17:03 segunda-feira, 20 de fevereiro de 2012 (rev 02)
#   - now you can use "bus <map name> <command>" to command your bots inside that map
#
# 01:01 domingo, 12 de fevereiro de 2012 (rev 01)
#   - fixed "bus command", where only commands without arguments (like sit, stand, st) would work                           
#   - fixed self name checking                                       
#   - added   hook to allow usage with macros                                    
#   - added MESSENGER_MODE to allow this plugin to act as a messenger (receive/send messages only)                                    
#                                    
# 05:52 quarta-feira, 8 de fevereiro de 2012
#    - released !
#
#   my special thanks goes to openkore team for developing BUS System !
#
# 31/12/2014 - add command 'party' or 'party name' by licielg
#
#                                       
# This source code is licensed under the                           
# GNU General Public License, Version 3.                           
# See http://www.gnu.org/licenses/gpl.html                           
#############################################################################
package busCommands;

use strict;
use Plugins;
use Log qw( warning message error );
use Globals;

use constant {
   PLUGINNAME            =>   "busCommands",
   BUS_MESSAGE_ID          =>    "busComm",
   # you can change some of this plugin settings below !
   BUS_COMMAND          =>    "bus",
   DEBUG               =>   0,      # set to 1 to show debug messages
   SILENT               =>   0,      # disable almost every message. error messages will still be shown
   MESSENGER_MODE         =>   0,      # use this to receive/send messages and not commands.
};

# Plugin
Plugins::register(PLUGINNAME, "receive and send commands (and messages too) via BUS system", \&unload);   
   my $myCmds = Commands::register([BUS_COMMAND,       "use ".BUS_COMMAND." <all|player name|party|<party name>|map name> <command>.",\&comm_Send]);
   
   my $networkHook = Plugins::addHook('Network::stateChanged',\&init);
   
my $bus_message_received;

sub comm_Send {
   my (undef, $cmm) = @_;
   $cmm =~ m/^"(.*)" (.*)$/;
   $cmm =~ m/^(\w+) (.*)$/ unless ($1);
   unless ($1 && $2) {
      msg("Command \"".BUS_COMMAND."\" failed, please use ".BUS_COMMAND." <all|player name|party|<party name>|map name> <command>.", 3);
      return;
   }
   if ($char && $bus->getState == 4) {
      my %args;
      if ($1 eq "party") {
         if ($char->{party}) {
            $args{player} = $char->{party}{name};
         } else {
            error("You not in a party.");
            return;
         }
      } else {
         $args{player} = $1;
      }
      $args{comm} = $2;
      $bus->send(BUS_MESSAGE_ID, \%args);
   }
   
   if ($1 eq $char->name || $1 eq "all") {
      Plugins::callHook('bus_received', {message => $2});
      return if (MESSENGER_MODE || $config{'busCommands_messengerMode'});
      msg("Running command \"$2\"");
      Commands::run($2);
   } elsif ($1 eq $field->name) {
         Plugins::callHook('bus_received', {message => $2});
         return if (MESSENGER_MODE || $config{'busCommands_messengerMode'});
         
         msg("Running command $2 received via BUS");
         Commands::run($2);
   } elsif($char->{party}) {
      if ($1 eq $char->{party}{name} || $1 eq "party") {
         Plugins::callHook('bus_received', {message => $2});
         return if (MESSENGER_MODE || $config{'busCommands_messengerMode'});
         msg("Running command $2 received via BUS");
         Commands::run($2);
      }
   }
}
         
# handle plugin loaded manually
if ($::net) {
   if ($::net->getState() > 1) {
      $bus_message_received = $bus->onMessageReceived->add(undef, \&bus_message_received);
      Plugins::delHook($networkHook);
      undef $networkHook;
   }
}

sub init {
   return if ($::net->getState() == 1);
   if (!$bus) {
      die("\n\n[".PLUGINNAME."] You MUST start BUS server and configure each bot to use it in order to use this plugin. Open and edit line bus 0 to bus 1 inside control/sys.txt \n\n", 3, 0);
   } elsif (!$bus_message_received) {
      $bus_message_received = $bus->onMessageReceived->add(undef, \&bus_message_received);
      Plugins::delHook($networkHook);
      undef $networkHook;
   }
}

sub bus_message_received {
   my (undef, undef, $msg) = @_;
   return if (!$char);
   return unless ($msg->{messageID} eq BUS_MESSAGE_ID);
   if ($msg->{args}{player} eq $char->name || $msg->{args}{player} eq "all") {
         Plugins::callHook('bus_received', {message => $msg->{args}{comm},});
         return if (MESSENGER_MODE || $config{'busCommands_messengerMode'});
         
         msg("Running command $msg->{args}{comm} received via BUS");
         Commands::run($msg->{args}{comm});
   } elsif ($msg->{args}{player} eq $field->name) {
      #if ($msg->{args}{player} eq $field->name) {
         Plugins::callHook('bus_received', {message => $msg->{args}{comm},});
         return if (MESSENGER_MODE || $config{'busCommands_messengerMode'});
         
         msg("Running command $msg->{args}{comm} received via BUS");
         Commands::run($msg->{args}{comm});
      #}
   } elsif($char->{party}) {
      if ($msg->{args}{player} eq $char->{party}{name}) {
         Plugins::callHook('bus_received', {message => $msg->{args}{comm},});
         return if (MESSENGER_MODE || $config{'busCommands_messengerMode'});
         
         msg("Running command $msg->{args}{comm} received via BUS");
         Commands::run($msg->{args}{comm});
      }
   }
}

sub msg {
   # SILENT constant support and sprintf.
   my ($msg, $msglevel, $debug) = @_;
   
   unless ($debug eq 1 && DEBUG ne 1) {
   $msg = "[".PLUGINNAME."] ".$msg."\n";
      if (!defined $msglevel || $msglevel == "" || $msglevel == 0) {
         warning($msg) unless (SILENT == 1);
      } elsif ($msglevel == 1) {
         message($msg) unless (SILENT == 1);
      } elsif ($msglevel == 2) {
         warning($msg) unless (SILENT == 1);
      } elsif ($msglevel == 3) {
         error($msg);
      }
   }
   return 1;
}

# Plugin unload
sub unload {
   message("\n[".PLUGINNAME."] unloading.\n\n");
   #Plugins::delHooks($myHooks);
   Plugins::delHook($networkHook) if $networkHook;
   Commands::unregister($myCmds);
   undef $myCmds;
   undef $networkHook;
   $bus->onMessageReceived->remove($bus_message_received) if $bus_message_received;
   undef $bus_message_received if $bus_message_received;
}

1;


Top
 Profile  
 
 Post subject: Re: buscommand update party
PostPosted: 20 Jan 2015, 11:28 
Offline
Noob
Noob

Joined: 17 Jan 2015, 20:45
Posts: 8
Awesome plugin.... thanks for plugin....
my master & slave only need little time to recover when lost party

automacro gotoMaster {
disabled 0
console /^I lost my master/
call {
$master = @config (followTarget)
do pm "$master" x $.map $.pos
}
timeout 1
}
automacro findSlave {
disabled 0
pm /x (.*) (.*) (.*)/
call {
$slavemap = $.lastMatch1
$slavemapx = $.lastMatch2
$slavemapy = $.lastMatch3
$lockMap = @config (lockMap)
$mymap = $.map
if ($mymap == $lockMap) goto findslave
if ($mymap == $slavemap) goto findslave
do eval warning "Slave not on Map\n";
stop
:findslave
do eval message "Commanding Slave to Move Towards Master\n";
do bus "$.lastpm" ai clear
do bus "$.lastpm" move $.map $.pos
}
timeout 1
}


my other idea:
automacro gotoMaster {
disabled 0
console /^I lost my master/
call {
$master = @config (followTarget)
$myname = ????
do bus "$master" bus "$myname" move [master map] [master position]
}
timeout 1
}
question:
how to get my name automatically?
how to get master map & master position?


Top
 Profile  
 
 Post subject: Re: buscommand update party
PostPosted: 20 Jan 2015, 18:39 
Offline
Developers
Developers
User avatar

Joined: 30 Apr 2008, 14:17
Posts: 621
Location: Moskow (Russia)
Shakti-lar, just use config options: followBot (not plugin :D )

_________________
All my posts are made by machine translator!
¤ Manual ¤ Anti BotKiller ¤ Packet Extractor v3 ¤
Image
Image


Top
 Profile  
 
 Post subject: Re: buscommand update party
PostPosted: 20 Jan 2015, 20:01 
Offline
Noob
Noob

Joined: 17 Jan 2015, 20:45
Posts: 8
@4epT:
yes i know there is followBot standard option
but with standard followBot, slave will pm master, and master will move to slave
in case master been followed by only 1 priest it will be good
but in my case, master been followed by 2 to 3 slave(priest + other dps), if slave(s) missed, 1 by 1 will pm master
and master will not go for mob monster, only move from 1 slave to another slave

i want that master will still move forward, and slaves will catch up to master if they lost
slave aiv:
ai_seq (auto) = move take items_take follow follow follow follow follow follow
Active tasks: RaiseStat, RaiseSkill, Timeout, Timeout, Timeout, Timeout,
Timeout, Timeout, Timeout, Timeout, Timeout, Timeout, Timeout, Timeout,
Timeout, Timeout, Timeout, Timeout, Timeout, Timeout, Timeout, Timeout,
Timeout, Timeout, Timeout, Timeout, Timeout, Timeout, Timeout, Timeout,
Timeout, Timeout, Timeout, Timeout, Timeout, Timeout, Timeout, Timeout,
Timeout, Timeout, Timeout, Timeout, Timeout, Timeout, Timeout, Timeout,
Timeout, Timeout, Timeout, Timeout, Timeout


Top
 Profile  
 
 Post subject: Re: buscommand update party
PostPosted: 21 Jan 2015, 09:16 
Offline
Noob
Noob

Joined: 18 Feb 2013, 17:28
Posts: 13
I don't know how to make it work as messenger mode.
So I just check out the code from svn and merge it with licielg's mod.

Code:
#############################################################################
# busCommands revision 03 plugin by imikelance/marcelofoxes/licielg                           
#                                                         
# Openkore: http://openkore.com/                                 
# Openkore Brazil: http://openkore.com.br/     
#
# 17:03 segunda-feira, 20 de fevereiro de 2012 (rev 02)
#   - now you can use "bus <map name> <command>" to command your bots inside that map
#
# 01:01 domingo, 12 de fevereiro de 2012 (rev 01)
#   - fixed "bus command", where only commands without arguments (like sit, stand, st) would work                           
#   - fixed self name checking                                       
#   - added   hook to allow usage with macros                                   
#   - added MESSENGER_MODE to allow this plugin to act as a messenger (receive/send messages only)                                   
#                                   
# 05:52 quarta-feira, 8 de fevereiro de 2012
#    - released !
#
#   my special thanks goes to openkore team for developing BUS System !
#
# 31/12/2014 - add command 'party' or 'party name' by licielg
#
#                                       
# This source code is licensed under the                           
# GNU General Public License, Version 3.                           
# See http://www.gnu.org/licenses/gpl.html                                        
#############################################################################
package busCommands;

use strict;
use Plugins;
use Log qw( warning message error );
use Globals;

use constant {
   PLUGINNAME            =>   "busCommands",
   BUS_MESSAGE_ID          =>    "busComm",
   BUS_MESSAGE_ID_MESS      =>    "busCM",
   # you can change some of this plugin settings below !
   BUS_COMMAND          =>    "bus",
   BUS_COMMAND_MESS          =>    "busmsg",
   DEBUG               =>   0,      # set to 1 to show debug messages
   SILENT               =>   0,      # disable almost every message. error messages will still be shown
   MESSENGER_MODE         =>   0,      # use this to receive/send messages and not commands.
};

# Plugin
Plugins::register(PLUGINNAME, "receive and send commands (and messages too) via BUS system", \&unload);   
    my $myCmds = Commands::register([BUS_COMMAND,       "use ".BUS_COMMAND." <all|player name|party|<party name>|map name> <command>.",\&comm_Send],
                            [BUS_COMMAND_MESS,   "use ".BUS_COMMAND_MESS." <all|player name|party|<party name>|map name> <message>.",\&msg_Send]);
   
   my $networkHook = Plugins::addHook('Network::stateChanged',\&init);
   
my $bus_message_received;

sub comm_Send {
   my (undef, $cmm) = @_;
   $cmm =~ m/^"(.*)" (.*)$/;
   $cmm =~ m/^(\w+) (.*)$/ unless ($1);
   unless ($1 && $2) {
        msg("Command \"".BUS_COMMAND."\" failed, please use ".BUS_COMMAND." <all|player name|party|<party name>|map name> <command>.", 3);
      return;
   }
   if ($char && $bus->getState == 4) {
      my %args;
        if ($1 eq "party") {
          if ($char->{party}) {
               $args{player} = $char->{party}{name};
           } else {
               error("You not in a party.");
               return;
           }
         } else {
         $args{player} = $1;
      }
      $args{comm} = $2;
      $bus->send(BUS_MESSAGE_ID, \%args);
   }
   
   if ($1 eq $char->name || $1 eq "all") {
        Plugins::callHook('bus_received', {message => $2});
      return if (MESSENGER_MODE || $config{'busCommands_messengerMode'});
      msg("Running command \"$2\"");
      Commands::run($2);
   } elsif ($1 eq $field->name) {
       Plugins::callHook('bus_received', {message => $2});
      return if (MESSENGER_MODE || $config{'busCommands_messengerMode'});         
      msg("Running command $2 received via BUS");
      Commands::run($2);
   } elsif($char->{party}) {
      if ($1 eq $char->{party}{name} || $1 eq "party") {
          Plugins::callHook('bus_received', {message => $2});
            return if (MESSENGER_MODE || $config{'busCommands_messengerMode'});
            msg("Running command $2 received via BUS");
            Commands::run($2);
      }
   }
}

sub msg_Send {
   my (undef, $cmm) = @_;
   $cmm =~ m/^"(.*)" (.*)$/;
   $cmm =~ m/^(\w+) (.*)$/ unless ($1);
   
   unless ($1 && $2) {
      msg("Command \"".BUS_COMMAND_MESS."\" failed, please use ".BUS_COMMAND_MESS." <all|player name|party|<party name>|map name> <message>.", 3);
      return;
      }
      
      if ($char && $bus->getState == 4) {
         my %args;
         if ($1 eq "party") {
            if ($char->{party}) {
               $args{player} = $char->{party}{name};
            } else {
               error("You not in a party.");
               return;
            }
         } else {
            $args{player} = $1;
         }
         $args{comm} = $2;
         $args{sender} = $char->name;
        $bus->send(BUS_MESSAGE_ID_MESS, \%args);
      
      if ($1 eq $char->name || $1 eq "all") {
         Plugins::callHook('bus_received', {message => $args{comm}, sender => $args{sender}});
      } elsif ($1 eq $field->name) {
         Plugins::callHook('bus_received', {message => $args{comm}, sender => $args{sender}});
      } elsif($char->{party}) {
         Plugins::callHook('bus_received', {message => $args{comm}, sender => $args{sender}});
      }
      }
}
         
# handle plugin loaded manually
if ($::net) {
   if ($::net->getState() > 1) {
      $bus_message_received = $bus->onMessageReceived->add(undef, \&bus_message_received);
      Plugins::delHook($networkHook);
      undef $networkHook;
   }
}

sub init {
   return if ($::net->getState() == 1);
   if (!$bus) {
      die("\n\n[".PLUGINNAME."] You MUST start BUS server and configure each bot to use it in order to use this plugin. Open and edit line bus 0 to bus 1 inside control/sys.txt \n\n", 3, 0);
   } elsif (!$bus_message_received) {
      $bus_message_received = $bus->onMessageReceived->add(undef, \&bus_message_received);
      Plugins::delHook($networkHook);
      undef $networkHook;
   }
}

sub bus_message_received {
   my (undef, undef, $msg) = @_;
   return if (!$char);
   if ($msg->{messageID} eq BUS_MESSAGE_ID) {
      if ($msg->{args}{player} eq $char->name || $msg->{args}{player} eq "all") {
         Plugins::callHook('bus_received', {message => $msg->{args}{comm},});            
            return if (MESSENGER_MODE || $config{'busCommands_messengerMode'});
         msg("Running command $msg->{args}{comm} received via BUS");
         Commands::run($msg->{args}{comm});
         } elsif ($msg->{args}{player} eq $field->name) {
         Plugins::callHook('bus_received', {message => $msg->{args}{comm},});            
            return if (MESSENGER_MODE || $config{'busCommands_messengerMode'});
         msg("Running command $msg->{args}{comm} received via BUS");
         Commands::run($msg->{args}{comm});   
         } elsif($char->{party}) {
            if ($msg->{args}{player} eq $char->{party}{name}) {
               Plugins::callHook('bus_received', {message => $msg->{args}{comm},});
               return if (MESSENGER_MODE || $config{'busCommands_messengerMode'});   
               msg("Running command $msg->{args}{comm} received via BUS");
               Commands::run($msg->{args}{comm});
         }
      }
   } elsif ($msg->{messageID} eq BUS_MESSAGE_ID_MESS) {
      if ($msg->{args}{player} eq $char->name || $msg->{args}{player} eq "all") {
         Plugins::callHook('bus_received', {message => $msg->{args}{comm}, sender => $msg->{args}{sender}});
         msg("$msg->{args}{sender} : $msg->{args}{comm}");
      } elsif ($msg->{args}{player} eq $field->name) {
         Plugins::callHook('bus_received', {message => $msg->{args}{comm}, sender => $msg->{args}{sender}});
         msg("$msg->{args}{sender} : $msg->{args}{comm}");
         } elsif($char->{party}) {
            if ($msg->{args}{player} eq $char->{party}{name}) {
            Plugins::callHook('bus_received', {message => $msg->{args}{comm}, sender => $msg->{args}{sender}});
            msg("$msg->{args}{sender} : $msg->{args}{comm}");
         }
      }
   }
}

sub msg {
   # SILENT constant support and sprintf.
   my ($msg, $msglevel, $debug) = @_;
   
   unless ($debug eq 1 && DEBUG ne 1) {
   $msg = "[".PLUGINNAME."] ".$msg."\n";
      if (!defined $msglevel || $msglevel == "" || $msglevel == 0) {
         warning($msg) unless (SILENT == 1);
      } elsif ($msglevel == 1) {
         message($msg) unless (SILENT == 1);
      } elsif ($msglevel == 2) {
         warning($msg) unless (SILENT == 1);
      } elsif ($msglevel == 3) {
         error($msg);
      }
   }
   return 1;
}

# Plugin unload
sub unload {
   message("\n[".PLUGINNAME."] unloading.\n\n");
   #Plugins::delHooks($myHooks);
   Plugins::delHook($networkHook) if $networkHook;
   Commands::unregister($myCmds);
   undef $myCmds;
   undef $networkHook;
   $bus->onMessageReceived->remove($bus_message_received) if $bus_message_received;
   undef $bus_message_received if $bus_message_received;
}

1;


So now we have two commands for bus system: bus and busmsg.

In your case, I think you can use busmsg to send messages using bus system.
Code:
automacro gotoMaster {
disabled 0
console /^I lost my master/
call {
$master = @config (followTarget)
do busmsg "$master" x $.map $.pos
}
timeout 1
}
automacro findSlave {
disabled 0
console /\[busCommands\] (.*) : x (.*) (.*) (.*)/
call {
$slavename = $.lastMatch1
$slavemap = $.lastMatch2
$slavemapx = $.lastMatch3
$slavemapy = $.lastMatch4
$lockMap = @config (lockMap)
$mymap = $.map
if ($mymap == $lockMap) goto findslave
if ($mymap == $slavemap) goto findslave
do eval warning "Slave not on Map\n";
stop
:findslave
do eval message "Commanding Slave to Move Towards Master\n";
do bus "$slavename" ai clear
do bus "$slavename" move $.map $.pos
}
timeout 1
}


Good luck.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group