From ea626d4b39b745a1265e4b113f87ca2d05896db7 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Fri, 25 Mar 2011 19:46:09 +1300 Subject: [PATCH] RMBO voices on build and kill. --- OpenRA.Game/Traits/Health.cs | 35 ++++++++++++--------- OpenRA.Game/Traits/TraitsInterfaces.cs | 1 + OpenRA.Mods.RA/AnnounceOnBuild.cs | 42 ++++++++++++++++++++++++++ OpenRA.Mods.RA/OpenRA.Mods.RA.csproj | 1 + mods/cnc/rules/infantry.yaml | 2 ++ mods/cnc/voices.yaml | 2 +- 6 files changed, 68 insertions(+), 15 deletions(-) create mode 100644 OpenRA.Mods.RA/AnnounceOnBuild.cs diff --git a/OpenRA.Game/Traits/Health.cs b/OpenRA.Game/Traits/Health.cs index 20b60ed428..b74c08b4ac 100755 --- a/OpenRA.Game/Traits/Health.cs +++ b/OpenRA.Game/Traits/Health.cs @@ -87,20 +87,27 @@ namespace OpenRA.Traits damage = (int)(damage * modifier); hp -= damage; - - foreach (var nd in self.TraitsImplementing().Concat(self.Owner.PlayerActor.TraitsImplementing())) - nd.Damaged(self, new AttackInfo - { - Attacker = attacker, - Damage = damage, - DamageState = this.DamageState, - PreviousDamageState = oldState, - DamageStateChanged = this.DamageState != oldState, - Warhead = warhead, - PreviousHealth = hp + damage < 0 ? 0 : hp + damage, - Health = hp - }); - + var ai = new AttackInfo + { + Attacker = attacker, + Damage = damage, + DamageState = this.DamageState, + PreviousDamageState = oldState, + DamageStateChanged = this.DamageState != oldState, + Warhead = warhead, + PreviousHealth = hp + damage < 0 ? 0 : hp + damage, + Health = hp + }; + + foreach (var nd in self.TraitsImplementing() + .Concat(self.Owner.PlayerActor.TraitsImplementing())) + nd.Damaged(self, ai); + + if (attacker != null && attacker.IsInWorld && !attacker.IsDead()) + foreach (var nd in attacker.TraitsImplementing() + .Concat(attacker.Owner.PlayerActor.TraitsImplementing())) + nd.AppliedDamage(attacker, self, ai); + if (hp <= 0) { hp = 0; diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index a5fdb2405c..77e96b28bb 100755 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -58,6 +58,7 @@ namespace OpenRA.Traits public interface ICustomUnitOrderGenerator : IOrderGenerator {}; public interface INotifySold { void Selling( Actor self ); void Sold( Actor self ); } public interface INotifyDamage { void Damaged(Actor self, AttackInfo e); } + public interface INotifyAppliedDamage { void AppliedDamage(Actor self, Actor damaged, AttackInfo e); } public interface INotifyBuildComplete { void BuildingComplete(Actor self); } public interface INotifyProduction { void UnitProduced(Actor self, Actor other, int2 exit); } public interface INotifyCapture { void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner); } diff --git a/OpenRA.Mods.RA/AnnounceOnBuild.cs b/OpenRA.Mods.RA/AnnounceOnBuild.cs new file mode 100644 index 0000000000..d53dc0d052 --- /dev/null +++ b/OpenRA.Mods.RA/AnnounceOnBuild.cs @@ -0,0 +1,42 @@ +#region Copyright & License Information +/* + * Copyright 2007-2011 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.Drawing; +using OpenRA.Effects; +using OpenRA.Mods.RA.Move; +using OpenRA.Traits; +using OpenRA.Traits.Activities; + +namespace OpenRA.Mods.RA +{ + public class AnnounceOnBuildInfo : ITraitInfo + { + public object Create(ActorInitializer init) { return new AnnounceOnBuild(init.self); } + } + + public class AnnounceOnBuild + { + public AnnounceOnBuild(Actor self) + { + Sound.PlayVoice("Build", self, self.Owner.Country.Race); + } + } + + public class AnnounceOnKillInfo : TraitInfo {} + + public class AnnounceOnKill : INotifyAppliedDamage + { + public void AppliedDamage(Actor self, Actor damaged, AttackInfo e) + { + if (e.DamageState == DamageState.Dead) + Sound.PlayVoice("Kill", self, self.Owner.Country.Race); + } + } +} diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 17f00e1283..8c81333d8c 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -333,6 +333,7 @@ + diff --git a/mods/cnc/rules/infantry.yaml b/mods/cnc/rules/infantry.yaml index e9e94c5a07..0321391079 100644 --- a/mods/cnc/rules/infantry.yaml +++ b/mods/cnc/rules/infantry.yaml @@ -180,3 +180,5 @@ RMBO: PrimaryWeapon: Sniper RenderInfantryProne: IdleAnimations: idle1,idle2,idle3 + AnnounceOnBuild: + AnnounceOnKill: \ No newline at end of file diff --git a/mods/cnc/voices.yaml b/mods/cnc/voices.yaml index 0de2c641c1..5c08b2e043 100644 --- a/mods/cnc/voices.yaml +++ b/mods/cnc/voices.yaml @@ -30,7 +30,7 @@ CivilianFemaleVoice: CommandoVoice: Voices: - Select: rokroll1,yeah1,yes1,yo1 + Select: yeah1,yes1,yo1 Move: cmon1,onit1,gotit1 Attack: onit1,gotit1 Demolish: bombit1