crude approximation, but it works.

This commit is contained in:
Chris Forbes
2009-12-28 19:33:10 +13:00
parent 436b261abf
commit 804a21443d
5 changed files with 46 additions and 5 deletions

View File

@@ -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<Renderable> Render() { yield break; }
}
}

View File

@@ -81,6 +81,7 @@
<Compile Include="Chrome.cs" />
<Compile Include="Combat.cs" />
<Compile Include="Effects\Corpse.cs" />
<Compile Include="Effects\Demolition.cs" />
<Compile Include="Effects\MoveFlash.cs" />
<Compile Include="Effects\Smoke.cs" />
<Compile Include="Effects\TeslaZap.cs" />

View File

@@ -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; }

View File

@@ -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));
}
}
}

View File

@@ -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