From 804a21443d09b23799619e2b487e39d55265bfe5 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 28 Dec 2009 19:33:10 +1300 Subject: [PATCH] crude approximation, but it works. --- OpenRa.Game/Effects/Demolition.cs | 34 +++++++++++++++++++++++ OpenRa.Game/OpenRa.Game.csproj | 1 + OpenRa.Game/Traits/Activities/Demolish.cs | 8 ++---- OpenRa.Game/Traits/C4Demolition.cs | 2 ++ units.ini | 6 ++++ 5 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 OpenRa.Game/Effects/Demolition.cs diff --git a/OpenRa.Game/Effects/Demolition.cs b/OpenRa.Game/Effects/Demolition.cs new file mode 100644 index 0000000000..aca6472949 --- /dev/null +++ b/OpenRa.Game/Effects/Demolition.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using OpenRa.Game.Traits; + +namespace OpenRa.Game.Effects +{ + class Demolition : IEffect + { + Actor attacker; + Actor target; + int delay; + + public Demolition(Actor attacker, Actor target, int delay) + { + this.attacker = attacker; + this.target = target; + this.delay = delay; + } + + public void Tick() + { + if (--delay <= 0) + Game.world.AddFrameEndTask(w => + { + w.Remove(this); + target.InflictDamage(attacker, target.Health, Rules.WarheadInfo["DemolishWarhead"]); + }); + } + + public IEnumerable Render() { yield break; } + } +} diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj index 04bd69d3ed..fcd353137c 100644 --- a/OpenRa.Game/OpenRa.Game.csproj +++ b/OpenRa.Game/OpenRa.Game.csproj @@ -81,6 +81,7 @@ + diff --git a/OpenRa.Game/Traits/Activities/Demolish.cs b/OpenRa.Game/Traits/Activities/Demolish.cs index ef6cdedeb8..6f8bb76be6 100644 --- a/OpenRa.Game/Traits/Activities/Demolish.cs +++ b/OpenRa.Game/Traits/Activities/Demolish.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using OpenRa.Game.Effects; namespace OpenRa.Game.Traits.Activities { @@ -18,11 +19,8 @@ namespace OpenRa.Game.Traits.Activities public IActivity Tick(Actor self) { if (target == null || target.IsDead) return NextActivity; - - // 1. run to adj tile - // 2. spawn timed demolition (for +3/4s) - // 3. run away --- where? - return this; + Game.world.AddFrameEndTask(w => w.Add(new Demolition(self, target, 25 * 2))); + return NextActivity; } public void Cancel(Actor self) { target = null; NextActivity = null; } diff --git a/OpenRa.Game/Traits/C4Demolition.cs b/OpenRa.Game/Traits/C4Demolition.cs index 23c469f6f1..552d57cdbe 100644 --- a/OpenRa.Game/Traits/C4Demolition.cs +++ b/OpenRa.Game/Traits/C4Demolition.cs @@ -24,7 +24,9 @@ namespace OpenRa.Game.Traits if (order.OrderString == "C4") { self.CancelActivity(); + self.QueueActivity(new Move(order.TargetActor, 2)); self.QueueActivity(new Demolish(order.TargetActor)); + self.QueueActivity(new Move(self.Location, 0)); } } } diff --git a/units.ini b/units.ini index 222b0667ea..156c0f25da 100755 --- a/units.ini +++ b/units.ini @@ -678,6 +678,7 @@ UnitExplodeWarhead Crush APMine ATMine +DemolishWarhead [HE] ImpactSound=kaboom25 @@ -703,6 +704,11 @@ Verses=100%,0%,0%,0%,0% ImpactSound=mine1 InfDeath=2 +[DemolishWarhead] +Verses=100%,100%,100%,100%,100% +ImpactSound=kaboom25 +Explosion=7 + [General] OreChance=.02 LowPowerSlowdown=3