sync bullets and missiles
to investigate desyncs StyleCop clean WeaponInfo and friends
This commit is contained in:
@@ -9,10 +9,10 @@
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Traits;
|
||||
using System.Linq;
|
||||
|
||||
namespace OpenRA.GameRules
|
||||
{
|
||||
@@ -20,7 +20,7 @@ namespace OpenRA.GameRules
|
||||
{
|
||||
[Desc("Distance (in pixels) from the explosion center at which damage is 1/2.")]
|
||||
public readonly int Spread = 1;
|
||||
[FieldLoader.LoadUsing( "LoadVersus" )]
|
||||
[FieldLoader.LoadUsing("LoadVersus")]
|
||||
[Desc("Damage vs each armortype. 0% = can't target.")]
|
||||
public readonly Dictionary<string, float> Versus;
|
||||
[Desc("Can this damage ore?")]
|
||||
@@ -62,17 +62,17 @@ namespace OpenRA.GameRules
|
||||
return Versus.TryGetValue(armor.Type, out versus) ? versus : 1;
|
||||
}
|
||||
|
||||
public WarheadInfo( MiniYaml yaml )
|
||||
public WarheadInfo(MiniYaml yaml)
|
||||
{
|
||||
FieldLoader.Load( this, yaml );
|
||||
FieldLoader.Load(this, yaml);
|
||||
}
|
||||
|
||||
static object LoadVersus( MiniYaml y )
|
||||
static object LoadVersus(MiniYaml y)
|
||||
{
|
||||
return y.NodesDict.ContainsKey( "Versus" )
|
||||
? y.NodesDict[ "Versus" ].NodesDict.ToDictionary(
|
||||
return y.NodesDict.ContainsKey("Versus")
|
||||
? y.NodesDict["Versus"].NodesDict.ToDictionary(
|
||||
a => a.Key,
|
||||
a => FieldLoader.GetValue<float>( "(value)", a.Value.Value ) )
|
||||
a => FieldLoader.GetValue<float>("(value)", a.Value.Value))
|
||||
: new Dictionary<string, float>();
|
||||
}
|
||||
}
|
||||
@@ -85,13 +85,13 @@ namespace OpenRA.GameRules
|
||||
|
||||
public class ProjectileArgs
|
||||
{
|
||||
public WeaponInfo weapon;
|
||||
public float firepowerModifier = 1.0f;
|
||||
public int facing;
|
||||
public WPos source;
|
||||
public Actor sourceActor;
|
||||
public WPos passiveTarget;
|
||||
public Target guidedTarget;
|
||||
public WeaponInfo Weapon;
|
||||
public float FirepowerModifier = 1.0f;
|
||||
public int Facing;
|
||||
public WPos Source;
|
||||
public Actor SourceActor;
|
||||
public WPos PassiveTarget;
|
||||
public Target GuidedTarget;
|
||||
}
|
||||
|
||||
public interface IProjectileInfo { IEffect Create(ProjectileArgs args); }
|
||||
@@ -109,30 +109,30 @@ namespace OpenRA.GameRules
|
||||
public readonly int BurstDelay = 5;
|
||||
public readonly float MinRange = 0;
|
||||
|
||||
[FieldLoader.LoadUsing( "LoadProjectile" )] public IProjectileInfo Projectile;
|
||||
[FieldLoader.LoadUsing( "LoadWarheads" )] public List<WarheadInfo> Warheads;
|
||||
[FieldLoader.LoadUsing("LoadProjectile")] public IProjectileInfo Projectile;
|
||||
[FieldLoader.LoadUsing("LoadWarheads")] public List<WarheadInfo> Warheads;
|
||||
|
||||
public WeaponInfo(string name, MiniYaml content)
|
||||
{
|
||||
FieldLoader.Load( this, content );
|
||||
FieldLoader.Load(this, content);
|
||||
}
|
||||
|
||||
static object LoadProjectile( MiniYaml yaml )
|
||||
static object LoadProjectile(MiniYaml yaml)
|
||||
{
|
||||
MiniYaml proj;
|
||||
if( !yaml.NodesDict.TryGetValue( "Projectile", out proj ) )
|
||||
if (!yaml.NodesDict.TryGetValue("Projectile", out proj))
|
||||
return null;
|
||||
var ret = Game.CreateObject<IProjectileInfo>( proj.Value + "Info" );
|
||||
FieldLoader.Load( ret, proj );
|
||||
var ret = Game.CreateObject<IProjectileInfo>(proj.Value + "Info");
|
||||
FieldLoader.Load(ret, proj);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static object LoadWarheads( MiniYaml yaml )
|
||||
static object LoadWarheads(MiniYaml yaml)
|
||||
{
|
||||
var ret = new List<WarheadInfo>();
|
||||
foreach( var w in yaml.Nodes )
|
||||
if( w.Key.Split( '@' )[ 0 ] == "Warhead" )
|
||||
ret.Add( new WarheadInfo( w.Value ) );
|
||||
foreach (var w in yaml.Nodes)
|
||||
if (w.Key.Split('@')[0] == "Warhead")
|
||||
ret.Add(new WarheadInfo(w.Value));
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -161,7 +161,6 @@ namespace OpenRA.GameRules
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public bool IsValidAgainst(Target target, World world)
|
||||
{
|
||||
if (target.Type == TargetType.Actor)
|
||||
|
||||
22
OpenRA.Mods.RA/Armament.cs
Executable file → Normal file
22
OpenRA.Mods.RA/Armament.cs
Executable file → Normal file
@@ -125,28 +125,28 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
var args = new ProjectileArgs
|
||||
{
|
||||
weapon = Weapon,
|
||||
facing = legacyFacing,
|
||||
firepowerModifier = self.TraitsImplementing<IFirepowerModifier>()
|
||||
Weapon = Weapon,
|
||||
Facing = legacyFacing,
|
||||
FirepowerModifier = self.TraitsImplementing<IFirepowerModifier>()
|
||||
.Select(a => a.GetFirepowerModifier())
|
||||
.Product(),
|
||||
|
||||
source = muzzlePosition,
|
||||
sourceActor = self,
|
||||
passiveTarget = target.CenterPosition,
|
||||
guidedTarget = target
|
||||
Source = muzzlePosition,
|
||||
SourceActor = self,
|
||||
PassiveTarget = target.CenterPosition,
|
||||
GuidedTarget = target
|
||||
};
|
||||
|
||||
attack.ScheduleDelayedAction(Info.FireDelay, () =>
|
||||
{
|
||||
if (args.weapon.Projectile != null)
|
||||
if (args.Weapon.Projectile != null)
|
||||
{
|
||||
var projectile = args.weapon.Projectile.Create(args);
|
||||
var projectile = args.Weapon.Projectile.Create(args);
|
||||
if (projectile != null)
|
||||
self.World.Add(projectile);
|
||||
|
||||
if (args.weapon.Report != null && args.weapon.Report.Any())
|
||||
Sound.Play(args.weapon.Report.Random(self.World.SharedRandom), self.CenterPosition);
|
||||
if (args.Weapon.Report != null && args.Weapon.Report.Any())
|
||||
Sound.Play(args.Weapon.Report.Random(self.World.SharedRandom), self.CenterPosition);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -59,18 +59,18 @@ namespace OpenRA.Mods.RA
|
||||
var pos = self.CenterPosition;
|
||||
var args = new ProjectileArgs
|
||||
{
|
||||
weapon = weapon,
|
||||
facing = self.Trait<IFacing>().Facing,
|
||||
Weapon = weapon,
|
||||
Facing = self.Trait<IFacing>().Facing,
|
||||
|
||||
source = pos,
|
||||
sourceActor = self,
|
||||
passiveTarget = pos - new WVec(0, 0, pos.Z)
|
||||
Source = pos,
|
||||
SourceActor = self,
|
||||
PassiveTarget = pos - new WVec(0, 0, pos.Z)
|
||||
};
|
||||
|
||||
self.World.Add(args.weapon.Projectile.Create(args));
|
||||
self.World.Add(args.Weapon.Projectile.Create(args));
|
||||
|
||||
if (args.weapon.Report != null && args.weapon.Report.Any())
|
||||
Sound.Play(args.weapon.Report.Random(self.World.SharedRandom), self.CenterPosition);
|
||||
if (args.Weapon.Report != null && args.Weapon.Report.Any())
|
||||
Sound.Play(args.Weapon.Report.Random(self.World.SharedRandom), self.CenterPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,41 +41,44 @@ namespace OpenRA.Mods.RA.Effects
|
||||
public IEffect Create(ProjectileArgs args) { return new Bullet(this, args); }
|
||||
}
|
||||
|
||||
public class Bullet : IEffect
|
||||
public class Bullet : IEffect, ISync
|
||||
{
|
||||
readonly BulletInfo info;
|
||||
readonly ProjectileArgs args;
|
||||
|
||||
ContrailRenderable trail;
|
||||
Animation anim;
|
||||
WAngle angle;
|
||||
WPos pos, target;
|
||||
int length;
|
||||
int facing;
|
||||
int ticks, smokeTicks;
|
||||
|
||||
[Sync] WAngle angle;
|
||||
[Sync] WPos pos, target;
|
||||
[Sync] int length;
|
||||
[Sync] int facing;
|
||||
[Sync] int ticks, smokeTicks;
|
||||
|
||||
[Sync] public Actor SourceActor { get { return args.SourceActor; } }
|
||||
|
||||
public Bullet(BulletInfo info, ProjectileArgs args)
|
||||
{
|
||||
this.info = info;
|
||||
this.args = args;
|
||||
this.pos = args.source;
|
||||
this.pos = args.Source;
|
||||
|
||||
// Convert ProjectileArg definitions to world coordinates
|
||||
// TODO: Change the yaml definitions so we don't need this
|
||||
var range = new WRange((int)(1024 * args.weapon.Range)); // Range in world units
|
||||
var range = new WRange((int)(1024 * args.Weapon.Range)); // Range in world units
|
||||
var inaccuracy = new WRange((int)(info.Inaccuracy * 1024 / Game.CellSize)); // Offset in world units at max range
|
||||
var speed = (int)(info.Speed * 4 * 1024 / (10 * Game.CellSize)); // Speed in world units per tick
|
||||
angle = WAngle.ArcTan((int)(info.Angle * 4 * 1024), 1024); // Angle in world angle
|
||||
|
||||
target = args.passiveTarget;
|
||||
target = args.PassiveTarget;
|
||||
if (info.Inaccuracy > 0)
|
||||
{
|
||||
var maxOffset = inaccuracy.Range * (target - args.source).Length / range.Range;
|
||||
target += WVec.FromPDF(args.sourceActor.World.SharedRandom, 2) * maxOffset / 1024;
|
||||
var maxOffset = inaccuracy.Range * (target - pos).Length / range.Range;
|
||||
target += WVec.FromPDF(args.SourceActor.World.SharedRandom, 2) * maxOffset / 1024;
|
||||
}
|
||||
|
||||
facing = Traits.Util.GetFacing(target - args.source, 0);
|
||||
length = Math.Max((target - args.source).Length / speed, 1);
|
||||
facing = Traits.Util.GetFacing(target - pos, 0);
|
||||
length = Math.Max((target - pos).Length / speed, 1);
|
||||
|
||||
if (info.Image != null)
|
||||
{
|
||||
@@ -85,8 +88,8 @@ namespace OpenRA.Mods.RA.Effects
|
||||
|
||||
if (info.ContrailLength > 0)
|
||||
{
|
||||
var color = info.ContrailUsePlayerColor ? ContrailRenderable.ChooseColor(args.sourceActor) : info.ContrailColor;
|
||||
trail = new ContrailRenderable(args.sourceActor.World, color, info.ContrailLength, info.ContrailDelay, 0);
|
||||
var color = info.ContrailUsePlayerColor ? ContrailRenderable.ChooseColor(args.SourceActor) : info.ContrailColor;
|
||||
trail = new ContrailRenderable(args.SourceActor.World, color, info.ContrailLength, info.ContrailDelay, 0);
|
||||
}
|
||||
|
||||
smokeTicks = info.TrailDelay;
|
||||
@@ -117,11 +120,11 @@ namespace OpenRA.Mods.RA.Effects
|
||||
if (anim != null)
|
||||
anim.Tick();
|
||||
|
||||
pos = WPos.LerpQuadratic(args.source, target, angle, ticks, length);
|
||||
pos = WPos.LerpQuadratic(args.Source, target, angle, ticks, length);
|
||||
|
||||
if (info.Trail != null && --smokeTicks < 0)
|
||||
{
|
||||
var delayedPos = WPos.LerpQuadratic(args.source, target, angle, ticks - info.TrailDelay, length);
|
||||
var delayedPos = WPos.LerpQuadratic(args.Source, target, angle, ticks - info.TrailDelay, length);
|
||||
world.AddFrameEndTask(w => w.Add(new Smoke(w, delayedPos, info.Trail)));
|
||||
smokeTicks = info.TrailInterval;
|
||||
}
|
||||
@@ -130,7 +133,7 @@ namespace OpenRA.Mods.RA.Effects
|
||||
trail.Update(pos);
|
||||
|
||||
if (ticks++ >= length || (!info.High && world.ActorMap
|
||||
.GetUnitsAt(pos.ToCPos()).Any(a => a.HasTrait<IBlocksBullets>())))
|
||||
.GetUnitsAt(pos.ToCPos()).Any(a => a.HasTrait<IBlocksBullets>())))
|
||||
{
|
||||
Explode(world);
|
||||
}
|
||||
@@ -145,7 +148,7 @@ namespace OpenRA.Mods.RA.Effects
|
||||
yield break;
|
||||
|
||||
var cell = pos.ToCPos();
|
||||
if (!args.sourceActor.World.FogObscures(cell))
|
||||
if (!args.SourceActor.World.FogObscures(cell))
|
||||
{
|
||||
if (info.Shadow)
|
||||
{
|
||||
@@ -154,7 +157,7 @@ namespace OpenRA.Mods.RA.Effects
|
||||
yield return r;
|
||||
}
|
||||
|
||||
var palette = wr.Palette(args.weapon.Underwater ? "shadow" : "effect");
|
||||
var palette = wr.Palette(args.Weapon.Underwater ? "shadow" : "effect");
|
||||
foreach (var r in anim.Render(pos, palette))
|
||||
yield return r;
|
||||
}
|
||||
@@ -167,7 +170,7 @@ namespace OpenRA.Mods.RA.Effects
|
||||
else
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
|
||||
Combat.DoImpacts(target, args.sourceActor, args.weapon, args.firepowerModifier);
|
||||
Combat.DoImpacts(target, args.SourceActor, args.Weapon, args.FirepowerModifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
6
OpenRA.Mods.RA/Effects/GravityBomb.cs
Executable file → Normal file
6
OpenRA.Mods.RA/Effects/GravityBomb.cs
Executable file → Normal file
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
this.info = info;
|
||||
this.args = args;
|
||||
pos = args.source;
|
||||
pos = args.Source;
|
||||
velocity = new WVec(WRange.Zero, WRange.Zero, -info.Velocity);
|
||||
|
||||
anim = new Animation(info.Image);
|
||||
@@ -52,10 +52,10 @@ namespace OpenRA.Mods.RA.Effects
|
||||
velocity -= new WVec(WRange.Zero, WRange.Zero, info.Acceleration);
|
||||
pos += velocity;
|
||||
|
||||
if (pos.Z <= args.passiveTarget.Z)
|
||||
if (pos.Z <= args.PassiveTarget.Z)
|
||||
{
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
Combat.DoImpacts(args.passiveTarget, args.sourceActor, args.weapon, args.firepowerModifier);
|
||||
Combat.DoImpacts(args.PassiveTarget, args.SourceActor, args.Weapon, args.FirepowerModifier);
|
||||
}
|
||||
|
||||
anim.Tick();
|
||||
|
||||
12
OpenRA.Mods.RA/Effects/LaserZap.cs
Executable file → Normal file
12
OpenRA.Mods.RA/Effects/LaserZap.cs
Executable file → Normal file
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA.Effects
|
||||
|
||||
public IEffect Create(ProjectileArgs args)
|
||||
{
|
||||
var c = UsePlayerColor ? args.sourceActor.Owner.Color.RGB : Color;
|
||||
var c = UsePlayerColor ? args.SourceActor.Owner.Color.RGB : Color;
|
||||
return new LaserZap(args, this, c);
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ namespace OpenRA.Mods.RA.Effects
|
||||
this.args = args;
|
||||
this.info = info;
|
||||
this.color = color;
|
||||
this.target = args.passiveTarget;
|
||||
this.target = args.PassiveTarget;
|
||||
|
||||
if (info.HitAnim != null)
|
||||
this.hitanim = new Animation(info.HitAnim);
|
||||
@@ -59,15 +59,15 @@ namespace OpenRA.Mods.RA.Effects
|
||||
public void Tick(World world)
|
||||
{
|
||||
// Beam tracks target
|
||||
if (args.guidedTarget.IsValidFor(args.sourceActor))
|
||||
target = args.guidedTarget.CenterPosition;
|
||||
if (args.GuidedTarget.IsValidFor(args.SourceActor))
|
||||
target = args.GuidedTarget.CenterPosition;
|
||||
|
||||
if (!doneDamage)
|
||||
{
|
||||
if (hitanim != null)
|
||||
hitanim.PlayThen("idle", () => animationComplete = true);
|
||||
|
||||
Combat.DoImpacts(target, args.sourceActor, args.weapon, args.firepowerModifier);
|
||||
Combat.DoImpacts(target, args.SourceActor, args.Weapon, args.FirepowerModifier);
|
||||
doneDamage = true;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace OpenRA.Mods.RA.Effects
|
||||
if (ticks < info.BeamDuration)
|
||||
{
|
||||
var rc = Color.FromArgb((info.BeamDuration - ticks) * 255 / info.BeamDuration, color);
|
||||
yield return new BeamRenderable(args.source, 0, target - args.source, info.BeamWidth, rc);
|
||||
yield return new BeamRenderable(args.Source, 0, target - args.Source, info.BeamWidth, rc);
|
||||
}
|
||||
|
||||
if (hitanim != null)
|
||||
|
||||
@@ -45,32 +45,38 @@ namespace OpenRA.Mods.RA.Effects
|
||||
public IEffect Create(ProjectileArgs args) { return new Missile(this, args); }
|
||||
}
|
||||
|
||||
class Missile : IEffect
|
||||
class Missile : IEffect, ISync
|
||||
{
|
||||
static readonly WRange MissileCloseEnough = new WRange(7 * 1024 / Game.CellSize);
|
||||
|
||||
readonly MissileInfo info;
|
||||
readonly ProjectileArgs args;
|
||||
readonly Animation anim;
|
||||
|
||||
ContrailRenderable trail;
|
||||
WPos pos;
|
||||
int facing;
|
||||
|
||||
WPos target;
|
||||
WVec offset;
|
||||
int ticks;
|
||||
bool exploded;
|
||||
|
||||
readonly int speed;
|
||||
|
||||
int ticksToNextSmoke;
|
||||
ContrailRenderable trail;
|
||||
|
||||
[Sync] WPos pos;
|
||||
[Sync] int facing;
|
||||
|
||||
[Sync] WPos targetPosition;
|
||||
[Sync] WVec offset;
|
||||
[Sync] int ticks;
|
||||
[Sync] bool exploded;
|
||||
|
||||
[Sync] public Actor SourceActor { get { return args.SourceActor; } }
|
||||
[Sync] public Target GuidedTarget { get { return args.GuidedTarget; } }
|
||||
|
||||
public Missile(MissileInfo info, ProjectileArgs args)
|
||||
{
|
||||
this.info = info;
|
||||
this.args = args;
|
||||
|
||||
pos = args.source;
|
||||
facing = args.facing;
|
||||
pos = args.Source;
|
||||
facing = args.Facing;
|
||||
|
||||
target = args.passiveTarget;
|
||||
targetPosition = args.PassiveTarget;
|
||||
|
||||
// Convert ProjectileArg definitions to world coordinates
|
||||
// TODO: Change the yaml definitions so we don't need this
|
||||
@@ -78,7 +84,7 @@ namespace OpenRA.Mods.RA.Effects
|
||||
speed = info.Speed * 1024 / (5 * Game.CellSize);
|
||||
|
||||
if (info.Inaccuracy > 0)
|
||||
offset = WVec.FromPDF(args.sourceActor.World.SharedRandom, 2) * inaccuracy / 1024;
|
||||
offset = WVec.FromPDF(args.SourceActor.World.SharedRandom, 2) * inaccuracy / 1024;
|
||||
|
||||
if (info.Image != null)
|
||||
{
|
||||
@@ -88,20 +94,17 @@ namespace OpenRA.Mods.RA.Effects
|
||||
|
||||
if (info.ContrailLength > 0)
|
||||
{
|
||||
var color = info.ContrailUsePlayerColor ? ContrailRenderable.ChooseColor(args.sourceActor) : info.ContrailColor;
|
||||
trail = new ContrailRenderable(args.sourceActor.World, color, info.ContrailLength, info.ContrailDelay, 0);
|
||||
var color = info.ContrailUsePlayerColor ? ContrailRenderable.ChooseColor(args.SourceActor) : info.ContrailColor;
|
||||
trail = new ContrailRenderable(args.SourceActor.World, color, info.ContrailLength, info.ContrailDelay, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static readonly WRange MissileCloseEnough = new WRange(7 * 1024 / Game.CellSize);
|
||||
int ticksToNextSmoke;
|
||||
|
||||
bool JammedBy(TraitPair<JamsMissiles> tp)
|
||||
{
|
||||
if ((tp.Actor.CenterPosition - pos).HorizontalLengthSquared > tp.Trait.Range * tp.Trait.Range)
|
||||
return false;
|
||||
|
||||
if (tp.Actor.Owner.Stances[args.sourceActor.Owner] == Stance.Ally && !tp.Trait.AlliedMissiles)
|
||||
if (tp.Actor.Owner.Stances[args.SourceActor.Owner] == Stance.Ally && !tp.Trait.AlliedMissiles)
|
||||
return false;
|
||||
|
||||
return tp.Actor.World.SharedRandom.Next(100 / tp.Trait.Chance) == 0;
|
||||
@@ -120,12 +123,12 @@ namespace OpenRA.Mods.RA.Effects
|
||||
anim.Tick();
|
||||
|
||||
// Missile tracks target
|
||||
if (args.guidedTarget.IsValidFor(args.sourceActor))
|
||||
target = args.guidedTarget.CenterPosition;
|
||||
if (args.GuidedTarget.IsValidFor(args.SourceActor))
|
||||
targetPosition = args.GuidedTarget.CenterPosition;
|
||||
|
||||
var dist = target + offset - pos;
|
||||
var dist = targetPosition + offset - pos;
|
||||
var desiredFacing = Traits.Util.GetFacing(dist, facing);
|
||||
var desiredAltitude = target.Z;
|
||||
var desiredAltitude = targetPosition.Z;
|
||||
var jammed = info.Jammable && world.ActorsWithTrait<JamsMissiles>().Any(j => JammedBy(j));
|
||||
|
||||
if (jammed)
|
||||
@@ -133,18 +136,18 @@ namespace OpenRA.Mods.RA.Effects
|
||||
desiredFacing = facing + world.SharedRandom.Next(-20, 21);
|
||||
desiredAltitude = world.SharedRandom.Next(-43, 86);
|
||||
}
|
||||
else if (!args.guidedTarget.IsValidFor(args.sourceActor))
|
||||
else if (!args.GuidedTarget.IsValidFor(args.SourceActor))
|
||||
desiredFacing = facing;
|
||||
|
||||
facing = Traits.Util.TickFacing(facing, desiredFacing, info.ROT);
|
||||
var move = new WVec(0, -1024, 0).Rotate(WRot.FromFacing(facing)) * speed / 1024;
|
||||
if (target.Z > 0 && info.TurboBoost)
|
||||
if (targetPosition.Z > 0 && info.TurboBoost)
|
||||
move = (move * 3) / 2;
|
||||
|
||||
if (pos.Z != desiredAltitude)
|
||||
{
|
||||
var delta = move.HorizontalLength * info.MaximumPitch.Tan() / 1024;
|
||||
var dz = (target.Z - pos.Z).Clamp(-delta, delta);
|
||||
var dz = (targetPosition.Z - pos.Z).Clamp(-delta, delta);
|
||||
move += new WVec(0, 0, dz);
|
||||
}
|
||||
|
||||
@@ -159,9 +162,9 @@ namespace OpenRA.Mods.RA.Effects
|
||||
if (info.ContrailLength > 0)
|
||||
trail.Update(pos);
|
||||
|
||||
var shouldExplode = pos.Z < 0 // Hit the ground
|
||||
|| dist.LengthSquared < MissileCloseEnough.Range * MissileCloseEnough.Range // Within range
|
||||
|| info.RangeLimit != 0 && ticks > info.RangeLimit // Ran out of fuel
|
||||
var shouldExplode = (pos.Z < 0) // Hit the ground
|
||||
|| (dist.LengthSquared < MissileCloseEnough.Range * MissileCloseEnough.Range) // Within range
|
||||
|| (info.RangeLimit != 0 && ticks > info.RangeLimit) // Ran out of fuel
|
||||
|| (!info.High && world.ActorMap.GetUnitsAt(pos.ToCPos())
|
||||
.Any(a => a.HasTrait<IBlocksBullets>())); // Hit a wall
|
||||
|
||||
@@ -182,7 +185,7 @@ namespace OpenRA.Mods.RA.Effects
|
||||
if (ticks <= info.Arm)
|
||||
return;
|
||||
|
||||
Combat.DoImpacts(pos, args.sourceActor, args.weapon, args.firepowerModifier);
|
||||
Combat.DoImpacts(pos, args.SourceActor, args.Weapon, args.FirepowerModifier);
|
||||
}
|
||||
|
||||
public IEnumerable<IRenderable> Render(WorldRenderer wr)
|
||||
@@ -190,9 +193,9 @@ namespace OpenRA.Mods.RA.Effects
|
||||
if (info.ContrailLength > 0)
|
||||
yield return trail;
|
||||
|
||||
if (!args.sourceActor.World.FogObscures(pos.ToCPos()))
|
||||
if (!args.SourceActor.World.FogObscures(pos.ToCPos()))
|
||||
{
|
||||
var palette = wr.Palette(args.weapon.Underwater ? "shadow" : "effect");
|
||||
var palette = wr.Palette(args.Weapon.Underwater ? "shadow" : "effect");
|
||||
foreach (var r in anim.Render(pos, palette))
|
||||
yield return r;
|
||||
}
|
||||
|
||||
8
OpenRA.Mods.RA/Effects/TeslaZap.cs
Executable file → Normal file
8
OpenRA.Mods.RA/Effects/TeslaZap.cs
Executable file → Normal file
@@ -48,8 +48,8 @@ namespace OpenRA.Mods.RA.Effects
|
||||
|
||||
if (!doneDamage)
|
||||
{
|
||||
var pos = Args.guidedTarget.IsValidFor(Args.sourceActor) ? Args.guidedTarget.CenterPosition : Args.passiveTarget;
|
||||
Combat.DoImpacts(pos, Args.sourceActor, Args.weapon, Args.firepowerModifier);
|
||||
var pos = Args.GuidedTarget.IsValidFor(Args.SourceActor) ? Args.GuidedTarget.CenterPosition : Args.PassiveTarget;
|
||||
Combat.DoImpacts(pos, Args.SourceActor, Args.Weapon, Args.FirepowerModifier);
|
||||
doneDamage = true;
|
||||
}
|
||||
}
|
||||
@@ -58,8 +58,8 @@ namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
if (!initialized)
|
||||
{
|
||||
var pos = Args.guidedTarget.IsValidFor(Args.sourceActor) ? Args.guidedTarget.CenterPosition : Args.passiveTarget;
|
||||
zap = new TeslaZapRenderable(Args.source, 0, pos - Args.source, Info.Image, Info.BrightZaps, Info.DimZaps);
|
||||
var pos = Args.GuidedTarget.IsValidFor(Args.SourceActor) ? Args.GuidedTarget.CenterPosition : Args.PassiveTarget;
|
||||
zap = new TeslaZapRenderable(Args.Source, 0, pos - Args.Source, Info.Image, Info.BrightZaps, Info.DimZaps);
|
||||
}
|
||||
yield return zap;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user