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

Fix a series of visibility/targeting bugs #9672

Merged
merged 4 commits into from
Oct 23, 2015

Conversation

penev92
Copy link
Member

@penev92 penev92 commented Oct 18, 2015

The commit messages say it all.
Fixes #9667 - spies were totally broken.
Fixes #9157 - basically nobody cared about invisibility on structures.

P.S.: Also fixes #9351.
P.P.S.: Also fixes #2959.
And let's say it fixes #9470.

@penev92 penev92 added this to the Next release milestone Oct 18, 2015
@@ -223,13 +223,29 @@ public IEnumerable<Armament> ChooseArmamentsForTarget(Target t, bool forceAttack
// (short-circuiting in the logical expression below)
var owner = null as Player;
if (t.Type == TargetType.FrozenActor)
owner = t.FrozenActor.Owner;
{
owner = t.FrozenActor.Actor.EffectiveOwner != null && t.FrozenActor.Actor.EffectiveOwner.Owner != null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will crash if the actor is dead (t.FrozenActor.Actor == null). You need to check for that case and use t.FrozenActor.Owner instead.


// Armaments are enumerated in attack.Armaments in construct order
// When autotargeting, first choose targets according to the used armament construct order
// And then according to distance from actor
// This enables preferential treatment of certain armaments
// (e.g. tesla trooper's tesla zap should have precedence over tesla charge)
var actrarms = inRange
var armamentForActor = inRange
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actorByArmament would be more accurate.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, but it makes no sense :|

 - Move a check for AutoTargetIgnore up the chain
 - Simplify some LINQs to a single .FirstOrDefault()
 - Rename local variable
@penev92
Copy link
Member Author

penev92 commented Oct 21, 2015

Updated.

@RoosterDragon
Copy link
Member

Confirmed this fixes being able to attack/auto-target cloaked structures. Spies can no longer be attacked/auto-targeted by normal units. Dogs can still attack and will auto-target disguised spies just fine.

👍

@RoosterDragon
Copy link
Member

Also fixes #9351.

})

.Where(kv => kv.Key != null && kv.Value.TraitOrDefault<AutoTargetIgnore>() == null)
.Where(kv => kv.Key != null && self.Owner.CanViewActor(kv.Value))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why you added the filter here and not before or after the AutoTargetIgnore test in line 161?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Performance. I wanted to do the visibility check as late as possible, because at that point chances are that most of the candidates have already been excluded.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, sounds reasonable.

@obrakmann
Copy link
Contributor

Would maybe fix #2959 as well?

@RoosterDragon
Copy link
Member

Also maybe #9470?

@penev92
Copy link
Member Author

penev92 commented Oct 22, 2015

Fixed the frozen actors issue.

@obrakmann
Copy link
Contributor

Works now 👍

obrakmann added a commit that referenced this pull request Oct 23, 2015
Fix a series of visibility/targeting bugs
@obrakmann obrakmann merged commit 206f644 into OpenRA:bleed Oct 23, 2015
@obrakmann
Copy link
Contributor

Changelog

@penev92 penev92 deleted the fixAutoTarget branch October 26, 2015 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment