diff --git a/OpenRA.Mods.RA/DemoTruck.cs b/OpenRA.Mods.RA/DemoTruck.cs index ddc0373746..b9a9ef77da 100644 --- a/OpenRA.Mods.RA/DemoTruck.cs +++ b/OpenRA.Mods.RA/DemoTruck.cs @@ -8,44 +8,63 @@ */ #endregion +using System.Collections.Generic; +using System.Drawing; +using OpenRA.Mods.RA.Activities; +using OpenRA.Mods.RA.Buildings; +using OpenRA.Mods.RA.Orders; using OpenRA.Traits; namespace OpenRA.Mods.RA { - class DemoTruckInfo : TraitInfo { } + // Requiring Explodes is busted. + // Exception when overriding Chronoshift event; removed for now, will look into it. + class DemoTruckInfo : TraitInfo {} //, Requires {} - class DemoTruck : Chronoshiftable, INotifyKilled + class DemoTruck : IIssueOrder, IResolveOrder, IOrderVoice { - // Explode on chronoshift - public override bool Teleport(Actor self, CPos targetLocation, int duration, bool killCargo, Actor chronosphere) + void Explode(Actor self) { - Detonate(self, chronosphere); - return false; - } - - // Fire primary on death - public void Killed(Actor self, AttackInfo e) - { - Detonate(self, e.Attacker); - } - - public void Detonate(Actor self, Actor detonatedBy) - { - var move = self.TraitOrDefault(); - var info = self.Info.Traits.Get(); - var altitude = move != null ? move.Altitude : 0; - - self.World.AddFrameEndTask( w => + self.World.AddFrameEndTask(w => { - if (self.Destroyed) return; - Combat.DoExplosion(self, info.PrimaryWeapon, self.CenterLocation, altitude); + self.InflictDamage(self, int.MaxValue, null); + }); + } - // Remove from world - self.Kill(self); - detonatedBy.Owner.Kills++; - self.Owner.Deaths++; - self.Destroy(); - } ); + public IEnumerable Orders + { + get + { + yield return new UnitTraitOrderTargeter("DemoAttack", 5, "attack", true, false) { ForceAttack = false }; + yield return new DeployOrderTargeter("DemoDeploy", 5); + } + } + + public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued) + { + if (order.OrderID == "DemoAttack" || order.OrderID == "DemoDeploy") + return new Order(order.OrderID, self, queued) { TargetActor = target.Actor }; + + return null; + } + + public string VoicePhraseForOrder(Actor self, Order order) + { + return "Attack"; + } + + public void ResolveOrder(Actor self, Order order) + { + if (order.OrderString == "DemoDeploy") + { + self.World.AddFrameEndTask(w => + { + self.QueueActivity(new MoveAdjacentTo(Target.FromOrder(order))); + self.QueueActivity(new CallFunc(() => Explode(self))); + }); + } + if (order.OrderString == "DemoAttack") + Explode(self); } } } diff --git a/mods/ra/bits/dtrk.shp b/mods/ra/bits/dtrk.shp new file mode 100644 index 0000000000..8e721b98d7 Binary files /dev/null and b/mods/ra/bits/dtrk.shp differ diff --git a/mods/ra/bits/dtrkicon.shp b/mods/ra/bits/dtrkicon.shp new file mode 100644 index 0000000000..644bd3a1d8 Binary files /dev/null and b/mods/ra/bits/dtrkicon.shp differ diff --git a/mods/ra/rules/vehicles.yaml b/mods/ra/rules/vehicles.yaml index b8759132dd..ab93c1c2ce 100644 --- a/mods/ra/rules/vehicles.yaml +++ b/mods/ra/rules/vehicles.yaml @@ -514,6 +514,7 @@ TTNK: Inherits: ^Tank Buildable: Queue: Vehicle + BuildPaletteOrder: 130 Prerequisites: stek,tsla Owner: soviet Valued: @@ -571,3 +572,33 @@ FTRK: EmptyWeapon: UnitExplodeSmall Selectable: Bounds: 28,28,0,0 + +DTRK: + Inherits: ^Vehicle + Buildable: + Queue: Vehicle + BuildPaletteOrder: 140 + Prerequisites: stek + Owner: soviet + Valued: + Cost: 1500 + Tooltip: + Name: Demolition Truck + Description: Demolition Truck, actively armed with explosives.\n Strong vs Everything,\n Weak vs Everything + Health: + HP: 110 + Armor: + Type: Light + Mobile: + Speed: 8 + RevealsShroud: + Range: 3 + RenderUnit: + AttackMove: + JustMove: yes + Explodes: + Weapon: Atomic + EmptyWeapon: Atomic + DemoTruck: + -IronCurtainable: + -Chronoshiftable: diff --git a/mods/ra/sequences.yaml b/mods/ra/sequences.yaml index 352f239f79..cb039c2b92 100644 --- a/mods/ra/sequences.yaml +++ b/mods/ra/sequences.yaml @@ -2267,4 +2267,9 @@ e8: Length: 18 die6: electro Start: 0 - Length: * \ No newline at end of file + Length: * + +dtrk: + idle: + Start: 0 + Facings: 32 \ No newline at end of file