From f2797c711c230031020be37817cd09efed1cda92 Mon Sep 17 00:00:00 2001 From: abc013 Date: Wed, 28 Oct 2020 19:42:55 +0100 Subject: [PATCH] Add InvalidBounceTerrain parameter to Projectile. --- OpenRA.Mods.Common/Projectiles/Bullet.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/OpenRA.Mods.Common/Projectiles/Bullet.cs b/OpenRA.Mods.Common/Projectiles/Bullet.cs index 27f610b5d6..adf3d847e8 100644 --- a/OpenRA.Mods.Common/Projectiles/Bullet.cs +++ b/OpenRA.Mods.Common/Projectiles/Bullet.cs @@ -93,6 +93,9 @@ namespace OpenRA.Mods.Common.Projectiles [Desc("Sound to play when the projectile hits the ground, but not the target.")] public readonly string BounceSound = null; + [Desc("Terrain where the projectile explodes instead of bouncing.")] + public readonly HashSet InvalidBounceTerrain = new HashSet(); + [Desc("If projectile touches an actor with one of these stances during or after the first bounce, trigger explosion.")] public readonly Stance ValidBounceBlockerStances = Stance.Enemy | Stance.Neutral; @@ -227,11 +230,16 @@ namespace OpenRA.Mods.Common.Projectiles if (flightLengthReached && shouldBounce) { + var terrainPos = world.Map.CellContaining(pos); + shouldExplode |= info.InvalidBounceTerrain.Contains(world.Map.GetTerrainInfo(terrainPos).Type); + shouldExplode |= AnyValidTargetsInRadius(world, pos, info.Width, args.SourceActor, true); + target += (pos - source) * info.BounceRangeModifier / 100; var dat = world.Map.DistanceAboveTerrain(target); target += new WVec(0, 0, -dat.Length); length = Math.Max((target - pos).Length / speed.Length, 1); + ticks = 0; source = pos; Game.Sound.Play(SoundType.World, info.BounceSound, source);