#68 Inaccurate weapons (2/2)

This commit is contained in:
Chris Forbes
2010-04-05 07:49:27 +12:00
parent 7dc765d120
commit 2f982c7eea
5 changed files with 38 additions and 23 deletions

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Effects
{
public readonly int Speed = 1;
public readonly string Trail = null;
public readonly bool Inaccurate = false;
public readonly float Inaccuracy = 0; // expressed as pixels/cell^2
public readonly string Image = null;
public readonly bool High = false;
public readonly bool Arcing = false;
@@ -57,7 +57,13 @@ namespace OpenRA.Effects
Info = info;
Args = args;
VisualDest = args.dest + (10 * args.firedBy.World.CosmeticRandom.Gauss2D(1)).ToInt2();
if (info.Inaccuracy > 0)
{
var factor = (Args.dest - Args.src).LengthSquared / (Game.CellSize * Game.CellSize);
Args.dest += (info.Inaccuracy * factor * args.firedBy.World.SharedRandom.Gauss2D(2)).ToInt2();
}
VisualDest = Args.dest + (10 * args.firedBy.World.CosmeticRandom.Gauss2D(1)).ToInt2();
if (Info.Image != null)
{