Automatically talk to NPC (after death) by Joseph

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
deFT
Noob
Noob
Posts: 2
Joined: 04 Jun 2009, 00:36
Noob?: Yes

Automatically talk to NPC (after death) by Joseph

#1 Post by deFT »

example

Code: Select all

talkAuto_afterDeath 1
talkAuto_distance 5
talkAuto_npc comodo 188 162
talkAuto_npc_steps c r0 n
autotalk.pl

Code: Select all

############################################################
#
# 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;
It's missing the other plugin that goes with it that talks to the healer npc when storaging.

genuine
Noob
Noob
Posts: 8
Joined: 15 May 2008, 08:19
Noob?: No

Re: Automatically talk to NPC (after death) by Joseph

#2 Post by genuine »

can u add a config command like

Code: Select all

talkAuto_hp 10
talkAuto_sp 5
so it will only trigger when he has sp below 5% and talk to healer NPC

wallydaza
Noob
Noob
Posts: 2
Joined: 19 Aug 2013, 03:41
Noob?: Yes

Re: Automatically talk to NPC (after death) by Joseph

#3 Post by wallydaza »

ahh yeah ^ i think he has a good point there

and uhm im wondering how to get to talk to the next npc after talking to another one?

i would really appreciate a reply
Thanks!

Post Reply