Removed old "distance" option from config.txt but maintained it's functionality so it shouldn't break existing configurations (won't have random distance, but won't bug too.)
src/AI/CoreLogic.pm
Code: Select all
Index: src/AI/CoreLogic.pm
===================================================================
--- src/AI/CoreLogic.pm (revision 8316)
+++ src/AI/CoreLogic.pm (working copy)
@@ -1143,13 +1143,21 @@
$args->{done} = 1;
return;
}
-
+ if (!AI::args->{distance}) {
+ # Calculate variable or fixed (old) distance
+ if ($config{'storageAuto_minDistance'} && $config{'storageAuto_maxDistance'}) {
+ AI::args->{distance} = $config{'storageAuto_minDistance'} + round(rand($config{'storageAuto_maxDistance'} - $config{'storageAuto_minDistance'}));
+ } else {
+ AI::args->{distance} = $config{'storageAuto_distance'};
+ }
+ }
+
# Determine whether we have to move to the NPC
if ($field->baseName ne $args->{npc}{map}) {
$do_route = 1;
} else {
- my $distance = distance($args->{npc}{pos}, $char->{pos_to});
- if ($distance > $config{'storageAuto_distance'}) {
+ my $distance_from_char = distance($args->{npc}{pos}, $char->{pos_to});
+ if (($distance_from_char > AI::args->{distance}) && !defined($args->{sentStore}) && !defined($ai_v{temp}{storage_opened})) {
$do_route = 1;
}
}
@@ -1173,7 +1181,7 @@
message TF("Calculating auto-storage route to: %s(%s): %s, %s\n", $maps_lut{$args->{npc}{map}.'.rsw'}, $args->{npc}{map}, $args->{npc}{pos}{x}, $args->{npc}{pos}{y}), "route";
ai_route($args->{npc}{map}, $args->{npc}{pos}{x}, $args->{npc}{pos}{y},
attackOnRoute => 1,
- distFromGoal => $config{'storageAuto_distance'});
+ distFromGoal => AI::args->{distance});
}
}
}
@@ -1431,14 +1439,23 @@
$args->{'done'} = 1;
return;
}
-
+
+ if (!AI::args->{distance}) {
+ if ($config{'sellAuto_standpoint'}) {
+ AI::args->{distance} = 1;
+ } elsif ($config{'sellAuto_minDistance'} && $config{'sellAuto_maxDistance'}) {
+ AI::args->{distance} = $config{'sellAuto_minDistance'} + round(rand($config{'sellAuto_maxDistance'} - $config{'sellAuto_minDistance'}));
+ } else {
+ AI::args->{distance} = $config{'sellAuto_distance'};
+ }
+ }
+
undef $ai_v{'temp'}{'do_route'};
if ($field->baseName ne $args->{'npc'}{'map'}) {
$ai_v{'temp'}{'do_route'} = 1;
} else {
$ai_v{'temp'}{'distance'} = distance($args->{'npc'}{'pos'}, $chars[$config{'char'}]{'pos_to'});
- $config{'sellAuto_distance'} = 1 if ($config{sellAuto_standpoint});
- if ($ai_v{'temp'}{'distance'} > $config{'sellAuto_distance'}) {
+ if (($ai_v{'temp'}{'distance'} > AI::args->{distance}) && !defined($args->{sentSell})) { # && !defined($ai_v{temp}{storage_opened})
$ai_v{'temp'}{'do_route'} = 1;
}
}
@@ -1459,7 +1476,7 @@
message TF("Calculating auto-sell route to: %s(%s): %s, %s\n", $maps_lut{$ai_seq_args[0]{'npc'}{'map'}.'.rsw'}, $ai_seq_args[0]{'npc'}{'map'}, $ai_seq_args[0]{'npc'}{'pos'}{'x'}, $ai_seq_args[0]{'npc'}{'pos'}{'y'}), "route";
ai_route($args->{'npc'}{'map'}, $args->{'npc'}{'pos'}{'x'}, $args->{'npc'}{'pos'}{'y'},
attackOnRoute => 1,
- distFromGoal => $config{'sellAuto_distance'},
+ distFromGoal => AI::args->{distance},
noSitAuto => 1);
}
} else {
@@ -1598,12 +1615,22 @@
}
undef $ai_v{'temp'}{'do_route'};
+ if (!AI::args->{distance}) {
+ # Calculate variable or fixed (old) distance
+ if ($config{"buyAuto_$args->{index}"."_standpoint"}) {
+ AI::args->{distance} = 1;
+ } elsif ($config{"buyAuto_".$args->{index}."_minDistance"} && $config{"buyAuto_".$args->{index}."_maxDistance"}) {
+ AI::args->{distance} = $config{"buyAuto_$args->{index}"."_minDistance"} + round(rand($config{"buyAuto_$args->{index}"."_maxDistance"} - $config{"buyAuto_$args->{index}"."_minDistance"}));
+ } else {
+ AI::args->{distance} = $config{"buyAuto_$args->{index}"."_distance"};
+ }
+ }
+
if ($field->baseName ne $args->{'npc'}{'map'}) {
$ai_v{'temp'}{'do_route'} = 1;
} else {
$ai_v{'temp'}{'distance'} = distance($args->{'npc'}{'pos'}, $chars[$config{'char'}]{'pos_to'});
- $config{"buyAuto_$args->{index}"."_distance"} = 1 if ($config{"buyAuto_$args->{index}"."_standpoint"});
- if ($ai_v{'temp'}{'distance'} > $config{"buyAuto_$args->{index}"."_distance"}) {
+ if (($ai_v{'temp'}{'distance'} > AI::args->{distance}) && !defined($args->{sentBuy})) {
$ai_v{'temp'}{'do_route'} = 1;
}
}
@@ -1632,7 +1659,7 @@
message TF($msgneeditem."Calculating auto-buy route to: %s (%s): %s, %s\n", $maps_lut{$args->{npc}{map}.'.rsw'}, $args->{npc}{map}, $args->{npc}{pos}{x}, $args->{npc}{pos}{y}), "route";
ai_route($args->{npc}{map}, $args->{npc}{pos}{x}, $args->{npc}{pos}{y},
attackOnRoute => 1,
- distFromGoal => $config{"buyAuto_$args->{index}"."_distance"});
+ distFromGoal => AI::args->{distance});
}
} else {
if ($args->{lastIndex} eq "" || $args->{lastIndex} != $args->{index}) {
Code: Select all
Index: config.txt
===================================================================
--- config.txt (revision 8316)
+++ config.txt (working copy)
@@ -622,7 +622,8 @@
buyAuto {
npc
standpoint
- distance 5
+ minDistance 3
+ maxDistance 7
price
minAmount 2
maxAmount 3
@@ -631,11 +632,13 @@
sellAuto 0
sellAuto_npc
sellAuto_standpoint
-sellAuto_distance 5
+sellAuto_minDistance 3
+sellAuto_maxDistance 7
storageAuto 0
storageAuto_npc
-storageAuto_distance 5
+storageAuto_minDistance 3
+storageAuto_maxDistance 7
storageAuto_npc_type 1
storageAuto_npc_steps
storageAuto_password