PDA

Ir para Versão Original : AutoKill Deluxe para SVN


Cefalexina
02/12/2007, 5:17:43
Alguem conhece um plugin similar ao Autokill Deluxe que funfe no SVN, ja que ele so funciona para o 1.6.9 , ou alguem que entenda, eu axei porai que e uma configuração muito pequena que deve ser feita nele para usar no SVN

Este plugin serve para atacar Players, tipo um plugin para pvp, mais na verdade presiso dele para atacar Mostros que sao interpretados como players pelo Openkore

Autokill_delux.pl
package Autokill_Delux;

### Autokill Delux v5.32 (no copyright)
# Put these options in your config.txt
# give_up_gtb 1
# gtb_defend 0
# Emp_priority 1
# WoE_Map_name nif_fild02
# Emp_break_Dist 7
# Class_priority_1 Assassin Cross
# Class_priority_2
# Class_priority_3
# Ignore_if_status Hide, Cloak, Poison

use strict;
use Time::HiRes qw(time); # better time function that allows me to calculate in mili and micro seconds
use Plugins;
use Globals;
use Utils;
use Misc;
use Log qw(message);
use Commands;
use AI;
# use Skills;
# use Skills; will be used for GTB defend. first ai_clear and then skills-> magic crasher

Plugins::register("Autokill Delux v5.32", "Systematic Approach to AUTOKILL non-guild players.", \&on_unload, \&on_reload);

### Hooks ###
my $Commands;
my $Autokill_Log;
my $Read_Autokill_Config;
my $main_AI;
############

### Config Read Values
my $GTB_giveup;
my $GTB_defend;
my $Break_EMP;
my $WoE_Map_Name;
my $Emp_Break_dist;
my $WoE_map_ingnore;
my $Class_Prio_1;
my $Class_Prio_2;
my $Class_Prio_3;
my $status_ignore;
######################

### Control Values for EMP breaking
my $EMP_Broke;
# 0 =EMP is not broking
# 1 = EMP is being attacked
# 2 = EMP broke
##################################

### Main AI Attack Controller
my $AI_attack = 0;
# 0 = idle
# 1 = autokill
# 2 = Ignore players and attack emperium
# 3 = Compatability issue fix with the Buff plugin
my $AI_nokill = 0;
# 0 = nothing
# 1 = set AI_attack to 0
# used mainly to prevent bad commucation between hooks
# and makes it easier to script
#############################

### Killable Players info
my %KILLABLE_PLAYERS;
my @KILL_PLAYERS;
my %KILL_nearest;
#########################

### Current Player
my $cur_pl;
#################

### Timeout AI
my $timeout_AI;
# timeout the ability to check for priorities
# this option saves processing time wasted
# by the amount times the AI_pre hook is called
my $attack_timeout;
# Timeout that is checked to see if player
# got stuck with a char
##############

### Timeout on player (reserved for future use)
# possibly it wil be removed if it's not useful
my $noattack_seconds;
# $player->{AK_timeout} = time;
# $noattack_seconds = 5;
##############

### Fix for Asura strike
my $use_skill_count;
### GTB magic skill fail
my @Magic_skills = (
"Napalm Beat",
"Soul Strike",
"Cold Bolt",
"Frost Diver",
"Fire Ball",
"Fire Wall",
"Fire Bolt",
"Lightening Bolt",
"Thunderstorm",
"Ruwach",
"Holy Light",
"Fire Pillar",
"Sightrasher",
"Meteor Storm",
"Jupitel Thunder",
"Lord of Vermilion",
"Water Ball",
"Frost Nova",
"Storm Gust",
"Earth Spike",
"Heaven's Drive",
"Napalm Vulcan",
"put_new_here"
);
########################

### Commands used to control Autokill
$Commands = Commands::register(
["autokill", "kills alll", \&Auto_Kill_Load],
["nokill", "Unload KILL", \&on_unload],
["killinfo", "Info on AUTOKILL", \&Kill_Info],
["killreset", "resets AUTOKILL", \&Hard_Reset]
);
#####################################

### Load Config of the Autokill
$Read_Autokill_Config = Plugins::addHook("start3", \&Load_Config);
###############################

sub on_reload { &on_unload; }

sub on_unload {
$AI_attack = -1;
undef $cur_pl;
AI::clear();
Log::delHook($Autokill_Log);
Plugins::delHook("start3", $Read_Autokill_Config);
Plugins::delHook("AI_pre", $main_AI);
message("Autokill Delux v5.32\nCreated by: smbot31 [AIM]\nEmail me at: secretmission3001\@yahoo.com\n", "info");
}

### Read Autokill Config
sub Load_Config {

$GTB_giveup = $::config{give_up_gtb};
$GTB_defend = $::config{gtb_defend};
$Break_EMP = $::config{Emp_priority};
$WoE_Map_Name = $::config{WoE_Map_name};
$Emp_Break_dist = $::config{Emp_break_Dist};
$WoE_map_ingnore = $::config{WoE_Map_ingnore};
$Class_Prio_1 = $::config{Class_priority_1};
$Class_Prio_2 = $::config{Class_priority_2};
$Class_Prio_3 = $::config{Class_priority_3};
$status_ignore = $::config{Ignore_if_status};
# make Giving up on enemy time and if undef set to 5 to prevent serious errors
# possibly make $CHECK_KILL blocks and AI_attack timeouts config selectable
# also maybe add the attack_if_status option info autokill

}

### Start Autokill by command "autokil"
sub Auto_Kill_Load {
undef $AI_attack;
$Autokill_Log = Log::addHook(\&Check_Target_Post, "Kill Check Target");
$main_AI = Plugins::addHook("AI_pre", \&AI_Main);
message("Autokill Delux v5.32 Activated\n", "info");
}

### Resets autokill if stuck
sub Hard_Reset {
undef $AI_attack;
# undef $EMP_Broke;
### Delete all non guild members from $players{};?
AI::clear();
message ("AUTOKILL_ - AI_attack reset\n" , "info");
}

