I add two attributes("nearMonsters" and "nearDist") into the config key of "useSelf_skill".
The description:
When I set the "useSelf_skill" for the "Endure" skill. I think the moment for using "Endure" on self should be before attacking or attacked (or even walking through some monsters). The conditions for using "Endure" on self should be how closed some specified monsters. So, I add the two attributes "nearMonsters" and "nearDist" into the config key of "useSelf_skill", and add some codes into /src/AI.pm and /src/Misc.pm.
the codes are:
the AI.pm:
(1) add a line before "ai_getAggressives". such as:
Code: Select all
...........
our @EXPORT = (
qw/
ai_clientSuspend
ai_drop
ai_follow
ai_partyfollow
ai_getNearMonster
ai_getAggressives
ai_getPlayerAggressives
ai_getMonstersAttacking
................
Code: Select all
sub ai_getNearMonster {
my ($type, $party) = @_;
my $dist = shift;
my $wantArray = wantarray;
my @agMonsters;
$dist = 20 unless($dist);
foreach my $monster (@{$monstersList->getItems()}) {
my $control = Misc::mon_control($monster->name,$monster->{nameID}) if $type || !$wantArray;
my $ID = $monster->{ID};
if ($monster->distance() < $dist) {
if ($wantArray) {
# Function is called in array context
push @agMonsters, $ID;
}
}
}
return @agMonsters;
}
Add lines with in the "checkSelfCondition" subroutime, near the line 3774 , such as:
Code: Select all
.......
if ($config{$prefix . "_notWhileSitting"} > 0) { return 0 if ($char->{sitting}); }
if ($config{$prefix . "_notInTown"} > 0) { return 0 if ($field->isCity); }
if ($config{$prefix . "_nearMonsters"} && ($prefix =~ /useSelf_skill/i)) {
my $exists;
foreach (ai_getNearMonster($config{$prefix . "_nearDist"})) {
if (existsInList($config{$prefix . "_nearMonsters"}, $monsters{$_}->name)) {
$exists = 1;
last;
}
}
return 0 unless $exists;
}
if ($config{$prefix . "_monsters"} && !($prefix =~ /skillSlot/i) && !($prefix =~ /ComboSlot/i)) {
my $exists;
foreach (ai_getAggressives()) {
.......