Add InvalidBounceTerrain parameter to Projectile.

This commit is contained in:
abc013
2020-10-28 19:42:55 +01:00
committed by Matthias Mailänder
parent 6b6b1e56e6
commit f2797c711c

View File

@@ -93,6 +93,9 @@ namespace OpenRA.Mods.Common.Projectiles
[Desc("Sound to play when the projectile hits the ground, but not the target.")] [Desc("Sound to play when the projectile hits the ground, but not the target.")]
public readonly string BounceSound = null; public readonly string BounceSound = null;
[Desc("Terrain where the projectile explodes instead of bouncing.")]
public readonly HashSet<string> InvalidBounceTerrain = new HashSet<string>();
[Desc("If projectile touches an actor with one of these stances during or after the first bounce, trigger explosion.")] [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; public readonly Stance ValidBounceBlockerStances = Stance.Enemy | Stance.Neutral;
@@ -227,11 +230,16 @@ namespace OpenRA.Mods.Common.Projectiles
if (flightLengthReached && shouldBounce) 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); shouldExplode |= AnyValidTargetsInRadius(world, pos, info.Width, args.SourceActor, true);
target += (pos - source) * info.BounceRangeModifier / 100; target += (pos - source) * info.BounceRangeModifier / 100;
var dat = world.Map.DistanceAboveTerrain(target); var dat = world.Map.DistanceAboveTerrain(target);
target += new WVec(0, 0, -dat.Length); target += new WVec(0, 0, -dat.Length);
length = Math.Max((target - pos).Length / speed.Length, 1); length = Math.Max((target - pos).Length / speed.Length, 1);
ticks = 0; ticks = 0;
source = pos; source = pos;
Game.Sound.Play(SoundType.World, info.BounceSound, source); Game.Sound.Play(SoundType.World, info.BounceSound, source);