Adds footstep sound variety, makes diving and clown suits have unique footstep sounds!

https://puu.sh/yQ8fs/61e12f15c6.webm
TODO: Get rid of the "damagesoundtype" system and replace it with simple "tag" checking to allow customizability from content pack side
Fix damagemodifier sounds never being played (I've never once heard LimbArmor play on anything but mantis)
This commit is contained in:
Alex Noir
2017-12-29 17:41:18 +03:00
parent ed98a6bc0b
commit 2cb0ee73be
31 changed files with 118 additions and 34 deletions

View File

@@ -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)

View File

@@ -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;
}
}

View File

@@ -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;

View File

@@ -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)];
}

View File

@@ -1150,6 +1150,18 @@
<None Include="$(MSBuildThisFileDirectory)Content\Sounds\Damage\HitArmor3.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)Content\Sounds\Damage\HitClown1.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)Content\Sounds\Damage\HitClown2.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)Content\Sounds\Damage\HitClown3.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)Content\Sounds\Damage\HitClown4.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)Content\Sounds\Damage\implode.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
@@ -1216,6 +1228,45 @@
<None Include="$(MSBuildThisFileDirectory)Content\Sounds\firelarge.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)Content\Sounds\Footsteps\Armor\armor-01.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)Content\Sounds\Footsteps\Armor\armor-02.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)Content\Sounds\Footsteps\Armor\armor-03.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)Content\Sounds\Footsteps\Clown\clown-01.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)Content\Sounds\Footsteps\Clown\clown-02.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)Content\Sounds\Footsteps\Metal\metal-01.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)Content\Sounds\Footsteps\Metal\metal-02.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)Content\Sounds\Footsteps\Metal\metal-03.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)Content\Sounds\Footsteps\Metal\metal-04.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)Content\Sounds\Footsteps\Metal\metal-05.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)Content\Sounds\Footsteps\Metal\metal-06.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)Content\Sounds\Footsteps\Metal\metal-07.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)Content\Sounds\Footsteps\step.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)Content\Sounds\Music\amb_JD_drone_clattering_machine.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
@@ -1342,9 +1393,6 @@
<None Include="$(MSBuildThisFileDirectory)Content\Sounds\Water\WaterAmbience2.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)Content\step.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)Content\utg_4.xnb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>

View File

@@ -65,7 +65,7 @@
<limb id = "8" radius="5" height="13" mass = "2" type ="LeftFoot" flip="true" pullpos="-5.0,0.0">
<sprite texture="Content/Characters/Human/[GENDER]legs.png" sourcerect="35,53,16,25" depth="0.14" origin="0.5,0.5"/>
<damagedsprite texture="Content/Characters/Human/damagedlegs.png" sourcerect="35,53,16,25" origin="0.5,0.5"/>
<sound file ="Content/step.ogg"/>
<sound file ="footstep_metal"/>
</limb>
<!-- right leg -->
@@ -80,7 +80,7 @@
<limb id = "11" radius="5" height="13" mass = "2" type ="RightFoot" flip="true" pullpos="-5.0,0.0">
<sprite texture="Content/Characters/Human/[GENDER]legs.png" sourcerect="35,53,16,25" origin="0.5,0.5"/>
<damagedsprite texture="Content/Characters/Human/damagedlegs.png" sourcerect="35,53,16,25" origin="0.5,0.5"/>
<sound file ="Content/step.ogg"/>
<sound file ="footstep_metal"/>
</limb>
<!-- head to body -->

View File

@@ -73,7 +73,7 @@
<limb id = "8" radius="5" height="13" mass = "2" type ="LeftFoot" flip="true" pullpos="-5.0,0.0">
<sprite texture="Content/Characters/Human/[GENDER]legs.png" sourcerect="35,53,16,25" depth="0.14" origin="0.5,0.5"/>
<damagedsprite texture="Content/Characters/Human/damagedlegs.png" sourcerect="35,53,16,25" origin="0.5,0.5"/>
<sound file ="Content/step.ogg"/>
<sound file ="footstep_metal"/>
</limb>
<!-- right leg -->
@@ -88,7 +88,7 @@
<limb id = "11" radius="5" height="13" mass = "2" type ="RightFoot" flip="true" pullpos="-5.0,0.0">
<sprite texture="Content/Characters/Human/[GENDER]legs.png" sourcerect="35,53,16,25" origin="0.5,0.5"/>
<damagedsprite texture="Content/Characters/Human/damagedlegs.png" sourcerect="35,53,16,25" origin="0.5,0.5"/>
<sound file ="Content/step.ogg"/>
<sound file ="footstep_metal"/>
</limb>

View File

@@ -76,7 +76,7 @@
</limb>
<limb id = "8" radius="5" height="13" mass = "2" type ="LeftFoot" flip="true" pullpos="-5.0,0.0">
<sprite texture="Content/Characters/Husk/legs.png" sourcerect="35,53,16,25" depth="0.14" origin="0.5,0.5"/>
<sound file ="Content/step.ogg"/>
<sound file ="footstep_armor"/>
</limb>
<!-- right leg -->
@@ -88,7 +88,7 @@
</limb>
<limb id = "11" radius="5" height="13" mass = "2" type ="RightFoot" flip="true" pullpos="-5.0,0.0">
<sprite texture="Content/Characters/Husk/legs.png" sourcerect="35,53,16,25" origin="0.5,0.5"/>
<sound file ="Content/step.ogg"/>
<sound file ="footstep_armor"/>
</limb>
<!-- head to body -->

View File

