Add strafing to C&C airstrike.
This commit is contained in:
@@ -19,28 +19,59 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
class AttackBomberInfo : AttackBaseInfo
|
||||
{
|
||||
public override object Create(ActorInitializer init) { return new AttackBomber(init.self); }
|
||||
[Desc("Armament name")]
|
||||
public readonly string Bombs = "primary";
|
||||
|
||||
[Desc("Armament name")]
|
||||
public readonly string Guns = "secondary";
|
||||
public readonly int FacingTolerance = 2;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new AttackBomber(init.self, this); }
|
||||
}
|
||||
|
||||
class AttackBomber : AttackBase, ISync
|
||||
{
|
||||
AttackBomberInfo info;
|
||||
[Sync] Target target;
|
||||
|
||||
public AttackBomber(Actor self)
|
||||
: base(self) { }
|
||||
public AttackBomber(Actor self, AttackBomberInfo info)
|
||||
: base(self)
|
||||
{
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public override void Tick(Actor self)
|
||||
{
|
||||
base.Tick(self);
|
||||
|
||||
if (!target.IsInRange(self.CenterPosition, GetMaximumRange()))
|
||||
return;
|
||||
|
||||
var facing = self.TraitOrDefault<IFacing>();
|
||||
var cp = self.CenterPosition;
|
||||
var t = Target.FromPos(cp - new WVec(0, 0, cp.Z));
|
||||
foreach (var a in Armaments)
|
||||
var bombTarget = Target.FromPos(cp - new WVec(0, 0, cp.Z));
|
||||
|
||||
// Bombs drop anywhere in range
|
||||
foreach (var a in Armaments.Where(a => a.Info.Name == info.Bombs))
|
||||
{
|
||||
var range = new WRange((int)(1024 * a.Weapon.Range));
|
||||
if (!target.IsInRange(self.CenterPosition, range))
|
||||
continue;
|
||||
|
||||
a.CheckFire(self, this, facing, bombTarget);
|
||||
}
|
||||
|
||||
// Guns only fire when approaching the target
|
||||
var facingToTarget = Util.GetFacing(target.CenterPosition - self.CenterPosition, facing.Facing);
|
||||
if (Math.Abs(facingToTarget - facing.Facing) % 256 > info.FacingTolerance)
|
||||
return;
|
||||
|
||||
foreach (var a in Armaments.Where(a => a.Info.Name == info.Guns))
|
||||
{
|
||||
var range = new WRange((int)(1024 * a.Weapon.Range));
|
||||
if (!target.IsInRange(self.CenterPosition, range))
|
||||
continue;
|
||||
|
||||
var t = Target.FromPos(cp - new WVec(0, range.Range / 2, cp.Z).Rotate(WRot.FromFacing(facing.Facing)));
|
||||
a.CheckFire(self, this, facing, t);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetTarget(WPos pos) { target = Target.FromPos(pos); }
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA
|
||||
[ActorReference]
|
||||
public readonly string UnitType = "badr.bomber";
|
||||
public readonly int SquadSize = 1;
|
||||
public readonly WVec SquadOffset = new WVec(-1536, 2048, 0);
|
||||
public readonly WVec SquadOffset = new WVec(-1536, 1536, 0);
|
||||
|
||||
public readonly int QuantizedFacings = 32;
|
||||
public readonly WRange Cordon = new WRange(5120);
|
||||
|
||||
Reference in New Issue
Block a user