reactOnNPC v.2.0.2 by hakore

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
darkzx
Noob
Noob
Posts: 2
Joined: 07 May 2008, 00:36
Noob?: No

Re: reactOnNPC v.1.1.1

#41 Post by darkzx »

Help Me !!!

Image

Image

Image


../config
reactOnNPC talk num @eval((#2~2@) ? '#2~1' : ((#3~2@) ? '#3~1' : ((#4~2@) ? '#4~1' : '#5~1'@)@)) {
type number
msg_0 /.*/i
msg_1 /.*/i
msg_2 /\D+(\d+)\D+(\d+\D+\d+)/i
msg_3 /\D+(\d+)\D+(\d+\D+\d+)/i
msg_4 /\D+(\d+)\D+(\d+\D+\d+)/i
msg_5 /\D+(\d+)\D+(\d+\D+\d+)/i
}

thx

darkzx
Noob
Noob
Posts: 2
Joined: 07 May 2008, 00:36
Noob?: No

Re: reactOnNPC v.1.1.1

#42 Post by darkzx »

######################################
## Credit. ReActOnNPCText by windows98SE Thk : Akimoto, Valkyrie, Q('',Q)Aya
## thx โค้ดเช็คสีของคุณ windows98SE
## Support : Sv. Eternal
## Edit by Komodo ^^'
## Ex. ../control/config.txt
## reactOnNPC onText num {
## type number
## }
##

package ReActOnNPCText;

use strict;
use Plugins;
use Globals;
use Utils;
use Commands;
use Log qw(message debug);
use encoding 'iso-8859-11';

Plugins::register('ReActOnNPCText', "ReActOnNPCText Function", \&Unload);

my $hooks = Plugins::addHooks(
['packet/npc_talk', \&onNPCTalk, undef],
['packet/npc_talk_close', \&onClo, undef],
['packet/npc_talk_continue', \&onCon, undef],
['packet/npc_talk_number', \&onNPCAction, undef]
);

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

my %reactOnNPC;
my $code;
my $str;

sub onNPCTalk {
my (undef, $args) = @_;
my $msg = I18N::bytesToString(unpack("Z*", substr($args->{RAW_MSG}, 8)));


my @npcMsg = '';
@npcMsg = split(/\^/,$msg);
$msg ='';
foreach my $line (@npcMsg) {
# Convert ASCII Background to =
if ($line =~ s/^[E|F|e|f][A-Fa-f0-9][D-Fd-f][A-Fa-f0-9]{3}//) {
$line =~ s/./x/g;
} else {
# Convert ASCII Number to #
$line =~ s/^[A-Fa-f0-9]{6}//;
$line =~ s/./=/g;
}
$msg .= $line;
}
debug "[Convert NPC message] to : $msg\n", "success";
if (!defined %reactOnNPC || $reactOnNPC{action}) {
undef %reactOnNPC if defined %reactOnNPC;
$reactOnNPC{index} = 1;
$reactOnNPC{msg}[$reactOnNPC{index}] = $msg;
} else {
$reactOnNPC{index}++;
$reactOnNPC{msg}[$reactOnNPC{index}] = $msg;
}
}

sub onNPCAction {
if($config{ReActOnNPCText}) {
$code = reply();
message "[ReActOnNPCText] Reacting to NPC. type Message \"$code\".\n", "success";
my $cmd = "talk num $code";
message "... delay 5 sec.\n", "success";
sleep 5;
Commands::run($cmd);
} else {
message "[ReActOnNPCText] You must read MANUAL befor use this Plugins\n", "success";
#Commands::run("relog");
}
}

sub onClo {
undef %reactOnNPC if defined %reactOnNPC;
}

my $total;
sub onCon {

message "[Text] 3 \"$reactOnNPC{msg}[3]\".\n", "success";
message "[Text] 4 \"$reactOnNPC{msg}[4]\".\n", "success";
message "[Text] 5 \"$reactOnNPC{msg}[5]\".\n", "success";
message "[Text] 6 \"$reactOnNPC{msg}[6]\".\n", "success";
$total = ($reactOnNPC{msg}[3].$reactOnNPC{msg}[4].$reactOnNPC{msg}[5].$reactOnNPC{msg}[6]);
$total =~ s/(\d+)//g;
$str = $total;
message "[Total Text] \"$str\".\n", "success";
undef %reactOnNPC if defined %reactOnNPC;

}

# $total = ($reactOnNPC{msg}[3].$reactOnNPC{msg}[4].$reactOnNPC{msg}[5].$reactOnNPC{msg}[6]);

sub reply {
my %thaiphrasedigit = ("windows98SE", 10,"thaikore", 100,"Akimoto", 1000,
"==============================", 1,
"=============================", 1,
"============================", 1,
"===========================", 1,
"==========================", 1,
"=========================", 1,
"========================", 1,
"=======================", 1,
"======================", 1,
"=====================", 1,
"====================", 1,
"===================", 1,
"==================", 1,
"=================", 1,
"================", 1,
"===============", 1,
"==============", 1,
"=============", 1,
"============", 1,
"===========", 1,
"==========", 1,
"=========", 1,
"========", 1,
"=======", 1,
"======", 1,
"=====", 1,
"====", 1,
"===", 1,
"==", 1,
"=", 1,

"xxxxx", 0,
"xxxx", 0,
"xxx", 0,
"xx", 0,
"x", 0,


"หนึ่ง", 1, "เอ็ด",1 , "สอง", 2, "ยี่",2 , "สาม", 3, "สี",4,"ห้า", 5, "หก", 6, "เจ็ด", 7, "แปด", 8, "เก้า", 9,"สิบ", 10, "ร้อย",100, "หมื่น", 10000,"แสน", 100000, "ล้าน", 1000000);

message "[ReActOnNPCThai V.3] String \"$str\".\n", "success";
my $keyword = "windows98SE|thaikore|Akimoto|หนึ่ง|เอ็ด|สอง|ยี่|สาม|สี่|ห้า|หก|เจ็ด|แปด|เก้
า
สิบ|ร้อย|พัน|หมื่น|แสน|ล้าน|xxxxx|xxxx|xxx|xx|x|==============================|=
============================|============================|======================
=
====|==========================|=========================|======================
=
=|=======================|======================|=====================|=========
=
==========|===================|==================|=================|============
=
===|===============|==============|=============|============|===========|======
=
===|=========|========|=======|======|=====|====|===|==|=";

my $sum = 0;
my $tmpCal = 0;

while (my ($ask) = $str =~ /($keyword)/) {
$str = substr($str, length($ask));
if ($ask =~ /(=|==|===)/) {
if ($sum == 0) {
$sum += $thaiphrasedigit{$ask};
} else {
if ($tmpCal == 0) {
$sum += $thaiphrasedigit{$ask};
} else {
$sum -= $tmpCal;
$sum += $tmpCal * $thaiphrasedigit{$ask};
}
}
$tmpCal = 0;
} else {
$tmpCal = $thaiphrasedigit{$ask};
$sum += $tmpCal;
}
}
$code = ($sum);
return $code;
}
return 1;
# =======================
# reactOnNPC v.1.1.1
# =======================
# This plugin is licensed under the GNU GPL
# Copyright 2006 by hakore
#
# http://forums.openkore.com/viewtopic.php?t=19973

package reactOnNPC;

use strict;
use Plugins;
use Globals;
use Utils;
use Commands;
use Log qw(message debug);

Plugins::register('reactOnNPC', "react on NPC messages", \&Unload);

my $hooks = ((substr($Settings::VERSION, 0, 3) >= 1.9) ?
Plugins::addHooks(
['packet/npc_talk', \&onNPCTalk, undef],
['packet/npc_talk_close', \&onNPCAction, undef],
['packet/npc_talk_continue', \&onNPCAction, undef],
['packet/npc_talk_number', \&onNPCAction, undef],
['packet/npc_talk_responses', \&onNPCAction, undef],
['packet/npc_talk_text', \&onNPCAction, undef]
) :
Plugins::addHooks(
['parseMsg/pre', \&onParseMsg,
{
'00B4' => [\&onNPCTalk, 'packet/npc_talk'],
'00B5' => [\&onNPCAction, 'packet/npc_talk_continue'],
'00B6' => [\&onNPCAction, 'packet/npc_talk_close'],
'00B7' => [\&onNPCAction, 'packet/npc_talk_responses'],
'0142' => [\&onNPCAction, 'packet/npc_talk_number'],
'01D4' => [\&onNPCAction, 'packet/npc_talk_text']
}
]
)
);

my %reactOnNPC;

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

sub onNPCTalk
{
my (undef, $args) = @_;
my $ID = unpack("V", substr($args->{RAW_MSG}, 4, 4));
my $msg = unpack("Z*", substr($args->{RAW_MSG}, 8));
if ((substr($Settings::VERSION, 0, 3) >= 1.9) && (substr($Settings::VERSION, 4) >= 1))
{
$msg = I18N::bytesToString($msg);
}

if (!defined %reactOnNPC || $reactOnNPC{action})
{
undef %reactOnNPC if defined %reactOnNPC;
$reactOnNPC{index} = 0;
$reactOnNPC{ID} = $ID;
$reactOnNPC{msg}[$reactOnNPC{index}] = $msg;
}
else
{
$reactOnNPC{index}++;
$reactOnNPC{msg}[$reactOnNPC{index}] = $msg;
}
debug "[reactOnNPC] NPC message saved ($reactOnNPC{index}): \"$msg\".\n", "reactOnNPC";
}

sub onNPCAction
{
my $type = substr(shift, 16);
$reactOnNPC{action} = $type;
debug "[reactOnNPC] onNPCAction type is: $type.\n", "reactOnNPC";

if ($type eq 'responses')
{
my $args = shift;
my $msg = unpack("Z*", substr($args->{RAW_MSG}, 8));
if ((substr($Settings::VERSION, 0, 3) >= 1.9) && (substr($Settings::VERSION, 4) >= 1))
{
$msg = I18N::bytesToString($msg);
}
undef @{$reactOnNPC{responses}};
my @responses = split /:/, $msg;
foreach (@responses) {
push @{$reactOnNPC{responses}}, $_ if $_ ne "";
}
}

my $i = 0;
while (exists $config{"reactOnNPC_$i"}) {
if (
!$config{"reactOnNPC_$i"}
|| !main::checkSelfCondition("reactOnNPC_$i")
|| ($config{"reactOnNPC_${i}_type"} && $config{"reactOnNPC_${i}_type"} ne $type)
) {
debug "[reactOnNPC] Conditions for reactOnNPC_$i not met.\n", "reactOnNPC";
$i++;
next;
}
my $j = 0;
my $ok = 1;
while (exists $config{"reactOnNPC_${i}_msg_$j"})
{
my $msg;
if (exists $reactOnNPC{msg}[$j])
{
$msg = $reactOnNPC{msg}[$j];
# Remove RO color codes
$msg =~ s/\^[a-fA-F0-9]{6}//g unless ($config{"reactOnNPC_${i}_useColors"});
}

if (!defined $msg || !match($j, $msg, $config{"reactOnNPC_${i}_msg_$j"}))
{
debug "[reactOnNPC] One or more lines doesn't match for \"reactOnNPC_$i\" ($j).\n", "reactOnNPC";
$ok = 0;
last;
}
$j++;
}

if ($ok)
{
my $cmd = $config{"reactOnNPC_$i"};
$cmd =~ s/#(\d+)~(\d+)/$reactOnNPC{match}[$1][$2]/g;
my $kws = 'eval|resp';
while (my ($kw, $expr) = $cmd =~ /\@($kws)\(((?:(?!(?<!\@)\@$kws\().)+?)(?<!\@)\)/)
{
my $eval;
my $eval_expr = $expr;
$eval_expr =~ s/\@(?=[\@)])//g;
if ($kw eq 'eval')
{
$eval = eval $eval_expr;
}
elsif ($kw eq 'resp')
{
$i = 0;
foreach (@{$reactOnNPC{responses}}) {
if (match(undef, $_, $eval_expr))
{
last;
}
$i++;
}
$eval = $i;
}
$expr = quotemeta $expr;
$cmd =~ s/\@$kw\($expr\)/$eval/g;
}
message "[reactOnNPC] Reacting to NPC. Executing command \"$cmd\".\n", "success";
Commands::run($cmd);
last;
}
$i++;
}
undef %reactOnNPC if $type eq 'close';
}

sub match
{
my ($line, $subject, $pattern) = @_;

debug "[reactOnNPC] Matching \"$subject\" to \"$pattern\" ($line)... ", "reactOnNPC";
if (my ($re, $ci) = $pattern =~ /^\/(.+?)\/(i?)$/)
{
if (($ci && $subject =~ /$re/i) || (!$ci && $subject =~ /$re/))
{
if (defined $line)
{
no strict;
foreach my $index (1..$#-)
{
$reactOnNPC{match}[$line][$index] = ${$index};
}
}
debug "regexp ok.\n", "reactOnNPC";
return 1;
}
}
elsif ($subject eq $pattern)
{
debug "ok.\n", "reactOnNPC";
return 1;
}
debug "doesn't match.\n", "reactOnNPC";
}

sub onParseMsg
{
my (undef, $args, $handlers) = @_;

if ($handlers->{$args->{switch}})
{
my $handler = $handlers->{$args->{switch}};
$handler->[0]->($handler->[1], ($args->{switch} eq '00B4' || $args->{switch} eq '00B7') ? {RAW_MSG => $args->{msg}} : undef);
}
}

return 1;

Mucilon
Cybernatic Entity
Cybernatic Entity
Posts: 249
Joined: 04 Apr 2008, 13:15
Noob?: Yes
Location: Brazil

Re: reactOnNPC v.1.1.1

#43 Post by Mucilon »

darkzx
First off all, erase your char name from the images or you will be banned from your RO server!
Second, I don't speak your language, can you translate it? Otherwise I can't help you!
I didn't know this ReActOnNPCText plugin...

SomkanE
Noob
Noob
Posts: 1
Joined: 10 May 2008, 01:12
Noob?: Yes

Re: reactOnNPC v.1.1.1

#44 Post by SomkanE »

I got the problem wit anti-bot system
the system change $char->cloths_color
and player have to type the color into textbox
ex. Red , Light Green , Brown , Black etc

i can write conf for reactOnNPC but i don't know how to get variables
from $char->cloths_color i mean command for reactOnNPC
ex. reactonNPC talk text ....\\ I don't know here

thx

Mushroom
Perl Monk
Perl Monk
Posts: 427
Joined: 04 Apr 2008, 14:04
Noob?: No
Location: Brazil

Re: reactOnNPC v.1.1.1

#45 Post by Mushroom »

Can this plugin answer this anti-bot??
http://www.ragnabr.net/a.n.t.i.b.o.t/
Take off the . from antibot.
I'm trying to make some macros, but nothing work ''/
For the ones that don't understand portuguese, i'm going to explain how the anti-bot work.
You have to type the number using alternatives answers. For exemple:

Code: Select all

Unknown #110043755: [Autenticação]
Unknown #110043755: Type using the menu:
Unknown #110043755: Type: 4 5 6
Unknown #110043755: Code: _ _ _ .
Unknown #110043755: Tried 1 of 3
Unknown #110043755: You still have 120 seconds.
Existe um NPC: Unknown #110043755 (129, 126) (ID 110043755) - (0)
----------Answers-----------
# Answer
0 ô.Né or ŠïX
1 f[Îvè or šê'VëN
2 nìnË or ZêRÒ
3 fõúR or *t+hrëé
4 tWô or ËÎghT
5 Cancel Chat 
So, the number is 4 5 6, so you have to type talk resp 3, talk resp 1, talk resp 0.
Quit.

Mucilon
Cybernatic Entity
Cybernatic Entity
Posts: 249
Joined: 04 Apr 2008, 13:15
Noob?: Yes
Location: Brazil

Re: reactOnNPC v.1.1.1

#46 Post by Mucilon »

Man,
you are a luck guy!!!
I used to play and bot at ragnaBR... so I have it done!
Use this code:

Code: Select all

reactOnNPC talk resp @resp(@@eval(my $test = #2~1;return ('/[zž].?.?[eêéèë3].?.?r.?.?[oôóòöõø0]/i'@) if($test == 0@);return ('/[uûúùü].?.?m/i'@) if ($test == 1@); return ('/[dÐ].?.?[oôóòöõø0].?.?[iîíì\|1].?.?[sš\$]/i'@) if ($test == 2@); return ('/[t†].?.?r.?.?[eêéèë3].?.?[sš\$]/i'@) if ($test == 3@); return ('/q.?.?[uûúùü].?.?[aâáàäãåª].?.?[t†].?.?r.?.?[oôóòöõø0]/i'@) if ($test == 4@); return ('/[c¢ç].?.?[iîíì\|1].?.?[nñ].?.?[c¢ç].?.?[oôóòöõø0]/i'@) if ($test == 5@); return ('/[sš\$].?.?[eêéèë3].?.?[iîíì\|1].?.?[sš\$]/i'@) if ($test == 6@); return ('/[sš\$].?.?[eêéèë3].?.?[t†].?.?[eêéèë3]/i'@) if ($test == 7@); return ('/[oôóòöõø0].?.?[iîíì\|1].?.?[t†].?.?[oôóòöõø0]/i'@) if ($test == 8@); return ('/[nñ].?.?[oôóòöõø0].?.?v.?.?[eêéèë3]/i'@) if ($test == 9@);@)) {
	type responses
	msg_0 [Autenticação]1
	msg_1 Digite Ultilizando o Menu:
	msg_2 /Digitar:\s(\d)\s(\d)\s(\d)$/
	msg_3 /Código: _ _ _ \.$/
}

reactOnNPC talk resp @resp(@@eval(my $test = #2~2;return ('/[zž].?.?[eêéèë3].?.?r.?.?[oôóòöõø0]/i'@) if($test == 0@);return ('/[uûúùü].?.?m/i'@) if ($test == 1@); return ('/[dÐ].?.?[oôóòöõø0].?.?[iîíì\|1].?.?[sš\$]/i'@) if ($test == 2@); return ('/[t†].?.?r.?.?[eêéèë3].?.?[sš\$]/i'@) if ($test == 3@); return ('/q.?.?[uûúùü].?.?[aâáàäãåª].?.?[t†].?.?r.?.?[oôóòöõø0]/i'@) if ($test == 4@); return ('/[c¢ç].?.?[iîíì\|1].?.?[nñ].?.?[c¢ç].?.?[oôóòöõø0]/i'@) if ($test == 5@); return ('/[sš\$].?.?[eêéèë3].?.?[iîíì\|1].?.?[sš\$]/i'@) if ($test == 6@); return ('/[sš\$].?.?[eêéèë3].?.?[t†].?.?[eêéèë3]/i'@) if ($test == 7@); return ('/[oôóòöõø0].?.?[iîíì\|1].?.?[t†].?.?[oôóòöõø0]/i'@) if ($test == 8@); return ('/[nñ].?.?[oôóòöõø0].?.?v.?.?[eêéèë3]/i'@) if ($test == 9@);@)) {
	type responses
	msg_0 [Autenticação]
	msg_1 Digite Ultilizando o Menu:
	msg_2 /Digitar:\s(\d)\s(\d)\s(\d)$/
	msg_3 /Código: \* _ _ \.$/
}

reactOnNPC talk resp @resp(@@eval(my $test = #2~3;return ('/[zž].?.?[eêéèë3].?.?r.?.?[oôóòöõø0]/i'@) if($test == 0@);return ('/[uûúùü].?.?m/i'@) if ($test == 1@); return ('/[dÐ].?.?[oôóòöõø0].?.?[iîíì\|1].?.?[sš\$]/i'@) if ($test == 2@); return ('/[t†].?.?r.?.?[eêéèë3].?.?[sš\$]/i'@) if ($test == 3@); return ('/q.?.?[uûúùü].?.?[aâáàäãåª].?.?[t†].?.?r.?.?[oôóòöõø0]/i'@) if ($test == 4@); return ('/[c¢ç].?.?[iîíì\|1].?.?[nñ].?.?[c¢ç].?.?[oôóòöõø0]/i'@) if ($test == 5@); return ('/[sš\$].?.?[eêéèë3].?.?[iîíì\|1].?.?[sš\$]/i'@) if ($test == 6@); return ('/[sš\$].?.?[eêéèë3].?.?[t†].?.?[eêéèë3]/i'@) if ($test == 7@); return ('/[oôóòöõø0].?.?[iîíì\|1].?.?[t†].?.?[oôóòöõø0]/i'@) if ($test == 8@); return ('/[nñ].?.?[oôóòöõø0].?.?v.?.?[eêéèë3]/i'@) if ($test == 9@);@)) {
	type responses
	msg_0 [Autenticação]
	msg_1 Digite Ultilizando o Menu:
	msg_2 /Digitar:\s(\d)\s(\d)\s(\d)$/
	msg_3 /Código: \* \* _ \.$/
}
And the most important, the reactOnNPC does not work for nested commnads like @resp(@@eval(...)), so I changed it, but this plugin I changed works just for nested commands use!

[The extension pl has been deactivated and can no longer be displayed.]


Mushroom
Perl Monk
Perl Monk
Posts: 427
Joined: 04 Apr 2008, 14:04
Noob?: No
Location: Brazil

Re: reactOnNPC v.1.1.1

#47 Post by Mushroom »

Thanks. =D
Quit.

Mushroom
Perl Monk
Perl Monk
Posts: 427
Joined: 04 Apr 2008, 14:04
Noob?: No
Location: Brazil

Re: reactOnNPC v.1.1.1

#48 Post by Mushroom »

I know that I did double post.

@Mucilon
It didn't work ''/
Here is the console.

Code: Select all

 Unknown #110043755: [Autenticação]
Unknown #110043755: Digite Ultilizando o Menu:
Unknown #110043755: Digitar: 8 7 6
Unknown #110043755: Código: _ _ _ .
Unknown #110043755: Tentativa 1 de 3
Unknown #110043755: Você tem 120 Segundos Restantes
Unknown #110043755: Auto-continuing talking
NPC Exists: Unknown #110043755
[success] [reactOnNPC] Resposta nao encontrada, chutando 3
[success] [reactOnNPC] Respondendo ao NPC: "talk resp 3" em 13.1549072265625 segundos.
[reactOnNPC] [reactOnNPC] Esperei 13.1549072265625 segundos...
[console] Error in function 'talk resp' (Respond to NPC)
Response 3 does not exist.
[list] ----------Responses-----------
#  Response
0  ¢I.ncØ ou ?zê}rÒ
1  Öî†Ö ou šéíS
2  dØíS ou šÊ*tê
3  uM* ou qÚà]T~rÖ
4  TrèŠ ou N]ÖVË
5  Cancel Chat
Quit.

Zairik
Noob
Noob
Posts: 4
Joined: 13 May 2008, 15:48
Noob?: No
Location: USA, NC
Contact:

Re: reactOnNPC v.1.1.1

#49 Post by Zairik »


Mucilon
Cybernatic Entity
Cybernatic Entity
Posts: 249
Joined: 04 Apr 2008, 13:15
Noob?: Yes
Location: Brazil

Re: reactOnNPC v.1.1.1

#50 Post by Mucilon »

Your code is still weak...

Post Reply