66iz
27th September 2005, 19:49
i have want is a bot e Function attackauto_killsteal monter
and a Change Source Function NotAttackDistance (#Avoid KSing)
Thx.
Ex.
Config.txt
attackauto_killsteal 0 notsteal 1 steal
NotAttackDistance 0 off-Function 5 On Function ( Distance 5 Block Near You )
##### AUTO-ATTACK #####
if (($ai_seq[0] eq "" || $ai_seq[0] eq "route" || $ai_seq[0] eq "route_getRoute" || $ai_seq[0] eq "route_getMapRoute" || $ai_seq[0] eq "follow"
|| $ai_seq[0] eq "sitAuto" || $ai_seq[0] eq "take" || $ai_seq[0] eq "items_gather" || $ai_seq[0] eq "items_take")
&& !($config{'itemsTakeAuto'} >= 2 && ($ai_seq[0] eq "take" || $ai_seq[0] eq "items_take"))
&& !($config{'itemsGatherAuto'} >= 2 && ($ai_seq[0] eq "take" || $ai_seq[0] eq "items_gather"))
&& timeOut(\%{$timeout{'ai_attack_auto'}})) {
undef @{$ai_v{'ai_attack_agMonsters'}};
undef @{$ai_v{'ai_attack_cleanMonsters'}};
undef @{$ai_v{'ai_attack_partyMonsters'}};
undef $ai_v{'temp'}{'foundID'};
if ($config{'tankMode'}) {
undef $ai_v{'temp'}{'found'};
foreach (@playersID) {
next if ($_ eq "");
if ($config{'tankModeTarget'} eq $players{$_}{'name'}) {
$ai_v{'temp'}{'found'} = 1;
last;
}
}
}
if (!$config{'tankMode'} || ($config{'tankMode'} && $ai_v{'temp'}{'found'})) {
$ai_v{'temp'}{'ai_follow_index'} = binFind(\@ai_seq, "follow");
if ($ai_v{'temp'}{'ai_follow_index'} ne "") {
$ai_v{'temp'}{'ai_follow_following'} = $ai_seq_args[$ai_v{'temp'}{'ai_follow_index'}]{'following'};
$ai_v{'temp'}{'ai_follow_ID'} = $ai_seq_args[$ai_v{'temp'}{'ai_follow_index'}]{'ID'};
} else {
undef $ai_v{'temp'}{'ai_follow_following'};
}
$ai_v{'temp'}{'ai_route_index'} = binFind(\@ai_seq, "route");
if ($ai_v{'temp'}{'ai_route_index'} ne "") {
$ai_v{'temp'}{'ai_route_attackOnRoute'} = $ai_seq_args[$ai_v{'temp'}{'ai_route_index'}]{'attackOnRoute'};
}
# List aggressive monsters
#@{$ai_v{'ai_attack_agMonsters'}} = ai_getAggressives() if ($config{'attackAuto'} && !($ai_v{'temp'}{'ai_route_index'} ne "" && !$ai_v{'temp'}{'ai_route_attackOnRoute'}));
if ($config{'attackAuto'} && !($ai_v{'temp'}{'ai_route_index'} ne "" && !$ai_v{'temp'}{'ai_route_attackOnRoute'})){
@{$ai_v{'ai_attack_agMonsters'}} = ai_getAggressives(1);
}
# There are two types of non-aggressive monsters. We generate two lists:
foreach (@monstersID) {
next if ($_ eq "");
# Detect Frozen & Trap Monster
if (!$monsters{$ID}{'state'}) {
# List monsters that the follow target or party members are attacking
if ((($config{'attackAuto_party'}
&& $ai_seq[0] ne "take" && $ai_seq[0] ne "items_take"
&& ($monsters{$_}{'dmgToParty'} > 0 || $monsters{$_}{'dmgFromParty'} > 0))
|| ($config{'attackAuto_followTarget'} && $ai_v{'temp'}{'ai_follow_following'}
&& ($monsters{$_}{'dmgToPlayer'}{$ai_v{'temp'}{'ai_fo llow_ID'}} > 0 || $monsters{$_}{'missedToPlayer'}{$ai_v{'temp'}{'ai_ follow_ID'}} > 0 || $monsters{$_}{'dmgFromPlayer'}{$ai_v{'temp'}{'ai_f ollow_ID'}} > 0)))
&& !($ai_v{'temp'}{'ai_route_index'} ne "" && !$ai_v{'temp'}{'ai_route_attackOnRoute'})
&& $monsters{$_}{'attack_failed'} == 0 && ($mon_control{lc($monsters{$_}{'name'})}{'attack_a uto'} >= 1 || $mon_control{lc($monsters{$_}{'name'})}{'attack_au to'} eq "")) {
push @{$ai_v{'ai_attack_partyMonsters'}}, $_;
# Begin the attack only when noone else is on screen.
} elsif ($config{'attackAuto_onlyWhenSafe'}
&& $config{'attackAuto'} >= 1
&& binSize(\@playersID) == 0
&& $ai_seq[0] ne "sitAuto" && $ai_seq[0] ne "take" && $ai_seq[0] ne "items_gather" && $ai_seq[0] ne "items_take"
&& !($monsters{$_}{'dmgFromYou'} == 0 && ($monsters{$_}{'dmgTo'} > 0 || $monsters{$_}{'dmgFrom'} > 0 || %{$monsters{$_}{'missedFromPlayer'}} || %{$monsters{$_}{'missedToPlayer'}} || %{$monsters{$_}{'castOnByPlayer'}})) && $monsters{$_}{'attack_failed'} == 0
&& !($ai_v{'temp'}{'ai_route_index'} ne "" && $ai_v{'temp'}{'ai_route_attackOnRoute'} <= 1)
&& ($mon_control{lc($monsters{$_}{'name'})}{'attack_a uto'} >= 1 || $mon_control{lc($monsters{$_}{'name'})}{'attack_au to'} eq "")) {
push @{$ai_v{'ai_attack_cleanMonsters'}}, $_;
# List monsters that nobody's attacking
} elsif ($config{'attackAuto'} >= 2
&& !$config{'attackAuto_onlyWhenSafe'}
&& $ai_seq[0] ne "sitAuto" && $ai_seq[0] ne "take" && $ai_seq[0] ne "items_gather" && $ai_seq[0] ne "items_take"
&& !($monsters{$_}{'dmgFromYou'} == 0 && ($monsters{$_}{'dmgTo'} > 0 || $monsters{$_}{'dmgFrom'} > 0 || %{$monsters{$_}{'missedFromPlayer'}} || %{$monsters{$_}{'missedToPlayer'}} || %{$monsters{$_}{'castOnByPlayer'}})) && $monsters{$_}{'attack_failed'} == 0
&& !($ai_v{'temp'}{'ai_route_index'} ne "" && $ai_v{'temp'}{'ai_route_attackOnRoute'} <= 1)
&& ($mon_control{lc($monsters{$_}{'name'})}{'attack_a uto'} >= 1 || $mon_control{lc($monsters{$_}{'name'})}{'attack_au to'} eq "")) {
#Avoid KSing
undef $m_plDist_small;
my $judgeFirst = 1;
my $m_cDist = distance(\%{$chars[$config{'char'}]{'pos_to'}}, \%{$monsters{$_}{'pos_to'}});
for ($i = 0; $i < @playersID; $i++) {
next if ($playersID[$i] eq "");
$m_plDist = distance(\%{$players{$playersID[$i]}{'pos_to'}}, \%{$monsters{$_}{'pos_to'}});
if ($judgeFirst || $m_plDist < $m_plDist_small) {
$m_plDist_small = $m_plDist;
$judgeFirst = 0;
}
}
if((!$m_plDist_small || $m_plDist_small >= $config{'NotAttackDistance'} || $m_cDist <= $m_plDist_small)
&&(($config{'attackAuto'}==2 && $mon_control{lc($monsters{$_}{'name'})}{'attack_au to'})||$config{'attackAuto'}>2)){
push @{$ai_v{'ai_attack_cleanMonsters'}}, $_;
}
}
}
}
#Reduce code size & fix monster Priority
undef $ai_v{'temp'}{'foundID'};
$ai_v{'temp'}{'foundID'} = selectTarget(@{$ai_v{'ai_attack_agMonsters'}}) if (@{$ai_v{'ai_attack_agMonsters'}});
$ai_v{'temp'}{'foundID'} = selectTarget(@{$ai_v{'ai_attack_partyMonsters'}}) if (!defined($ai_v{'temp'}{'foundID'}) && @{$ai_v{'ai_attack_partyMonsters'}});
$ai_v{'temp'}{'foundID'} = selectTarget(@{$ai_v{'ai_attack_cleanMonsters'}}) if (!defined($ai_v{'temp'}{'foundID'}) && @{$ai_v{'ai_attack_cleanMonsters'}});
}
if ($ai_v{'temp'}{'foundID'}) {
ai_setSuspend(0);
attack($ai_v{'temp'}{'foundID'});
} else {
$timeout{'ai_attack_auto'}{'time'} = time;
}
}
and a Change Source Function NotAttackDistance (#Avoid KSing)
Thx.
Ex.
Config.txt
attackauto_killsteal 0 notsteal 1 steal
NotAttackDistance 0 off-Function 5 On Function ( Distance 5 Block Near You )
##### AUTO-ATTACK #####
if (($ai_seq[0] eq "" || $ai_seq[0] eq "route" || $ai_seq[0] eq "route_getRoute" || $ai_seq[0] eq "route_getMapRoute" || $ai_seq[0] eq "follow"
|| $ai_seq[0] eq "sitAuto" || $ai_seq[0] eq "take" || $ai_seq[0] eq "items_gather" || $ai_seq[0] eq "items_take")
&& !($config{'itemsTakeAuto'} >= 2 && ($ai_seq[0] eq "take" || $ai_seq[0] eq "items_take"))
&& !($config{'itemsGatherAuto'} >= 2 && ($ai_seq[0] eq "take" || $ai_seq[0] eq "items_gather"))
&& timeOut(\%{$timeout{'ai_attack_auto'}})) {
undef @{$ai_v{'ai_attack_agMonsters'}};
undef @{$ai_v{'ai_attack_cleanMonsters'}};
undef @{$ai_v{'ai_attack_partyMonsters'}};
undef $ai_v{'temp'}{'foundID'};
if ($config{'tankMode'}) {
undef $ai_v{'temp'}{'found'};
foreach (@playersID) {
next if ($_ eq "");
if ($config{'tankModeTarget'} eq $players{$_}{'name'}) {
$ai_v{'temp'}{'found'} = 1;
last;
}
}
}
if (!$config{'tankMode'} || ($config{'tankMode'} && $ai_v{'temp'}{'found'})) {
$ai_v{'temp'}{'ai_follow_index'} = binFind(\@ai_seq, "follow");
if ($ai_v{'temp'}{'ai_follow_index'} ne "") {
$ai_v{'temp'}{'ai_follow_following'} = $ai_seq_args[$ai_v{'temp'}{'ai_follow_index'}]{'following'};
$ai_v{'temp'}{'ai_follow_ID'} = $ai_seq_args[$ai_v{'temp'}{'ai_follow_index'}]{'ID'};
} else {
undef $ai_v{'temp'}{'ai_follow_following'};
}
$ai_v{'temp'}{'ai_route_index'} = binFind(\@ai_seq, "route");
if ($ai_v{'temp'}{'ai_route_index'} ne "") {
$ai_v{'temp'}{'ai_route_attackOnRoute'} = $ai_seq_args[$ai_v{'temp'}{'ai_route_index'}]{'attackOnRoute'};
}
# List aggressive monsters
#@{$ai_v{'ai_attack_agMonsters'}} = ai_getAggressives() if ($config{'attackAuto'} && !($ai_v{'temp'}{'ai_route_index'} ne "" && !$ai_v{'temp'}{'ai_route_attackOnRoute'}));
if ($config{'attackAuto'} && !($ai_v{'temp'}{'ai_route_index'} ne "" && !$ai_v{'temp'}{'ai_route_attackOnRoute'})){
@{$ai_v{'ai_attack_agMonsters'}} = ai_getAggressives(1);
}
# There are two types of non-aggressive monsters. We generate two lists:
foreach (@monstersID) {
next if ($_ eq "");
# Detect Frozen & Trap Monster
if (!$monsters{$ID}{'state'}) {
# List monsters that the follow target or party members are attacking
if ((($config{'attackAuto_party'}
&& $ai_seq[0] ne "take" && $ai_seq[0] ne "items_take"
&& ($monsters{$_}{'dmgToParty'} > 0 || $monsters{$_}{'dmgFromParty'} > 0))
|| ($config{'attackAuto_followTarget'} && $ai_v{'temp'}{'ai_follow_following'}
&& ($monsters{$_}{'dmgToPlayer'}{$ai_v{'temp'}{'ai_fo llow_ID'}} > 0 || $monsters{$_}{'missedToPlayer'}{$ai_v{'temp'}{'ai_ follow_ID'}} > 0 || $monsters{$_}{'dmgFromPlayer'}{$ai_v{'temp'}{'ai_f ollow_ID'}} > 0)))
&& !($ai_v{'temp'}{'ai_route_index'} ne "" && !$ai_v{'temp'}{'ai_route_attackOnRoute'})
&& $monsters{$_}{'attack_failed'} == 0 && ($mon_control{lc($monsters{$_}{'name'})}{'attack_a uto'} >= 1 || $mon_control{lc($monsters{$_}{'name'})}{'attack_au to'} eq "")) {
push @{$ai_v{'ai_attack_partyMonsters'}}, $_;
# Begin the attack only when noone else is on screen.
} elsif ($config{'attackAuto_onlyWhenSafe'}
&& $config{'attackAuto'} >= 1
&& binSize(\@playersID) == 0
&& $ai_seq[0] ne "sitAuto" && $ai_seq[0] ne "take" && $ai_seq[0] ne "items_gather" && $ai_seq[0] ne "items_take"
&& !($monsters{$_}{'dmgFromYou'} == 0 && ($monsters{$_}{'dmgTo'} > 0 || $monsters{$_}{'dmgFrom'} > 0 || %{$monsters{$_}{'missedFromPlayer'}} || %{$monsters{$_}{'missedToPlayer'}} || %{$monsters{$_}{'castOnByPlayer'}})) && $monsters{$_}{'attack_failed'} == 0
&& !($ai_v{'temp'}{'ai_route_index'} ne "" && $ai_v{'temp'}{'ai_route_attackOnRoute'} <= 1)
&& ($mon_control{lc($monsters{$_}{'name'})}{'attack_a uto'} >= 1 || $mon_control{lc($monsters{$_}{'name'})}{'attack_au to'} eq "")) {
push @{$ai_v{'ai_attack_cleanMonsters'}}, $_;
# List monsters that nobody's attacking
} elsif ($config{'attackAuto'} >= 2
&& !$config{'attackAuto_onlyWhenSafe'}
&& $ai_seq[0] ne "sitAuto" && $ai_seq[0] ne "take" && $ai_seq[0] ne "items_gather" && $ai_seq[0] ne "items_take"
&& !($monsters{$_}{'dmgFromYou'} == 0 && ($monsters{$_}{'dmgTo'} > 0 || $monsters{$_}{'dmgFrom'} > 0 || %{$monsters{$_}{'missedFromPlayer'}} || %{$monsters{$_}{'missedToPlayer'}} || %{$monsters{$_}{'castOnByPlayer'}})) && $monsters{$_}{'attack_failed'} == 0
&& !($ai_v{'temp'}{'ai_route_index'} ne "" && $ai_v{'temp'}{'ai_route_attackOnRoute'} <= 1)
&& ($mon_control{lc($monsters{$_}{'name'})}{'attack_a uto'} >= 1 || $mon_control{lc($monsters{$_}{'name'})}{'attack_au to'} eq "")) {
#Avoid KSing
undef $m_plDist_small;
my $judgeFirst = 1;
my $m_cDist = distance(\%{$chars[$config{'char'}]{'pos_to'}}, \%{$monsters{$_}{'pos_to'}});
for ($i = 0; $i < @playersID; $i++) {
next if ($playersID[$i] eq "");
$m_plDist = distance(\%{$players{$playersID[$i]}{'pos_to'}}, \%{$monsters{$_}{'pos_to'}});
if ($judgeFirst || $m_plDist < $m_plDist_small) {
$m_plDist_small = $m_plDist;
$judgeFirst = 0;
}
}
if((!$m_plDist_small || $m_plDist_small >= $config{'NotAttackDistance'} || $m_cDist <= $m_plDist_small)
&&(($config{'attackAuto'}==2 && $mon_control{lc($monsters{$_}{'name'})}{'attack_au to'})||$config{'attackAuto'}>2)){
push @{$ai_v{'ai_attack_cleanMonsters'}}, $_;
}
}
}
}
#Reduce code size & fix monster Priority
undef $ai_v{'temp'}{'foundID'};
$ai_v{'temp'}{'foundID'} = selectTarget(@{$ai_v{'ai_attack_agMonsters'}}) if (@{$ai_v{'ai_attack_agMonsters'}});
$ai_v{'temp'}{'foundID'} = selectTarget(@{$ai_v{'ai_attack_partyMonsters'}}) if (!defined($ai_v{'temp'}{'foundID'}) && @{$ai_v{'ai_attack_partyMonsters'}});
$ai_v{'temp'}{'foundID'} = selectTarget(@{$ai_v{'ai_attack_cleanMonsters'}}) if (!defined($ai_v{'temp'}{'foundID'}) && @{$ai_v{'ai_attack_cleanMonsters'}});
}
if ($ai_v{'temp'}{'foundID'}) {
ai_setSuspend(0);
attack($ai_v{'temp'}{'foundID'});
} else {
$timeout{'ai_attack_auto'}{'time'} = time;
}
}