diff --git a/OpenRA.Mods.RA/Activities/HeliAttack.cs b/OpenRA.Mods.RA/Activities/HeliAttack.cs index 14bd3ea24a..fae9b230ed 100644 --- a/OpenRA.Mods.RA/Activities/HeliAttack.cs +++ b/OpenRA.Mods.RA/Activities/HeliAttack.cs @@ -63,32 +63,9 @@ namespace OpenRA.Mods.RA.Activities if (!float2.WithinEpsilon(float2.Zero, dist, range * Game.CellSize)) self.CenterLocation += (rawSpeed / dist.Length) * dist; - var otherHelis = self.World.FindUnitsInCircle(self.CenterLocation, info.IdealSeparation) - .Where(a => a.traits.Contains()); - - var f = otherHelis - .Select(h => GetRepulseForce(self, h)) - .Aggregate(float2.Zero, (a, b) => a + b); - - self.CenterLocation += rawSpeed * f; - - self.Location = ((1 / 24f) * self.CenterLocation).ToInt2(); - return this; } - const float Epsilon = .5f; - float2 GetRepulseForce(Actor self, Actor h) - { - if (self == h) - return float2.Zero; - var d = self.CenterLocation - h.CenterLocation; - if (d.LengthSquared < Epsilon) - return float2.FromAngle((float)self.World.SharedRandom.NextDouble() * 3.14f); - - return (2 / d.LengthSquared) * d; - } - public void Cancel(Actor self) { target = null; NextActivity = null; } } } diff --git a/OpenRA.Mods.RA/Activities/HeliFly.cs b/OpenRA.Mods.RA/Activities/HeliFly.cs index 7525948f01..533cb24b96 100644 --- a/OpenRA.Mods.RA/Activities/HeliFly.cs +++ b/OpenRA.Mods.RA/Activities/HeliFly.cs @@ -50,15 +50,7 @@ namespace OpenRA.Mods.RA.Activities return this; } - // Prevent multiple units from stacking together - var otherHelis = self.World.FindUnitsInCircle(self.CenterLocation, info.IdealSeparation) - .Where(a => a.traits.Contains()); - - var f = otherHelis - .Select(h => GetRepulseForce(self, h)) - .Aggregate(float2.Zero, (a, b) => a + b); - - var dist = Dest - self.CenterLocation + f; + var dist = Dest - self.CenterLocation; if (float2.WithinEpsilon(float2.Zero, dist, 2)) { self.CenterLocation = Dest; @@ -76,19 +68,6 @@ namespace OpenRA.Mods.RA.Activities return this; } - - // Todo: Duplicated from HeliAttack - const float Epsilon = .5f; - float2 GetRepulseForce(Actor self, Actor h) - { - if (self == h) - return float2.Zero; - var d = self.CenterLocation - h.CenterLocation; - if (d.LengthSquared < Epsilon) - return float2.FromAngle((float)self.World.SharedRandom.NextDouble() * 3.14f); - - return (2 / d.LengthSquared) * d; - } public void Cancel(Actor self) { isCanceled = true; NextActivity = null; } } diff --git a/OpenRA.Mods.RA/AttackHeli.cs b/OpenRA.Mods.RA/AttackHeli.cs index 03394eacef..f270dbc544 100644 --- a/OpenRA.Mods.RA/AttackHeli.cs +++ b/OpenRA.Mods.RA/AttackHeli.cs @@ -37,7 +37,6 @@ namespace OpenRA.Mods.RA { target = order.TargetActor; self.QueueActivity(new HeliAttack(order.TargetActor)); - //self.QueueActivity(new HeliReturn()); } } } diff --git a/OpenRA.Mods.RA/Helicopter.cs b/OpenRA.Mods.RA/Helicopter.cs index f1be6b177f..a6160413f8 100644 --- a/OpenRA.Mods.RA/Helicopter.cs +++ b/OpenRA.Mods.RA/Helicopter.cs @@ -32,12 +32,12 @@ namespace OpenRA.Mods.RA public readonly string[] RepairBuildings = { "fix" }; public readonly string[] RearmBuildings = { "hpad" }; public readonly int CruiseAltitude = 20; - public readonly int IdealSeparation = 80; + public readonly int IdealSeparation = 40; public readonly bool LandWhenIdle = true; public object Create(Actor self) { return new Helicopter(self); } } - class Helicopter : IIssueOrder, IResolveOrder, IMovement + class Helicopter : ITick, IIssueOrder, IResolveOrder, IMovement { public IDisposable reservation; public Helicopter(Actor self) {} @@ -106,7 +106,36 @@ namespace OpenRA.Mods.RA ? (IActivity)new Rearm() : new Repair()); } } + + public void Tick(Actor self) + { + var rawSpeed = .2f * Util.GetEffectiveSpeed(self, UnitMovementType.Fly); + var otherHelis = self.World.FindUnitsInCircle(self.CenterLocation, self.Info.Traits.Get().IdealSeparation) + .Where(a => a.traits.Contains()); + var f = otherHelis + .Select(h => self.traits.Get().GetRepulseForce(self, h)) + .Aggregate(float2.Zero, (a, b) => a + b); + + self.CenterLocation += rawSpeed * f; + self.Location = ((1 / 24f) * self.CenterLocation).ToInt2(); + } + + const float Epsilon = .5f; + public float2 GetRepulseForce(Actor self, Actor h) + { + if (self == h) + return float2.Zero; + var d = self.CenterLocation - h.CenterLocation; + + if (d.Length > self.Info.Traits.Get().IdealSeparation) + return float2.Zero; + + if (d.LengthSquared < Epsilon) + return float2.FromAngle((float)self.World.SharedRandom.NextDouble() * 3.14f); + return (5 / d.LengthSquared) * d; + } + public UnitMovementType GetMovementType() { return UnitMovementType.Fly; } public bool CanEnterCell(int2 location) { return true; } } diff --git a/mods/cnc/vehicles.yaml b/mods/cnc/vehicles.yaml index 8aea79eb39..ac22a69863 100644 --- a/mods/cnc/vehicles.yaml +++ b/mods/cnc/vehicles.yaml @@ -444,7 +444,7 @@ HELI: WithShadow: LimitedAmmo: Ammo: 15 - + PipCount: 5 ORCA: Inherits: ^Plane Buildable: