Skip to content

Commit

Permalink
Merge pull request OpenRA#2754 from Mailaender/auto-target-desync-hotfix
Browse files Browse the repository at this point in the history
Hotfix: Addresses Desync Issues in AutoTarget Trait
  • Loading branch information
chrisforbes committed Mar 11, 2013
2 parents 7cbc4a2 + 97d850e commit 623fce3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 2 additions & 2 deletions OpenRA.Mods.RA/Attack/AttackBase.cs
Expand Up @@ -36,8 +36,8 @@ public abstract class AttackBaseInfo : ITraitInfo
public readonly bool AlignIdleTurrets = false;
public readonly bool CanAttackGround = true;

public readonly float ScanTimeAverage = 2f;
public readonly float ScanTimeSpread = .5f;
public readonly int MinimumScanTimeInterval = 30;
public readonly int MaximumScanTimeInterval = 60;

public abstract object Create(ActorInitializer init);

Expand Down
4 changes: 1 addition & 3 deletions OpenRA.Mods.RA/AutoTarget.cs
Expand Up @@ -107,9 +107,7 @@ public void ScanAndAttack(Actor self)
Actor ChooseTarget(Actor self, float range)
{
var info = self.Info.Traits.Get<AttackBaseInfo>();
nextScanTime = (int)(25 * (info.ScanTimeAverage +
(self.World.SharedRandom.NextFloat() * 2 - 1) * info.ScanTimeSpread));
Log.Write("debug", "Actor {0}; nextScanTime: {1}", self.ActorID, nextScanTime);
nextScanTime = self.World.SharedRandom.Next(info.MinimumScanTimeInterval, info.MaximumScanTimeInterval);

var inRange = self.World.FindUnitsInCircle(self.CenterLocation, (int)(Game.CellSize * range));

Expand Down

0 comments on commit 623fce3

Please sign in to comment.