After an evening of disappointment, little me that has no knowlede of Pearl whatsoever, figured out the problem... i guess.
The respective code, that checks the list of avaliable monsters, apparently misses the distance check in 2 of 4 occasions (where weirdly in the other 2 the check was implemented)
Explicit i mean:
Code: Select all
if (!defined($highestPri) || ($priority{$name} > $highestPri)) {
$highestPri = $priority{$name};
$smallestDist = $dist;
$bestTarget = $_;
}
if ((!defined($highestPri) || $priority{$name} == $highestPri)
&& (!defined($smallestDist) || $dist < $smallestDist)) {
$highestPri = $priority{$name};
$smallestDist = $dist;
$bestTarget = $_;
}
When it says the checked monsters priority is greater than the last priority checked, (which is the case whenever you did not set any priority at all, i assume) it substitutes the just checked monster for the last one.
That way the outcome is, the overall last checked monster will be the $bestTarget.
So you basically have to weave
Code: Select all
&& (!defined($smallestDist) || $dist < $smallestDist)
into the first condition, which exists twice (once for line-of-sight monsters and once for the others), or set the desired monster explicit as the highest priority target i figure.
I`ve been maintaining my bot for about 30 minutes with this modification now, and it has yet to fail me.
On 10/10 occasions, where it had the opportunity to do its little dance, it didnt and killed the monsters one after the other in order of their distance.
If someone with knowledge of the code could check my suspicion, i would be happy, because maybe i didnt think of some issues that my little workaround could cause.
Greetz, EverythingIsAllright