Merge pull request #7640 from Phrohdoh/rand-dmg-sounds
SoundOnDamageTransition to use string[].
This commit is contained in:
@@ -8,14 +8,18 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using OpenRA.Support;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits
|
namespace OpenRA.Mods.Common.Traits
|
||||||
{
|
{
|
||||||
public class SoundOnDamageTransitionInfo : ITraitInfo
|
public class SoundOnDamageTransitionInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
public readonly string DamagedSound;
|
[Desc("Play a random sound from this list when damaged.")]
|
||||||
public readonly string DestroyedSound;
|
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); }
|
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)
|
public void DamageStateChanged(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
|
var rand = Game.CosmeticRandom;
|
||||||
|
|
||||||
if (e.DamageState == DamageState.Dead)
|
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)
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -707,6 +707,18 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
node.Key = "Refinery";
|
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);
|
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -397,8 +397,8 @@
|
|||||||
BuildSounds: constru2.aud, hvydoor1.aud
|
BuildSounds: constru2.aud, hvydoor1.aud
|
||||||
TerrainTypes: Clear,Road
|
TerrainTypes: Clear,Road
|
||||||
SoundOnDamageTransition:
|
SoundOnDamageTransition:
|
||||||
DamagedSound: xplos.aud
|
DamagedSounds: xplos.aud
|
||||||
DestroyedSound: crumble.aud
|
DestroyedSounds: crumble.aud
|
||||||
RenderBuilding:
|
RenderBuilding:
|
||||||
WithBuildingExplosion:
|
WithBuildingExplosion:
|
||||||
Delay: 1
|
Delay: 1
|
||||||
@@ -655,10 +655,11 @@
|
|||||||
Health:
|
Health:
|
||||||
HP: 500
|
HP: 500
|
||||||
SoundOnDamageTransition:
|
SoundOnDamageTransition:
|
||||||
DamagedSound: xplos.aud
|
DamagedSounds: xplos.aud
|
||||||
DestroyedSound: xplobig4.aud
|
DestroyedSounds: xplobig4.aud
|
||||||
BodyOrientation:
|
BodyOrientation:
|
||||||
ScriptTriggers:
|
ScriptTriggers:
|
||||||
|
|
||||||
^Crate:
|
^Crate:
|
||||||
Tooltip:
|
Tooltip:
|
||||||
Name: Crate
|
Name: Crate
|
||||||
|
|||||||
@@ -899,7 +899,7 @@ BRIK:
|
|||||||
CrushClasses: heavywall
|
CrushClasses: heavywall
|
||||||
-CrushSound:
|
-CrushSound:
|
||||||
SoundOnDamageTransition:
|
SoundOnDamageTransition:
|
||||||
DestroyedSound: crumble.aud
|
DestroyedSounds: crumble.aud
|
||||||
LineBuild:
|
LineBuild:
|
||||||
Range: 8
|
Range: 8
|
||||||
NodeTypes: concrete
|
NodeTypes: concrete
|
||||||
|
|||||||
@@ -294,8 +294,8 @@
|
|||||||
ExternalCapturable:
|
ExternalCapturable:
|
||||||
ExternalCapturableBar:
|
ExternalCapturableBar:
|
||||||
SoundOnDamageTransition:
|
SoundOnDamageTransition:
|
||||||
DamagedSound: EXPLSML1.WAV
|
DamagedSounds: EXPLSML1.WAV
|
||||||
DestroyedSound: EXPLHG1.WAV
|
DestroyedSounds: EXPLHG1.WAV
|
||||||
RenderBuilding:
|
RenderBuilding:
|
||||||
WithBuildingExplosion:
|
WithBuildingExplosion:
|
||||||
RepairableBuilding:
|
RepairableBuilding:
|
||||||
@@ -331,3 +331,4 @@
|
|||||||
Range: 2c0, 5c0
|
Range: 2c0, 5c0
|
||||||
ScriptTriggers:
|
ScriptTriggers:
|
||||||
WithMakeAnimation:
|
WithMakeAnimation:
|
||||||
|
|
||||||
|
|||||||
@@ -465,8 +465,8 @@ wall:
|
|||||||
Prerequisites: barracks
|
Prerequisites: barracks
|
||||||
BuildPaletteOrder: 60
|
BuildPaletteOrder: 60
|
||||||
SoundOnDamageTransition:
|
SoundOnDamageTransition:
|
||||||
DamagedSound:
|
DamagedSounds:
|
||||||
DestroyedSound: EXPLSML4.WAV
|
DestroyedSounds: EXPLSML4.WAV
|
||||||
Valued:
|
Valued:
|
||||||
Cost: 100
|
Cost: 100
|
||||||
CustomSellValue:
|
CustomSellValue:
|
||||||
@@ -841,3 +841,4 @@ conyard.ordos:
|
|||||||
RenderBuilding:
|
RenderBuilding:
|
||||||
Image: conyard.ordos
|
Image: conyard.ordos
|
||||||
-RaceImages:
|
-RaceImages:
|
||||||
|
|
||||||
|
|||||||
@@ -383,8 +383,8 @@
|
|||||||
ExternalCapturable:
|
ExternalCapturable:
|
||||||
ExternalCapturableBar:
|
ExternalCapturableBar:
|
||||||
SoundOnDamageTransition:
|
SoundOnDamageTransition:
|
||||||
DamagedSound: kaboom1.aud
|
DamagedSounds: kaboom1.aud
|
||||||
DestroyedSound: kaboom22.aud
|
DestroyedSounds: kaboom22.aud
|
||||||
RenderBuilding:
|
RenderBuilding:
|
||||||
WithMakeAnimation:
|
WithMakeAnimation:
|
||||||
WithBuildingExplosion:
|
WithBuildingExplosion:
|
||||||
@@ -445,8 +445,8 @@
|
|||||||
Adjacent: 7
|
Adjacent: 7
|
||||||
TerrainTypes: Clear,Road
|
TerrainTypes: Clear,Road
|
||||||
SoundOnDamageTransition:
|
SoundOnDamageTransition:
|
||||||
DamagedSound: sandbag2.aud
|
DamagedSounds: sandbag2.aud
|
||||||
DestroyedSound: sandbag2.aud
|
DestroyedSounds: sandbag2.aud
|
||||||
Crushable:
|
Crushable:
|
||||||
CrushClasses: wall
|
CrushClasses: wall
|
||||||
BlocksBullets:
|
BlocksBullets:
|
||||||
|
|||||||
@@ -1533,8 +1533,8 @@ BRIK:
|
|||||||
Name: Concrete Wall
|
Name: Concrete Wall
|
||||||
Description: Stop units and blocks enemy fire.
|
Description: Stop units and blocks enemy fire.
|
||||||
SoundOnDamageTransition:
|
SoundOnDamageTransition:
|
||||||
DamagedSound: crmble2.aud
|
DamagedSounds: crmble2.aud
|
||||||
DestroyedSound: kaboom30.aud
|
DestroyedSounds: kaboom30.aud
|
||||||
Health:
|
Health:
|
||||||
HP: 500
|
HP: 500
|
||||||
Armor:
|
Armor:
|
||||||
|
|||||||
@@ -16,8 +16,8 @@
|
|||||||
GivesBuildableArea:
|
GivesBuildableArea:
|
||||||
Capturable:
|
Capturable:
|
||||||
SoundOnDamageTransition:
|
SoundOnDamageTransition:
|
||||||
DamagedSound: expnew01.aud
|
DamagedSounds: expnew01.aud
|
||||||
DestroyedSound: crmble2.aud
|
DestroyedSounds: crmble2.aud
|
||||||
RenderBuilding:
|
RenderBuilding:
|
||||||
WithBuildingExplosion:
|
WithBuildingExplosion:
|
||||||
RepairableBuilding:
|
RepairableBuilding:
|
||||||
@@ -84,8 +84,8 @@
|
|||||||
Adjacent: 7
|
Adjacent: 7
|
||||||
TerrainTypes: Clear, Road
|
TerrainTypes: Clear, Road
|
||||||
SoundOnDamageTransition:
|
SoundOnDamageTransition:
|
||||||
DamagedSound: expnew01.aud
|
DamagedSounds: expnew01.aud
|
||||||
DestroyedSound: crmble2.aud
|
DestroyedSounds: crmble2.aud
|
||||||
Crushable:
|
Crushable:
|
||||||
CrushClasses: wall
|
CrushClasses: wall
|
||||||
BlocksBullets:
|
BlocksBullets:
|
||||||
@@ -491,3 +491,4 @@
|
|||||||
Footprint: x
|
Footprint: x
|
||||||
Dimensions: 1, 1
|
Dimensions: 1, 1
|
||||||
BodyOrientation:
|
BodyOrientation:
|
||||||
|
|
||||||
|
|||||||
@@ -406,8 +406,8 @@ GASAND:
|
|||||||
BuildPaletteOrder: 1000
|
BuildPaletteOrder: 1000
|
||||||
Prerequisites: ~structures.gdi
|
Prerequisites: ~structures.gdi
|
||||||
SoundOnDamageTransition:
|
SoundOnDamageTransition:
|
||||||
DamagedSound: sandbag1.aud
|
DamagedSounds: sandbag1.aud
|
||||||
DestroyedSound: sandbag1.aud
|
DestroyedSounds: sandbag1.aud
|
||||||
Valued:
|
Valued:
|
||||||
Cost: 25
|
Cost: 25
|
||||||
CustomSellValue:
|
CustomSellValue:
|
||||||
@@ -433,8 +433,8 @@ GAWALL:
|
|||||||
BuildPaletteOrder: 1001
|
BuildPaletteOrder: 1001
|
||||||
Prerequisites: ~structures.gdi
|
Prerequisites: ~structures.gdi
|
||||||
SoundOnDamageTransition:
|
SoundOnDamageTransition:
|
||||||
DamagedSound:
|
DamagedSounds:
|
||||||
DestroyedSound:
|
DestroyedSounds:
|
||||||
Valued:
|
Valued:
|
||||||
Cost: 50
|
Cost: 50
|
||||||
CustomSellValue:
|
CustomSellValue:
|
||||||
@@ -458,8 +458,8 @@ NAWALL:
|
|||||||
BuildPaletteOrder: 1001
|
BuildPaletteOrder: 1001
|
||||||
Prerequisites: ~structures.nod
|
Prerequisites: ~structures.nod
|
||||||
SoundOnDamageTransition:
|
SoundOnDamageTransition:
|
||||||
DamagedSound:
|
DamagedSounds:
|
||||||
DestroyedSound:
|
DestroyedSounds:
|
||||||
Valued:
|
Valued:
|
||||||
Cost: 50
|
Cost: 50
|
||||||
CustomSellValue:
|
CustomSellValue:
|
||||||
|
|||||||
Reference in New Issue
Block a user