mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-07-04 05:55:47 -07:00
Fix Capture oversight in GetBestAttackAgainst in 9fcfdb0324
This fixes units always using capture attack on a building, since rp22569 forgot to eliminate Capture from the attack types when not allowed. Reported by: minohaka Patch by: Freagarach Reviewed by: wraitii Fixes #5544 Differential Revision: https://code.wildfiregames.com/D2134 This was SVN commit r22575.
This commit is contained in:
parent
82f1d2718b
commit
fee7dba38f
2 changed files with 7 additions and 2 deletions
|
|
@ -412,8 +412,12 @@ Attack.prototype.GetBestAttackAgainst = function(target, allowCapture)
|
|||
|
||||
// Check whether the target is capturable and prefer that when it is allowed.
|
||||
let captureIndex = types.indexOf("Capture");
|
||||
if (captureIndex != -1 && allowCapture)
|
||||
return "Capture";
|
||||
if (captureIndex != -1)
|
||||
{
|
||||
if (allowCapture)
|
||||
return "Capture";
|
||||
types.splice(captureIndex, 1);
|
||||
}
|
||||
|
||||
let isPreferred = className => this.GetPreferredClasses(className).some(isTargetClass);
|
||||
|
||||
|
|
|
|||
|
|
@ -268,6 +268,7 @@ testGetBestAttackAgainst("FemaleCitizen", "Melee", undefined);
|
|||
testGetBestAttackAgainst("Archer", "Ranged", undefined);
|
||||
testGetBestAttackAgainst("Domestic", "Slaughter", "Slaughter");
|
||||
testGetBestAttackAgainst("Structure", "Capture", "Capture", true);
|
||||
testGetBestAttackAgainst("Structure", "Ranged", undefined, false);
|
||||
|
||||
function testPredictTimeToTarget(selfPosition, horizSpeed, targetPosition, targetVelocity)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue