diff --git a/src/AI/Attack.pm b/src/AI/Attack.pm index 127798949f..13aae6d4c0 100644 --- a/src/AI/Attack.pm +++ b/src/AI/Attack.pm @@ -487,17 +487,10 @@ sub main { Benchmark::end("ai_attack (part 1.2)") if DEBUG; Benchmark::end("ai_attack (part 1)") if DEBUG; - my $melee; - my $ranged; if (defined $args->{attackMethod}{type} && exists $args->{ai_attack_failed_give_up} && defined $args->{ai_attack_failed_give_up}{time}) { debug "Deleting ai_attack_failed_give_up time.\n"; delete $args->{ai_attack_failed_give_up}{time}; - } elsif ($args->{attackMethod}{maxDistance} == 1) { - $melee = 1; - - } elsif ($args->{attackMethod}{maxDistance} > 1) { - $ranged = 1; } $args->{attackMethod}{maxDistance} += $args->{temporary_extra_range}; @@ -512,8 +505,7 @@ sub main { } else { $canAttack = -2; } - - my $range_type_string = ($melee ? "Melee" : ($ranged ? "Ranged" : "None")); + my $canAttack_fail_string = (($canAttack == -2) ? "No Method" : (($canAttack == -1) ? "No LOS" : (($canAttack == 0) ? "No Range" : "OK"))); # Here we check if the monster which we are waiting to get closer to us is in fact close enough @@ -595,7 +587,7 @@ sub main { } if ($canAttack == 0 && $youHitTarget) { - debug TF("[%s - %s] We were able to hit target even though it is out of range or LOS, accepting and continuing. (you %s (%d %d), target %s (%d %d) [(%d %d) -> (%d %d)], distance %d, maxDistance %d, dmgFromYou %d)\n", $canAttack_fail_string, $range_type_string, $char, $realMyPos->{x}, $realMyPos->{y}, $target, $realMonsterPos->{x}, $realMonsterPos->{y}, $target->{pos}{x}, $target->{pos}{y}, $target->{pos_to}{x}, $target->{pos_to}{y}, $realMonsterDist, $args->{attackMethod}{maxDistance}, $target->{dmgFromYou}), 'ai_attack'; + debug TF("[%s] We were able to hit target even though it is out of range or LOS, accepting and continuing. (you %s (%d %d), target %s (%d %d) [(%d %d) -> (%d %d)], distance %d, maxDistance %d, dmgFromYou %d)\n", $canAttack_fail_string, $char, $realMyPos->{x}, $realMyPos->{y}, $target, $realMonsterPos->{x}, $realMonsterPos->{y}, $target->{pos}{x}, $target->{pos}{y}, $target->{pos_to}{x}, $target->{pos_to}{y}, $realMonsterDist, $args->{attackMethod}{maxDistance}, $target->{dmgFromYou}), 'ai_attack'; if ($clientDist > $args->{attackMethod}{maxDistance} && $clientDist <= ($args->{attackMethod}{maxDistance} + 1) && $args->{temporary_extra_range} == 0) { debug TF("[%s] Probably extra range provided by the server due to chasing, increasing range by 1.\n", $canAttack_fail_string), 'ai_attack'; $args->{temporary_extra_range} = 1; @@ -629,11 +621,11 @@ sub main { $args->{ai_attack_failed_waitForAgressive_give_up}{time} = time if !$args->{ai_attack_failed_waitForAgressive_give_up}{time}; if (timeOut($args->{ai_attack_failed_waitForAgressive_give_up})) { delete $args->{ai_attack_failed_waitForAgressive_give_up}{time}; - warning TF("[%s - %s] Waited too long for target to get closer, dropping target. (you %s (%d %d), target %s (%d %d) [(%d %d) -> (%d %d)], distance %d, maxDistance %d, dmgFromYou %d)\n", $canAttack_fail_string, $range_type_string, $char, $realMyPos->{x}, $realMyPos->{y}, $target, $realMonsterPos->{x}, $realMonsterPos->{y}, $target->{pos}{x}, $target->{pos}{y}, $target->{pos_to}{x}, $target->{pos_to}{y}, $realMonsterDist, $args->{attackMethod}{maxDistance}, $target->{dmgFromYou}), 'ai_attack'; + warning TF("[%s] Waited too long for target to get closer, dropping target. (you %s (%d %d), target %s (%d %d) [(%d %d) -> (%d %d)], distance %d, maxDistance %d, dmgFromYou %d)\n", $canAttack_fail_string, $char, $realMyPos->{x}, $realMyPos->{y}, $target, $realMonsterPos->{x}, $realMonsterPos->{y}, $target->{pos}{x}, $target->{pos}{y}, $target->{pos_to}{x}, $target->{pos_to}{y}, $realMonsterDist, $args->{attackMethod}{maxDistance}, $target->{dmgFromYou}), 'ai_attack'; giveUp($args, $ID, 0); } else { $messageSender->sendAction($ID, ($config{'tankMode'}) ? 0 : 7) if ($config{"attackBeyondMaxDistance_sendAttackWhileWaiting"}); - debug TF("[%s - %s - Waiting] %s (%d %d), target %s (%d %d) [(%d %d) -> (%d %d)], distance %d, maxDistance %d, dmgFromYou %d.\n", $canAttack_fail_string, $range_type_string, $char, $realMyPos->{x}, $realMyPos->{y}, $target, $realMonsterPos->{x}, $realMonsterPos->{y}, $target->{pos}{x}, $target->{pos}{y}, $target->{pos_to}{x}, $target->{pos_to}{y}, $realMonsterDist, $args->{attackMethod}{maxDistance}, $target->{dmgFromYou}), 'ai_attack'; + debug TF("[%s - Waiting] %s (%d %d), target %s (%d %d) [(%d %d) -> (%d %d)], distance %d, maxDistance %d, dmgFromYou %d.\n", $canAttack_fail_string, $char, $realMyPos->{x}, $realMyPos->{y}, $target, $realMonsterPos->{x}, $realMonsterPos->{y}, $target->{pos}{x}, $target->{pos}{y}, $target->{pos_to}{x}, $target->{pos_to}{y}, $realMonsterDist, $args->{attackMethod}{maxDistance}, $target->{dmgFromYou}), 'ai_attack'; } $found_action = 1; } @@ -646,10 +638,10 @@ sub main { ) { debug "Attack $char ($realMyPos->{x} $realMyPos->{y}) - target $target ($realMonsterPos->{x} $realMonsterPos->{y})\n"; if ($canAttack == 0) { - debug "[Attack] [$range_type_string] [No range] Too far from us to attack, distance is $realMonsterDist, attack maxDistance is $args->{attackMethod}{maxDistance}\n", 'ai_attack'; + debug "[Attack] [No range] Too far from us to attack, distance is $realMonsterDist, attack maxDistance is $args->{attackMethod}{maxDistance}\n", 'ai_attack'; } elsif ($canAttack == -1) { - debug "[Attack] [$range_type_string] [No LOS] No LOS from player to mob\n", 'ai_attack'; + debug "[Attack] [No LOS] No LOS from player to mob\n", 'ai_attack'; } my $pos = meetingPosition($char, 1, $target, $args->{attackMethod}{maxDistance}); diff --git a/src/AI/SlaveAttack.pm b/src/AI/SlaveAttack.pm index e72843614b..bab2176b5f 100644 --- a/src/AI/SlaveAttack.pm +++ b/src/AI/SlaveAttack.pm @@ -426,17 +426,10 @@ sub main { $args->{attackMethod}{maxDistance} = $args->{attackMethod}{distance}; } - my $melee; - my $ranged; if (defined $args->{attackMethod}{type} && exists $args->{ai_attack_failed_give_up} && defined $args->{ai_attack_failed_give_up}{time}) { debug "[Slave $slave] Deleting ai_attack_failed_give_up time.\n"; delete $args->{ai_attack_failed_give_up}{time}; - } elsif ($args->{attackMethod}{maxDistance} == 1) { - $melee = 1; - - } elsif ($args->{attackMethod}{maxDistance} > 1) { - $ranged = 1; } #$args->{attackMethod}{maxDistance} += $args->{temporary_extra_range}; @@ -451,8 +444,7 @@ sub main { } else { $canAttack = -2; } - - my $range_type_string = ($melee ? "Melee" : ($ranged ? "Ranged" : "None")); + my $canAttack_fail_string = (($canAttack == -2) ? "No Method" : (($canAttack == -1) ? "No LOS" : (($canAttack == 0) ? "No Range" : "OK"))); # Here we check if the monster which we are waiting to get closer to us is in fact close enough @@ -534,7 +526,7 @@ sub main { } if ($canAttack == 0 && $youHitTarget) { - debug TF("[%s] [%s - %s] We were able to hit target even though it is out of range or LOS, accepting and continuing. (you (%d %d), target %s (%d %d) [(%d %d) -> (%d %d)], distance %d, maxDistance %d)\n", $slave, $canAttack_fail_string, $range_type_string, $realMyPos->{x}, $realMyPos->{y}, $target, $realMonsterPos->{x}, $realMonsterPos->{y}, $target->{pos}{x}, $target->{pos}{y}, $target->{pos_to}{x}, $target->{pos_to}{y}, $realMonsterDist, $args->{attackMethod}{maxDistance}), 'ai_attack'; + debug TF("[%s] [%s] We were able to hit target even though it is out of range or LOS, accepting and continuing. (you (%d %d), target %s (%d %d) [(%d %d) -> (%d %d)], distance %d, maxDistance %d)\n", $slave, $canAttack_fail_string, $realMyPos->{x}, $realMyPos->{y}, $target, $realMonsterPos->{x}, $realMonsterPos->{y}, $target->{pos}{x}, $target->{pos}{y}, $target->{pos_to}{x}, $target->{pos_to}{y}, $realMonsterDist, $args->{attackMethod}{maxDistance}), 'ai_attack'; if ($clientDist > $args->{attackMethod}{maxDistance} && $clientDist <= ($args->{attackMethod}{maxDistance} + 1) && $args->{temporary_extra_range} == 0) { debug TF("[$canAttack_fail_string] Probably extra range provided by the server due to chasing, increasing range by 1.\n"), 'ai_attack'; $args->{temporary_extra_range} = 1; @@ -568,11 +560,11 @@ sub main { $args->{ai_attack_failed_waitForAgressive_give_up}{time} = time if !$args->{ai_attack_failed_waitForAgressive_give_up}{time}; if (timeOut($args->{ai_attack_failed_waitForAgressive_give_up})) { delete $args->{ai_attack_failed_waitForAgressive_give_up}{time}; - warning TF("[%s] [%s - %s] Waited too long for target to get closer, dropping target. (you (%d %d), target %s (%d %d) [(%d %d) -> (%d %d)], distance %d, maxDistance %d)\n", $slave, $canAttack_fail_string, $range_type_string, $realMyPos->{x}, $realMyPos->{y}, $target, $realMonsterPos->{x}, $realMonsterPos->{y}, $target->{pos}{x}, $target->{pos}{y}, $target->{pos_to}{x}, $target->{pos_to}{y}, $realMonsterDist, $args->{attackMethod}{maxDistance}), 'ai_attack'; + warning TF("[%s] [%s] Waited too long for target to get closer, dropping target. (you (%d %d), target %s (%d %d) [(%d %d) -> (%d %d)], distance %d, maxDistance %d)\n", $slave, $canAttack_fail_string, $realMyPos->{x}, $realMyPos->{y}, $target, $realMonsterPos->{x}, $realMonsterPos->{y}, $target->{pos}{x}, $target->{pos}{y}, $target->{pos_to}{x}, $target->{pos_to}{y}, $realMonsterDist, $args->{attackMethod}{maxDistance}), 'ai_attack'; giveUp($slave, $args, $ID, 0); } else { $slave->sendAttack($ID) if ($config{$slave->{configPrefix}."attackBeyondMaxDistance_sendAttackWhileWaiting"}); - debug TF("[%s] [%s - %s] [Waiting] (%d %d), target %s (%d %d) [(%d %d) -> (%d %d)], distance %d, maxDistance %d.\n", $slave, $canAttack_fail_string, $range_type_string, $realMyPos->{x}, $realMyPos->{y}, $target, $realMonsterPos->{x}, $realMonsterPos->{y}, $target->{pos}{x}, $target->{pos}{y}, $target->{pos_to}{x}, $target->{pos_to}{y}, $realMonsterDist, $args->{attackMethod}{maxDistance}), 'ai_attack'; + debug TF("[%s] [%s] [Waiting] (%d %d), target %s (%d %d) [(%d %d) -> (%d %d)], distance %d, maxDistance %d.\n", $slave, $canAttack_fail_string, $realMyPos->{x}, $realMyPos->{y}, $target, $realMonsterPos->{x}, $realMonsterPos->{y}, $target->{pos}{x}, $target->{pos}{y}, $target->{pos_to}{x}, $target->{pos_to}{y}, $realMonsterDist, $args->{attackMethod}{maxDistance}), 'ai_attack'; } $found_action = 1; } @@ -585,10 +577,10 @@ sub main { ) { debug "Attack $slave ($realMyPos->{x} $realMyPos->{y}) - target $target ($realMonsterPos->{x} $realMonsterPos->{y})\n"; if ($canAttack == 0) { - debug "[Slave $slave] [Attack] [$range_type_string] [No range] Too far from us to attack, distance is $realMonsterDist, attack maxDistance is $args->{attackMethod}{maxDistance}\n", 'ai_attack'; + debug "[Slave $slave] [Attack] [No range] Too far from us to attack, distance is $realMonsterDist, attack maxDistance is $args->{attackMethod}{maxDistance}\n", 'ai_attack'; } elsif ($canAttack == -1) { - debug "[Slave $slave] [Attack] [$range_type_string] [No LOS] No LOS from player to mob\n", 'ai_attack'; + debug "[Slave $slave] [Attack] [No LOS] No LOS from player to mob\n", 'ai_attack'; } my $pos = meetingPosition($slave, 2, $target, $args->{attackMethod}{maxDistance}); @@ -652,7 +644,7 @@ sub main { } if ($args->{attackMethod}{type} eq "weapon") { - if ($config{$slave->{configPrefix}.'attack_dance_melee'} && $melee) { + if ($config{$slave->{configPrefix}.'attack_dance_melee'}) { if (timeOut($timeout{$slave->{ai_dance_attack_melee_timeout}})) { my $cell = get_dance_position($slave, $target); debug TF("Slave %s will dance type %d from (%d, %d) to (%d, %d), target %s at (%d, %d).\n", $slave, $config{$slave->{configPrefix}.'attack_dance_melee'}, $realMyPos->{x}, $realMyPos->{y}, $cell->{x}, $cell->{y}, $target, $realMonsterPos->{x}, $realMonsterPos->{y}); @@ -662,7 +654,7 @@ sub main { $timeout{$slave->{ai_dance_attack_melee_timeout}}{time} = time; } - } elsif ($config{$slave->{configPrefix}.'attack_dance_ranged'} && $ranged) { + } elsif ($config{$slave->{configPrefix}.'attack_dance_ranged'}) { if (timeOut($timeout{$slave->{ai_dance_attack_ranged_timeout}})) { my $cell = get_dance_position($slave, $target); debug TF("Slave %s will range dance type %d from (%d, %d) to (%d, %d), target %s at (%d, %d).\n", $slave, $config{$slave->{configPrefix}.'attack_dance_ranged'}, $realMyPos->{x}, $realMyPos->{y}, $cell->{x}, $cell->{y}, $target, $realMonsterPos->{x}, $realMonsterPos->{y});