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 invalid target crash if Leap target dies. #15998

Merged
merged 1 commit into from Jan 5, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion OpenRA.Mods.Cnc/Activities/Leap.cs
Expand Up @@ -33,6 +33,7 @@ public class Leap : Activity
bool canceled = false;
bool jumpComplete = false;
int ticks = 0;
WPos targetPosition;

public Leap(Actor self, Target target, Mobile mobile, Mobile targetMobile, int speed, AttackLeap attack, EdibleByLeap edible)
{
Expand Down Expand Up @@ -61,6 +62,7 @@ protected override void OnFirstRun(Actor self)
if (canceled)
return;

targetPosition = target.CenterPosition;
attack.GrantLeapCondition(self);
}

Expand All @@ -79,7 +81,10 @@ public override Activity Tick(Actor self)
return this;
}

var position = length > 1 ? WPos.Lerp(origin, target.CenterPosition, ticks, length - 1) : target.CenterPosition;
if (target.Type != TargetType.Invalid)
targetPosition = target.CenterPosition;

var position = length > 1 ? WPos.Lerp(origin, targetPosition, ticks, length - 1) : targetPosition;
mobile.SetVisualPosition(self, position);

// We are at the destination
Expand Down