### Debuging command
sub Kill_Info {

my $msg; # use swrite()

for (my $i = 0; $i < @playersID; $i++) {
my $player = $players{$playersID[$i]};
my $name = $player->{name};
my $guild = $player->{guild}{name};
my $accID = $player->{nameID};
my $ID = $player->{binID};
my $lvl = $player->{lv};
my $job = $jobs_lut{$players{$playersID[$i]}{'jobID'}};
my $myguild = $char->{guild}{name};
$myguild = 'No Guild' if $myguild eq "";
# my $top_headgear = headgearName($player->{headgear}{top});
# my $mid_headgear = headgearName($player->{headgear}{mid});
# my $low_headgear = headgearName($player->{headgear}{low});
# my $weapon = main::itemName({nameID => $player->{weapon}});
# my $shield = main::itemName({nameID => $player->{shield}});
# my $shoes = main::itemName({nameID => $player->{shoes}});
my $sex = $sex_lut{$player->{sex}};
next if $name eq "";
#$msg .=" \n"
$msg .= "-------------------------------------------------------------------------------\n";
$msg .= swrite(
" Account ID: @<<<<<<<<<<<<<<<<<",
[$accID]
);
$msg .= swrite(
" ID: @<<< Sex: @<<<< ",
[$ID, $sex]
);
$msg .= swrite(
" Name: @<<<<<<<<<<<<<<<<<<<<<<<<<<< Guild: @<<<<<<<<<<<<<<<<<<<<<<<<<<< ",
[$name, $guild]
);
my $dist = distance($char->{pos_to}, $player->{pos_to});
$msg .= swrite(
" Job: @<<<<<<<<<<<<<<<<<<<<<<<<<<< Dist: @<<<<<<<<<<<<<<<<<<<<<<<<<<< ",
[$job, $dist]
);
my $statusactive;

if ($job eq $Class_Prio_1) {
$msg .=" First class priority\n";
}
elsif ($job eq $Class_Prio_2) {
$msg .=" Second class priority\n";
}
elsif ($job eq $Class_Prio_3) {
$msg .=" Third class priority\n";
}
else {
$msg .=" No class priority\n";
}
if ($myguild eq $guild) {
$msg .=" Player is in your Guild\n";
}
if ($player->{'dead'}) {
$msg .=" Player is dead\n";
}
if (whenStatusActivePL($playersID[$i], $status_ignore)) {
$msg .=" Player is: $status_ignore\n";
$statusactive = 1;
}
if (!timeOut($player->{AK_timeout}, $noattack_seconds)) {
$msg .=" Player is timeout - $noattack_seconds\n";
$statusactive = 1;
}
if ($player->{GTB}) {
$msg .=" Player has a GTB\n";
$statusactive = 1;
}
if ($lvl > 98 && $guild ne $myguild && !$player->{'dead'} && !$statusactive) {
$msg .=" --Killable--\n";
}
else {
$msg .=" Can't be killed\n";
}
$msg .= "-------------------------------------------------------------------------------\n";
message($msg, "list");
undef $msg;
}

undef $msg;
$msg .= "\n-------------------------------------------------------------------------------\n";
$msg .= swrite(
" Your Name: @<<<<<<<<<<<<<<<<<<<<<<<<<<< Your Guild: @<<<<<<<<<<<<<<<<<<<<<<<<<<<",
[$char->{name}, $char->{guild}{name}]
);
$msg .= " Current field: $field{name}\n";
if ($char->{'dead'}) {
$msg .= " You are dead\n";
}
if ($AI_attack == 1) {
my $player_info = $players{$playersID[$cur_pl]};
my $player_name = $player_info->{name};
my $player_ID = $player_info->{binID};
$msg .= "\tAUTOKILL TARGET - \($player_ID\) $player_name\n";
}
$msg .= "-------------------------------------------------------------------------------\n";
$msg .= " DEBUGING - VALUES\n";
$msg .= " \$AI_attack = $AI_attack\n";
$msg .= " \$EMP_Broke = $EMP_Broke\n";
$msg .= "\n OPTIONS- DEBUG\n";
### PUT all values of config value and use if ? then : else
$msg .= " \$GTB_giveup: ";
if ($GTB_giveup == 1) {$msg .= "yes\n";} else {$msg .= "no\n";};
$msg .= " \$GTB_defend: \(This option is not yet working\)\n";
$msg .= " \$Break_EMP: ";
if ($Break_EMP == 1) {$msg .= "yes\n";} else {$msg .= "no\n";};
$msg .= " \$WoE_Map_Name: $WoE_Map_Name\n";
$msg .= " \$Emp_Break_dist: $Emp_Break_dist\n";
$msg .= " \$Class_Prio_1: $Class_Prio_1\n";
$msg .= " \$Class_Prio_2: $Class_Prio_2\n";
$msg .= " \$Class_Prio_3: $Class_Prio_3\n";
$msg .= " \$status_ignore: $status_ignore\n";
$msg .= "-------------------------------------------------------------------------------\n";
message($msg, "list");
undef $msg;

#### OTHER DEBUGS TEMP

#################
}

