Fix TD gunboat attack behaviour

This commit is contained in:
Oliver Brakmann
2016-02-03 19:28:45 +01:00
parent dc6d31cec8
commit ce62e456d7

View File

@@ -58,16 +58,20 @@ namespace OpenRA.Mods.Common.Traits
readonly IMove move;
readonly Target target;
readonly bool forceAttack;
readonly bool onRailsHack;
public AttackActivity(Actor self, Target target, bool allowMove, bool forceAttack)
{
attack = self.Trait<AttackFollow>();
move = allowMove ? self.TraitOrDefault<IMove>() : null;
// HACK: Mobile.OnRails is horrible
// HACK: Mobile.OnRails is horrible. Blergh.
var mobile = move as Mobile;
if (mobile != null && mobile.Info.OnRails)
{
move = null;
onRailsHack = true;
}
this.target = target;
this.forceAttack = forceAttack;
@@ -96,11 +100,15 @@ namespace OpenRA.Mods.Common.Traits
if (move != null)
return ActivityUtils.SequenceActivities(move.MoveFollow(self, target, weapon.Weapon.MinRange, maxRange), this);
if (target.IsInRange(self.CenterPosition, weapon.MaxRange()) && !target.IsInRange(self.CenterPosition, weapon.Weapon.MinRange))
if (!onRailsHack &&
target.IsInRange(self.CenterPosition, weapon.MaxRange()) &&
!target.IsInRange(self.CenterPosition, weapon.Weapon.MinRange))
return this;
}
if (!onRailsHack)
attack.Target = Target.Invalid;
return NextActivity;
}
}