Add defend stance support for turreted units
This commit is contained in:
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove)
|
||||
{
|
||||
return new AttackActivity( newTarget );
|
||||
return new AttackActivity( newTarget, allowMove );
|
||||
}
|
||||
|
||||
public override void ResolveOrder(Actor self, Order order)
|
||||
@@ -69,7 +69,13 @@ namespace OpenRA.Mods.RA
|
||||
class AttackActivity : Activity
|
||||
{
|
||||
readonly Target target;
|
||||
public AttackActivity( Target newTarget ) { this.target = newTarget; }
|
||||
readonly bool allowMove;
|
||||
|
||||
public AttackActivity( Target newTarget, bool allowMove )
|
||||
{
|
||||
this.target = newTarget;
|
||||
this.allowMove = allowMove;
|
||||
}
|
||||
|
||||
public override Activity Tick( Actor self )
|
||||
{
|
||||
@@ -81,15 +87,17 @@ namespace OpenRA.Mods.RA
|
||||
var attack = self.Trait<AttackTurreted>();
|
||||
const int RangeTolerance = 1; /* how far inside our maximum range we should try to sit */
|
||||
var weapon = attack.ChooseWeaponForTarget(target);
|
||||
|
||||
if (weapon != null)
|
||||
{
|
||||
attack.target = target;
|
||||
|
||||
if (self.HasTrait<Mobile>() && !self.Info.Traits.Get<MobileInfo>().OnRails)
|
||||
if (allowMove && self.HasTrait<Mobile>() && !self.Info.Traits.Get<MobileInfo>().OnRails)
|
||||
return Util.SequenceActivities(
|
||||
new Follow( target, Math.Max( 0, (int)weapon.Info.Range - RangeTolerance ) ),
|
||||
this );
|
||||
}
|
||||
|
||||
return NextActivity;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user