Tweak helicopter movement / attack
This commit is contained in:
@@ -39,8 +39,10 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
|
|
||||||
var limitedAmmo = self.traits.GetOrDefault<LimitedAmmo>();
|
var limitedAmmo = self.traits.GetOrDefault<LimitedAmmo>();
|
||||||
if (limitedAmmo != null && !limitedAmmo.HasAmmo())
|
if (limitedAmmo != null && !limitedAmmo.HasAmmo())
|
||||||
|
{
|
||||||
|
self.QueueActivity(new HeliReturn());
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
}
|
||||||
var unit = self.traits.Get<Unit>();
|
var unit = self.traits.Get<Unit>();
|
||||||
|
|
||||||
var info = self.Info.Traits.Get<HelicopterInfo>();
|
var info = self.Info.Traits.Get<HelicopterInfo>();
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA.Activities
|
namespace OpenRA.Mods.RA.Activities
|
||||||
{
|
{
|
||||||
@@ -48,8 +49,16 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
unit.Altitude += Math.Sign(info.CruiseAltitude - unit.Altitude);
|
unit.Altitude += Math.Sign(info.CruiseAltitude - unit.Altitude);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
var dist = Dest - self.CenterLocation;
|
// 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;
|
||||||
if (float2.WithinEpsilon(float2.Zero, dist, 2))
|
if (float2.WithinEpsilon(float2.Zero, dist, 2))
|
||||||
{
|
{
|
||||||
self.CenterLocation = Dest;
|
self.CenterLocation = Dest;
|
||||||
@@ -67,6 +76,19 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
|
|
||||||
return this;
|
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; }
|
public void Cancel(Actor self) { isCanceled = true; NextActivity = null; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||||
* This file is part of OpenRA.
|
* This file is part of OpenRA.
|
||||||
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
target = order.TargetActor;
|
target = order.TargetActor;
|
||||||
self.QueueActivity(new HeliAttack(order.TargetActor));
|
self.QueueActivity(new HeliAttack(order.TargetActor));
|
||||||
self.QueueActivity(new HeliReturn());
|
//self.QueueActivity(new HeliReturn());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ namespace OpenRA.Mods.RA
|
|||||||
public readonly string[] RearmBuildings = { "hpad" };
|
public readonly string[] RearmBuildings = { "hpad" };
|
||||||
public readonly int CruiseAltitude = 20;
|
public readonly int CruiseAltitude = 20;
|
||||||
public readonly int IdealSeparation = 80;
|
public readonly int IdealSeparation = 80;
|
||||||
|
public readonly bool LandWhenIdle = true;
|
||||||
public object Create(Actor self) { return new Helicopter(self); }
|
public object Create(Actor self) { return new Helicopter(self); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,8 +79,12 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
self.QueueActivity(new HeliFly(Util.CenterOfCell(order.TargetLocation)));
|
self.QueueActivity(new HeliFly(Util.CenterOfCell(order.TargetLocation)));
|
||||||
self.QueueActivity(new Turn(self.Info.Traits.GetOrDefault<UnitInfo>().InitialFacing));
|
|
||||||
self.QueueActivity(new HeliLand(true));
|
if (self.Info.Traits.Get<HelicopterInfo>().LandWhenIdle)
|
||||||
|
{
|
||||||
|
self.QueueActivity(new Turn(self.Info.Traits.GetOrDefault<UnitInfo>().InitialFacing));
|
||||||
|
self.QueueActivity(new HeliLand(true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (order.OrderString == "Enter")
|
if (order.OrderString == "Enter")
|
||||||
|
|||||||
@@ -418,7 +418,7 @@ HELI:
|
|||||||
Buildable:
|
Buildable:
|
||||||
Icon: heliicnh
|
Icon: heliicnh
|
||||||
BuildPaletteOrder: 60
|
BuildPaletteOrder: 60
|
||||||
Prerequisites: hpad
|
Prerequisites: hpad, hq
|
||||||
BuiltAt: hpad
|
BuiltAt: hpad
|
||||||
Owner: nod
|
Owner: nod
|
||||||
Cost: 1200
|
Cost: 1200
|
||||||
@@ -438,6 +438,7 @@ HELI:
|
|||||||
PrimaryOffset: -5,0,0,2
|
PrimaryOffset: -5,0,0,2
|
||||||
SecondaryOffset: 5,0,0,2
|
SecondaryOffset: 5,0,0,2
|
||||||
Helicopter:
|
Helicopter:
|
||||||
|
LandWhenIdle: no
|
||||||
RenderUnitRotor:
|
RenderUnitRotor:
|
||||||
PrimaryOffset: 0,0,0,-2
|
PrimaryOffset: 0,0,0,-2
|
||||||
WithShadow:
|
WithShadow:
|
||||||
@@ -449,7 +450,7 @@ ORCA:
|
|||||||
Buildable:
|
Buildable:
|
||||||
Icon: orcaicnh
|
Icon: orcaicnh
|
||||||
BuildPaletteOrder: 60
|
BuildPaletteOrder: 60
|
||||||
Prerequisites: hpad
|
Prerequisites: hpad, hq
|
||||||
BuiltAt: hpad
|
BuiltAt: hpad
|
||||||
Owner: gdi
|
Owner: gdi
|
||||||
Cost: 1200
|
Cost: 1200
|
||||||
@@ -469,6 +470,7 @@ ORCA:
|
|||||||
PrimaryOffset: -5,0,0,2
|
PrimaryOffset: -5,0,0,2
|
||||||
SecondaryOffset: 5,0,0,2
|
SecondaryOffset: 5,0,0,2
|
||||||
Helicopter:
|
Helicopter:
|
||||||
|
LandWhenIdle: no
|
||||||
RenderUnit:
|
RenderUnit:
|
||||||
WithShadow:
|
WithShadow:
|
||||||
LimitedAmmo:
|
LimitedAmmo:
|
||||||
|
|||||||
Reference in New Issue
Block a user