### AI post - Log Hooked
sub Check_Target_Post {

### Variables used to detect messages
my $type = shift;
my $domain = shift;
my $level = shift;
my $currentVerbosity = shift;
my $message = shift;
my $user_data = shift;
#####################################

### GTB Detect and register
my $Magic_Miss = 'You use (.*) \(.* on Player (.*) \((.*)\) - Dmg: Miss';
my $Magic_Failed = 'Skill (.*) failed \(Basic\)';
# $Magic_Miss detects AoE (Area of Effect) skills like strom gust
# $Magic_Failed focuses on sigle target skills
# In other servers all magic miss instead of failing so $Magic_Miss is used for both Aoe and target skills
# @Magic_skills
if ($GTB_giveup == 1 && $AI_attack == 1 && $message =~ /$Magic_Miss/i) {
my $name_gtb_check = $2;
my $skill_gtb_check = $1;
my $ID_gtb_check = $3;
foreach (@Magic_skills) {
if ($_ eq $skill_gtb_check) {
my $player = $players{$playersID[$ID_gtb_check]};
my $name = $player->{name};
my $ID = $player->{binID};
my $GTB = $player->{GTB};
if ($GTB) {
# Do nothing
}
elsif (!$GTB) {
$player->{GTB} = 1;
message ("AUTOKILL - PLAYER \($ID\) $name has a GTB: Ignoring\n", "info");
}
}
}
}
elsif ($GTB_giveup == 1 && $AI_attack == 1 && $message =~ /$Magic_Failed/i) {
my $skill_gtb_check = $1;
foreach (@Magic_skills) { # Even thouhg its only for skills that taget a single player it also superfluously checks for AoE
if ($_ eq $skill_gtb_check) {
my $player = $players{$playersID[$cur_pl]};
my $name = $player->{name};
my $ID = $player->{binID};
my $GTB = $player->{GTB};
if (!$GTB) {
$player->{GTB} = 1;
message ("AUTOKILL - PLAYER \($ID\) $name has a GTB: Ignoring\n", "info");
}
}
}
}
###########################

### String used to compare a codition
# ADD Map Changed to the list
my $Taget_died = 'Target Died';
my $You_died = 'You have died';
my $Target_lost = 'Target lost';
my $Cant_reach = 'Can\'t reach or damage target, dropping target';
my $Map_change = 'Map Change: ';
# Timeout that checks if player is stuck
my $You_attack = 'You attack Player';
my $You_use_skill = 'You use .* on player';
# Fix for Asura strike
my $Permited_use = 'Permitted to use Extremity Fist';
my $You_use_Asura = 'You use Extremity Fist';
# Compatability With Buff plugin
my $Buff_start = 'Player.*is being Buffed';
my $Buff_success = 'Player Buff Completed';
my $Buff_giveup = 'Gave up on skill buff!';
####################################

if ($AI_attack == 2 && $message =~ /$Taget_died/i) {
$AI_nokill = 1;
$EMP_Broke = 2;
message ("AUTOKILL - EMP Broken\n", "info");
}
elsif ($AI_attack == 1 && $message =~ /$Taget_died/i) {
$AI_nokill = 1;
$AI_attack = -1; # waits for AI_main
my $player = $players{$playersID[$cur_pl]};
my $name = $player->{name};
my $ID = $player->{binID};
$player->{'dead'} = 1;
message ("AUTOKILLED - Player \($ID\) $name\n", "info");
}
elsif ($AI_attack == 1 && $message =~ /$You_died/i) {
$AI_nokill = 1;
$char->{'dead'} = 1;
}
elsif ($AI_attack == 1 && $message =~ /$Cant_reach/i) {
$AI_nokill = 1;
}
elsif ($AI_attack == 1 && $message =~ /$Target_lost/i) {
$AI_nokill = 1;
my $iID = $playersID[$cur_pl];
delete $players{$iID};
binRemove(\@playersID, $iID);
}
elsif ($AI_attack == 1 && $message =~ /$Map_change/i) {
$AI_nokill = 1;
}
elsif ($AI_attack == 1 && $message =~ /$You_attack/i) {
$attack_timeout = time;
}
elsif ($AI_attack == 1 && $message =~ /$You_use_skill/i) {
$attack_timeout = time;
}
elsif ($AI_attack == 1 && $message =~ /$Permited_use/i) {
# Fix for monks-champs
# maybe delete char and see if that works out better
$use_skill_count++;
if ($use_skill_count >= 20) {

my $DSC = Skills->new(auto => 'Dangerous Soul Collect');
my $Fury = Skills->new(auto => 'Vigor Explosion');
my $isself = $accountID;

if ($char->{spirits} < 5) {
main::ai_skillUse($DSC->handle, 1, 0, 0, $isself);
} else {
main::ai_skillUse($Fury->handle, 5, 0, 0, $isself);
undef $use_skill_count;
message "AUTOKILL - Asura failed and stucked \(Method: Use 'Vigor Explosion.'\)\n";
}
}

# $AI_nokill = 1;
# my $player = $players{$playersID[$cur_pl]};

}
elsif ($AI_attack == 1 && $message =~ /$You_use_Asura/) {
undef $use_skill_count;
}
elsif ($AI_attack == 1 && $message =~ /$Buff_start/) {
AI::clear();
$AI_attack = 3;
}
elsif ($AI_attack == 3 && $message =~ /$Buff_success/) {
$AI_nokill = 1;
}
elsif ($AI_attack == 3 && $message =~ /$Buff_giveup/) {
$AI_nokill = 1;
}
}

