diff --git a/OpenRA.Mods.Cnc/CarpetBomb.cs b/OpenRA.Mods.Cnc/CarpetBomb.cs new file mode 100644 index 0000000000..66b1ea5e81 --- /dev/null +++ b/OpenRA.Mods.Cnc/CarpetBomb.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using OpenRA.Traits; +using OpenRA.GameRules; + +namespace OpenRA.Mods.Cnc +{ + class CarpetBombInfo : ITraitInfo + { + public readonly string Weapon = null; + public readonly int Interval = 0; + public readonly int Range = 0; + + public object Create(Actor self) { return new CarpetBomb(self); } + } + + class CarpetBomb : ITick + { + int2 Target; + int dropDelay; + + public CarpetBomb(Actor self) { } + + public void SetTarget(int2 targetCell) { Target = targetCell; } + + public void Tick(Actor self) + { + var info = self.Info.Traits.Get(); + + if ((self.Location - Target).LengthSquared > info.Range * info.Range) + return; + + var limitedAmmo = self.traits.GetOrDefault(); + if (limitedAmmo != null && !limitedAmmo.HasAmmo()) + return; + + if (--dropDelay <= 0) + { + dropDelay = info.Interval; + + var args = new ProjectileArgs + { + srcAltitude = self.traits.Get().Altitude, + destAltitude = 0, + src = self.CenterLocation.ToInt2(), + dest = self.CenterLocation.ToInt2(), + facing = self.traits.Get().Facing, + firedBy = self, + weapon = Rules.Weapons[info.Weapon.ToLowerInvariant()] + }; + + self.World.Add(args.weapon.Projectile.Create(args)); + } + } + } +} diff --git a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj index d8cc715923..e81ec72a2a 100644 --- a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj +++ b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj @@ -46,6 +46,7 @@ +