Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Ragnarok Online
You last visited: Today at 16:46

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Ragnarok Autorefiner BOT

Discussion on Ragnarok Autorefiner BOT within the Ragnarok Online forum part of the MMORPGs category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Sep 2010
Posts: 4
Received Thanks: 0
Thumbs up Ragnarok Autorefiner BOT





"CODE"

# refineAuto.pl
#
# Automated Mass Refining
# version 0.0.1
# Openkore 2.0.0

package refineAuto;

use strict;
use Plugins;
use Globals;
use AI;
use Log;
use Actor::Item;
use Network::Send;
use Misc;

# Config keys used:
# refineAuto enable/disable auto refining
# refineAuto_npc refiner npc
# refineAuto_distance distence to stand from npc
# refineAuto_maxRefine maximum refining rate
# refineAuto_npc_steps npc talking sequence when refining
# refineAuto_equip equipment name that will be refined, without +
# refineAuto_useMagnifier enable item identification with magnifier
# refineAuto_material materials needed to refine
# refineAuto_minZenny minimum amount of zenny needed to refine
# refineAuto_getAutoAdjust automatically adjusts getAuto
# refineAuto_incremental when incremental refining should start
# refineAuto_dcWhenDone disconnect if resources are depleted

Plugins::register('autorefine', 'automatic refining', \&unload_callback);
my $plugin_hook = Plugins::addHook("AI_pre", \&autorefine);

sub autorefine {
# Initiate autorefine, AI must be idle
if ($config{'refineAuto'} && AI::isIdle) {
AI::queue('refineAuto');
Log::message "refineAuto initiated\n";
} elsif (AI::is('refineAuto')) {
my $args = AI::args;

if (!$args->{npc}) {
$args->{npc} = {};
main::getNPCInfo($config{refineAuto_npc},
$args->{npc});
}
# Move to NPC if needed
elsif (($field{name} ne $args->{npc}{map})
|| ((Utils::distance($args->{npc}{pos}, $char->{pos_to})
> $config{refineAuto_distance}))) {

Log::message "Calculating refineAuto 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},
distFromGoal =>
$config{refineAuto_distance});
} else {
# We arrived at refiner

# Check arguments for incremental refining
# If refineAuto_incremental is invalid or not specified
# Set refineAuto_incremental to maxRefine

if (!($config{refineAuto_incremental} > 0
&& $config{refineAuto_incremental}
< $config{refineAuto_maxRefine})) {

$config{refineAuto_incremental} =
$config{refineAuto_maxRefine};
}

# Equipped and ready to refine
if ($args->{equip}) {
refine_item($args);
}

# Check if we have all the requirements
elsif (check_requirements($args)) {
equip_item($args);
}
}
}
}

sub refine_item {
my $args = shift;

Log::message "Trying to refine $args->{equip}{name}\n";

if ($args->{refine} < $config{refineAuto_incremental}) {
main::ai_talkNPC($args->{npc}{pos}{x}, $args->{npc}{pos}{y},
$config{refineAuto_npc_steps});
Log::message "Refining $args->{equip}{name}\n";
$args->{equip} = undef;
$args->{refine} = undef;
}
}

sub equip_item {
my $args = shift;
my $i;
my $item;
my $type;
my $refine;

$args->{equip} = undef;
$args->{refine} = undef;

for ($i = 0; $i < @{$char->{inventory}}; $i++) {
$item = $char->{inventory}[$i];
next unless $item && %{$item};

$type = $item->{type};
# Check if it is an equipment, refer to tables/itemtypes.txt
if ($type == 4 || $type == 5 || $type == 11 || $type == 8
|| $type == 9) {
# Check if it is the right equipment
if ($item->{name} =~
m/(\Q$config{refineAuto_equip}\E)/) {

Log::message "Trying to equip $1\n";
# Check its current refine rate
$refine = $item->{name} =~ m/^\+(\d)/ ? $1 : 0;
if ($refine < $config{refineAuto_incremental}) {
identify_item($item);

# If this doesn't work, just sendEquip
$item->equip;

$args->{equip} = $item;
$args->{refine} = $refine;

Log::message "Item equipped\n";
return;
}
}
}
}
}

