From a9da6bb2d8f4c67373ed4978f6ab37f0c9ebe168 Mon Sep 17 00:00:00 2001 From: Gustas <37534529+PunkPun@users.noreply.github.com> Date: Wed, 31 Aug 2022 17:45:10 +0300 Subject: [PATCH] Introduce MinDistance to AreaBeam projectile --- OpenRA.Mods.Common/Projectiles/AreaBeam.cs | 17 ++++++++++++++++- mods/d2k/weapons/other.yaml | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Projectiles/AreaBeam.cs b/OpenRA.Mods.Common/Projectiles/AreaBeam.cs index 159277685c..c094ec40c9 100644 --- a/OpenRA.Mods.Common/Projectiles/AreaBeam.cs +++ b/OpenRA.Mods.Common/Projectiles/AreaBeam.cs @@ -42,6 +42,9 @@ namespace OpenRA.Mods.Common.Projectiles [Desc("How far beyond the target the projectile keeps on travelling.")] public readonly WDist BeyondTargetRange = new WDist(0); + [Desc("The minimum distance the beam travels.")] + public readonly WDist MinDistance = WDist.Zero; + [Desc("Damage modifier applied at each range step.")] public readonly int[] Falloff = { 100, 100 }; @@ -136,7 +139,19 @@ namespace OpenRA.Mods.Common.Projectiles // Update the target position with the range we shoot beyond the target by // I.e. we can deliberately overshoot, so aim for that position var dir = new WVec(0, -1024, 0).Rotate(WRot.FromYaw(towardsTargetFacing)); - target += dir * info.BeyondTargetRange.Length / 1024; + var dist = (args.SourceActor.CenterPosition - target).Length; + int extraDist; + if (info.MinDistance.Length > dist) + { + if (info.MinDistance.Length - dist < info.BeyondTargetRange.Length) + extraDist = info.BeyondTargetRange.Length; + else + extraDist = info.MinDistance.Length - dist; + } + else + extraDist = info.BeyondTargetRange.Length; + + target += dir * extraDist / 1024; length = Math.Max((target - headPos).Length / speed.Length, 1); weaponRange = new WDist(Util.ApplyPercentageModifiers(args.Weapon.Range.Length, args.RangeModifiers)); diff --git a/mods/d2k/weapons/other.yaml b/mods/d2k/weapons/other.yaml index f4d718bb6a..c7f5d8df43 100644 --- a/mods/d2k/weapons/other.yaml +++ b/mods/d2k/weapons/other.yaml @@ -13,6 +13,7 @@ Sound: Falloff: 0, 0, 100, 0 Range: 0, 0c450, 4c0, 8c0 BeyondTargetRange: 1c0 + MinDistance: 5c0 Color: 00FFFFC8 Warhead@1Dam: SpreadDamage Range: 0, 32