Option to configure damage sounds for structures with a specific tag, some new sounds
This commit is contained in:
@@ -1462,6 +1462,24 @@
|
||||
<None Include="Content\Sounds\firelarge.ogg">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Content\Sounds\Damage\GlassBreak1.ogg">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Content\Sounds\Damage\GlassBreak2.ogg">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Content\Sounds\Damage\GlassBreak3.ogg">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Content\Sounds\Damage\GlassImpact1.ogg">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Content\Sounds\Damage\GlassImpact2.ogg">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Content\Sounds\Damage\GlassImpact3.ogg">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Content\Sounds\Music\amb_JD_drone_clattering_machine.ogg">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -108,22 +108,22 @@
|
||||
<sprite texture="Content/Map/testroom.png" sourcerect="550,804,24,96" depth = "0.85" />
|
||||
</CableHolderVertical>
|
||||
|
||||
<topwindow width="128" height="49" body="true" health="100">
|
||||
<topwindow width="128" height="49" body="true" health="100" tags="glass">
|
||||
<sprite texture="Content/Map/testroom.png" sourcerect="208,848,128,80" depth ="0.05"/>
|
||||
<backgroundsprite texture="Content/Map/testroom.png" sourcerect="344,848,128,80" depth ="0.85"/>
|
||||
</topwindow>
|
||||
|
||||
<verticalwindow width="128" height ="224" body="true" health="100">
|
||||
<verticalwindow width="128" height ="224" body="true" health="100" tags="glass">
|
||||
<sprite texture="Content/Map/testroom.png" sourcerect="368,544,128,224" depth ="0.05"/>
|
||||
<backgroundsprite texture="Content/Map/testroom.png" sourcerect="239,544,128,224" depth ="0.85"/>
|
||||
</verticalwindow>
|
||||
|
||||
<horizontalresizablewindow width="128" height ="64" body="true" health="100" resizehorizontal="true">
|
||||
<horizontalresizablewindow width="128" height ="64" body="true" health="100" tags="glass" resizehorizontal="true">
|
||||
<sprite texture="Content/Map/testroom.png" sourcerect="207,771,128,64" depth ="0.06"/>
|
||||
<backgroundsprite texture="Content/Map/testroom.png" sourcerect="337,771,128,64" depth ="0.85"/>
|
||||
</horizontalresizablewindow>
|
||||
|
||||
<verticalresizablewindow width = "64" height ="128" body="true" health="100" resizevertical="true">
|
||||
<verticalresizablewindow width = "64" height ="128" body="true" health="100" tags="glass" resizevertical="true">
|
||||
<sprite texture="Content/Map/testroom.png" sourcerect="896,80,64,128" depth ="0.06"/>
|
||||
<backgroundsprite texture="Content/Map/testroom.png" sourcerect="961,80,64,128" depth ="0.85"/>
|
||||
</verticalresizablewindow>
|
||||
|
||||
BIN
Subsurface/Content/Sounds/Damage/GlassBreak1.ogg
Normal file
BIN
Subsurface/Content/Sounds/Damage/GlassBreak1.ogg
Normal file
Binary file not shown.
BIN
Subsurface/Content/Sounds/Damage/GlassBreak2.ogg
Normal file
BIN
Subsurface/Content/Sounds/Damage/GlassBreak2.ogg
Normal file
Binary file not shown.
BIN
Subsurface/Content/Sounds/Damage/GlassBreak3.ogg
Normal file
BIN
Subsurface/Content/Sounds/Damage/GlassBreak3.ogg
Normal file
Binary file not shown.
BIN
Subsurface/Content/Sounds/Damage/GlassImpact1.ogg
Normal file
BIN
Subsurface/Content/Sounds/Damage/GlassImpact1.ogg
Normal file
Binary file not shown.
BIN
Subsurface/Content/Sounds/Damage/GlassImpact2.ogg
Normal file
BIN
Subsurface/Content/Sounds/Damage/GlassImpact2.ogg
Normal file
Binary file not shown.
BIN
Subsurface/Content/Sounds/Damage/GlassImpact3.ogg
Normal file
BIN
Subsurface/Content/Sounds/Damage/GlassImpact3.ogg
Normal file
Binary file not shown.
@@ -10,7 +10,14 @@
|
||||
<damagesound file="Content/Sounds/Damage/StructureBlunt8.ogg" damagerange="60.0,90.0" damagesoundtype="StructureBlunt"/>
|
||||
<damagesound file="Content/Sounds/Damage/StructureBlunt9.ogg" damagerange="80.0,100.0" damagesoundtype="StructureBlunt"/>
|
||||
<damagesound file="Content/Sounds/Damage/StructureBlunt10.ogg" damagerange="80.0,100.0" damagesoundtype="StructureBlunt"/>
|
||||
|
||||
|
||||
<damagesound file="Content/Sounds/Damage/GlassImpact1.ogg" damagerange="0.0,10.0" damagesoundtype="StructureBlunt" requiredtag="glass"/>
|
||||
<damagesound file="Content/Sounds/Damage/GlassImpact2.ogg" damagerange="5.0,15.0" damagesoundtype="StructureBlunt" requiredtag="glass"/>
|
||||
<damagesound file="Content/Sounds/Damage/GlassImpact3.ogg" damagerange="10.0,20.0" damagesoundtype="StructureBlunt" requiredtag="glass"/>
|
||||
|
||||
<damagesound file="Content/Sounds/Damage/GlassBreak1.ogg" damagerange="20.0,50.0" damagesoundtype="StructureBlunt" requiredtag="glass"/>
|
||||
<damagesound file="Content/Sounds/Damage/GlassBreak1.ogg" damagerange="25.0,80.0" damagesoundtype="StructureBlunt" requiredtag="glass"/>
|
||||
<damagesound file="Content/Sounds/Damage/GlassBreak1.ogg" damagerange="50.0,100.0" damagesoundtype="StructureBlunt" requiredtag="glass"/>
|
||||
|
||||
<damagesound file="Content/Sounds/Damage/StructureCrunch1.ogg" damagerange="0.0,40.0" damagesoundtype="StructureSlash"/>
|
||||
<damagesound file="Content/Sounds/Damage/StructureCrunch2.ogg" damagerange="5.0,70.0" damagesoundtype="StructureSlash"/>
|
||||
@@ -30,7 +37,8 @@
|
||||
|
||||
<damagesound file="Content/Sounds/Damage/HitArmor1.ogg" damagerange="5.0,80.0" damagesoundtype="LimbArmor"/>
|
||||
<damagesound file="Content/Sounds/Damage/HitArmor2.ogg" damagerange="5.0,80.0" damagesoundtype="LimbArmor"/>
|
||||
<damagesound file="Content/Sounds/Damage/HitArmor3.ogg" damagerange="40.0,100.0" damagesoundtype="LimbArmor"/>
|
||||
<damagesound file="Content/Sounds/Damage/HitArmor3.ogg" damagerange="40.0,100.0" damagesoundtype="LimbArmor"/>
|
||||
|
||||
|
||||
<damagesound file="Content/Sounds/Damage/creak1.ogg" damagesoundtype="Pressure"/>
|
||||
<damagesound file="Content/Sounds/Damage/creak2.ogg" damagesoundtype="Pressure"/>
|
||||
|
||||
@@ -142,11 +142,12 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public static void RangedStructureDamage(Vector2 worldPosition, float worldRange, float damage)
|
||||
/// <summary>
|
||||
/// Returns a dictionary where the keys are the structures that took damage and the values are the amount of damage taken
|
||||
/// </summary>
|
||||
public static Dictionary<Structure,float> RangedStructureDamage(Vector2 worldPosition, float worldRange, float damage)
|
||||
{
|
||||
List<Structure> structureList = new List<Structure>();
|
||||
|
||||
|
||||
List<Structure> structureList = new List<Structure>();
|
||||
float dist = 600.0f;
|
||||
foreach (MapEntity entity in MapEntity.mapEntityList)
|
||||
{
|
||||
@@ -161,14 +162,28 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
Dictionary<Structure, float> damagedStructures = new Dictionary<Structure, float>();
|
||||
foreach (Structure structure in structureList)
|
||||
{
|
||||
for (int i = 0; i < structure.SectionCount; i++)
|
||||
{
|
||||
float distFactor = 1.0f - (Vector2.Distance(structure.SectionPosition(i, true), worldPosition) / worldRange);
|
||||
if (distFactor > 0.0f) structure.AddDamage(i, damage * distFactor);
|
||||
}
|
||||
if (distFactor <= 0.0f) continue;
|
||||
|
||||
structure.AddDamage(i, damage * distFactor);
|
||||
|
||||
if (damagedStructures.ContainsKey(structure))
|
||||
{
|
||||
damagedStructures[structure] += damage * distFactor;
|
||||
}
|
||||
else
|
||||
{
|
||||
damagedStructures.Add(structure, damage * distFactor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return damagedStructures;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,6 +151,11 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public List<string> Tags
|
||||
{
|
||||
get { return prefab.tags; }
|
||||
}
|
||||
|
||||
public override Rectangle Rect
|
||||
{
|
||||
get
|
||||
|
||||
@@ -85,22 +85,9 @@ namespace Barotrauma
|
||||
{
|
||||
StructurePrefab sp = new StructurePrefab();
|
||||
sp.name = element.Name.ToString();
|
||||
|
||||
//Vector4 sourceVector = ToolBox.GetAttributeVector4(element, "sourcerect", new Vector4(0,0,1,1));
|
||||
|
||||
//Rectangle sourceRect = new Rectangle(
|
||||
// (int)sourceVector.X,
|
||||
// (int)sourceVector.Y,
|
||||
// (int)sourceVector.Z,
|
||||
// (int)sourceVector.W);
|
||||
|
||||
//if (element.Attribute("sprite") != null)
|
||||
//{
|
||||
// sp.sprite = new Sprite(element.Attribute("sprite").Value, sourceRect, Vector2.Zero);
|
||||
|
||||
// sp.sprite.Depth = ToolBox.GetAttributeFloat(element, "depth", 0.0f);
|
||||
|
||||
//}
|
||||
sp.tags = new List<string>();
|
||||
sp.tags.AddRange(ToolBox.GetAttributeString(element, "tags", "").Split(','));
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
|
||||
@@ -492,8 +492,6 @@ namespace Barotrauma
|
||||
|
||||
Vector2 lastContactPoint = worldPoints[0];
|
||||
|
||||
SoundPlayer.PlayDamageSound(DamageSoundType.StructureBlunt, impact * 10.0f, ConvertUnits.ToDisplayUnits(lastContactPoint));
|
||||
|
||||
if (Character.Controlled != null && Character.Controlled.Submarine == submarine)
|
||||
{
|
||||
GameMain.GameScreen.Cam.Shake = impact * 2.0f;
|
||||
@@ -526,7 +524,29 @@ namespace Barotrauma
|
||||
item.body.ApplyLinearImpulse(item.body.Mass * impulse);
|
||||
}
|
||||
|
||||
Explosion.RangedStructureDamage(ConvertUnits.ToDisplayUnits(lastContactPoint), impact * 50.0f, impact * DamageMultiplier);
|
||||
var damagedStructures = Explosion.RangedStructureDamage(ConvertUnits.ToDisplayUnits(lastContactPoint), impact * 50.0f, impact * DamageMultiplier);
|
||||
|
||||
//play a damage sound for the structure that took the most damage
|
||||
float maxDamage = 0.0f;
|
||||
Structure maxDamageStructure = null;
|
||||
foreach (KeyValuePair<Structure,float> structureDamage in damagedStructures)
|
||||
{
|
||||
if (maxDamageStructure == null || structureDamage.Value > maxDamage)
|
||||
{
|
||||
maxDamage = structureDamage.Value;
|
||||
maxDamageStructure = structureDamage.Key;
|
||||
}
|
||||
}
|
||||
|
||||
if (maxDamageStructure != null)
|
||||
{
|
||||
SoundPlayer.PlayDamageSound(
|
||||
DamageSoundType.StructureBlunt,
|
||||
impact * 10.0f,
|
||||
ConvertUnits.ToDisplayUnits(lastContactPoint),
|
||||
MathHelper.Clamp(maxDamage * 4.0f, 1000.0f, 4000.0f),
|
||||
maxDamageStructure.Tags);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,11 +28,15 @@ namespace Barotrauma
|
||||
|
||||
public readonly Sound sound;
|
||||
|
||||
public DamageSound(Sound sound, Vector2 damageRange, DamageSoundType damageType)
|
||||
public readonly string requiredTag;
|
||||
|
||||
public DamageSound(Sound sound, Vector2 damageRange, DamageSoundType damageType, string requiredTag = "")
|
||||
{
|
||||
this.sound = sound;
|
||||
this.damageRange = damageRange;
|
||||
this.damageType = damageType;
|
||||
|
||||
this.requiredTag = requiredTag;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,10 +158,13 @@ namespace Barotrauma
|
||||
if (damageSound == null) continue;
|
||||
|
||||
DamageSoundType damageSoundType = DamageSoundType.None;
|
||||
|
||||
Enum.TryParse<DamageSoundType>(ToolBox.GetAttributeString(subElement, "damagesoundtype", "None"), false, out damageSoundType);
|
||||
|
||||
damageSounds.Add(new DamageSound(
|
||||
damageSound, ToolBox.GetAttributeVector2(subElement, "damagerange", new Vector2(0.0f, 100.0f)), damageSoundType));
|
||||
damageSound,
|
||||
ToolBox.GetAttributeVector2(subElement, "damagerange", new Vector2(0.0f, 100.0f)),
|
||||
damageSoundType,
|
||||
ToolBox.GetAttributeString(subElement, "requiredtag", "")));
|
||||
|
||||
break;
|
||||
default:
|
||||
@@ -390,10 +397,15 @@ namespace Barotrauma
|
||||
PlayDamageSound(damageType, damage, bodyPosition, 800.0f);
|
||||
}
|
||||
|
||||
public static void PlayDamageSound(DamageSoundType damageType, float damage, Vector2 position, float range = 2000.0f)
|
||||
public static void PlayDamageSound(DamageSoundType damageType, float damage, Vector2 position, float range = 2000.0f, List<string> tags = null)
|
||||
{
|
||||
damage = MathHelper.Clamp(damage+Rand.Range(-10.0f, 10.0f), 0.0f, 100.0f);
|
||||
var sounds = damageSounds.Where(x => damage >= x.damageRange.X && damage <= x.damageRange.Y && x.damageType == damageType).ToList();
|
||||
var sounds = damageSounds.FindAll(s =>
|
||||
damage >= s.damageRange.X &&
|
||||
damage <= s.damageRange.Y &&
|
||||
s.damageType == damageType &&
|
||||
(string.IsNullOrEmpty(s.requiredTag) || (tags != null && tags.Contains(s.requiredTag))));
|
||||
|
||||
if (!sounds.Any()) return;
|
||||
|
||||
int selectedSound = Rand.Int(sounds.Count);
|
||||
|
||||
Reference in New Issue
Block a user