diff --git a/OpenRA.Mods.RA/Armament.cs b/OpenRA.Mods.RA/Armament.cs index a4c1914c3a..6a2dcda31a 100644 --- a/OpenRA.Mods.RA/Armament.cs +++ b/OpenRA.Mods.RA/Armament.cs @@ -101,7 +101,8 @@ namespace OpenRA.Mods.RA // The world coordinate model uses Actor.Orientation public void CheckFire(Actor self, AttackBase attack, IFacing facing, Target target) { - if (FireDelay > 0) return; + if (FireDelay > 0) + return; var limitedAmmo = self.TraitOrDefault(); if (limitedAmmo != null && !limitedAmmo.HasAmmo()) @@ -113,7 +114,7 @@ namespace OpenRA.Mods.RA if (!target.IsInRange(self.CenterPosition, range)) return; - if (target.IsInRange(self.CenterPosition, minRange)) + if (minRange != WRange.Zero && target.IsInRange(self.CenterPosition, minRange)) return; if (!Weapon.IsValidAgainst(target, self.World)) diff --git a/OpenRA.Mods.RA/AttackBomber.cs b/OpenRA.Mods.RA/AttackBomber.cs new file mode 100644 index 0000000000..5f43f80dd3 --- /dev/null +++ b/OpenRA.Mods.RA/AttackBomber.cs @@ -0,0 +1,54 @@ +#region Copyright & License Information +/* + * Copyright 2007-2013 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation. For more information, + * see COPYING. + */ +#endregion + +using System; +using System.Collections.Generic; +using System.Linq; +using OpenRA.FileFormats; +using OpenRA.GameRules; +using OpenRA.Traits; + +namespace OpenRA.Mods.RA +{ + class AttackBomberInfo : AttackBaseInfo + { + public override object Create(ActorInitializer init) { return new AttackBomber(init.self); } + } + + class AttackBomber : AttackBase, ISync + { + [Sync] Target target; + + public AttackBomber(Actor self) + : base(self) { } + + public override void Tick(Actor self) + { + base.Tick(self); + + if (!target.IsInRange(self.CenterPosition, GetMaximumRange())) + return; + + var facing = self.TraitOrDefault(); + var cp = self.CenterPosition; + var t = Target.FromPos(cp - new WVec(0, 0, cp.Z)); + foreach (var a in Armaments) + a.CheckFire(self, this, facing, t); + } + + public void SetTarget(WPos pos) { target = Target.FromPos(pos); } + + public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove) + { + // TODO: Player controlled units want this too! + throw new NotImplementedException("CarpetBomb requires a scripted target"); + } + } +} diff --git a/OpenRA.Mods.RA/CarpetBomb.cs b/OpenRA.Mods.RA/CarpetBomb.cs deleted file mode 100644 index c5cdcc6a91..0000000000 --- a/OpenRA.Mods.RA/CarpetBomb.cs +++ /dev/null @@ -1,78 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) - * This file is part of OpenRA, which is free software. It is made - * available to you under the terms of the GNU General Public License - * as published by the Free Software Foundation. For more information, - * see COPYING. - */ -#endregion - -using System.Linq; -using OpenRA.GameRules; -using OpenRA.Traits; - -namespace OpenRA.Mods.RA -{ - class CarpetBombInfo : ITraitInfo - { - [WeaponReference] - public readonly string Weapon = null; - public readonly int Range = 3; - - public object Create(ActorInitializer init) { return new CarpetBomb(this); } - } - - // TODO: maybe integrate this better with the normal weapons system? - class CarpetBomb : ITick, ISync - { - CarpetBombInfo info; - Target target; - - [Sync] int dropDelay; - [Sync] WRange range; - - public CarpetBomb(CarpetBombInfo info) - { - this.info = info; - - // TODO: Push this conversion into the yaml - range = WRange.FromCells(info.Range); - } - - public void SetTarget(CPos targetCell) { target = Target.FromCell(targetCell); } - public void SetTarget(WPos pos) { target = Target.FromPos(pos); } - - public void Tick(Actor self) - { - if (!target.IsInRange(self.CenterPosition, range)) - return; - - var limitedAmmo = self.TraitOrDefault(); - if (limitedAmmo != null && !limitedAmmo.HasAmmo()) - return; - - if (--dropDelay <= 0) - { - var weapon = Rules.Weapons[info.Weapon.ToLowerInvariant()]; - dropDelay = weapon.ROF; - - var pos = self.CenterPosition; - var args = new ProjectileArgs - { - Weapon = weapon, - Facing = self.Trait().Facing, - - Source = pos, - SourceActor = self, - PassiveTarget = pos - new WVec(0, 0, pos.Z) - }; - - self.World.Add(args.Weapon.Projectile.Create(args)); - - if (args.Weapon.Report != null && args.Weapon.Report.Any()) - Sound.Play(args.Weapon.Report.Random(self.World.SharedRandom), self.CenterPosition); - } - } - } -} diff --git a/OpenRA.Mods.RA/Missions/MissionUtils.cs b/OpenRA.Mods.RA/Missions/MissionUtils.cs index 75d6ddbfc9..5b8cf38044 100644 --- a/OpenRA.Mods.RA/Missions/MissionUtils.cs +++ b/OpenRA.Mods.RA/Missions/MissionUtils.cs @@ -98,7 +98,7 @@ namespace OpenRA.Mods.RA.Missions new FacingInit(Util.GetFacing(location - entry, 0)), new AltitudeInit(Rules.Info["badr.bomber"].Traits.Get().CruiseAltitude), }); - badger.Trait().SetTarget(location); + badger.Trait().SetTarget(location.CenterPosition); badger.QueueActivity(Fly.ToCell(location)); badger.QueueActivity(new FlyOffMap()); badger.QueueActivity(new RemoveSelf()); diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 50f6ce7bbb..c627a2aef8 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -179,7 +179,6 @@ - @@ -472,6 +471,7 @@ + diff --git a/OpenRA.Mods.RA/SupportPowers/AirstrikePower.cs b/OpenRA.Mods.RA/SupportPowers/AirstrikePower.cs index b9faeae598..2838bc4ae6 100755 --- a/OpenRA.Mods.RA/SupportPowers/AirstrikePower.cs +++ b/OpenRA.Mods.RA/SupportPowers/AirstrikePower.cs @@ -87,7 +87,7 @@ namespace OpenRA.Mods.RA new FacingInit(attackFacing), }); - a.Trait().SetTarget(target + targetOffset); + a.Trait().SetTarget(target + targetOffset); if (flare != null) a.QueueActivity(new CallFunc(() => flare.Destroy())); diff --git a/mods/cnc/rules/aircraft.yaml b/mods/cnc/rules/aircraft.yaml index 1608909af2..b7ad96b2ae 100644 --- a/mods/cnc/rules/aircraft.yaml +++ b/mods/cnc/rules/aircraft.yaml @@ -187,9 +187,9 @@ A10: WithShadow: LimitedAmmo: Ammo: 10 - CarpetBomb: + AttackBomber: + Armament: Weapon: Napalm - Range: 3 -Selectable: -GainsExperience: FlyAwayOnIdle: diff --git a/mods/cnc/weapons.yaml b/mods/cnc/weapons.yaml index 418253060e..6cc52e3336 100644 --- a/mods/cnc/weapons.yaml +++ b/mods/cnc/weapons.yaml @@ -727,6 +727,7 @@ TowerMissle: Napalm: ROF: 2 + Range: 3 Projectile: GravityBomb Image: BOMBLET Warhead: diff --git a/mods/d2k/rules/aircraft.yaml b/mods/d2k/rules/aircraft.yaml index 132e5ffb12..1072ee9a93 100644 --- a/mods/d2k/rules/aircraft.yaml +++ b/mods/d2k/rules/aircraft.yaml @@ -94,8 +94,8 @@ ORNI: HuskActor: ORNI.Husk ORNI.bomber: - CarpetBomb: - Range: 3 + AttackBomber: + Armament: Weapon: Napalm Inherits: ^Plane Health: diff --git a/mods/d2k/weapons.yaml b/mods/d2k/weapons.yaml index 4c46be0add..268520cb8e 100644 --- a/mods/d2k/weapons.yaml +++ b/mods/d2k/weapons.yaml @@ -482,6 +482,7 @@ ParaBomb: Napalm: ROF: 2 + Range: 3 Projectile: GravityBomb Image: BOMBS Warhead: diff --git a/mods/ra/maps/Fort-Lonestar/map.yaml b/mods/ra/maps/Fort-Lonestar/map.yaml index a90523ad52..288d4ed84c 100644 --- a/mods/ra/maps/Fort-Lonestar/map.yaml +++ b/mods/ra/maps/Fort-Lonestar/map.yaml @@ -1002,8 +1002,8 @@ Rules: Armor: Type: Concrete BADR.Bomber: - CarpetBomb: - Range: 3 + AttackBomber: + Armament: Weapon: ParaBomb Inherits: ^Plane Health: diff --git a/mods/ra/rules/aircraft.yaml b/mods/ra/rules/aircraft.yaml index fa1da4cb27..50b6ecfa78 100644 --- a/mods/ra/rules/aircraft.yaml +++ b/mods/ra/rules/aircraft.yaml @@ -36,8 +36,8 @@ BADR: RejectsOrders: BADR.Bomber: - CarpetBomb: - Range: 3 + AttackBomber: + Armament: Weapon: ParaBomb Inherits: ^Plane Health: diff --git a/mods/ra/weapons.yaml b/mods/ra/weapons.yaml index e6ef429de8..219395caab 100644 --- a/mods/ra/weapons.yaml +++ b/mods/ra/weapons.yaml @@ -898,7 +898,7 @@ DepthCharge: ParaBomb: ROF: 10 - Range: 4.5 + Range: 3 Report: CHUTE1.AUD Projectile: GravityBomb Image: PARABOMB