diff --git a/OpenRA.Mods.RA/AttackBomber.cs b/OpenRA.Mods.RA/AttackBomber.cs index 590e35821f..1c97616a4b 100644 --- a/OpenRA.Mods.RA/AttackBomber.cs +++ b/OpenRA.Mods.RA/AttackBomber.cs @@ -23,19 +23,22 @@ namespace OpenRA.Mods.RA [Desc("Armament name")] public readonly string Guns = "secondary"; public readonly int FacingTolerance = 2; + public readonly WRange VisionRange = WRange.FromCells(10); public override object Create(ActorInitializer init) { return new AttackBomber(init.self, this); } } - class AttackBomber : AttackBase, ISync + class AttackBomber : AttackBase, ISync, INotifyKilled { AttackBomberInfo info; + Actor camera; [Sync] Target target; public AttackBomber(Actor self, AttackBomberInfo info) : base(self) { this.info = info; + this.camera = null; } public override void Tick(Actor self) @@ -46,6 +49,23 @@ namespace OpenRA.Mods.RA var cp = self.CenterPosition; var bombTarget = Target.FromPos(cp - new WVec(0, 0, cp.Z)); + // Provide vision + if (this.camera == null && + target.IsInRange(self.CenterPosition, this.info.VisionRange)) + { + this.camera = self.World.CreateActor("camera", new TypeDictionary + { + new LocationInit(target.CenterPosition.ToCPos()), + new OwnerInit(self.Owner), + }); + } + else if (this.camera != null && + !target.IsInRange(self.CenterPosition, this.info.VisionRange)) + { + self.World.Remove(this.camera); + this.camera = null; + } + // Bombs drop anywhere in range foreach (var a in Armaments.Where(a => a.Info.Name == info.Bombs)) { @@ -72,6 +92,15 @@ namespace OpenRA.Mods.RA public void SetTarget(WPos pos) { target = Target.FromPos(pos); } + public void Killed(Actor self, AttackInfo e) + { + if (this.camera != null) + { + self.World.Remove(this.camera); + this.camera = null; + } + } + public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove) { // TODO: Player controlled units want this too! diff --git a/mods/cnc/rules/aircraft.yaml b/mods/cnc/rules/aircraft.yaml index 438c53f123..4bacb26cbb 100644 --- a/mods/cnc/rules/aircraft.yaml +++ b/mods/cnc/rules/aircraft.yaml @@ -192,8 +192,6 @@ A10: HP: 150 Armor: Type: Heavy - RevealsShroud: - Range: 12 RenderUnit: WithShadow: AttackBomber: diff --git a/mods/cnc/rules/system-actors.yaml b/mods/cnc/rules/system-actors.yaml index 72f82fbe2a..10ee6f00a0 100644 --- a/mods/cnc/rules/system-actors.yaml +++ b/mods/cnc/rules/system-actors.yaml @@ -39,4 +39,13 @@ waypoint: Waypoint: RenderEditorOnly: BodyOrientation: +CAMERA: + Aircraft: + Health: + HP: 1000 + RevealsShroud: + Range: 10 + ProximityCaptor: + Types: Camera + BodyOrientation: