From 027a281ae38c926688c43936fef3b18bd297da21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Thu, 2 Jan 2014 19:21:46 +0100 Subject: [PATCH] define torpedoes in a more generic way fixes #3252 and closes #2097 --- OpenRA.Game/GameRules/WeaponInfo.cs | 8 +------- OpenRA.Mods.RA/Effects/Missile.cs | 9 +++++++-- mods/ra/rules/defaults.yaml | 2 ++ mods/ra/weapons.yaml | 14 +++++++++----- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/OpenRA.Game/GameRules/WeaponInfo.cs b/OpenRA.Game/GameRules/WeaponInfo.cs index 2aa17decf3..b40405ceb2 100644 --- a/OpenRA.Game/GameRules/WeaponInfo.cs +++ b/OpenRA.Game/GameRules/WeaponInfo.cs @@ -179,13 +179,7 @@ namespace OpenRA.GameRules if (!world.Map.IsInMap(cell)) return false; - if (ValidTargets.Contains("Ground") && world.GetTerrainType(cell) != "Water") - return true; - - if (ValidTargets.Contains("Water") && world.GetTerrainType(cell) == "Water") - return true; - - return false; + return true; } return false; diff --git a/OpenRA.Mods.RA/Effects/Missile.cs b/OpenRA.Mods.RA/Effects/Missile.cs index 6525ea01d3..eac4983278 100755 --- a/OpenRA.Mods.RA/Effects/Missile.cs +++ b/OpenRA.Mods.RA/Effects/Missile.cs @@ -42,6 +42,8 @@ namespace OpenRA.Mods.RA.Effects public readonly bool ContrailUsePlayerColor = false; public readonly int ContrailDelay = 1; public readonly bool Jammable = true; + [Desc("Explodes when leaving the following terrain type, e.g., Water for torpedoes.")] + public readonly string BoundToTerrainType = ""; public IEffect Create(ProjectileArgs args) { return new Missile(this, args); } } @@ -153,11 +155,14 @@ namespace OpenRA.Mods.RA.Effects if (info.ContrailLength > 0) trail.Update(pos); + var cell = pos.ToCPos(); + var shouldExplode = (pos.Z < 0) // Hit the ground || (dist.LengthSquared < MissileCloseEnough.Range * MissileCloseEnough.Range) // Within range || (info.RangeLimit != 0 && ticks > info.RangeLimit) // Ran out of fuel - || (!info.High && world.ActorMap.GetUnitsAt(pos.ToCPos()) - .Any(a => a.HasTrait())); // Hit a wall + || (!info.High && world.ActorMap.GetUnitsAt(cell) + .Any(a => a.HasTrait())) // Hit a wall + || (!string.IsNullOrEmpty(info.BoundToTerrainType) && world.GetTerrainType(cell) != info.BoundToTerrainType); // Hit incompatible terrain if (shouldExplode) Explode(world); diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index 640dc9732c..7e7bf5e408 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -459,6 +459,8 @@ HP: 1000 ProximityCaptor: Types: Bridge + Armor: + Type: Concrete AutoTargetIgnore: BodyOrientation: LuaScriptEvents: diff --git a/mods/ra/weapons.yaml b/mods/ra/weapons.yaml index 390fa5ab9a..2a5c36c6a7 100644 --- a/mods/ra/weapons.yaml +++ b/mods/ra/weapons.yaml @@ -508,7 +508,7 @@ MammothTusk: Range: 8c0 Report: MISSILE6.AUD Burst: 2 - ValidTargets: Ground, Air + ValidTargets: Air, Ground, Water Projectile: Missile Speed: 341 Arm: 2 @@ -789,7 +789,7 @@ Stinger: Report: MISSILE6.AUD Burst: 2 BurstDelay: 0 - ValidTargets: Ground, Air + ValidTargets: Air, Ground, Water Projectile: Missile Arm: 3 High: true @@ -830,15 +830,18 @@ TorpTube: Trail: bubbles ROT: 1 RangeLimit: 160 + BoundToTerrainType: Water Warhead: - Spread: 128 + Spread: 426 Versus: None: 30% Wood: 75% Light: 75% - Concrete: 50% + Concrete: 500% WaterExplosion: large_splash WaterImpactSound: splash9.aud + Explosion: large_explosion + ImpactSound: kaboom12.aud InfDeath: 4 SmudgeType: Crater Damage: 180 @@ -1207,7 +1210,7 @@ FLAK-23: ROF: 10 Range: 8c0 Report: AACANON3.AUD - ValidTargets: Air,Ground + ValidTargets: Air, Ground, Water Projectile: Bullet Speed: 1c682 High: true @@ -1220,6 +1223,7 @@ FLAK-23: Heavy: 10% Concrete: 20% Explosion: small_explosion_air + WaterExplosion: small_splash Damage: 20 Sniper: