Fix TD gunboat attack behaviour
This commit is contained in:
@@ -58,16 +58,20 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
readonly IMove move;
|
readonly IMove move;
|
||||||
readonly Target target;
|
readonly Target target;
|
||||||
readonly bool forceAttack;
|
readonly bool forceAttack;
|
||||||
|
readonly bool onRailsHack;
|
||||||
|
|
||||||
public AttackActivity(Actor self, Target target, bool allowMove, bool forceAttack)
|
public AttackActivity(Actor self, Target target, bool allowMove, bool forceAttack)
|
||||||
{
|
{
|
||||||
attack = self.Trait<AttackFollow>();
|
attack = self.Trait<AttackFollow>();
|
||||||
move = allowMove ? self.TraitOrDefault<IMove>() : null;
|
move = allowMove ? self.TraitOrDefault<IMove>() : null;
|
||||||
|
|
||||||
// HACK: Mobile.OnRails is horrible
|
// HACK: Mobile.OnRails is horrible. Blergh.
|
||||||
var mobile = move as Mobile;
|
var mobile = move as Mobile;
|
||||||
if (mobile != null && mobile.Info.OnRails)
|
if (mobile != null && mobile.Info.OnRails)
|
||||||
|
{
|
||||||
move = null;
|
move = null;
|
||||||
|
onRailsHack = true;
|
||||||
|
}
|
||||||
|
|
||||||
this.target = target;
|
this.target = target;
|
||||||
this.forceAttack = forceAttack;
|
this.forceAttack = forceAttack;
|
||||||
@@ -96,11 +100,15 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
if (move != null)
|
if (move != null)
|
||||||
return ActivityUtils.SequenceActivities(move.MoveFollow(self, target, weapon.Weapon.MinRange, maxRange), this);
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
attack.Target = Target.Invalid;
|
if (!onRailsHack)
|
||||||
|
attack.Target = Target.Invalid;
|
||||||
|
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user