Revert "Fixes AttackMove moving even if an enemy is within range."

This reverts commit a155c7b7ac.
This commit is contained in:
Paul Chote
2014-12-22 15:17:51 +13:00
parent e212517bbb
commit 488f0d1140
3 changed files with 17 additions and 44 deletions

View File

@@ -20,42 +20,24 @@ namespace OpenRA.Mods.RA.Activities
{
const int ScanInterval = 7;
int scanTicks;
bool hasMoved;
Activity inner;
int scanTicks;
AutoTarget autoTarget;
public AttackMoveActivity(Actor self, Activity inner)
{
this.inner = inner;
autoTarget = self.TraitOrDefault<AutoTarget>();
hasMoved = false;
}
public override Activity Tick(Actor self)
{
if (autoTarget != null)
if (autoTarget != null && --scanTicks <= 0)
{
// If the actor hasn't moved since the activity was issued
if (!hasMoved)
autoTarget.ResetScanTimer();
if (--scanTicks <= 0)
{
var attackActivity = autoTarget.ScanAndAttack(self);
if (attackActivity != null)
{
if (!hasMoved)
return attackActivity;
self.QueueActivity(false, attackActivity);
}
scanTicks = ScanInterval;
}
autoTarget.ScanAndAttack(self);
scanTicks = ScanInterval;
}
hasMoved = true;
if (inner == null)
return NextActivity;

View File

@@ -134,7 +134,7 @@ namespace OpenRA.Mods.RA
return;
self.SetTargetLine(target, Color.Red);
self.QueueActivity(false, AttackTarget(target, true));
AttackTarget(target, order.Queued, true);
}
}
@@ -160,12 +160,15 @@ namespace OpenRA.Mods.RA
public Armament ChooseArmamentForTarget(Target t) { return Armaments.FirstOrDefault(a => a.Weapon.IsValidAgainst(t, self.World, self)); }
public Activity AttackTarget(Target target, bool allowMove)
public void AttackTarget(Target target, bool queued, bool allowMove)
{
if (!target.IsValidFor(self))
return null;
return;
return GetAttackActivity(self, target, allowMove);
if (!queued)
self.CancelActivity();
self.QueueActivity(GetAttackActivity(self, target, allowMove));
}
public bool IsReachableTarget(Target target, bool allowMove)

View File

@@ -101,7 +101,7 @@ namespace OpenRA.Mods.RA
Aggressor = attacker;
if (at == null || !at.IsReachableTarget(at.Target, info.AllowMovement && Stance != UnitStance.Defend))
self.QueueActivity(false, Attack(self, Aggressor));
Attack(self, Aggressor);
}
public void TickIdle(Actor self)
@@ -111,13 +111,7 @@ namespace OpenRA.Mods.RA
var allowMovement = info.AllowMovement && Stance != UnitStance.Defend;
if (at == null || !at.IsReachableTarget(at.Target, allowMovement))
{
var act = ScanAndAttack(self);
if (act != null)
{
self.QueueActivity(false, act);
}
}
ScanAndAttack(self);
}
public void Tick(Actor self)
@@ -138,25 +132,19 @@ namespace OpenRA.Mods.RA
return currentTarget;
}
public void ResetScanTimer()
{
nextScanTime = 0;
}
public Activity ScanAndAttack(Actor self)
public void ScanAndAttack(Actor self)
{
var targetActor = ScanForTarget(self, null);
if (targetActor != null)
return Attack(self, targetActor);
return null;
Attack(self, targetActor);
}
Activity Attack(Actor self, Actor targetActor)
void Attack(Actor self, Actor targetActor)
{
TargetedActor = targetActor;
var target = Target.FromActor(targetActor);
self.SetTargetLine(target, Color.Red, false);
return attack.AttackTarget(target, info.AllowMovement && Stance != UnitStance.Defend);
attack.AttackTarget(target, false, info.AllowMovement && Stance != UnitStance.Defend);
}
Actor ChooseTarget(Actor self, WRange range)