Add support for inaccuracy to LaserZap
This commit is contained in:
@@ -42,6 +42,9 @@ namespace OpenRA.Mods.Common.Projectiles
|
|||||||
[Desc("Beam follows the target.")]
|
[Desc("Beam follows the target.")]
|
||||||
public readonly bool TracksTarget = true;
|
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).")]
|
[Desc("Draw a second beam (for 'glow' effect).")]
|
||||||
public readonly bool SecondaryBeam = false;
|
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 ProjectileArgs args;
|
||||||
readonly LaserZapInfo info;
|
readonly LaserZapInfo info;
|
||||||
@@ -84,7 +87,8 @@ namespace OpenRA.Mods.Common.Projectiles
|
|||||||
int ticks = 0;
|
int ticks = 0;
|
||||||
bool doneDamage;
|
bool doneDamage;
|
||||||
bool animationComplete;
|
bool animationComplete;
|
||||||
WPos target;
|
[Sync] WPos target;
|
||||||
|
[Sync] WPos source;
|
||||||
|
|
||||||
public LaserZap(LaserZapInfo info, ProjectileArgs args, Color color)
|
public LaserZap(LaserZapInfo info, ProjectileArgs args, Color color)
|
||||||
{
|
{
|
||||||
@@ -93,6 +97,14 @@ namespace OpenRA.Mods.Common.Projectiles
|
|||||||
this.color = color;
|
this.color = color;
|
||||||
secondaryColor = info.SecondaryBeamUsePlayerColor ? args.SourceActor.Owner.Color.RGB : info.SecondaryBeamColor;
|
secondaryColor = info.SecondaryBeamUsePlayerColor ? args.SourceActor.Owner.Color.RGB : info.SecondaryBeamColor;
|
||||||
target = args.PassiveTarget;
|
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))
|
if (!string.IsNullOrEmpty(info.HitAnim))
|
||||||
hitanim = new Animation(args.SourceActor.World, info.HitAnim);
|
hitanim = new Animation(args.SourceActor.World, info.HitAnim);
|
||||||
|
|||||||
Reference in New Issue
Block a user