diff --git a/OpenRA.Mods.Common/Effects/Bullet.cs b/OpenRA.Mods.Common/Effects/Bullet.cs index ba4577266c..0b04322fa3 100644 --- a/OpenRA.Mods.Common/Effects/Bullet.cs +++ b/OpenRA.Mods.Common/Effects/Bullet.cs @@ -31,8 +31,8 @@ namespace OpenRA.Mods.Common.Effects [Desc("Image to display.")] public readonly string Image = null; - [Desc("Loop this sequence of Image while this projectile is moving.")] - [SequenceReference("Image")] public readonly string Sequence = "idle"; + [Desc("Loop these sequences of Image while this projectile is moving.")] + [SequenceReference("Image")] public readonly string[] Sequences = { "idle" }; [Desc("The palette used to draw this projectile.")] [PaletteReference] public readonly string Palette = "effect"; @@ -118,7 +118,7 @@ namespace OpenRA.Mods.Common.Effects if (!string.IsNullOrEmpty(info.Image)) { anim = new Animation(world, info.Image, GetEffectiveFacing); - anim.PlayRepeating(info.Sequence); + anim.PlayRepeating(info.Sequences.Random(world.SharedRandom)); } if (info.ContrailLength > 0) @@ -157,7 +157,7 @@ namespace OpenRA.Mods.Common.Effects if (!string.IsNullOrEmpty(info.Trail) && --smokeTicks < 0) { var delayedPos = WPos.LerpQuadratic(args.Source, target, angle, ticks - info.TrailDelay, length); - world.AddFrameEndTask(w => w.Add(new Smoke(w, delayedPos, info.Trail, trailPalette, info.Sequence))); + world.AddFrameEndTask(w => w.Add(new Smoke(w, delayedPos, info.Trail, trailPalette, info.Sequences.Random(world.SharedRandom)))); smokeTicks = info.TrailInterval; } diff --git a/OpenRA.Mods.Common/Effects/Shrapnel.cs b/OpenRA.Mods.Common/Effects/Shrapnel.cs deleted file mode 100644 index 10e0b2b1a4..0000000000 --- a/OpenRA.Mods.Common/Effects/Shrapnel.cs +++ /dev/null @@ -1,147 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2015 The OpenRA Developers (see AUTHORS) - * This file is part of OpenRA, which is free software. It is made - * available to you under the terms of the GNU General Public License - * as published by the Free Software Foundation. For more information, - * see COPYING. - */ -#endregion - -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using OpenRA.Effects; -using OpenRA.GameRules; -using OpenRA.Graphics; -using OpenRA.Mods.Common.Graphics; -using OpenRA.Traits; - -namespace OpenRA.Mods.Common.Effects -{ - public class ShrapnelInfo : IProjectileInfo - { - [Desc("Projectile speed in WDist / tick, two values indicate variable velocity.")] - public readonly WDist[] Speed = { new WDist(17) }; - - [Desc("Image to display.")] - public readonly string Image = null; - - [Desc("Loop these sequences of Image while this projectile is moving.")] - [SequenceReference("Image")] public readonly string[] Sequences = { "idle" }; - - [Desc("The palette used to draw this projectile.")] - public readonly string Palette = "effect"; - - [Desc("Does this projectile have a shadow?")] - public readonly bool Shadow = false; - - [Desc("Palette to use for this projectile's shadow if Shadow is true.")] - public readonly string ShadowPalette = "shadow"; - - [Desc("Arc in WAngles, two values indicate variable arc.")] - public readonly WAngle[] Angle = { WAngle.Zero }; - - public IEffect Create(ProjectileArgs args) { return new Shrapnel(this, args); } - } - - public class Shrapnel : IEffect, ISync - { - readonly ShrapnelInfo info; - readonly ProjectileArgs args; - readonly Animation anim; - [Sync] readonly WAngle angle; - [Sync] readonly WDist speed; - - [Sync] WPos pos, target; - [Sync] int length; - [Sync] int facing; - [Sync] int ticks; - - [Sync] public Actor SourceActor { get { return args.SourceActor; } } - - public Shrapnel(ShrapnelInfo info, ProjectileArgs args) - { - this.info = info; - this.args = args; - this.pos = args.Source; - - var world = args.SourceActor.World; - - if (info.Angle.Length > 1) - angle = new WAngle(world.SharedRandom.Next(info.Angle[0].Angle, info.Angle[1].Angle)); - else - angle = info.Angle[0]; - - if (info.Speed.Length > 1) - speed = new WDist(world.SharedRandom.Next(info.Speed[0].Length, info.Speed[1].Length)); - else - speed = info.Speed[0]; - - target = args.PassiveTarget; - - facing = OpenRA.Traits.Util.GetFacing(target - pos, 0); - length = Math.Max((target - pos).Length / speed.Length, 1); - - if (!string.IsNullOrEmpty(info.Image)) - { - anim = new Animation(world, info.Image, GetEffectiveFacing); - anim.PlayRepeating(info.Sequences.Random(world.SharedRandom)); - } - } - - int GetEffectiveFacing() - { - var at = (float)ticks / (length - 1); - var attitude = angle.Tan() * (1 - 2 * at) / (4 * 1024); - - var u = (facing % 128) / 128f; - var scale = 512 * u * (1 - u); - - return (int)(facing < 128 - ? facing - scale * attitude - : facing + scale * attitude); - } - - public void Tick(World world) - { - if (anim != null) - anim.Tick(); - - pos = WPos.LerpQuadratic(args.Source, target, angle, ticks, length); - - if (ticks++ >= length) - Explode(world); - } - - public IEnumerable Render(WorldRenderer wr) - { - if (anim == null || ticks >= length) - yield break; - - var world = args.SourceActor.World; - if (!world.FogObscures(pos)) - { - if (info.Shadow) - { - var dat = world.Map.DistanceAboveTerrain(pos); - var shadowPos = pos - new WVec(0, 0, dat.Length); - foreach (var r in anim.Render(shadowPos, wr.Palette(info.ShadowPalette))) - yield return r; - } - - var palette = wr.Palette(info.Palette); - foreach (var r in anim.Render(pos, palette)) - yield return r; - } - } - - void Explode(World world) - { - world.AddFrameEndTask(w => w.Remove(this)); - - args.Weapon.Impact(Target.FromPos(pos), args.SourceActor, args.DamageModifiers); - } - } -} diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index 374ce1713f..3314d73807 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -163,7 +163,6 @@ - diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index 7ff22a81a2..f08947cf3b 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -2277,6 +2277,14 @@ namespace OpenRA.Mods.Common.UtilityCommands } } + if (engineVersion < 20150828) + { + if (depth == 2 && parentKey == "Projectile" && parent.Value.Value == "Bullet" && node.Key == "Sequence") + { + node.Key = "Sequences"; + } + } + UpgradeWeaponRules(engineVersion, ref node.Value.Nodes, node, depth + 1); } } diff --git a/mods/d2k/weapons.yaml b/mods/d2k/weapons.yaml index b2d9d2aad9..ff42a4d70e 100644 --- a/mods/d2k/weapons.yaml +++ b/mods/d2k/weapons.yaml @@ -682,7 +682,7 @@ Shrapnel: ReloadDelay: 60 Range: 4c0 Report: - Projectile: Shrapnel + Projectile: Bullet Speed: 50, 125 Blockable: false Angle: 91, 264 diff --git a/mods/ts/weapons/explosions.yaml b/mods/ts/weapons/explosions.yaml index 5453bd3a44..7635d027d7 100644 --- a/mods/ts/weapons/explosions.yaml +++ b/mods/ts/weapons/explosions.yaml @@ -48,7 +48,7 @@ SmallDebris: ReloadDelay: 60 Range: 4c0 Report: - Projectile: Shrapnel + Projectile: Bullet Speed: 50, 125 Angle: 91, 264 Image: dbrissm @@ -59,7 +59,7 @@ LargeDebris: ReloadDelay: 60 Range: 4c0 Report: - Projectile: Shrapnel + Projectile: Bullet Speed: 50, 125 Angle: 91, 264 Image: dbrislg