diff --git a/OpenRA.Game/Combat.cs b/OpenRA.Game/Combat.cs index 003a815161..3e0518e903 100644 --- a/OpenRA.Game/Combat.cs +++ b/OpenRA.Game/Combat.cs @@ -69,6 +69,19 @@ namespace OpenRA (int)GetDamageToInflict(victim, args, warhead, firepowerModifier), warhead); } + public static void DoImpacts(ProjectileArgs args, int2 visualLocation) + { + foreach (var warhead in args.weapon.Warheads) + { + Action a = () => DoImpact(warhead, args, visualLocation); + if (warhead.Delay > 0) + args.firedBy.World.AddFrameEndTask( + w => w.Add(new DelayedAction(warhead.Delay, a))); + else + a(); + } + } + static float GetMaximumSpread(WeaponInfo weapon, WarheadInfo warhead, float modifier) { return (int)(warhead.Spread * Math.Log(Math.Abs(weapon.Damage * modifier), 2)); diff --git a/OpenRA.Game/Effects/Bullet.cs b/OpenRA.Game/Effects/Bullet.cs index a88d7a87ef..a733162e35 100755 --- a/OpenRA.Game/Effects/Bullet.cs +++ b/OpenRA.Game/Effects/Bullet.cs @@ -78,11 +78,7 @@ namespace OpenRA.Effects { t += 40; - if (t > TotalTime()) /* remove finished bullets */ - { - world.AddFrameEndTask(w => w.Remove(this)); - Combat.DoImpact(Args.weapon.Warheads[0], Args, VisualDest - new int2(0, Args.destAltitude)); - } + if (t > TotalTime()) Explode( world ); if (Info.Trail != null) { @@ -126,5 +122,11 @@ namespace OpenRA.Effects Info.UnderWater ? "shadow" : Args.firedBy.Owner.Palette); } } + + void Explode( World world ) + { + world.AddFrameEndTask(w => w.Remove(this)); + Combat.DoImpacts(Args, VisualDest - new int2(0, Args.destAltitude)); + } } } diff --git a/OpenRA.Game/GameRules/WarheadInfo.cs b/OpenRA.Game/GameRules/WarheadInfo.cs index 3a82865e83..603621c8c1 100644 --- a/OpenRA.Game/GameRules/WarheadInfo.cs +++ b/OpenRA.Game/GameRules/WarheadInfo.cs @@ -34,6 +34,7 @@ namespace OpenRA.GameRules public readonly string ImpactSound = null; public readonly string WaterImpactSound = null; public readonly int Damage = 0; // for new weapons infrastructure + public readonly int Delay = 0; // delay in ticks before dealing the damage. 0=instant public float EffectivenessAgainst(ArmorType at) { return Verses[ (int)at ]; } }