#68 Inaccurate weapons (2/2)
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace OpenRA.Effects
|
||||
public readonly bool Shadow = true;
|
||||
public readonly bool Proximity = false;
|
||||
public readonly string Trail = null;
|
||||
public readonly bool Inaccurate = false;
|
||||
public readonly float Inaccuracy = 0; // pixels/cell^2, not yet implemented for missiles
|
||||
public readonly string Image = null;
|
||||
public readonly int ROT = 5;
|
||||
public readonly int RangeLimit = 0;
|
||||
@@ -48,6 +48,7 @@ namespace OpenRA.Effects
|
||||
readonly MissileInfo Info;
|
||||
readonly ProjectileArgs Args;
|
||||
|
||||
int2 offset;
|
||||
float2 Pos;
|
||||
readonly Animation anim;
|
||||
int Facing;
|
||||
@@ -63,6 +64,12 @@ namespace OpenRA.Effects
|
||||
Altitude = Args.srcAltitude;
|
||||
Facing = Args.facing;
|
||||
|
||||
if (info.Inaccuracy > 0)
|
||||
{
|
||||
var factor = (Args.dest - Args.src).LengthSquared / (Game.CellSize * Game.CellSize);
|
||||
offset = (info.Inaccuracy * factor * args.firedBy.World.SharedRandom.Gauss2D(2)).ToInt2();
|
||||
}
|
||||
|
||||
if (Info.Image != null)
|
||||
{
|
||||
anim = new Animation(Info.Image, () => Facing);
|
||||
@@ -77,17 +84,19 @@ namespace OpenRA.Effects
|
||||
{
|
||||
t += 40;
|
||||
|
||||
var targetPosition = Args.target.CenterLocation + offset;
|
||||
|
||||
var targetUnit = Args.target.traits.GetOrDefault<Unit>();
|
||||
var targetAltitude = targetUnit != null ? targetUnit.Altitude : 0;
|
||||
Altitude += Math.Sign(targetAltitude - Altitude);
|
||||
|
||||
Traits.Util.TickFacing(ref Facing,
|
||||
Traits.Util.GetFacing(Args.target.CenterLocation - Pos, Facing),
|
||||
Traits.Util.GetFacing(targetPosition - Pos, Facing),
|
||||
Info.ROT);
|
||||
|
||||
anim.Tick();
|
||||
|
||||
var dist = Args.target.CenterLocation - Pos;
|
||||
var dist = targetPosition - Pos;
|
||||
if (dist.LengthSquared < MissileCloseEnough * MissileCloseEnough || Args.target.IsDead)
|
||||
Explode(world);
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ APTusk:
|
||||
Shadow: false
|
||||
Proximity: true
|
||||
Trail: smokey
|
||||
Inaccurate: true
|
||||
Inaccuracy: 3
|
||||
Image: DRAGON
|
||||
ROT: 5
|
||||
RangeLimit: 20
|
||||
|
||||
@@ -93,7 +93,7 @@ Rockets:
|
||||
High: yes
|
||||
Shadow: no
|
||||
Proximity: yes
|
||||
Inaccurate: yes
|
||||
Inaccuracy: 3
|
||||
Image: DRAGON
|
||||
ROT: 5
|
||||
Trail: smokey
|
||||
@@ -161,7 +161,7 @@ Grenade:
|
||||
Speed: 5
|
||||
High: yes
|
||||
Arcing: yes
|
||||
Inaccurate: yes
|
||||
Inaccuracy: 5
|
||||
Image: BOMB
|
||||
Warhead:
|
||||
Spread: 6
|
||||
@@ -251,7 +251,7 @@ MissilePack:
|
||||
High: yes
|
||||
Shadow: no
|
||||
Proximity: yes
|
||||
Inaccurate: yes
|
||||
Inaccuracy: 3
|
||||
Image: DRAGON
|
||||
ROT: 5
|
||||
Trail: smokey
|
||||
@@ -276,7 +276,7 @@ MissilePack:
|
||||
High: yes
|
||||
Shadow: no
|
||||
Proximity: yes
|
||||
Inaccurate: yes
|
||||
Inaccuracy: 5
|
||||
Image: DRAGON
|
||||
ROT: 5
|
||||
Trail: smokey
|
||||
@@ -299,7 +299,7 @@ Ballistic:
|
||||
Speed: 12
|
||||
High: yes
|
||||
Arcing: yes
|
||||
Inaccurate: yes
|
||||
Inaccuracy: 5
|
||||
Image: 120MM
|
||||
Warhead:
|
||||
Damage: 150
|
||||
@@ -333,7 +333,7 @@ BoatMissile:
|
||||
High: yes
|
||||
Shadow: no
|
||||
Proximity: yes
|
||||
Inaccurate: yes
|
||||
Inaccuracy: 5
|
||||
Image: DRAGON
|
||||
ROT: 5
|
||||
Trail: smokey
|
||||
@@ -357,7 +357,7 @@ Tomahawk:
|
||||
High: yes
|
||||
Shadow: no
|
||||
Proximity: yes
|
||||
Inaccurate: yes
|
||||
Inaccuracy: 3
|
||||
Image: DRAGON
|
||||
ROT: 5
|
||||
Trail: smokey
|
||||
@@ -436,7 +436,7 @@ HonestJohn:
|
||||
High: yes
|
||||
Shadow: no
|
||||
Proximity: yes
|
||||
Inaccurate: yes
|
||||
Inaccuracy: 3
|
||||
Image: MISSILE
|
||||
Speed: 15
|
||||
Warhead:
|
||||
|
||||
@@ -49,7 +49,7 @@ Maverick:
|
||||
Shadow: false
|
||||
Proximity: true
|
||||
Trail: smokey
|
||||
Inaccurate: true
|
||||
Inaccuracy: 3
|
||||
Image: DRAGON
|
||||
ROT: 5
|
||||
RangeLimit: 20
|
||||
@@ -148,7 +148,7 @@ Dragon:
|
||||
Shadow: false
|
||||
Proximity: true
|
||||
Trail: smokey
|
||||
Inaccurate: true
|
||||
Inaccuracy: 3
|
||||
Image: DRAGON
|
||||
ROT: 5
|
||||
RangeLimit: 20
|
||||
@@ -174,7 +174,7 @@ Hellfire:
|
||||
Shadow: false
|
||||
Proximity: true
|
||||
Trail: smokey
|
||||
Inaccurate: true
|
||||
Inaccuracy: 3
|
||||
Image: DRAGON
|
||||
ROT: 5
|
||||
RangeLimit: 20
|
||||
@@ -195,7 +195,7 @@ Grenade:
|
||||
Speed: 5
|
||||
High: true
|
||||
Arcing: true
|
||||
Inaccurate: true
|
||||
Inaccuracy: 3
|
||||
Image: BOMB
|
||||
Warhead:
|
||||
Spread: 6
|
||||
@@ -306,7 +306,7 @@ MammothTusk:
|
||||
Shadow: false
|
||||
Proximity: true
|
||||
Trail: smokey
|
||||
Inaccurate: true
|
||||
Inaccuracy: 3
|
||||
Image: DRAGON
|
||||
ROT: 5
|
||||
RangeLimit: 20
|
||||
@@ -328,7 +328,7 @@ MammothTusk:
|
||||
Speed: 12
|
||||
High: true
|
||||
Arcing: true
|
||||
Inaccurate:true
|
||||
Inaccuracy: 5
|
||||
Image: 120MM
|
||||
Warhead:
|
||||
Spread: 6
|
||||
@@ -461,7 +461,7 @@ RedEye:
|
||||
Speed: 12
|
||||
High: true
|
||||
Arcing: true
|
||||
Inaccurate:true
|
||||
Inaccuracy: 3
|
||||
Image: 120MM
|
||||
Warhead:
|
||||
Spread: 6
|
||||
@@ -544,7 +544,7 @@ DepthCharge:
|
||||
Image: BOMB
|
||||
Arcing: true
|
||||
High: true
|
||||
Inaccurate: true
|
||||
Inaccuracy: 3
|
||||
Warhead:
|
||||
Spread: 3
|
||||
Wall: true
|
||||
@@ -613,7 +613,7 @@ SCUD:
|
||||
Shadow: false
|
||||
Proximity: true
|
||||
Trail: smokey
|
||||
Inaccurate: true
|
||||
Inaccuracy: 5
|
||||
Image: V2
|
||||
Warhead:
|
||||
Spread: 6
|
||||
|
||||
Reference in New Issue
Block a user