From 5463176fa36b3144368bfcb18d9d892ce41e5374 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Fri, 9 Sep 2016 01:32:42 +0200 Subject: [PATCH 1/8] Adapt LaserZap Color description and Args structure To match AreaBeam. --- OpenRA.Mods.Common/Projectiles/AreaBeam.cs | 2 +- OpenRA.Mods.Common/Projectiles/LaserZap.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/OpenRA.Mods.Common/Projectiles/AreaBeam.cs b/OpenRA.Mods.Common/Projectiles/AreaBeam.cs index 1f72ab7c96..0151e7ffaf 100644 --- a/OpenRA.Mods.Common/Projectiles/AreaBeam.cs +++ b/OpenRA.Mods.Common/Projectiles/AreaBeam.cs @@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Projectiles [Desc("Extra search radius beyond beam width. Required to ensure affecting actors with large health radius.")] public readonly WDist TargetExtraSearchRadius = new WDist(1536); - [Desc("Should the beam be visuall rendered? False = Beam is invisible.")] + [Desc("Should the beam be visually rendered? False = Beam is invisible.")] public readonly bool RenderBeam = true; [Desc("Equivalent to sequence ZOffset. Controls Z sorting.")] diff --git a/OpenRA.Mods.Common/Projectiles/LaserZap.cs b/OpenRA.Mods.Common/Projectiles/LaserZap.cs index fbef53af42..64070d1f11 100644 --- a/OpenRA.Mods.Common/Projectiles/LaserZap.cs +++ b/OpenRA.Mods.Common/Projectiles/LaserZap.cs @@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Projectiles public readonly bool UsePlayerColor = false; - [Desc("Laser color.")] + [Desc("Color of the beam.")] public readonly Color Color = Color.Red; [Desc("Impact animation.")] @@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Projectiles public IProjectile Create(ProjectileArgs args) { var c = UsePlayerColor ? args.SourceActor.Owner.Color.RGB : Color; - return new LaserZap(args, this, c); + return new LaserZap(this, args, c); } } @@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.Projectiles bool animationComplete; WPos target; - public LaserZap(ProjectileArgs args, LaserZapInfo info, Color color) + public LaserZap(LaserZapInfo info, ProjectileArgs args, Color color) { this.args = args; this.info = info; From a98818ef47eb9285b6dd2b1abec404747839356b Mon Sep 17 00:00:00 2001 From: reaperrr Date: Fri, 9 Sep 2016 01:42:37 +0200 Subject: [PATCH 2/8] Rename LaserZap.BeamDuration to Duration --- OpenRA.Mods.Common/Projectiles/LaserZap.cs | 8 ++++---- OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs | 7 +++++++ mods/ts/weapons/energyweapons.yaml | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/OpenRA.Mods.Common/Projectiles/LaserZap.cs b/OpenRA.Mods.Common/Projectiles/LaserZap.cs index 64070d1f11..c4ec2473f4 100644 --- a/OpenRA.Mods.Common/Projectiles/LaserZap.cs +++ b/OpenRA.Mods.Common/Projectiles/LaserZap.cs @@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Projectiles [Desc("Equivalent to sequence ZOffset. Controls Z sorting.")] public readonly int ZOffset = 0; - public readonly int BeamDuration = 10; + public readonly int Duration = 10; public readonly bool UsePlayerColor = false; @@ -94,7 +94,7 @@ namespace OpenRA.Mods.Common.Projectiles if (hitanim != null) hitanim.Tick(); - if (++ticks >= info.BeamDuration && animationComplete) + if (++ticks >= info.Duration && animationComplete) world.AddFrameEndTask(w => w.Remove(this)); } @@ -104,9 +104,9 @@ namespace OpenRA.Mods.Common.Projectiles wr.World.FogObscures(args.Source)) yield break; - if (ticks < info.BeamDuration) + if (ticks < info.Duration) { - var rc = Color.FromArgb((info.BeamDuration - ticks) * color.A / info.BeamDuration, color); + var rc = Color.FromArgb((info.Duration - ticks) * color.A / info.Duration, color); yield return new BeamRenderable(args.Source, info.ZOffset, target - args.Source, info.Shape, info.Width, rc); } diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index 486228374a..49f7adf1b4 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -422,6 +422,13 @@ namespace OpenRA.Mods.Common.UtilityCommands node.Key = "Speed"; } + // Rename LaserZap BeamDuration to just Duration + if (engineVersion < 20161009) + { + if (node.Key == "BeamDuration") + node.Key = "Duration"; + } + UpgradeWeaponRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1); } } diff --git a/mods/ts/weapons/energyweapons.yaml b/mods/ts/weapons/energyweapons.yaml index 8f0b71be88..4be40a3673 100644 --- a/mods/ts/weapons/energyweapons.yaml +++ b/mods/ts/weapons/energyweapons.yaml @@ -193,7 +193,7 @@ TurretLaserFire: Report: lastur1.aud Projectile: LaserZap Width: 50 - BeamDuration: 5 + Duration: 5 ZOffset: 2047 Color: FF000045 Warhead@1Dam: SpreadDamage From 6b3c3cd12731ee3ea3393553718f3318631e90d2 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Tue, 20 Sep 2016 16:32:44 +0200 Subject: [PATCH 3/8] Add SecondaryBeam to LaserZap for TS-like laser glow effect --- OpenRA.Mods.Common/Projectiles/LaserZap.cs | 28 +++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Projectiles/LaserZap.cs b/OpenRA.Mods.Common/Projectiles/LaserZap.cs index c4ec2473f4..906b7da91b 100644 --- a/OpenRA.Mods.Common/Projectiles/LaserZap.cs +++ b/OpenRA.Mods.Common/Projectiles/LaserZap.cs @@ -39,6 +39,23 @@ namespace OpenRA.Mods.Common.Projectiles [Desc("Color of the beam.")] public readonly Color Color = Color.Red; + [Desc("Draw a second beam (for 'glow' effect).")] + public readonly bool SecondaryBeam = false; + + [Desc("The width of the zap.")] + public readonly WDist SecondaryBeamWidth = new WDist(86); + + [Desc("The shape of the beam. Accepts values Cylindrical or Flat.")] + public readonly BeamRenderableShape SecondaryBeamShape = BeamRenderableShape.Cylindrical; + + [Desc("Equivalent to sequence ZOffset. Controls Z sorting.")] + public readonly int SecondaryBeamZOffset = 0; + + public readonly bool SecondaryBeamUsePlayerColor = false; + + [Desc("Color of the secondary beam.")] + public readonly Color SecondaryBeamColor = Color.Red; + [Desc("Impact animation.")] public readonly string HitAnim = null; @@ -59,8 +76,9 @@ namespace OpenRA.Mods.Common.Projectiles readonly ProjectileArgs args; readonly LaserZapInfo info; readonly Animation hitanim; + readonly Color color; + readonly Color secondaryColor; int ticks = 0; - Color color; bool doneDamage; bool animationComplete; WPos target; @@ -70,6 +88,7 @@ namespace OpenRA.Mods.Common.Projectiles this.args = args; this.info = info; this.color = color; + secondaryColor = info.SecondaryBeamUsePlayerColor ? args.SourceActor.Owner.Color.RGB : info.SecondaryBeamColor; target = args.PassiveTarget; if (!string.IsNullOrEmpty(info.HitAnim)) @@ -108,6 +127,13 @@ namespace OpenRA.Mods.Common.Projectiles { var rc = Color.FromArgb((info.Duration - ticks) * color.A / info.Duration, color); yield return new BeamRenderable(args.Source, info.ZOffset, target - args.Source, info.Shape, info.Width, rc); + + if (info.SecondaryBeam) + { + var src = Color.FromArgb((info.Duration - ticks) * secondaryColor.A / info.Duration, secondaryColor); + yield return new BeamRenderable(args.Source, info.SecondaryBeamZOffset, target - args.Source, + info.SecondaryBeamShape, info.SecondaryBeamWidth, src); + } } if (hitanim != null) From 76dc4eafd154e8796bdeb2a9cb6f16be1a4eefd5 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Tue, 20 Sep 2016 16:33:14 +0200 Subject: [PATCH 4/8] Enable secondary laser beam glow for Obelisks and Laser Turrets in TS --- mods/ts/weapons/energyweapons.yaml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/mods/ts/weapons/energyweapons.yaml b/mods/ts/weapons/energyweapons.yaml index 4be40a3673..23571f4d30 100644 --- a/mods/ts/weapons/energyweapons.yaml +++ b/mods/ts/weapons/energyweapons.yaml @@ -180,8 +180,14 @@ ObeliskLaserFire: Range: 10c512 Report: obelray1.aud Projectile: LaserZap - Width: 85 + Width: 72 + Duration: 15 ZOffset: 2047 + Color: FF000080 + SecondaryBeam: true + SecondaryBeamWidth: 180 + SecondaryBeamZOffset: 2047 + SecondaryBeamColor: FF000040 Warhead@1Dam: SpreadDamage Spread: 42 Damage: 250 @@ -192,10 +198,14 @@ TurretLaserFire: Range: 5c512 Report: lastur1.aud Projectile: LaserZap - Width: 50 - Duration: 5 + Width: 36 + Duration: 8 ZOffset: 2047 - Color: FF000045 + Color: FF000080 + SecondaryBeam: true + SecondaryBeamWidth: 144 + SecondaryBeamZOffset: 2047 + SecondaryBeamColor: FF000030 Warhead@1Dam: SpreadDamage Spread: 42 Damage: 30 From 38b10511c36884dc43784075e5a81778f56a1b8f Mon Sep 17 00:00:00 2001 From: reaperrr Date: Tue, 20 Sep 2016 16:47:25 +0200 Subject: [PATCH 5/8] Allow disabling target-tracking of lasers This is necessary for features like inaccuracy. --- OpenRA.Mods.Common/Projectiles/LaserZap.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Projectiles/LaserZap.cs b/OpenRA.Mods.Common/Projectiles/LaserZap.cs index 906b7da91b..eb9a00f629 100644 --- a/OpenRA.Mods.Common/Projectiles/LaserZap.cs +++ b/OpenRA.Mods.Common/Projectiles/LaserZap.cs @@ -39,6 +39,9 @@ namespace OpenRA.Mods.Common.Projectiles [Desc("Color of the beam.")] public readonly Color Color = Color.Red; + [Desc("Beam follows the target.")] + public readonly bool TracksTarget = true; + [Desc("Draw a second beam (for 'glow' effect).")] public readonly bool SecondaryBeam = false; @@ -98,7 +101,7 @@ namespace OpenRA.Mods.Common.Projectiles public void Tick(World world) { // Beam tracks target - if (args.GuidedTarget.IsValidFor(args.SourceActor)) + if (info.TracksTarget && args.GuidedTarget.IsValidFor(args.SourceActor)) target = args.GuidedTarget.CenterPosition; if (!doneDamage) From 2a00a606d29678686cf1db30a8369566efd6c90f Mon Sep 17 00:00:00 2001 From: reaperrr Date: Tue, 20 Sep 2016 17:02:45 +0200 Subject: [PATCH 6/8] Add support for inaccuracy to LaserZap --- OpenRA.Mods.Common/Projectiles/LaserZap.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Projectiles/LaserZap.cs b/OpenRA.Mods.Common/Projectiles/LaserZap.cs index eb9a00f629..46e8c821fe 100644 --- a/OpenRA.Mods.Common/Projectiles/LaserZap.cs +++ b/OpenRA.Mods.Common/Projectiles/LaserZap.cs @@ -42,6 +42,9 @@ namespace OpenRA.Mods.Common.Projectiles [Desc("Beam follows the target.")] public readonly bool TracksTarget = true; + [Desc("Maximum offset at the maximum range.")] + public readonly WDist Inaccuracy = WDist.Zero; + [Desc("Draw a second beam (for 'glow' effect).")] public readonly bool SecondaryBeam = false; @@ -74,7 +77,7 @@ namespace OpenRA.Mods.Common.Projectiles } } - public class LaserZap : IProjectile + public class LaserZap : IProjectile, ISync { readonly ProjectileArgs args; readonly LaserZapInfo info; @@ -84,7 +87,8 @@ namespace OpenRA.Mods.Common.Projectiles int ticks = 0; bool doneDamage; bool animationComplete; - WPos target; + [Sync] WPos target; + [Sync] WPos source; public LaserZap(LaserZapInfo info, ProjectileArgs args, Color color) { @@ -93,6 +97,14 @@ namespace OpenRA.Mods.Common.Projectiles this.color = color; secondaryColor = info.SecondaryBeamUsePlayerColor ? args.SourceActor.Owner.Color.RGB : info.SecondaryBeamColor; target = args.PassiveTarget; + source = args.Source; + + if (info.Inaccuracy.Length > 0) + { + var inaccuracy = OpenRA.Mods.Common.Util.ApplyPercentageModifiers(info.Inaccuracy.Length, args.InaccuracyModifiers); + var maxOffset = inaccuracy * (target - source).Length / args.Weapon.Range.Length; + target += WVec.FromPDF(args.SourceActor.World.SharedRandom, 2) * maxOffset / 1024; + } if (!string.IsNullOrEmpty(info.HitAnim)) hitanim = new Animation(args.SourceActor.World, info.HitAnim); From e69ad1cb2de768e50d8cc77098b9c10b60300263 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Tue, 20 Sep 2016 17:03:12 +0200 Subject: [PATCH 7/8] Add support for being blockable to LaserZap --- OpenRA.Mods.Common/Projectiles/LaserZap.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/OpenRA.Mods.Common/Projectiles/LaserZap.cs b/OpenRA.Mods.Common/Projectiles/LaserZap.cs index 46e8c821fe..c29b85f0d6 100644 --- a/OpenRA.Mods.Common/Projectiles/LaserZap.cs +++ b/OpenRA.Mods.Common/Projectiles/LaserZap.cs @@ -16,6 +16,7 @@ using OpenRA.GameRules; using OpenRA.Graphics; using OpenRA.Mods.Common.Effects; using OpenRA.Mods.Common.Graphics; +using OpenRA.Mods.Common.Traits; using OpenRA.Traits; namespace OpenRA.Mods.Common.Projectiles @@ -45,6 +46,12 @@ namespace OpenRA.Mods.Common.Projectiles [Desc("Maximum offset at the maximum range.")] public readonly WDist Inaccuracy = WDist.Zero; + [Desc("Extra search radius beyond beam width. Required to ensure affecting actors with large health radius.")] + public readonly WDist TargetExtraSearchRadius = new WDist(1536); + + [Desc("Beam can be blocked.")] + public readonly bool Blockable = false; + [Desc("Draw a second beam (for 'glow' effect).")] public readonly bool SecondaryBeam = false; @@ -116,6 +123,14 @@ namespace OpenRA.Mods.Common.Projectiles if (info.TracksTarget && args.GuidedTarget.IsValidFor(args.SourceActor)) target = args.GuidedTarget.CenterPosition; + // Check for blocking actors + WPos blockedPos; + if (info.Blockable && BlocksProjectiles.AnyBlockingActorsBetween(world, source, target, + info.Width, info.TargetExtraSearchRadius, out blockedPos)) + { + target = blockedPos; + } + if (!doneDamage) { if (hitanim != null) From 64e1b1dbdb4b84f56d1b0daabf2a28111b9c9d44 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Tue, 20 Sep 2016 17:18:44 +0200 Subject: [PATCH 8/8] Sanitize TS Obelisk charge delay This makes the Obelisk fire right at the end of the charge animation and sound. --- mods/ts/rules/nod-support.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ts/rules/nod-support.yaml b/mods/ts/rules/nod-support.yaml index 8aa1bd9167..808875da52 100644 --- a/mods/ts/rules/nod-support.yaml +++ b/mods/ts/rules/nod-support.yaml @@ -110,7 +110,7 @@ NAOBEL: LocalOffset: 1400,210,800 AttackCharge: ChargeAudio: obelpowr.aud - InitialChargeDelay: 120 + InitialChargeDelay: 65 WithChargeOverlay: Sequence: active Palette: player