Heli pips and separation
This commit is contained in:
@@ -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<Helicopter>());
|
||||
|
||||
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; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Helicopter>());
|
||||
|
||||
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; }
|
||||
}
|
||||
|
||||
@@ -37,7 +37,6 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
target = order.TargetActor;
|
||||
self.QueueActivity(new HeliAttack(order.TargetActor));
|
||||
//self.QueueActivity(new HeliReturn());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<HelicopterInfo>().IdealSeparation)
|
||||
.Where(a => a.traits.Contains<Helicopter>());
|
||||
|
||||
var f = otherHelis
|
||||
.Select(h => self.traits.Get<Helicopter>().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<HelicopterInfo>().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; }
|
||||
}
|
||||
|
||||
@@ -444,7 +444,7 @@ HELI:
|
||||
WithShadow:
|
||||
LimitedAmmo:
|
||||
Ammo: 15
|
||||
|
||||
PipCount: 5
|
||||
ORCA:
|
||||
Inherits: ^Plane
|
||||
Buildable:
|
||||
|
||||
Reference in New Issue
Block a user