Merge pull request #5236 from reaperrr/deathsound
Closes #2392 Closes #4680
This commit is contained in:
@@ -368,6 +368,19 @@ namespace OpenRA
|
|||||||
return PlayPredefined(null, voicedUnit, type, phrase, variant, true);
|
return PlayPredefined(null, voicedUnit, type, phrase, variant, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool PlayVoiceLocal(string phrase, Actor voicedUnit, string variant, WPos pos)
|
||||||
|
{
|
||||||
|
if (voicedUnit == null || phrase == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var mi = voicedUnit.Info.Traits.GetOrDefault<SelectableInfo>();
|
||||||
|
if (mi == null || mi.Voice == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var type = mi.Voice.ToLowerInvariant();
|
||||||
|
return PlayPredefined(null, voicedUnit, type, phrase, variant, true);
|
||||||
|
}
|
||||||
|
|
||||||
public static bool PlayNotification(Player player, string type, string notification, string variant)
|
public static bool PlayNotification(Player player, string type, string notification, string variant)
|
||||||
{
|
{
|
||||||
if (type == null || notification == null)
|
if (type == null || notification == null)
|
||||||
|
|||||||
53
OpenRA.Mods.RA/DeathSounds.cs
Normal file
53
OpenRA.Mods.RA/DeathSounds.cs
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
#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 System.Linq;
|
||||||
|
using OpenRA.Mods.RA.Move;
|
||||||
|
using OpenRA.Primitives;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.RA
|
||||||
|
{
|
||||||
|
public class DeathSoundsInfo : ITraitInfo
|
||||||
|
{
|
||||||
|
public readonly string DeathVoice = "Die";
|
||||||
|
public readonly string Burned = null;
|
||||||
|
public readonly string Zapped = null;
|
||||||
|
|
||||||
|
public object Create(ActorInitializer init) { return new DeathSounds(this); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DeathSounds : INotifyKilled
|
||||||
|
{
|
||||||
|
DeathSoundsInfo info;
|
||||||
|
|
||||||
|
public DeathSounds(DeathSoundsInfo info) { this.info = info; }
|
||||||
|
|
||||||
|
public void Killed(Actor self, AttackInfo e)
|
||||||
|
{
|
||||||
|
// Killed by some non-standard means
|
||||||
|
if (e.Warhead == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var cp = self.CenterPosition;
|
||||||
|
|
||||||
|
// Killed by fire
|
||||||
|
if (info.Burned != null && e.Warhead.InfDeath == 5)
|
||||||
|
Sound.Play(info.Burned, cp);
|
||||||
|
|
||||||
|
// Killed by Tesla/Laser zap
|
||||||
|
if (info.Zapped != null && e.Warhead.InfDeath == 6)
|
||||||
|
Sound.Play(info.Zapped, cp);
|
||||||
|
|
||||||
|
if ((e.Warhead.InfDeath < 5) || (info.Burned == null && info.Zapped == null))
|
||||||
|
Sound.PlayVoiceLocal(info.DeathVoice, self, self.Owner.Country.Race, cp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -216,6 +216,7 @@
|
|||||||
<Compile Include="Crates\SupportPowerCrateAction.cs" />
|
<Compile Include="Crates\SupportPowerCrateAction.cs" />
|
||||||
<Compile Include="CreateMPPlayers.cs" />
|
<Compile Include="CreateMPPlayers.cs" />
|
||||||
<Compile Include="CrushableInfantry.cs" />
|
<Compile Include="CrushableInfantry.cs" />
|
||||||
|
<Compile Include="DeathSounds.cs" />
|
||||||
<Compile Include="DemoTruck.cs" />
|
<Compile Include="DemoTruck.cs" />
|
||||||
<Compile Include="DetectCloaked.cs" />
|
<Compile Include="DetectCloaked.cs" />
|
||||||
<Compile Include="Effects\Bullet.cs" />
|
<Compile Include="Effects\Bullet.cs" />
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
{
|
{
|
||||||
public readonly int MinIdleWaitTicks = 30;
|
public readonly int MinIdleWaitTicks = 30;
|
||||||
public readonly int MaxIdleWaitTicks = 110;
|
public readonly int MaxIdleWaitTicks = 110;
|
||||||
public readonly bool UseInfantryDeath = true;
|
public readonly bool SpawnsCorpse = true;
|
||||||
public readonly string[] IdleAnimations = { };
|
public readonly string[] IdleAnimations = { };
|
||||||
public readonly string[] StandAnimations = { "stand" };
|
public readonly string[] StandAnimations = { "stand" };
|
||||||
|
|
||||||
@@ -125,19 +125,17 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Possibly move this into a separate trait
|
||||||
public void Killed(Actor self, AttackInfo e)
|
public void Killed(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
// Killed by some non-standard means
|
// Killed by some non-standard means
|
||||||
if (e.Warhead == null)
|
if (e.Warhead == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// TODO: Possibly move Die sound out of this Render trait entirely
|
if (info.SpawnsCorpse)
|
||||||
if (info.UseInfantryDeath == true)
|
|
||||||
{
|
{
|
||||||
Sound.PlayVoice("Die", self, self.Owner.Country.Race);
|
|
||||||
SpawnCorpse(self, "die{0}".F(e.Warhead.InfDeath));
|
SpawnCorpse(self, "die{0}".F(e.Warhead.InfDeath));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SpawnCorpse(Actor self, string sequence)
|
public void SpawnCorpse(Actor self, string sequence)
|
||||||
|
|||||||
@@ -187,6 +187,8 @@
|
|||||||
DetectCloaked:
|
DetectCloaked:
|
||||||
Range: 1
|
Range: 1
|
||||||
ScriptTriggers:
|
ScriptTriggers:
|
||||||
|
DeathSounds:
|
||||||
|
Burned: yell1.aud
|
||||||
|
|
||||||
^CivInfantry:
|
^CivInfantry:
|
||||||
Inherits: ^Infantry
|
Inherits: ^Infantry
|
||||||
@@ -266,6 +268,7 @@
|
|||||||
Huntable:
|
Huntable:
|
||||||
LuaScriptEvents:
|
LuaScriptEvents:
|
||||||
ScriptTriggers:
|
ScriptTriggers:
|
||||||
|
DeathSounds:
|
||||||
|
|
||||||
^Plane:
|
^Plane:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
@@ -588,4 +591,3 @@
|
|||||||
BodyOrientation:
|
BodyOrientation:
|
||||||
LuaScriptEvents:
|
LuaScriptEvents:
|
||||||
ScriptTriggers:
|
ScriptTriggers:
|
||||||
|
|
||||||
|
|||||||
@@ -195,6 +195,7 @@
|
|||||||
Huntable:
|
Huntable:
|
||||||
LuaScriptEvents:
|
LuaScriptEvents:
|
||||||
ScriptTriggers:
|
ScriptTriggers:
|
||||||
|
DeathSounds:
|
||||||
|
|
||||||
^Plane:
|
^Plane:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
|
|||||||
@@ -1308,7 +1308,8 @@ Rules:
|
|||||||
SpeedModifier:
|
SpeedModifier:
|
||||||
^Infantry:
|
^Infantry:
|
||||||
ScriptInvulnerable:
|
ScriptInvulnerable:
|
||||||
-Selectable: # short-term hack to make infantry not play die sounds until we fix RenderInfantry
|
DeathSounds:
|
||||||
|
DeathVoice:
|
||||||
GivesBounty:
|
GivesBounty:
|
||||||
Percentage: 0
|
Percentage: 0
|
||||||
GainsExperience:
|
GainsExperience:
|
||||||
@@ -1320,6 +1321,11 @@ Rules:
|
|||||||
ScriptInvulnerable:
|
ScriptInvulnerable:
|
||||||
GivesBounty:
|
GivesBounty:
|
||||||
Percentage: 0
|
Percentage: 0
|
||||||
|
GainsExperience:
|
||||||
|
CostThreshold:
|
||||||
|
FirepowerModifier:
|
||||||
|
ArmorModifier:
|
||||||
|
SpeedModifier:
|
||||||
^Plane:
|
^Plane:
|
||||||
ScriptInvulnerable:
|
ScriptInvulnerable:
|
||||||
GivesBounty:
|
GivesBounty:
|
||||||
|
|||||||
@@ -168,6 +168,7 @@
|
|||||||
Huntable:
|
Huntable:
|
||||||
LuaScriptEvents:
|
LuaScriptEvents:
|
||||||
ScriptTriggers:
|
ScriptTriggers:
|
||||||
|
DeathSounds:
|
||||||
|
|
||||||
^Ship:
|
^Ship:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
|
|||||||
@@ -132,6 +132,8 @@
|
|||||||
Huntable:
|
Huntable:
|
||||||
LuaScriptEvents:
|
LuaScriptEvents:
|
||||||
ScriptTriggers:
|
ScriptTriggers:
|
||||||
|
DeathSounds:
|
||||||
|
Zapped: electro1.aud
|
||||||
|
|
||||||
^CivilianInfantry:
|
^CivilianInfantry:
|
||||||
Inherits: ^Infantry
|
Inherits: ^Infantry
|
||||||
|
|||||||
@@ -480,7 +480,7 @@ MMCH:
|
|||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
Range: 8c0
|
Range: 8c0
|
||||||
RenderInfantry:
|
RenderInfantry:
|
||||||
UseInfantryDeath: false
|
SpawnsCorpse: false
|
||||||
Turreted:
|
Turreted:
|
||||||
AttackTurreted:
|
AttackTurreted:
|
||||||
WithTurret:
|
WithTurret:
|
||||||
@@ -550,7 +550,7 @@ SMECH:
|
|||||||
Armament:
|
Armament:
|
||||||
Weapon: AssaultCannon
|
Weapon: AssaultCannon
|
||||||
RenderInfantry:
|
RenderInfantry:
|
||||||
UseInfantryDeath: false
|
SpawnsCorpse: false
|
||||||
Selectable:
|
Selectable:
|
||||||
Voices: Mech
|
Voices: Mech
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user