diff --git a/src/AI/Attack.pm b/src/AI/Attack.pm index 2aa1c824d1..3570be139e 100644 --- a/src/AI/Attack.pm +++ b/src/AI/Attack.pm @@ -39,11 +39,7 @@ sub process { Benchmark::begin("ai_attack") if DEBUG; my $args = AI::args; - if ( - (AI::action eq "attack" && $args->{ID}) - || (AI::action eq "route" && AI::action (1) eq "attack" && $args->{attackID}) - || (AI::action eq "move" && AI::action (2) eq "attack" && $args->{attackID}) - ) { + if (shouldAttack($action, $args)) { my $ID; my $ataqArgs; if (AI::action eq "attack") { @@ -205,6 +201,15 @@ sub process { Benchmark::end("ai_attack") if DEBUG; } +sub shouldAttack { + my ($action, $args) = @_; + return ( + ($action eq "attack" && $args->{ID}) + || ($action eq "route" && AI::action(1) eq "attack" && $args->{attackID}) + || ($action eq "move" && AI::action(2) eq "attack" && $args->{attackID}) + ); +} + sub shouldGiveUp { my ($args, $ID) = @_; return !$config{attackNoGiveup} && (timeOut($args->{ai_attack_giveup}) || $args->{unstuck}{count} > 5);