Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce MinDistance to AreaBeam projectile #20244

Merged
merged 1 commit into from Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 16 additions & 1 deletion OpenRA.Mods.Common/Projectiles/AreaBeam.cs
Expand Up @@ -42,6 +42,9 @@ public class AreaBeamInfo : IProjectileInfo
[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 };

Expand Down Expand Up @@ -136,7 +139,19 @@ public AreaBeam(AreaBeamInfo info, ProjectileArgs args, Color color)
// 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));
Expand Down
1 change: 1 addition & 0 deletions mods/d2k/weapons/other.yaml
Expand Up @@ -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
Expand Down