diff --git a/OpenRA.Mods.D2k/AttackSwallow.cs b/OpenRA.Mods.D2k/AttackSwallow.cs index 1f9adea519..16616e5cf0 100644 --- a/OpenRA.Mods.D2k/AttackSwallow.cs +++ b/OpenRA.Mods.D2k/AttackSwallow.cs @@ -13,9 +13,8 @@ using OpenRA.Traits; namespace OpenRA.Mods.D2k { - // TODO: This is a copy of AttackLeap. Maybe combine them in AttackMelee trait when the code is finalized? [Desc("Sandworms use this attack model.")] - class AttackSwallowInfo : AttackFrontalInfo, Requires + class AttackSwallowInfo : AttackFrontalInfo { [Desc("The number of ticks it takes to return underground.")] public int ReturnTime = 60; diff --git a/OpenRA.Mods.D2k/OpenRA.Mods.D2k.csproj b/OpenRA.Mods.D2k/OpenRA.Mods.D2k.csproj index a1ec8a43ba..3edfdb132e 100644 --- a/OpenRA.Mods.D2k/OpenRA.Mods.D2k.csproj +++ b/OpenRA.Mods.D2k/OpenRA.Mods.D2k.csproj @@ -69,10 +69,7 @@ - - - @@ -94,11 +91,6 @@ - - - - - diff --git a/OpenRA.Mods.D2k/Sandworm.cs b/OpenRA.Mods.D2k/Sandworm.cs deleted file mode 100644 index 33b022c28f..0000000000 --- a/OpenRA.Mods.D2k/Sandworm.cs +++ /dev/null @@ -1,31 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2014 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 OpenRA.Mods.RA; -using OpenRA.Mods.RA.Move; -using OpenRA.Mods.RA.Render; -using OpenRA.Traits; - -namespace OpenRA.Mods.D2k -{ - class SandwormInfo : Requires, Requires, IOccupySpaceInfo - { - readonly public string WormSignNotification = "WormSign"; - - public object Create(ActorInitializer init) { return new Sandworm(this); } - } - - class Sandworm - { - public Sandworm(SandwormInfo info) - { - } - } -} diff --git a/OpenRA.Mods.D2k/SwallowActor.cs b/OpenRA.Mods.D2k/SwallowActor.cs index 345826b956..6c4798375c 100644 --- a/OpenRA.Mods.D2k/SwallowActor.cs +++ b/OpenRA.Mods.D2k/SwallowActor.cs @@ -17,27 +17,30 @@ using OpenRA.Traits; namespace OpenRA.Mods.D2k { - public enum AttackState { Burrowed, EmergingAboveGround, ReturningUnderground } + enum AttackState { Burrowed, EmergingAboveGround, ReturningUnderground } class SwallowActor : Activity { readonly Target target; - readonly Sandworm sandworm; readonly WeaponInfo weapon; + readonly RenderUnit renderUnit; readonly AttackSwallow swallow; readonly IPositionable positionable; int countdown; - AttackState stance = AttackState.Burrowed; + AttackState stance; public SwallowActor(Actor self, Target target, WeaponInfo weapon) { this.target = target; this.weapon = weapon; positionable = self.TraitOrDefault(); - sandworm = self.TraitOrDefault(); swallow = self.TraitOrDefault(); + renderUnit = self.TraitOrDefault(); countdown = swallow.AttackSwallowInfo.AttackTime; + + renderUnit.DefaultAnimation.ReplaceAnim("burrowed"); + stance = AttackState.Burrowed; } bool WormAttack(Actor worm) @@ -45,14 +48,14 @@ namespace OpenRA.Mods.D2k var targetLocation = target.Actor.Location; var lunch = worm.World.ActorMap.GetUnitsAt(targetLocation) - .Where(t => !t.Equals(worm) && weapon.IsValidAgainst(t, worm)); + .Where(t => !t.Equals(worm) && weapon.IsValidAgainst(t, worm)); if (!lunch.Any()) return false; stance = AttackState.EmergingAboveGround; lunch.Do(t => t.World.AddFrameEndTask(_ => { t.World.Remove(t); t.Kill(t); })); // Dispose of the evidence (we don't want husks) - + positionable.SetPosition(worm, targetLocation); PlayAttackAnimation(worm); @@ -61,7 +64,6 @@ namespace OpenRA.Mods.D2k void PlayAttackAnimation(Actor self) { - var renderUnit = self.Trait(); renderUnit.PlayCustomAnim(self, "sand"); renderUnit.PlayCustomAnim(self, "mouth"); } @@ -74,28 +76,27 @@ namespace OpenRA.Mods.D2k return this; } - if (stance == AttackState.ReturningUnderground) // Wait for the worm to get back underground + if (stance == AttackState.ReturningUnderground) // Wait for the worm to get back underground { - if (self.World.SharedRandom.Next() % 2 == 0) // There is a 50-50 chance that the worm would just go away + if (self.World.SharedRandom.Next()%2 == 0) // There is a 50-50 chance that the worm would just go away { - self.CancelActivity(); - self.World.AddFrameEndTask(w => w.Remove(self)); - var wormManager = self.World.WorldActor.TraitOrDefault(); - if (wormManager != null) - wormManager.DecreaseWorms(); + self.CancelActivity(); + self.World.AddFrameEndTask(w => w.Remove(self)); + var wormManager = self.World.WorldActor.TraitOrDefault(); + if (wormManager != null) + wormManager.DecreaseWorms(); + } + else + { + renderUnit.DefaultAnimation.ReplaceAnim("idle"); } - - // TODO: If the worm did not disappear, make the animation reappear here - return NextActivity; } if (stance == AttackState.Burrowed) // Wait for the worm to get in position { - // TODO: Make the worm animation (currenty the lightning) disappear here - // This is so that the worm cancels an attack against a target that has reached solid rock - if (sandworm == null || positionable == null || !positionable.CanEnterCell(target.Actor.Location, null, false)) + if (positionable == null || !positionable.CanEnterCell(target.Actor.Location, null, false)) return NextActivity; var success = WormAttack(self); diff --git a/OpenRA.Mods.D2k/WormManager.cs b/OpenRA.Mods.D2k/WormManager.cs index 7e04c93891..fa44011c8f 100644 --- a/OpenRA.Mods.D2k/WormManager.cs +++ b/OpenRA.Mods.D2k/WormManager.cs @@ -27,6 +27,8 @@ namespace OpenRA.Mods.D2k [Desc("Average time (seconds) between worm spawn")] public readonly int SpawnInterval = 180; + public readonly string WormSignNotification = "WormSign"; + public readonly string WormSignature = "sandworm"; public readonly string WormOwnerPlayer = "Creeps"; @@ -71,6 +73,8 @@ namespace OpenRA.Mods.D2k new LocationInit(spawnLocation) })); wormsPresent++; + + AnnounceWormSign(self); } CPos GetRandomSpawnPosition(Actor self) @@ -82,6 +86,12 @@ namespace OpenRA.Mods.D2k { wormsPresent--; } + + void AnnounceWormSign(Actor self) + { + if (self.World.LocalPlayer != null) + Sound.PlayNotification(self.World.Map.Rules, self.World.LocalPlayer, "Speech", info.WormSignNotification, self.World.LocalPlayer.Country.Race); + } } [Desc("An actor with this trait indicates a valid spawn point for sandworms.")] diff --git a/OpenRA.Mods.RA/Attack/AttackWander.cs b/OpenRA.Mods.RA/Attack/AttackWander.cs index 06e194993e..e6ec96baa3 100644 --- a/OpenRA.Mods.RA/Attack/AttackWander.cs +++ b/OpenRA.Mods.RA/Attack/AttackWander.cs @@ -17,7 +17,7 @@ namespace OpenRA.Mods.RA "This conflicts with player orders and should only be added to animal creeps.")] class AttackWanderInfo : ITraitInfo { - readonly public int WanderMoveRadius = 10; + public readonly int WanderMoveRadius = 10; [Desc("Number of ticks to wait until decreasing the effective move radius.")] public readonly int MoveReductionRadiusScale = 5; diff --git a/mods/cnc/rules/civilian.yaml b/mods/cnc/rules/civilian.yaml index 34871fa770..f82793b58d 100644 --- a/mods/cnc/rules/civilian.yaml +++ b/mods/cnc/rules/civilian.yaml @@ -458,6 +458,7 @@ VICE: MuzzleSplitFacings: 8 AttackFrontal: AttackWander: + WanderMoveRadius: 4 RenderUnit: WithMuzzleFlash: SplitFacings: true diff --git a/mods/d2k/rules/arrakis.yaml b/mods/d2k/rules/arrakis.yaml index bd549fbc84..43e718f53e 100644 --- a/mods/d2k/rules/arrakis.yaml +++ b/mods/d2k/rules/arrakis.yaml @@ -41,7 +41,6 @@ SANDWORM: RenderUnit: BodyOrientation: HiddenUnderFog: - Sandworm: AppearsOnRadar: UseLocation: yes AttackSwallow: diff --git a/mods/d2k/sequences/infantry.yaml b/mods/d2k/sequences/infantry.yaml index 5aff4af1d3..e828e28d57 100644 --- a/mods/d2k/sequences/infantry.yaml +++ b/mods/d2k/sequences/infantry.yaml @@ -456,5 +456,7 @@ sandworm: Length: 35 Tick: 180 BlendMode: Additive + burrowed: DATA + Start: 39 icon: wormicon Start: 0 \ No newline at end of file diff --git a/mods/ts/rules/infantry.yaml b/mods/ts/rules/infantry.yaml index 476c4fda9a..b70348c923 100644 --- a/mods/ts/rules/infantry.yaml +++ b/mods/ts/rules/infantry.yaml @@ -583,6 +583,7 @@ DOGGIE: Weapon: FiendShard AttackFrontal: AttackWander: + WanderMoveRadius: 4 VISSML: Inherits: ^Infantry