Improved visuals, added WormSign norification
This commit is contained in:
@@ -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<SandwormInfo>
|
||||
class AttackSwallowInfo : AttackFrontalInfo
|
||||
{
|
||||
[Desc("The number of ticks it takes to return underground.")]
|
||||
public int ReturnTime = 60;
|
||||
|
||||
@@ -69,10 +69,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AttackSwallow.cs" />
|
||||
<Compile Include="Sandworm.cs" />
|
||||
<Compile Include="SwallowActor.cs" />
|
||||
<Compile Include="ThrowsShrapnel.cs" />
|
||||
<Compile Include="DamagedWithoutFoundation.cs" />
|
||||
<Compile Include="SpriteLoaders\R8Loader.cs" />
|
||||
<Compile Include="Traits\Buildings\DamagedWithoutFoundation.cs" />
|
||||
<Compile Include="Traits\Render\WithBuildingPlacedOverlay.cs" />
|
||||
@@ -94,11 +91,6 @@
|
||||
<Compile Include="AutoCarryall\AutoCarryall.cs" />
|
||||
<Compile Include="AutoCarryall\Carryable.cs" />
|
||||
<Compile Include="AutoCarryall\CarryUnit.cs" />
|
||||
<Compile Include="World\ChooseBuildTabOnSelect.cs" />
|
||||
<Compile Include="World\PaletteFromR8.cs" />
|
||||
<Compile Include="World\FogPaletteFromR8.cs" />
|
||||
<Compile Include="World\D2kResourceLayer.cs" />
|
||||
<Compile Include="World\PaletteFromScaledPalette.cs" />
|
||||
<Compile Include="WormManager.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
|
||||
@@ -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<RenderUnitInfo>, Requires<MobileInfo>, IOccupySpaceInfo
|
||||
{
|
||||
readonly public string WormSignNotification = "WormSign";
|
||||
|
||||
public object Create(ActorInitializer init) { return new Sandworm(this); }
|
||||
}
|
||||
|
||||
class Sandworm
|
||||
{
|
||||
public Sandworm(SandwormInfo info)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<Mobile>();
|
||||
sandworm = self.TraitOrDefault<Sandworm>();
|
||||
swallow = self.TraitOrDefault<AttackSwallow>();
|
||||
renderUnit = self.TraitOrDefault<RenderUnit>();
|
||||
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>();
|
||||
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<WormManager>();
|
||||
if (wormManager != null)
|
||||
wormManager.DecreaseWorms();
|
||||
self.CancelActivity();
|
||||
self.World.AddFrameEndTask(w => w.Remove(self));
|
||||
var wormManager = self.World.WorldActor.TraitOrDefault<WormManager>();
|
||||
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);
|
||||
|
||||
@@ -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.")]
|
||||
|
||||
Reference in New Issue
Block a user