Calculating Auto Talk Route (spamming)

Private server support - Only post connectivity issues in the subforum!

Moderator: Moderators

striker12
Noob
Noob
Posts: 12
Joined: 09 Jul 2014, 09:58
Noob?: Yes

Calculating Auto Talk Route (spamming)

#1 Post by striker12 »

I'm using an auto talk plugin for my openkore, but i got the message "calculating auto talk route" infinite times and the bot does not talk to the npc
I'm trying to talk to a healer npc.



############################################################
#
# autotalk
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#

package autotalk;

use strict;
use Plugins;
use AI;
use Commands;
use Globals;
use Log;
use Utils;

Plugins::register('autotalk', 'talks to NPC after death or via command', \&unload);
my $mainLoopHook = Plugins::addHook('AI_pre', \&mainLoop);
my $hookCommandPost = Plugins::addHook('Command_post', \&onCommandPost);

my $queueNextLoop;

sub unload {
Plugins::delHook('AI_pre', $mainLoopHook);
Plugins::delHook('Command_post', $hookCommandPost);
}

sub onCommandPost {
my (undef, $args) = @_;
my ($cmd, $subcmd) = split(' ', $args->{input}, 2);

if ($cmd eq "autotalk") {
AI::queue('talkAuto');
$args->{return} = 1;
}
}

sub mainLoop {
if ($queueNextLoop) {
AI::queue('talkAuto');
$queueNextLoop = 0;
}

# Queue talkAuto after death
if (AI::action eq "dead" && !$::char->{dead}) {
if (!$::char->{resurrected}) {
$queueNextLoop = 1 if ($::config{'talkAuto_afterDeath'});
}
}

AUTOTALK: {

if (AI::action eq "talkAuto" && AI::args->{done}) {
# Autotalk finished
AI::dequeue;

} elsif (AI::action eq "talkAuto") {
# Main autotalk block
my $args = AI::args;

# Stop if talkAuto is not enabled, or if the specified NPC is invalid
$args->{npc} = {};
main::getNPCInfo($::config{'talkAuto_npc'}, $args->{npc});
if (!defined($args->{npc}{ok})) {
$args->{done} = 1;
return;
}

# Determine whether we have to move to the NPC
my $do_route;
if ($::field{'name'} ne $args->{npc}{map}) {
$do_route = 1;
} else {
my $distance = Utils::distance($args->{npc}{pos}, $::char->{pos_to});
if ($distance > $::config{'talkAuto_distance'}) {
$do_route = 1;
}
}

if ($do_route) {
Log::message "Calculating auto-talk route to: $::maps_lut{$args->{npc}{map}.'.rsw'}($args->{npc}{map}): $args->{npc}{pos}{x}, $args->{npc}{pos}{y}\n", "route";
main::ai_route($args->{npc}{map}, $args->{npc}{pos}{x}, $args->{npc}{pos}{y},
attackOnRoute => 1,
distFromGoal => $::config{'talkAuto_distance'},
noSitAuto => 1);
} else {
# Talk to NPC if we haven't done so
if (!defined($args->{queuedTalkSequence})) {
$args->{queuedTalkSequence} = 1;

if (defined $args->{npc}{id}) {
main::ai_talkNPC(ID => $args->{npc}{id}, $::config{'talkAuto_npc_steps'});
} else {
main::ai_talkNPC($args->{npc}{pos}{x}, $args->{npc}{pos}{y}, $::config{'talkAuto_npc_steps'});
}

return;
}

$args->{done} = 1;
}
}

} #END OF BLOCK AUTOTALK
}

return 1;

-------------------------------------------------------------------

in Config:

talkAuto_afterDeath 1
talkAuto_distance 5
talkAuto_npc moc_ruins 72 164
talkAuto_npc_steps c r0 n

---------------------------------------------------------------------

Could you help me? TY
User avatar
SkylorD
Moderators
Moderators
Posts: 1202
Joined: 16 Dec 2011, 02:53
Noob?: No
Location: Brazil

Re: Calculating Auto Talk Route (spamming)

#2 Post by SkylorD »

if ($::field{'name'} ne $args->{npc}{map}) {
For example, try to change $::field{'name'} to $field->baseName.
Learn rules
striker12
Noob
Noob
Posts: 12
Joined: 09 Jul 2014, 09:58
Noob?: Yes

Re: Calculating Auto Talk Route (spamming)

#3 Post by striker12 »

Solved. TY

Do you know if its possible to use "talk to npc" 2x? Like...talk to the healer and then talk to the warper...i tried but it does only one action...

i copied the entire block 2 time and put the npc information on then, but kore just executes one of them, and the 2 blocks get the same configuration after it