@@ -97,8 +97,8 @@
<sprite texture="DivingSuit.png" limb="RightLeg" sourcerect="17,47,21,51" origin="0.5,0.55" hidelimb="true"/>
<sprite texture="DivingSuit.png" limb="LeftLeg" sourcerect="17,47,21,51" origin="0.5,0.55" hidelimb="true"/>
<sprite texture="DivingSuit.png" limb="RightFoot" sourcerect="30,100,20,25" origin="0.5,0.5" depth="0.13" inheritlimbdepth="false" hidelimb="true"/>
<sprite texture="DivingSuit.png" limb="LeftFoot" sourcerect="30,100,20,25" origin="0.5,0.5" depth="0.13" inheritlimbdepth="false" hidelimb="true"/>
<sprite texture="DivingSuit.png" limb="RightFoot" sound="footstep_armor" sourcerect="30,100,20,25" origin="0.5,0.5" depth="0.13" inheritlimbdepth="false" hidelimb="true"/>
<sprite texture="DivingSuit.png" limb="LeftFoot" sound="footstep_armor" sourcerect="30,100,20,25" origin="0.5,0.5" depth="0.13" inheritlimbdepth="false" hidelimb="true"/>
<StatusEffect type="OnWearing" target="Character" HideFace="true" ObstructVision="true" PressureProtection="100.0" SpeedMultiplier="0.6" LowPassMultiplier="0.2" setvalue="true" disabledeltatime="true"/>
<StatusEffect type="OnWearing" target="Contained,Character" OxygenAvailable="1000.0" Condition="-0.5">

View File

@@ -84,9 +84,13 @@
<sprite texture="clownpants.png" limb="RightLeg" sourcerect="37,0,28,52" origin="0.55,0.5" depth="0.11" hidelimb="true"/>
<sprite texture="clownpants.png" limb="LeftLeg" sourcerect="37,0,28,52" origin="0.55,0.5" depth="0.15" hidelimb="true"/>
<sprite texture="clownpants.png" limb="RightFoot" sourcerect="65,41,15,39" origin="0.5,0.35" depth="0.11" hidelimb="true"/>
<sprite texture="clownpants.png" limb="LeftFoot" sourcerect="65,41,15,39" origin="0.5,0.35" depth="0.15" hidelimb="true"/>
<sprite texture="clownpants.png" limb="RightFoot" sound="footstep_clown" sourcerect="65,41,15,39" origin="0.5,0.35" depth="0.11" hidelimb="true"/>
<sprite texture="clownpants.png" limb="LeftFoot" sound="footstep_clown" sourcerect="65,41,15,39" origin="0.5,0.35" depth="0.15" hidelimb="true"/>
<!-- HENK -->
<!-- DamageSound isn't played, not even for diving suits/ballistic helmet/armor. Needs looking into.
<damagemodifier damagetype="Blunt" armorsector="0.0,360.0" damagemultiplier="1.2" damagesound="LimbClown"/>
<damagemodifier damagetype="Slash" armorsector="0.0,360.0" damagemultiplier="1.2" damagesound="LimbClown"/> -->
</Wearable>
</Item>
</Items>

View File

@@ -38,7 +38,11 @@
<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/HitClown1.ogg" damagerange="0.0,40.0" damagesoundtype="LimbClown"/>
<damagesound file="Content/Sounds/Damage/HitClown1.ogg" damagerange="0.0,40.0" damagesoundtype="LimbClown"/>
<damagesound file="Content/Sounds/Damage/HitClown3.ogg" damagerange="25.0,75.0" damagesoundtype="LimbClown"/>
<damagesound file="Content/Sounds/Damage/HitClown3.ogg" damagerange="50.0,100.0" damagesoundtype="LimbClown"/>
<damagesound file="Content/Sounds/Damage/creak1.ogg" damagesoundtype="Pressure"/>
<damagesound file="Content/Sounds/Damage/creak2.ogg" damagesoundtype="Pressure"/>
@@ -52,6 +56,22 @@
<drown file="Content/Sounds/Water/Drown3.ogg"/>
<drown file="Content/Sounds/Water/Drown4.ogg"/>
<footstep file="Content/Sounds/Footsteps/step.ogg"/>
<footstep_metal file="Content/Sounds/Footsteps/Metal/metal-01.ogg"/>
<footstep_metal file="Content/Sounds/Footsteps/Metal/metal-02.ogg"/>
<footstep_metal file="Content/Sounds/Footsteps/Metal/metal-03.ogg"/>
<footstep_metal file="Content/Sounds/Footsteps/Metal/metal-04.ogg"/>
<footstep_metal file="Content/Sounds/Footsteps/Metal/metal-05.ogg"/>
<footstep_metal file="Content/Sounds/Footsteps/Metal/metal-06.ogg"/>
<footstep_metal file="Content/Sounds/Footsteps/Metal/metal-07.ogg"/>
<footstep_armor file="Content/Sounds/Footsteps/Armor/armor-01.ogg"/>
<footstep_armor file="Content/Sounds/Footsteps/Armor/armor-02.ogg"/>
<footstep_armor file="Content/Sounds/Footsteps/Armor/armor-03.ogg"/>
<footstep_clown file="Content/Sounds/Footsteps/Clown/clown-01.ogg"/>
<footstep_clown file="Content/Sounds/Footsteps/Clown/clown-02.ogg"/>
<ambient file="Content/Sounds/Ambient/Ambient1.ogg"/>
<ambient file="Content/Sounds/Ambient/Ambient2.ogg"/>
<ambient file="Content/Sounds/Ambient/Ambient3.ogg"/>

View File

@@ -534,12 +534,6 @@ namespace Barotrauma
}
#if CLIENT
if (hitSound != null)
{
hitSound.Remove();
hitSound = null;
}
if (LightSource != null)
{
LightSource.Remove();

View File

@@ -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 ">":

View File

@@ -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":