diff --git a/Barotrauma/BarotraumaClient/Source/Characters/Animation/Ragdoll.cs b/Barotrauma/BarotraumaClient/Source/Characters/Animation/Ragdoll.cs index 17f75eb98..14edcee1e 100644 --- a/Barotrauma/BarotraumaClient/Source/Characters/Animation/Ragdoll.cs +++ b/Barotrauma/BarotraumaClient/Source/Characters/Animation/Ragdoll.cs @@ -1,4 +1,5 @@ -using FarseerPhysics; +using Barotrauma.Items.Components; +using FarseerPhysics; using FarseerPhysics.Dynamics; using FarseerPhysics.Dynamics.Joints; using Microsoft.Xna.Framework; @@ -20,7 +21,12 @@ namespace Barotrauma if (impact > 3.0f && limb.HitSound != null && limb.SoundTimer <= 0.0f) { limb.SoundTimer = Limb.SoundInterval; - limb.HitSound.Play(volume, impact * 100.0f, limb.WorldPosition); + SoundPlayer.PlaySound(limb.HitSound, volume, impact * 100.0f, limb.WorldPosition); + foreach(WearableSprite wearable in limb.WearingItems) + { + if (limb.type == wearable.Limb && wearable.Sound != null) + SoundPlayer.PlaySound(wearable.Sound, volume, impact * 100.0f, limb.WorldPosition); + } } } else if (body.UserData is Limb || body == Collider.FarseerBody) diff --git a/Barotrauma/BarotraumaClient/Source/Characters/Limb.cs b/Barotrauma/BarotraumaClient/Source/Characters/Limb.cs index 237dcfa98..37552200d 100644 --- a/Barotrauma/BarotraumaClient/Source/Characters/Limb.cs +++ b/Barotrauma/BarotraumaClient/Source/Characters/Limb.cs @@ -17,9 +17,9 @@ namespace Barotrauma private set; } - Sound hitSound; + string hitSound; - public Sound HitSound + public string HitSound { get { return hitSound; } } @@ -34,7 +34,7 @@ namespace Barotrauma LightSource = new LightSource(subElement); break; case "sound": - hitSound = Sound.Load(subElement.GetAttributeString("file", "")); + hitSound = subElement.GetAttributeString("file", ""); break; } } diff --git a/Barotrauma/BarotraumaClient/Source/Sounds/Sound.cs b/Barotrauma/BarotraumaClient/Source/Sounds/Sound.cs index c1dd80996..34ebeb3d3 100644 --- a/Barotrauma/BarotraumaClient/Source/Sounds/Sound.cs +++ b/Barotrauma/BarotraumaClient/Source/Sounds/Sound.cs @@ -87,6 +87,10 @@ namespace Barotrauma DebugConsole.ThrowError("File \"" + file + "\" not found!"); return null; } + + Sound dupe = Sound.loadedSounds.Find(s => s.filePath == file); + if (dupe != null) + return dupe; return new Sound(file, destroyOnGameEnd); } @@ -100,6 +104,9 @@ namespace Barotrauma { newSound.baseVolume = element.GetAttributeFloat("volume", 1.0f); newSound.range = element.GetAttributeFloat("range", 1000.0f); + Sound dupe = Sound.loadedSounds.Find(s => s.filePath == filePath && s.baseVolume == newSound.baseVolume && s.range == newSound.range); + if (dupe != null) + return dupe; } return newSound; diff --git a/Barotrauma/BarotraumaClient/Source/Sounds/SoundPlayer.cs b/Barotrauma/BarotraumaClient/Source/Sounds/SoundPlayer.cs index 9f7055eae..0bc96bace 100644 --- a/Barotrauma/BarotraumaClient/Source/Sounds/SoundPlayer.cs +++ b/Barotrauma/BarotraumaClient/Source/Sounds/SoundPlayer.cs @@ -271,7 +271,7 @@ namespace Barotrauma public static Sound GetSound(string soundTag) { var matchingSounds = miscSounds[soundTag].ToList(); - if (matchingSounds.Count == 0) return null; + if (matchingSounds.Count == 0) return Sound.Load(soundTag); return matchingSounds[Rand.Int(matchingSounds.Count)]; } diff --git a/Barotrauma/BarotraumaShared/BarotraumaShared.projitems b/Barotrauma/BarotraumaShared/BarotraumaShared.projitems index 73d4912a1..461ba8e9a 100644 --- a/Barotrauma/BarotraumaShared/BarotraumaShared.projitems +++ b/Barotrauma/BarotraumaShared/BarotraumaShared.projitems @@ -1150,6 +1150,18 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + PreserveNewest @@ -1216,6 +1228,45 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + PreserveNewest @@ -1342,9 +1393,6 @@ PreserveNewest - - PreserveNewest - PreserveNewest diff --git a/Barotrauma/BarotraumaShared/Content/Characters/Human/human.xml b/Barotrauma/BarotraumaShared/Content/Characters/Human/human.xml index 8cd39e6fd..929e6f009 100644 --- a/Barotrauma/BarotraumaShared/Content/Characters/Human/human.xml +++ b/Barotrauma/BarotraumaShared/Content/Characters/Human/human.xml @@ -65,7 +65,7 @@ - + @@ -80,7 +80,7 @@ - + diff --git a/Barotrauma/BarotraumaShared/Content/Characters/Human/humanhusk.xml b/Barotrauma/BarotraumaShared/Content/Characters/Human/humanhusk.xml index 33e8bad60..ae252d2e7 100644 --- a/Barotrauma/BarotraumaShared/Content/Characters/Human/humanhusk.xml +++ b/Barotrauma/BarotraumaShared/Content/Characters/Human/humanhusk.xml @@ -73,7 +73,7 @@ - + @@ -88,7 +88,7 @@ - + diff --git a/Barotrauma/BarotraumaShared/Content/Characters/Husk/husk.xml b/Barotrauma/BarotraumaShared/Content/Characters/Husk/husk.xml index c79e29116..a94590bd6 100644 --- a/Barotrauma/BarotraumaShared/Content/Characters/Husk/husk.xml +++ b/Barotrauma/BarotraumaShared/Content/Characters/Husk/husk.xml @@ -76,7 +76,7 @@ - + @@ -88,7 +88,7 @@ - + diff --git a/Barotrauma/BarotraumaShared/Content/Items/Diving/divinggear.xml b/Barotrauma/BarotraumaShared/Content/Items/Diving/divinggear.xml index 05256665b..5a764f80c 100644 --- a/Barotrauma/BarotraumaShared/Content/Items/Diving/divinggear.xml +++ b/Barotrauma/BarotraumaShared/Content/Items/Diving/divinggear.xml @@ -97,8 +97,8 @@ - - + + diff --git a/Barotrauma/BarotraumaShared/Content/Items/Jobgear/misc.xml b/Barotrauma/BarotraumaShared/Content/Items/Jobgear/misc.xml index 26ac6fc54..efd6af51d 100644 --- a/Barotrauma/BarotraumaShared/Content/Items/Jobgear/misc.xml +++ b/Barotrauma/BarotraumaShared/Content/Items/Jobgear/misc.xml @@ -84,9 +84,13 @@ - - + + + + diff --git a/Barotrauma/BarotraumaShared/Content/Sounds/Damage/HitClown1.ogg b/Barotrauma/BarotraumaShared/Content/Sounds/Damage/HitClown1.ogg new file mode 100644 index 000000000..f38004a88 Binary files /dev/null and b/Barotrauma/BarotraumaShared/Content/Sounds/Damage/HitClown1.ogg differ diff --git a/Barotrauma/BarotraumaShared/Content/Sounds/Damage/HitClown2.ogg b/Barotrauma/BarotraumaShared/Content/Sounds/Damage/HitClown2.ogg new file mode 100644 index 000000000..81ff5864b Binary files /dev/null and b/Barotrauma/BarotraumaShared/Content/Sounds/Damage/HitClown2.ogg differ diff --git a/Barotrauma/BarotraumaShared/Content/Sounds/Damage/HitClown3.ogg b/Barotrauma/BarotraumaShared/Content/Sounds/Damage/HitClown3.ogg new file mode 100644 index 000000000..210e633a1 Binary files /dev/null and b/Barotrauma/BarotraumaShared/Content/Sounds/Damage/HitClown3.ogg differ diff --git a/Barotrauma/BarotraumaShared/Content/Sounds/Damage/HitClown4.ogg b/Barotrauma/BarotraumaShared/Content/Sounds/Damage/HitClown4.ogg new file mode 100644 index 000000000..8d0294b86 Binary files /dev/null and b/Barotrauma/BarotraumaShared/Content/Sounds/Damage/HitClown4.ogg differ diff --git a/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Armor/armor-01.ogg b/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Armor/armor-01.ogg new file mode 100644 index 000000000..8ef4ceda7 Binary files /dev/null and b/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Armor/armor-01.ogg differ diff --git a/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Armor/armor-02.ogg b/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Armor/armor-02.ogg new file mode 100644 index 000000000..b37028ebd Binary files /dev/null and b/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Armor/armor-02.ogg differ diff --git a/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Armor/armor-03.ogg b/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Armor/armor-03.ogg new file mode 100644 index 000000000..9db560df8 Binary files /dev/null and b/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Armor/armor-03.ogg differ diff --git a/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Clown/clown-01.ogg b/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Clown/clown-01.ogg new file mode 100644 index 000000000..13dc7da09 Binary files /dev/null and b/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Clown/clown-01.ogg differ diff --git a/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Clown/clown-02.ogg b/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Clown/clown-02.ogg new file mode 100644 index 000000000..e6b473665 Binary files /dev/null and b/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Clown/clown-02.ogg differ diff --git a/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Metal/metal-01.ogg b/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Metal/metal-01.ogg new file mode 100644 index 000000000..df55e6444 Binary files /dev/null and b/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Metal/metal-01.ogg differ diff --git a/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Metal/metal-02.ogg b/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Metal/metal-02.ogg new file mode 100644 index 000000000..eb4d0b74d Binary files /dev/null and b/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Metal/metal-02.ogg differ diff --git a/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Metal/metal-03.ogg b/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Metal/metal-03.ogg new file mode 100644 index 000000000..f2bd383dd Binary files /dev/null and b/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Metal/metal-03.ogg differ diff --git a/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Metal/metal-04.ogg b/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Metal/metal-04.ogg new file mode 100644 index 000000000..1011a26d5 Binary files /dev/null and b/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Metal/metal-04.ogg differ diff --git a/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Metal/metal-05.ogg b/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Metal/metal-05.ogg new file mode 100644 index 000000000..9662054dc Binary files /dev/null and b/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Metal/metal-05.ogg differ diff --git a/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Metal/metal-06.ogg b/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Metal/metal-06.ogg new file mode 100644 index 000000000..2ee071ba8 Binary files /dev/null and b/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Metal/metal-06.ogg differ diff --git a/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Metal/metal-07.ogg b/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Metal/metal-07.ogg new file mode 100644 index 000000000..318070139 Binary files /dev/null and b/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/Metal/metal-07.ogg differ diff --git a/Barotrauma/BarotraumaShared/Content/step.ogg b/Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/step.ogg similarity index 100% rename from Barotrauma/BarotraumaShared/Content/step.ogg rename to Barotrauma/BarotraumaShared/Content/Sounds/Footsteps/step.ogg diff --git a/Barotrauma/BarotraumaShared/Content/Sounds/sounds.xml b/Barotrauma/BarotraumaShared/Content/Sounds/sounds.xml index d4156d5d9..d065c575b 100644 --- a/Barotrauma/BarotraumaShared/Content/Sounds/sounds.xml +++ b/Barotrauma/BarotraumaShared/Content/Sounds/sounds.xml @@ -38,7 +38,11 @@ - + + + + + @@ -52,6 +56,22 @@ + + + + + + + + + + + + + + + + diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Limb.cs b/Barotrauma/BarotraumaShared/Source/Characters/Limb.cs index c0d435e75..a130ddb68 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Limb.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Limb.cs @@ -534,12 +534,6 @@ namespace Barotrauma } #if CLIENT - if (hitSound != null) - { - hitSound.Remove(); - hitSound = null; - } - if (LightSource != null) { LightSource.Remove(); diff --git a/Barotrauma/BarotraumaShared/Source/Characters/StatusEffect.cs b/Barotrauma/BarotraumaShared/Source/Characters/StatusEffect.cs index 3114b148a..16655024c 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/StatusEffect.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/StatusEffect.cs @@ -49,11 +49,11 @@ namespace Barotrauma switch (Operator) { case "==": - if (property.GetValue().Equals(floatValue == null ? floatValue : Value)) + if (property.GetValue().Equals(floatValue == null ? Value : floatValue)) return true; break; case "!=": - if (property.GetValue().Equals(floatValue == null ? floatValue : Value)) + if (property.GetValue().Equals(floatValue == null ? Value : floatValue)) return true; break; case ">": diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Wearable.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Wearable.cs index 168387bc8..41bd2b074 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Wearable.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Wearable.cs @@ -10,19 +10,23 @@ namespace Barotrauma.Items.Components class WearableSprite { public readonly Sprite Sprite; + public readonly LimbType Limb; public readonly bool HideLimb; public readonly bool InheritLimbDepth; public readonly LimbType DepthLimb; public readonly Wearable WearableComponent; + public readonly string Sound; - public WearableSprite(Wearable item, Sprite sprite, bool hideLimb, bool inheritLimbDepth = true, LimbType depthLimb = LimbType.None) + public WearableSprite(Wearable item, Sprite sprite, LimbType limb, bool hideLimb, bool inheritLimbDepth = true, LimbType depthLimb = LimbType.None, string sound = null) { WearableComponent = item; Sprite = sprite; + Limb = limb; HideLimb = hideLimb; InheritLimbDepth = inheritLimbDepth; DepthLimb = depthLimb; + Sound = sound; } } @@ -66,15 +70,16 @@ namespace Barotrauma.Items.Components string spritePath = subElement.Attribute("texture").Value; spritePath = Path.GetDirectoryName(item.Prefab.ConfigFile) + "/" + spritePath; + var sound = subElement.GetAttributeString("sound", ""); var sprite = new Sprite(subElement, "", spritePath); - wearableSprites[i] = new WearableSprite(this, sprite, - subElement.GetAttributeBool("hidelimb", false), - subElement.GetAttributeBool("inheritlimbdepth", true), - (LimbType)Enum.Parse(typeof(LimbType), subElement.GetAttributeString("depthlimb", "None"), true)); - limbType[i] = (LimbType)Enum.Parse(typeof(LimbType), subElement.GetAttributeString("limb", "Head"), true); + wearableSprites[i] = new WearableSprite(this, sprite, limbType[i], + subElement.GetAttributeBool("hidelimb", false), + subElement.GetAttributeBool("inheritlimbdepth", true), + (LimbType)Enum.Parse(typeof(LimbType), subElement.GetAttributeString("depthlimb", "None"), true), sound); + i++; break; case "damagemodifier":