Merge pull request #7640 from Phrohdoh/rand-dmg-sounds

SoundOnDamageTransition to use string[].
This commit is contained in:
Oliver Brakmann
2015-03-14 12:39:20 +01:00
10 changed files with 57 additions and 29 deletions

View File

@@ -8,14 +8,18 @@
*/
#endregion
using OpenRA.Support;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
public class SoundOnDamageTransitionInfo : ITraitInfo
{
public readonly string DamagedSound;
public readonly string DestroyedSound;
[Desc("Play a random sound from this list when damaged.")]
public readonly string[] DamagedSounds = { };
[Desc("Play a random sound from this list when destroyed.")]
public readonly string[] DestroyedSounds = { };
public object Create(ActorInitializer init) { return new SoundOnDamageTransition(this); }
}
@@ -31,10 +35,18 @@ namespace OpenRA.Mods.Common.Traits
public void DamageStateChanged(Actor self, AttackInfo e)
{
var rand = Game.CosmeticRandom;
if (e.DamageState == DamageState.Dead)
Sound.Play(info.DestroyedSound, self.CenterPosition);
{
var sound = info.DestroyedSounds.RandomOrDefault(rand);
Sound.Play(sound, self.CenterPosition);
}
else if (e.DamageState >= DamageState.Heavy && e.PreviousDamageState < DamageState.Heavy)
Sound.Play(info.DamagedSound, self.CenterPosition);
{
var sound = info.DamagedSounds.RandomOrDefault(rand);
Sound.Play(sound, self.CenterPosition);
}
}
}
}

View File

@@ -707,6 +707,18 @@ namespace OpenRA.Mods.Common.UtilityCommands
node.Key = "Refinery";
}
// Append an 's' as the fields were changed from string to string[]
if (engineVersion < 20150311)
{
if (depth == 2 && parentKey == "SoundOnDamageTransition")
{
if (node.Key == "DamagedSound")
node.Key = "DamagedSounds";
else if (node.Key == "DestroyedSound")
node.Key = "DestroyedSounds";
}
}
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
}
}

View File

@@ -397,8 +397,8 @@
BuildSounds: constru2.aud, hvydoor1.aud
TerrainTypes: Clear,Road
SoundOnDamageTransition:
DamagedSound: xplos.aud
DestroyedSound: crumble.aud
DamagedSounds: xplos.aud
DestroyedSounds: crumble.aud
RenderBuilding:
WithBuildingExplosion:
Delay: 1
@@ -655,10 +655,11 @@
Health:
HP: 500
SoundOnDamageTransition:
DamagedSound: xplos.aud
DestroyedSound: xplobig4.aud
DamagedSounds: xplos.aud
DestroyedSounds: xplobig4.aud
BodyOrientation:
ScriptTriggers:
^Crate:
Tooltip:
Name: Crate

View File

@@ -899,7 +899,7 @@ BRIK:
CrushClasses: heavywall
-CrushSound:
SoundOnDamageTransition:
DestroyedSound: crumble.aud
DestroyedSounds: crumble.aud
LineBuild:
Range: 8
NodeTypes: concrete

View File

@@ -294,8 +294,8 @@
ExternalCapturable:
ExternalCapturableBar:
SoundOnDamageTransition:
DamagedSound: EXPLSML1.WAV
DestroyedSound: EXPLHG1.WAV
DamagedSounds: EXPLSML1.WAV
DestroyedSounds: EXPLHG1.WAV
RenderBuilding:
WithBuildingExplosion:
RepairableBuilding:
@@ -331,3 +331,4 @@
Range: 2c0, 5c0
ScriptTriggers:
WithMakeAnimation:

View File

@@ -465,8 +465,8 @@ wall:
Prerequisites: barracks
BuildPaletteOrder: 60
SoundOnDamageTransition:
DamagedSound:
DestroyedSound: EXPLSML4.WAV
DamagedSounds:
DestroyedSounds: EXPLSML4.WAV
Valued:
Cost: 100
CustomSellValue:
@@ -841,3 +841,4 @@ conyard.ordos:
RenderBuilding:
Image: conyard.ordos
-RaceImages:

View File

@@ -383,8 +383,8 @@
ExternalCapturable:
ExternalCapturableBar:
SoundOnDamageTransition:
DamagedSound: kaboom1.aud
DestroyedSound: kaboom22.aud
DamagedSounds: kaboom1.aud
DestroyedSounds: kaboom22.aud
RenderBuilding:
WithMakeAnimation:
WithBuildingExplosion:
@@ -445,8 +445,8 @@
Adjacent: 7
TerrainTypes: Clear,Road
SoundOnDamageTransition:
DamagedSound: sandbag2.aud
DestroyedSound: sandbag2.aud
DamagedSounds: sandbag2.aud
DestroyedSounds: sandbag2.aud
Crushable:
CrushClasses: wall
BlocksBullets:

View File

@@ -1533,8 +1533,8 @@ BRIK:
Name: Concrete Wall
Description: Stop units and blocks enemy fire.
SoundOnDamageTransition:
DamagedSound: crmble2.aud
DestroyedSound: kaboom30.aud
DamagedSounds: crmble2.aud
DestroyedSounds: kaboom30.aud
Health:
HP: 500
Armor:

View File

@@ -16,8 +16,8 @@
GivesBuildableArea:
Capturable:
SoundOnDamageTransition:
DamagedSound: expnew01.aud
DestroyedSound: crmble2.aud
DamagedSounds: expnew01.aud
DestroyedSounds: crmble2.aud
RenderBuilding:
WithBuildingExplosion:
RepairableBuilding:
@@ -84,8 +84,8 @@
Adjacent: 7
TerrainTypes: Clear, Road
SoundOnDamageTransition:
DamagedSound: expnew01.aud
DestroyedSound: crmble2.aud
DamagedSounds: expnew01.aud
DestroyedSounds: crmble2.aud
Crushable:
CrushClasses: wall
BlocksBullets:
@@ -491,3 +491,4 @@
Footprint: x
Dimensions: 1, 1
BodyOrientation:

View File

@@ -406,8 +406,8 @@ GASAND:
BuildPaletteOrder: 1000
Prerequisites: ~structures.gdi
SoundOnDamageTransition:
DamagedSound: sandbag1.aud
DestroyedSound: sandbag1.aud
DamagedSounds: sandbag1.aud
DestroyedSounds: sandbag1.aud
Valued:
Cost: 25
CustomSellValue:
@@ -433,8 +433,8 @@ GAWALL:
BuildPaletteOrder: 1001
Prerequisites: ~structures.gdi
SoundOnDamageTransition:
DamagedSound:
DestroyedSound:
DamagedSounds:
DestroyedSounds:
Valued:
Cost: 50
CustomSellValue:
@@ -458,8 +458,8 @@ NAWALL:
BuildPaletteOrder: 1001
Prerequisites: ~structures.nod
SoundOnDamageTransition:
DamagedSound:
DestroyedSound:
DamagedSounds:
DestroyedSounds:
Valued:
Cost: 50
CustomSellValue: