Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HasAnyValidWeapons doesn't check if Armament is disabled by a condition #13855

Closed
MustaphaTR opened this issue Aug 17, 2017 · 3 comments · Fixed by #13856
Closed

HasAnyValidWeapons doesn't check if Armament is disabled by a condition #13855

MustaphaTR opened this issue Aug 17, 2017 · 3 comments · Fixed by #13856
Labels

Comments

@MustaphaTR
Copy link
Member

public bool HasAnyValidWeapons(Target t, bool checkForCenterTargetingWeapons = false)
{
if (IsTraitDisabled)
return false;
if (Info.AttackRequiresEnteringCell && (positionable == null || !positionable.CanEnterCell(t.Actor.Location, null, false)))
return false;
// PERF: Avoid LINQ.
foreach (var armament in Armaments)
{
var checkIsValid = checkForCenterTargetingWeapons ? armament.Weapon.TargetActorCenter : !armament.OutOfAmmo;
if (checkIsValid && armament.Weapon.IsValidAgainst(t, self.World, self))
return true;
}

On the image, Overlord tanks that under Hunt() activity tries to attack the Comanches, even tho they don't have Overlord Gatling upgrade (so Gatling weapon is disabled)
overlords

@pchote
Copy link
Member

pchote commented Aug 17, 2017

You can work around this in your yaml, and still should even after #13856 to improve performance: use your upgrade condition to switch between AutoTargetPrioritys that do/don't target aircraft.

@MustaphaTR
Copy link
Member Author

I already did that after noticing the bug, but it doesn't look like fixing it alone, this is something to do with Hunt() too, not just AutoTarget behaviour.

@GraionDilach
Copy link
Contributor

That's probably due to #12856.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants