Skip to content

Commit

Permalink
Fix VTOL influence removal timing on take-off
Browse files Browse the repository at this point in the history
  • Loading branch information
reaperrr committed May 26, 2019
1 parent bb65118 commit f708417
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions OpenRA.Mods.Common/Activities/Air/TakeOff.cs
Expand Up @@ -22,6 +22,7 @@ public class TakeOff : Activity
readonly IMove move;
readonly Target target;
bool moveToRallyPoint;
bool removedInfluence;

public TakeOff(Actor self, Target target)
{
Expand All @@ -48,14 +49,33 @@ protected override void OnFirstRun(Actor self)
if (aircraft.ForceLanding)
return;

// We are taking off, so remove reservation and influence in ground cells.
aircraft.UnReserve();
aircraft.RemoveInfluence();
// Only non-VTOLs should remove influence and reservation immediately.
// VTOLs will do this after reaching CruiseAltitude or when activity is cancelled.
if (!aircraft.Info.VTOL)
{
// We are taking off, so remove reservation and influence in ground cells.
aircraft.UnReserve();
aircraft.RemoveInfluence();
removedInfluence = true;
}

if (aircraft.Info.TakeoffSounds.Length > 0)
Game.Sound.Play(SoundType.World, aircraft.Info.TakeoffSounds, self.World, aircraft.CenterPosition);
}

protected override void OnLastRun(Actor self)
{
if (aircraft.ForceLanding)
return;

if (removedInfluence || !aircraft.Info.VTOL)
return;

// We are taking off, so remove reservation and influence in ground cells.
aircraft.UnReserve();
aircraft.RemoveInfluence();
}

public override Activity Tick(Actor self)
{
if (ChildActivity != null)
Expand Down Expand Up @@ -95,6 +115,14 @@ public override Activity Tick(Actor self)
}
}

if (!removedInfluence)
{
// We have taken off, so remove reservation and influence in ground cells if that hasn't happened yet.
aircraft.UnReserve();
aircraft.RemoveInfluence();
removedInfluence = true;
}

// Checking for NextActivity == null again in case another activity was queued while taking off
if (moveToRallyPoint && NextActivity == null)
{
Expand Down

0 comments on commit f708417

Please sign in to comment.