# Assumes proper configuration
sub identify_item {
my $item = shift;

# Check if the item is already Identified
if ($item->{identified}) {
return;
}
}

sub check_requirements {
my $args = shift;

$args->{retry} = 0 unless defined $args->{retry};
$args->{getPlus} = 0 unless defined $args->{getPlus};

# Item shortage after 3 retries
if ($args->{retry} > 3) {
if ($config{refineAuto_incremental} > 0
&& $config{refineAuto_incremental}
< $config{refineAuto_maxRefine}) {
$args->{retry} = 0;
$config{refineAuto_incremental} += 1;
} else {
done_refine();
}
}

# Automatic getAuto adjustment, only done when storage auto failed
if ($config{refineAuto_getAutoAdjust} == 1 && $args->{retry} > 1
&& $args->{getPlus} < $config{refineAuto_incremental}) {
# Look for getAuto index to adjust
my $i = 0;
my $done = 0;
while ($config{"getAuto_$i"} ne "") {
if ($config{"getAuto_$i"} =~
m/(\Q$config{refineAuto_equip}\E)/) {

my $prefix = ($args->{getPlus} == 0) ?
"" : "+$args->{getPlus} ";

$config{"getAuto_$i"} = $prefix .
$config{refineAuto_equip};
Log::message 'getAuto adjusted\n';
$args->{getPlus} += 1;
$args->{retry} = 0;
$done = 1;
}
last if $done;
$i++;
}
}

# Check for config
if ($config{refineAuto_equip}
&& $config{refineAuto_material}
&& $config{refineAuto_minZenny}) {
my $material = Actor::Item::get($config{refineAuto_material}, 0, 1);
my $equip = undef;
my $want_magnifier = undef;
my $plus;

# Check for equipment, starting from +0 to max
for ($plus = 0;
$plus < $config{refineAuto_incremental}; $plus++) {
my $prefix = ($plus == 0) ? "" : "+$plus ";
$equip = Actor::Item::get($prefix .
$config{refineAuto_equip}, 0, 0);
last if defined $equip;
}

if ($config{refineAuto_useMagnifier}) {
if (!defined Actor::Item::get("Magnifier", 0, 1)) {
$want_magnifier = 1;
}
} elsif ($char->{skills}{MC_IDENTIFY}{lv} != 1) {
Log::message "No Identify skill, magnifier is needed";
$config{refineAuto_useMagnifier} = 1;
return 0;
}

if (defined $material
&& defined $equip
&& $char->{zenny} >= $config{refineAuto_minZenny}
&& !$want_magnifier) {
$args->{retry} = 0;
return 1;
} elsif ($char->{zenny} < $config{refineAuto_minZenny}) {
done_refine();
} elsif ($args->{retry} > 0 && !defined $material) {
done_refine();
} else {
if ($config{refineAuto_visitStorage} != 0) {
AI::queue("storageAuto");
}
$args->{retry} += 1;
}


} else {
Log::message "Incomplete configuration for refineAuto\n";
}
return 0;
}

sub done_refine {
if ($config{refineAuto_dcWhenDone}) {
Misc::quit();
} else {
AI::dequeue();
}
}

sub unload_callback {
}

return 1;

################################################## ###########


Add this on your Config.txt


refineAuto 1
refineAuto_npc ein_in01 24 87
refineAuto_distance 5
refineAuto_maxRefine 9
refineAuto_npc_steps c r4 r1 d9 c r0 c c r0 c c n
refineAuto_equip Muffler [1]
refineAuto_material Elunium
refineAuto_minZenny 14000
refineAuto_incremental 4
refineAuto_getAutoAdjust 0
refineAuto_dcWhenDone 0
refineAuto_visitStorage 0


Just Edit your Server on Servers.txt
talaheb is offline  
Old 06/22/2011, 22:10   #2
 
elite*gold: 0
Join Date: Jan 2010
Posts: 5
Received Thanks: 0
0.0 thanks. does it works on 2.0.7?
ohyeahsohot1 is offline  
Old 07/13/2011, 14:31   #3
 
elite*gold: 0
Join Date: Jun 2008
Posts: 25
Received Thanks: 0
Quote:
Originally Posted by talaheb View Post



"CODE"

# refineAuto.pl
#
# Automated Mass Refining
# version 0.0.1
# Openkore 2.0.0

package refineAuto;

use strict;
use Plugins;
use Globals;
use AI;
use Log;
use Actor::Item;
use Network::Send;
use Misc;

# Config keys used:
# refineAuto enable/disable auto refining
# refineAuto_npc refiner npc
# refineAuto_distance distence to stand from npc
# refineAuto_maxRefine maximum refining rate
# refineAuto_npc_steps npc talking sequence when refining
# refineAuto_equip equipment name that will be refined, without +
# refineAuto_useMagnifier enable item identification with magnifier
# refineAuto_material materials needed to refine
# refineAuto_minZenny minimum amount of zenny needed to refine
# refineAuto_getAutoAdjust automatically adjusts getAuto
# refineAuto_incremental when incremental refining should start
# refineAuto_dcWhenDone disconnect if resources are depleted

Plugins::register('autorefine', 'automatic refining', \&unload_callback);
my $plugin_hook = Plugins::addHook("AI_pre", \&autorefine);

sub autorefine {
# Initiate autorefine, AI must be idle
if ($config{'refineAuto'} && AI::isIdle) {
AI::queue('refineAuto');
Log::message "refineAuto initiated\n";
} elsif (AI::is('refineAuto')) {
my $args = AI::args;

if (!$args->{npc}) {
$args->{npc} = {};
main::getNPCInfo($config{refineAuto_npc},
$args->{npc});
}
# Move to NPC if needed
elsif (($field{name} ne $args->{npc}{map})
|| ((Utils::distance($args->{npc}{pos}, $char->{pos_to})
> $config{refineAuto_distance}))) {

Log::message "Calculating refineAuto 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},
distFromGoal =>
$config{refineAuto_distance});
} else {
# We arrived at refiner

# Check arguments for incremental refining
# If refineAuto_incremental is invalid or not specified
# Set refineAuto_incremental to maxRefine

if (!($config{refineAuto_incremental} > 0
&& $config{refineAuto_incremental}
< $config{refineAuto_maxRefine})) {

$config{refineAuto_incremental} =
$config{refineAuto_maxRefine};
}

# Equipped and ready to refine
if ($args->{equip}) {
refine_item($args);
}

# Check if we have all the requirements
elsif (check_requirements($args)) {
equip_item($args);
}
}
}
}

sub refine_item {
my $args = shift;

Log::message "Trying to refine $args->{equip}{name}\n";

if ($args->{refine} < $config{refineAuto_incremental}) {
main::ai_talkNPC($args->{npc}{pos}{x}, $args->{npc}{pos}{y},
$config{refineAuto_npc_steps});
Log::message "Refining $args->{equip}{name}\n";
$args->{equip} = undef;
$args->{refine} = undef;
}
}

sub equip_item {
my $args = shift;
my $i;
my $item;
my $type;
my $refine;

$args->{equip} = undef;
$args->{refine} = undef;

for ($i = 0; $i < @{$char->{inventory}}; $i++) {
$item = $char->{inventory}[$i];
next unless $item && %{$item};

$type = $item->{type};
# Check if it is an equipment, refer to tables/itemtypes.txt
if ($type == 4 || $type == 5 || $type == 11 || $type == 8
|| $type == 9) {
# Check if it is the right equipment
if ($item->{name} =~
m/(\Q$config{refineAuto_equip}\E)/) {

Log::message "Trying to equip $1\n";
# Check its current refine rate
$refine = $item->{name} =~ m/^\+(\d)/ ? $1 : 0;
if ($refine < $config{refineAuto_incremental}) {
identify_item($item);

# If this doesn't work, just sendEquip
$item->equip;

$args->{equip} = $item;
$args->{refine} = $refine;

Log::message "Item equipped\n";
return;
}
}
}
}
}

# Assumes proper configuration
sub identify_item {
my $item = shift;

# Check if the item is already Identified
if ($item->{identified}) {
return;
}
}

sub check_requirements {
my $args = shift;

$args->{retry} = 0 unless defined $args->{retry};
$args->{getPlus} = 0 unless defined $args->{getPlus};

# Item shortage after 3 retries
if ($args->{retry} > 3) {
if ($config{refineAuto_incremental} > 0
&& $config{refineAuto_incremental}
< $config{refineAuto_maxRefine}) {
$args->{retry} = 0;
$config{refineAuto_incremental} += 1;
} else {
done_refine();
}
}

# Automatic getAuto adjustment, only done when storage auto failed
if ($config{refineAuto_getAutoAdjust} == 1 && $args->{retry} > 1
&& $args->{getPlus} < $config{refineAuto_incremental}) {
# Look for getAuto index to adjust
my $i = 0;
my $done = 0;
while ($config{"getAuto_$i"} ne "") {
if ($config{"getAuto_$i"} =~
m/(\Q$config{refineAuto_equip}\E)/) {

my $prefix = ($args->{getPlus} == 0) ?
"" : "+$args->{getPlus} ";

$config{"getAuto_$i"} = $prefix .
$config{refineAuto_equip};
Log::message 'getAuto adjusted\n';
$args->{getPlus} += 1;
$args->{retry} = 0;
$done = 1;
}
last if $done;
$i++;
}
}

# Check for config
if ($config{refineAuto_equip}
&& $config{refineAuto_material}
&& $config{refineAuto_minZenny}) {
my $material = Actor::Item::get($config{refineAuto_material}, 0, 1);
my $equip = undef;
my $want_magnifier = undef;
my $plus;

# Check for equipment, starting from +0 to max
for ($plus = 0;
$plus < $config{refineAuto_incremental}; $plus++) {
my $prefix = ($plus == 0) ? "" : "+$plus ";
$equip = Actor::Item::get($prefix .
$config{refineAuto_equip}, 0, 0);
last if defined $equip;
}

if ($config{refineAuto_useMagnifier}) {
if (!defined Actor::Item::get("Magnifier", 0, 1)) {
$want_magnifier = 1;
}
} elsif ($char->{skills}{MC_IDENTIFY}{lv} != 1) {
Log::message "No Identify skill, magnifier is needed";
$config{refineAuto_useMagnifier} = 1;
return 0;
}

if (defined $material
&& defined $equip
&& $char->{zenny} >= $config{refineAuto_minZenny}
&& !$want_magnifier) {
$args->{retry} = 0;
return 1;
} elsif ($char->{zenny} < $config{refineAuto_minZenny}) {
done_refine();
} elsif ($args->{retry} > 0 && !defined $material) {
done_refine();
} else {
if ($config{refineAuto_visitStorage} != 0) {
AI::queue("storageAuto");
}
$args->{retry} += 1;
}


} else {
Log::message "Incomplete configuration for refineAuto\n";
}
return 0;
}

sub done_refine {
if ($config{refineAuto_dcWhenDone}) {
Misc::quit();
} else {
AI::dequeue();
}
}

sub unload_callback {
}

return 1;


Where can i put this code?
ahuhu1 is offline  
Old 07/18/2011, 12:01   #4
 
ChibiEbil's Avatar
 
elite*gold: 0
Join Date: Aug 2005
Posts: 1,738
Received Thanks: 74
plugins directory => refineAuto.pl
ChibiEbil is offline  
Old 01/24/2012, 15:40   #5
 
elite*gold: 0
Join Date: Aug 2009
Posts: 4
Received Thanks: 0
just wanna ask if it will not break the weapon?
ho0oh101 is offline  
Old 02/02/2012, 08:54   #6
 
elite*gold: 0
Join Date: Apr 2011
Posts: 2
Received Thanks: 0
can this be used on other Private ragnarok server???
BTW... how to use this,,

/heh
kraken9329 is offline  

Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.