sub AI_Main {

### Checks for EMP priority
my $CHECK_KILL = 0;
$EMP_Broke = 0 if $field{name} ne $WoE_Map_Name;
if ($Break_EMP == 1 && $WoE_Map_Name eq $field{name} && $EMP_Broke == 0) {
my $If_EMP;
for (my $i = 0; $i < @monstersID; $i++) {
next if ($monstersID[$i] eq "");
my $mob_dist = distance(\%{$chars[$config{'char'}]{'pos_to'}}, \%{$monsters{$monstersID[$i]}{'pos_to'}});
if ($monsters{$monstersID[$i]}{'name'} eq "Emperium" && $mob_dist < $Emp_Break_dist) {
$AI_attack = 2;
$EMP_Broke = 1;
$monsters{$monstersID[$i]}{'dmgToYou'} = 1;
$If_EMP = 1;
AI::clear();
Commands::run("a $i");
message ("AUTOKILL - EMP priority\n", "info");
}
}
if ($If_EMP == 0) {
$CHECK_KILL = 1;
}
}
elsif ($Break_EMP == 1 && $WoE_Map_Name eq $field{name} && $EMP_Broke == 2) {
$CHECK_KILL = 1;
}
elsif ($Break_EMP == 1 && $WoE_Map_Name ne $field{name}) {
$CHECK_KILL = 1;
}
elsif ($Break_EMP == 0) {
$CHECK_KILL = 1;
}
#########################

### Algorithm that Checks Players to Kill
if ($CHECK_KILL == 1 && $AI_attack == 0 && timeOut($timeout_AI, 0.2)) {
undef %KILLABLE_PLAYERS;
undef @KILL_PLAYERS;
undef %KILL_nearest;
if ($AI_attack == 0 && !$char->{'dead'} && $field{name} ne "geffen" && $field{name} ne $WoE_map_ingnore) {
for (my $i = 0; $i < @playersID; $i++) {
my $player = $players{$playersID[$i]};
my $ID_byte = $playersID[$i];
my $name = $player->{name};
my $guild = $player->{guild}{name};
my $party = $player->{party}{name};
my $acc_ID = $player->{nameID};
my $ID = $player->{binID};
my $lvl = $player->{lv};
my $job = $jobs_lut{$players{$playersID[$i]}{'jobID'}};
my $my_guild = $char->{guild}{name};
my $my_party = $char->{party}{name};
$my_guild = 'No Guild' if $my_guild eq "";
$my_party = 'No Party' if $my_party eq "";
next if $name eq "";
next if $my_party eq $party;
next if whenStatusActivePL($playersID[$i], $status_ignore);
next if $lvl < 99;
next if $player->{'dead'};
next if $player->{GTB} == 1;
next if !timeOut($player->{AK_timeout}, $noattack_seconds);
if ($guild ne $my_guild) {
$KILLABLE_PLAYERS{$i} = $job;
### TRouble shoot ###
message "READ 4\n";
foreach (keys %KILLABLE_PLAYERS) {
message "DEBUG - $_ - $KILLABLE_PLAYERS{$_}\n";
}
######################
}
}
foreach (keys %KILLABLE_PLAYERS) { # Check Priority one
if ($KILLABLE_PLAYERS{$_} eq $Class_Prio_1) {
my $Array_counter = @KILL_PLAYERS;
$KILL_PLAYERS[$Array_counter] = $_;
}
}
if (!@KILL_PLAYERS) { # Check Priority two
foreach (keys %KILLABLE_PLAYERS) {
if ($KILLABLE_PLAYERS{$_} eq $Class_Prio_2) {
my $Array_counter = @KILL_PLAYERS;
$KILL_PLAYERS[$Array_counter] = $_;
}
}
}
if (!@KILL_PLAYERS) { # Check Priority three
foreach (keys %KILLABLE_PLAYERS) {
if ($KILLABLE_PLAYERS{$_} eq $Class_Prio_3) {
my $Array_counter = @KILL_PLAYERS;
$KILL_PLAYERS[$Array_counter] = $_;
}
}
}
if (!@KILL_PLAYERS) { # Check Random
foreach (keys %KILLABLE_PLAYERS) {
my $Array_counter = @KILL_PLAYERS;
$KILL_PLAYERS[$Array_counter] = $_;
}
}
foreach (0..$#KILL_PLAYERS) { # Makes @KILL_PLAYERS into %KILL_nearest to calculate distance
$KILL_nearest{$_} = $KILL_PLAYERS[$_];
}
my $comp1;
my $comp2;
my @delete;
foreach $comp1 (keys %KILL_nearest) { # Calculates which player is the closest
foreach $comp2 (keys %KILL_nearest) {
my $player1 = $players{$playersID[$KILL_nearest{$comp1}]};
my $dist1 = distance($player1->{'pos_to'}, $char->{'pos_to'});
my $player2 = $players{$playersID[$KILL_nearest{$comp2}]};
my $dist2 = distance($player2->{'pos_to'}, $char->{'pos_to'});
if ($dist1 > $dist2) {
push @delete, $comp1;
next;
}
elsif ($dist1 < $dist2) {
push @delete, $comp2;
next;
}
}
}
foreach (@delete) { # Deletes the players calculated to be far.
delete $KILL_nearest{$_};
}
foreach (keys %KILL_nearest) { # Autokills the player(s) remeaning - sometimes theres more then one player if they both stand on the sane block
my $player = $players{$playersID[$KILL_nearest{$_}]};
my $name = $player->{name};
my $ID = $player->{binID};
my $job = $jobs_lut{$players{$playersID[$KILL_nearest{$_}]}{'jobID'}};
$cur_pl = $KILL_nearest{$_};
$players{$playersID[$cur_pl]}{'dmgToYou'} = 1; # prevensts KS error
$attack_timeout = time; # timeout used for checking if char is stuck
$AI_attack = 1;
AI::clear();
Commands::run("kill $ID");
message ("AUTOKILLING - \($ID\) $name '$job'\n", "info");
last;
}

}
### Timeout
$timeout_AI = time;
###########
}
elsif ($AI_attack == 1 && timeOut($timeout_AI, 0.2)) {
my $Player = $players{$playersID[$cur_pl]};
my $GTB = $Player->{GTB};
if ($GTB == 1) {
AI::clear();
$AI_attack = 0;
}
elsif (whenStatusActivePL($playersID[$cur_pl], $status_ignore)) {
AI::clear();
$AI_attack = 0;
}
else {
undef %KILLABLE_PLAYERS;
undef @KILL_PLAYERS;
undef %KILL_nearest;
# $AI_attack == 0 if $field{name} eq "geffen"; # prevents glitch
for (my $i = 0; $i < @playersID; $i++) {
my $player = $players{$playersID[$i]};
my $ID_byte = $playersID[$i];
my $name = $player->{name};
my $guild = $player->{guild}{name};
my $party = $player->{party}{name};
my $acc_ID = $player->{nameID};
my $ID = $player->{binID};
my $lvl = $player->{lv};
my $job = $jobs_lut{$players{$playersID[$i]}{'jobID'}};
my $my_guild = $char->{guild}{name};
my $my_party = $char->{party}{name};
$my_guild = 'No Guild' if $my_guild eq "";
$my_party = 'No Party' if $my_party eq "";
next if $name eq "";
next if $my_party eq $party;
next if whenStatusActivePL($playersID[$i], $status_ignore);
next if $lvl < 99;
next if $player->{'dead'};
next if $player->{GTB} == 1;
next if !timeOut($player->{AK_timeout}, $noattack_seconds);
if ($guild ne $my_guild) {
$KILLABLE_PLAYERS{$i} = $job;
}
}
foreach (keys %KILLABLE_PLAYERS) { # Check Priority one
if ($KILLABLE_PLAYERS{$_} eq $Class_Prio_1) {
my $Array_counter = @KILL_PLAYERS;
$KILL_PLAYERS[$Array_counter] = $_;
}
}
if (!@KILL_PLAYERS) { # Check Priority two
foreach (keys %KILLABLE_PLAYERS) {
if ($KILLABLE_PLAYERS{$_} eq $Class_Prio_2) {
my $Array_counter = @KILL_PLAYERS;
$KILL_PLAYERS[$Array_counter] = $_;
}
}
}
if (!@KILL_PLAYERS) { # Check Priority three
foreach (keys %KILLABLE_PLAYERS) {
if ($KILLABLE_PLAYERS{$_} eq $Class_Prio_3) {
my $Array_counter = @KILL_PLAYERS;
$KILL_PLAYERS[$Array_counter] = $_;
}
}
}
# if @KILL_PLAYERS stays undefined it wont do anything
if (@KILL_PLAYERS) {
foreach (0..$#KILL_PLAYERS) {
$KILL_nearest{$_} = $KILL_PLAYERS[$_];
}
my $comp1;
my $comp2;
my @delete;
foreach $comp1 (keys %KILL_nearest) {
foreach $comp2 (keys %KILL_nearest) {
my $player1 = $players{$playersID[$KILL_nearest{$comp1}]};
my $dist1 = distance($player1->{'pos_to'}, $char->{'pos_to'});
my $player2 = $players{$playersID[$KILL_nearest{$comp2}]};
my $dist2 = distance($player2->{'pos_to'}, $char->{'pos_to'});
if ($dist1 > $dist2) {
push @delete, $comp1;
next;
} elsif ($dist1 < $dist2) {
push @delete, $comp2;
next;
}
}
}
foreach (@delete) {
delete $KILL_nearest{$_};
}
foreach (keys %KILL_nearest) {
if ($cur_pl != $KILL_nearest{$_}) {
my $player = $players{$playersID[$KILL_nearest{$_}]};
my $name = $player->{name};
my $ID = $player->{binID};
my $job = $jobs_lut{$players{$playersID[$KILL_nearest{$_}]}{'jobID'}};
$cur_pl = $KILL_nearest{$_}; # Sets the Global value $cur_pl so other parts of the script can access it
$players{$playersID[$cur_pl]}{'dmgToYou'} = 1; # prevensts KS error
$attack_timeout = time; # timeout used for checking if char is stuck
$AI_attack = 1;
AI::clear();
Commands::run("kill $ID");
message ("AUTOKILLING - \($ID\) $name '$job'\n", "info");
last;
}
}
}
}
### Timeout on AI hook
$timeout_AI = time;
######################

### del if player stuck
if (AI::is("move")) {
$attack_timeout = time;
}
elsif (AI::is("attack", "skill_use") && timeOut($attack_timeout, 5.2)) {
$AI_nokill = 1;
my $iID = $playersID[$cur_pl];
delete $players{$iID};
binRemove(\@playersID, $iID);
message "AUTOKILL - Unstucking \(Method: Player deleted.\)\n";
}
################
}
#########################################

### Reset AUTOKILL
if ($AI_nokill == 1) {
$AI_nokill = 0;
$AI_attack = 0;
undef $cur_pl;
AI::clear();
message ("AUTOKILL - Searching for next target\n", "info");
}
#################
}

return 1;