Merge pull request #6799 from pchote/additional-sounds

Made use of various additional sound files in Red Alert
This commit is contained in:
Paul Chote
2014-10-20 20:28:17 +13:00
12 changed files with 66 additions and 17 deletions

View File

@@ -26,8 +26,9 @@ namespace OpenRA.Mods.RA.Activities
var limitedAmmo = self.TraitOrDefault<LimitedAmmo>();
if (!limitedAmmo.HasAmmo())
{
var info = self.Info.Traits.Get<MinelayerInfo>();
// rearm & repair at fix, then back out here to refill the minefield some more
var buildings = self.Info.Traits.Get<MinelayerInfo>().RearmBuildings;
var buildings = info.RearmBuildings;
var rearmTarget = self.World.Actors.Where(a => self.Owner.Stances[a.Owner] == Stance.Ally
&& buildings.Contains(a.Info.Name))
.ClosestTo(self);
@@ -38,26 +39,27 @@ namespace OpenRA.Mods.RA.Activities
return Util.SequenceActivities(
new MoveAdjacentTo(self, Target.FromActor(rearmTarget)),
movement.MoveTo(self.World.Map.CellContaining(rearmTarget.CenterPosition), rearmTarget),
new Rearm(self),
new Rearm(self, info.RearmSound),
new Repair(rearmTarget),
this);
}
var ml = self.Trait<Minelayer>();
if (ml.Minefield.Contains(self.Location) &&
ShouldLayMine(self, self.Location))
if (ml.Minefield.Contains(self.Location) && ShouldLayMine(self, self.Location))
{
LayMine(self);
return Util.SequenceActivities(new Wait(20), this); // a little wait after placing each mine, for show
}
if (ml.Minefield.Length > 0)
{
for (var n = 0; n < 20; n++) // dont get stuck forever here
{
var p = ml.Minefield.Random(self.World.SharedRandom);
if (ShouldLayMine(self, p))
return Util.SequenceActivities( movement.MoveTo(p, 0), this );
}
}
// TODO: return somewhere likely to be safe (near fix) so we're not sitting out in the minefield.

View File

@@ -19,18 +19,21 @@ namespace OpenRA.Mods.RA.Activities
readonly LimitedAmmo limitedAmmo;
int ticksPerPip = 25 * 2;
int remainingTicks = 25 * 2;
string sound = null;
public Rearm(Actor self)
public Rearm(Actor self, string sound = null)
{
limitedAmmo = self.TraitOrDefault<LimitedAmmo>();
if (limitedAmmo != null)
ticksPerPip = limitedAmmo.ReloadTimePerAmmo();
remainingTicks = ticksPerPip;
this.sound = sound;
}
public override Activity Tick(Actor self)
{
if (IsCanceled || limitedAmmo == null) return NextActivity;
if (IsCanceled || limitedAmmo == null)
return NextActivity;
if (--remainingTicks == 0)
{
@@ -44,6 +47,8 @@ namespace OpenRA.Mods.RA.Activities
return NextActivity;
hostBuilding.Trait<RenderBuilding>().PlayCustomAnim(hostBuilding, "active");
if (sound != null)
Sound.Play(sound, self.CenterPosition);
remainingTicks = limitedAmmo.ReloadTimePerAmmo();
}

View File

@@ -12,6 +12,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
[Desc("Play the Build voice of this actor when trained.")]
public class AnnounceOnBuildInfo : ITraitInfo
{
public object Create(ActorInitializer init) { return new AnnounceOnBuild(init.self); }

View File

@@ -12,15 +12,36 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
public class AnnounceOnKillInfo : TraitInfo<AnnounceOnKill> {}
[Desc("Play the Kill voice of this actor when eliminating enemies.")]
public class AnnounceOnKillInfo : ITraitInfo
{
[Desc("Minimum duration (in seconds) between sound events.")]
public readonly int Interval = 5;
public object Create(ActorInitializer init) { return new AnnounceOnKill(init.self, this); }
}
public class AnnounceOnKill : INotifyAppliedDamage
{
readonly AnnounceOnKillInfo info;
int lastAnnounce;
public AnnounceOnKill(Actor self, AnnounceOnKillInfo info)
{
this.info = info;
lastAnnounce = -info.Interval * 25;
}
public void AppliedDamage(Actor self, Actor damaged, AttackInfo e)
{
if (e.DamageState == DamageState.Dead)
Sound.PlayVoice("Kill", self, self.Owner.Country.Race);
if (e.DamageState == DamageState.Dead && damaged != e.Attacker) // don't notify suicides
{
if (self.World.WorldTick - lastAnnounce > info.Interval * 25)
Sound.PlayVoice("Kill", self, self.Owner.Country.Race);
lastAnnounce = self.World.WorldTick;
}
}
}
}

View File

@@ -30,6 +30,8 @@ namespace OpenRA.Mods.RA
public readonly int FlashInterval = 4;
[Desc("Duration of each flash")]
public readonly int FlashDuration = 3;
[Desc("Voice string when planting explosive charges.")]
public readonly string Voice = "Attack";
public object Create(ActorInitializer init) { return new C4Demolition(this); }
}
@@ -82,7 +84,7 @@ namespace OpenRA.Mods.RA
public string VoicePhraseForOrder(Actor self, Order order)
{
return order.OrderString == "C4" ? "Attack" : null;
return order.OrderString == "C4" ? info.Voice : null;
}
class C4DemolitionOrderTargeter : UnitOrderTargeter

View File

@@ -23,6 +23,8 @@ namespace OpenRA.Mods.RA
[ActorReference] public readonly string Mine = "minv";
[ActorReference] public readonly string[] RearmBuildings = { "fix" };
public readonly string RearmSound = "minelay1.aud";
public readonly float MinefieldDepth = 1.5f;
public object Create(ActorInitializer init) { return new Minelayer(init.self); }
@@ -30,7 +32,7 @@ namespace OpenRA.Mods.RA
class Minelayer : IIssueOrder, IResolveOrder, IPostRenderSelection, ISync
{
/* [Sync] when sync can cope with arrays! */
/* TODO: [Sync] when sync can cope with arrays! */
public CPos[] Minefield = null;
[Sync] CPos minefieldStart;
Actor self;