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)
|
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)
|
public override void ResolveOrder(Actor self, Order order)
|
||||||
@@ -69,7 +69,13 @@ namespace OpenRA.Mods.RA
|
|||||||
class AttackActivity : Activity
|
class AttackActivity : Activity
|
||||||
{
|
{
|
||||||
readonly Target target;
|
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 )
|
public override Activity Tick( Actor self )
|
||||||
{
|
{
|
||||||
@@ -81,15 +87,17 @@ namespace OpenRA.Mods.RA
|
|||||||
var attack = self.Trait<AttackTurreted>();
|
var attack = self.Trait<AttackTurreted>();
|
||||||
const int RangeTolerance = 1; /* how far inside our maximum range we should try to sit */
|
const int RangeTolerance = 1; /* how far inside our maximum range we should try to sit */
|
||||||
var weapon = attack.ChooseWeaponForTarget(target);
|
var weapon = attack.ChooseWeaponForTarget(target);
|
||||||
|
|
||||||
if (weapon != null)
|
if (weapon != null)
|
||||||
{
|
{
|
||||||
attack.target = target;
|
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(
|
return Util.SequenceActivities(
|
||||||
new Follow( target, Math.Max( 0, (int)weapon.Info.Range - RangeTolerance ) ),
|
new Follow( target, Math.Max( 0, (int)weapon.Info.Range - RangeTolerance ) ),
|
||||||
this );
|
this );
|
||||||
}
|
}
|
||||||
|
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user