- The range and volume of sounds emitted by StatusEffects can be changed and they can be set to loop.

- StatusEffect sounds are configured as child elements of the StatusEffect (instead of attributes).
- Background sprites can emit sounds.
This commit is contained in:
Joonas Rikkonen
2017-08-24 19:56:31 +03:00
parent 7186a8010a
commit 4bdbf05875
23 changed files with 218 additions and 112 deletions
@@ -1228,6 +1228,9 @@
<None Include="$(MSBuildThisFileDirectory)Content\Sounds\UI\UImsg.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)Content\Sounds\Water\BlackSmoker.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)Content\Sounds\Water\Drown1.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
@@ -103,7 +103,8 @@
<Holdable slots="Any,RightHand,LeftHand" handle1="0,-5">
<StatusEffect type="Always" target="Hull" oxygen="5000.0"/>
<StatusEffect type="OnImpact" target="This" Condition="0.0" setvalue="true" sound="Content/Items/Reactor/explosion.ogg">
<StatusEffect type="OnImpact" target="This" Condition="0.0" setvalue="true">
<sound file="Content/Items/Reactor/explosion.ogg"/>
<Explosion range="600.0" structuredamage="400" damage="300" stun="5" force="20.0"/>
</StatusEffect>
</Holdable>
@@ -168,7 +169,8 @@
<Projectile launchimpulse="80.0">
<Attack damage="1000" bleedingdamage="10" structuredamage="500" damagetype="Blunt"/>
<StatusEffect type="OnUse" Condition="-100.0" stun="10.0" disabledeltatime="true" sound="Content/Items/Artifacts/alienweapon.ogg">
<StatusEffect type="OnUse" Condition="-100.0" stun="10.0" disabledeltatime="true">
<sound file="Content/Items/Artifacts/alienweapon.ogg"/>
<Explosion range="1000.0" structuredamage="5000" damage="1000" stun="10" force="50.0"/>
</StatusEffect>
@@ -16,7 +16,8 @@
<Body width="12" height="33" density="5"/>
<Pickable holdpos="30,-15" handle1="0,1" slots="RightHand,LeftHand,Any">
<StatusEffect type="OnFire" target="This" Condition="-100.0" sound="Content/Items/Reactor/explosion.ogg" disabledeltatime="true">
<StatusEffect type="OnFire" target="This" Condition="-100.0" disabledeltatime="true">
<sound file="Content/Items/Reactor/explosion.ogg"/>
<Explosion range="250.0" structuredamage="10" damage="20" stun="5" force="3.0"/>
</StatusEffect>
</Pickable>
@@ -133,7 +134,6 @@
<RequiredItems name="Battery Cell,Fulgurium Battery Cell" type="Contained" msg="Battery Cell required"/>
<StatusEffect type="OnUse" target="Contained" Condition="-1.0"/>
<sound file="scooter.ogg" type="OnUse" range="500.0" loop="true"/>
<LightComponent LightColor="1.0,1.0,1.0,1.0" Flicker="0.2" range="800">
<LightTexture texture="Content/Lights/lightcone.png" origin="0.05, 0.5" size="2.0,1.0"/>
</LightComponent>
@@ -86,7 +86,8 @@
<Body width="24" height="12" density="60"/>
<Holdable slots="Any,RightHand,LeftHand" handle1="0,0">
<StatusEffect type="OnBroken" target="This" Condition="-100.0" sound="Content/Items/Reactor/explosion.ogg">
<StatusEffect type="OnBroken" target="This" Condition="-100.0">
<sound file="Content/Items/Reactor/explosion.ogg"/>
<Explosion range="500.0" structuredamage="2" damage="20" stun="5" force="20.0"/>
<Fire size="100.0"/>
</StatusEffect>
@@ -16,7 +16,8 @@
<MeleeWeapon slots="Any,RightHand,LeftHand"
aimpos="5,0" handle1="-5,0" holdangle="10" reload="1.0">
<StatusEffect type="OnUse" target="Contained, Character" Condition="-25.0" disabledeltatime="true" sound="Content/Items/Medical/syringe.ogg">
<StatusEffect type="OnUse" target="Contained, Character" Condition="-25.0" disabledeltatime="true" >
<sound file="Content/Items/Medical/syringe.ogg" range="500"/>
<RequiredItem name="chem" type="Contained"/>
<Use/>
</StatusEffect>
@@ -42,8 +43,10 @@
<MeleeWeapon slots="Any,RightHand,LeftHand"
aimpos="5,0" handle1="-5,0" holdangle="10" reload="1.0">
<StatusEffect type="OnUse" target="This" Condition="-25.0" disabledeltatime="true" sound="Content/Items/Medical/bandage.ogg"/>
<StatusEffect type="OnUse" target="This, Character" bleeding="-0.1" duration="5.0" sound="Content/Items/Medical/bandage.ogg"/>
<StatusEffect type="OnUse" target="This" Condition="-25.0" disabledeltatime="true"/>
<StatusEffect type="OnUse" target="This, Character" bleeding="-0.1" duration="5.0">
<Sound file="Content/Items/Medical/bandage.ogg" range="500"/>
</StatusEffect>
</MeleeWeapon>
</Item>
@@ -275,7 +278,8 @@
<Holdable slots="Any,RightHand,LeftHand">
<StatusEffect type="OnFire" target="this" condition="-50"/>
<StatusEffect type="OnBroken" target="This" Condition="-100.0" sound="Content/Items/Reactor/explosion.ogg">
<StatusEffect type="OnBroken" target="This" Condition="-100.0">
<Sound file="Content/Items/Reactor/explosion.ogg"/>
<Explosion range="500" damage="5" stun="3" force="0.1"/>
</StatusEffect>
</Holdable>
@@ -27,7 +27,8 @@
<StatusEffect type="OnActive" target="Contained" targetnames="Fuel Rod, Heat Absorber, Temperature Control Circuit" Condition="-0.1" />
<sound file="reactor.ogg" type="OnActive" range="2000.0" volume="FissionRate" volumemultiplier="0.02" loop="true"/>
<StatusEffect type="OnBroken" target="This" FissionRate="0.0" disabledeltatime="true" sound="Content/Items/Reactor/explosion.ogg">
<StatusEffect type="OnBroken" target="This" FissionRate="0.0" disabledeltatime="true">
<Sound file="Content/Items/Reactor/explosion.ogg" range="5000"/>
<Explosion range ="800" damage="500" structuredamage="400" stun="5.0" force="5.0"/>
</StatusEffect>
</Reactor>
@@ -117,7 +117,8 @@
<Body width="12" height="33" density="5"/>
<Holdable slots="RightHand,Any" holdpos="30,-15" handle1="0,5" handle2="0,-5">
<StatusEffect type="OnFire" target="This" Condition="-100.0" sound="Content/Items/Reactor/explosion.ogg" disabledeltatime="true">
<StatusEffect type="OnFire" target="This" Condition="-100.0" disabledeltatime="true">
<sound file="Content/Items/Reactor/explosion.ogg"/>
<Explosion range="250.0" structuredamage="15" damage="25" stun="5" force="3.0"/>
</StatusEffect>
</Holdable>
@@ -81,7 +81,8 @@
<Holdable slots="RightHand+LeftHand" holdpos="0,-50" handle1="-10,20" handle2="10,20" aimable="false"/>
<Projectile launchimpulse="5.0">
<StatusEffect type="OnImpact" Condition="-100.0" stun="10.0" disabledeltatime="true" sound="Content/Items/Weapons/bigexplosion.ogg">
<StatusEffect type="OnImpact" Condition="-100.0" stun="10.0" disabledeltatime="true">
<sound file="Content/Items/Weapons/bigexplosion.ogg" range="10000"/>
<Explosion range="1000.0" structuredamage="1000" damage="1000" stun="10" force="50.0"/>
</StatusEffect>
<StatusEffect type="OnImpact" target="Contained" Condition="-100.0"/>
@@ -12,7 +12,8 @@
<Body width="16" height="7"/>
<Pickable slots="Any">
<StatusEffect type="OnBroken" target="This" Condition="-100.0" sound="Content/Items/Reactor/explosion.ogg">
<StatusEffect type="OnBroken" target="This" Condition="-100.0">
<sound file="Content/Items/Reactor/explosion.ogg" range="3000"/>
<Explosion range="500.0" structuredamage="250" damage="200" stun="5" force="20.0" severlimbsprobability="0.5" decal="explosion" decalsize="0.5"/>
</StatusEffect>
</Pickable>
@@ -30,7 +31,8 @@
<Pickable slots="Any">
<StatusEffect type="OnFire" target="This" Condition="-50.0"/>
<StatusEffect type="OnBroken" target="This" Condition="-100.0" sound="Content/Items/Reactor/explosion.ogg">
<StatusEffect type="OnBroken" target="This" Condition="-100.0">
<sound file="Content/Items/Reactor/explosion.ogg" range="3000"/>
<Explosion range="600.0" structuredamage="150" damage="300" stun="5" force="20.0" severlimbsprobability="0.6" decal="explosion" decalsize="0.5"/>
</StatusEffect>
</Pickable>
@@ -49,7 +51,8 @@
<Pickable slots="Any">
<StatusEffect type="Always" target="This" Condition="-0.35"/>
<StatusEffect type="OnFire" target="This" Condition="-50.0"/>
<StatusEffect type="OnBroken" target="This" Condition="-100.0" sound="Content/Items/Reactor/explosion.ogg">
<StatusEffect type="OnBroken" target="This" Condition="-100.0">
<sound file="Content/Items/Reactor/explosion.ogg" range="3000"/>
<Explosion range="600.0" structuredamage="150" damage="300" stun="5" force="20.0" severlimbsprobability="0.6" decal="explosion" decalsize="0.5"/>
</StatusEffect>
</Pickable>
@@ -68,7 +71,8 @@
<Pickable slots="Any">
<StatusEffect type="OnFire" target="This" Condition="-50.0"/>
<StatusEffect type="OnBroken" target="This" Condition="-100.0" sound="Content/Items/Reactor/explosion.ogg">
<StatusEffect type="OnBroken" target="This" Condition="-100.0">
<sound file="Content/Items/Reactor/explosion.ogg" range="2000"/>
<Explosion range="500.0" structuredamage="50" damage="300" stun="5" force="20.0" severlimbsprobability="0.6"/>
<Fire size="500"/>
</StatusEffect>
@@ -120,7 +124,8 @@
<StatusEffect type="OnImpact" target="This" Condition="0.0" setvalue="true"/>
<StatusEffect type="OnFire" target="This" Condition="-50.0"/>
<StatusEffect type="OnBroken" target="This" Condition="-100.0" sound="Content/Items/Reactor/explosion.ogg">
<StatusEffect type="OnBroken" target="This" Condition="-100.0">
<sound file="Content/Items/Reactor/explosion.ogg" range="3000"/>
<Explosion range="600.0" structuredamage="400" damage="300" stun="5" force="20.0" severlimbsprobability="0.4" decal="explosion" decalsize="0.5"/>
</StatusEffect>
@@ -12,7 +12,8 @@
<Turret barrelsprite="railgunbarrel.png" canbeselected = "true" linkable="true" origin="0.5, 0.85" barrelpos="128, 128"
rotationlimits="180,360"
powerconsumption="20000.0">
<StatusEffect type="OnUse" target="This" sound="Content/Items/Weapons/railgun.ogg">
<StatusEffect type="OnUse" target="This">
<sound file="Content/Items/Weapons/railgun.ogg" range="5000"/>
<Explosion range="1000.0" structuredamage="0" force="0.01" camerashake="10.0"/>
</StatusEffect>
</Turret>
@@ -117,7 +118,8 @@
<Projectile launchimpulse="80.0">
<Attack damage="1000" bleedingdamage="10" structuredamage="200" damagetype="Blunt" severlimbsprobability="1.0"/>
<StatusEffect type="OnUse" Condition="-100.0" stun="10.0" disabledeltatime="true" sound="Content/Items/Weapons/bigexplosion.ogg">
<StatusEffect type="OnUse" Condition="-100.0" stun="10.0" disabledeltatime="true">
<sound file="Content/Items/Weapons/bigexplosion.ogg"/>
<Explosion range="1000.0" structuredamage="1000" damage="1000" stun="10" force="50.0" severlimbsprobability="0.8" decal="explosion" decalsize="1.0"/>
</StatusEffect>
@@ -66,7 +66,8 @@
<Body width="11" height="24" density="30"/>
<Throwable slots="Any,RightHand,LeftHand" holdpos="0,0" handle1="0,0" throwforce="4.0" aimpos="35,-10">
<StatusEffect type="OnUse" target="This" Condition="-100.0" delay="3.0" sound="Content/Items/Weapons/stungrenade.ogg">
<StatusEffect type="OnUse" target="This" Condition="-100.0" delay="3.0">
<sound file="Content/Items/Weapons/stungrenade.ogg"/>
<Explosion range="500" damage="5" stun="25" force="0.1"/>
</StatusEffect>
</Throwable>
@@ -83,7 +84,8 @@
<Body width="11" height="24" density="30"/>
<Throwable slots="Any,RightHand,LeftHand" holdpos="0,0" handle1="0,0" throwforce="4.0" aimpos="35,-10">
<StatusEffect type="OnUse" target="This" Condition="-100.0" delay="3.0" sound="Content/Items/Weapons/stungrenade.ogg">
<StatusEffect type="OnUse" target="This" Condition="-100.0" delay="3.0">
<sound file="Content/Items/Weapons/stungrenade.ogg"/>
<Explosion range="500" damage="5" stun="1" force="0.1"/>
<Fire size="300.0"/>
</StatusEffect>
@@ -110,11 +112,13 @@
<MeleeWeapon slots="Any,RightHand,LeftHand"
aimpos="50,0" handle1="-5,0" holdangle="10" reload="1.0">
<Attack damage="2" stun="0.2" damagetype="Blunt" sound="Content/Items/Weapons/smack.ogg"/>
<StatusEffect type="OnUse" target="Contained,Character" Condition="-25.0" stun="15.0" disabledeltatime="true" sound="Content/Items/Weapons/stunbaton.ogg">
<StatusEffect type="OnUse" target="Contained,Character" Condition="-25.0" stun="15.0" disabledeltatime="true">
<sound file="Content/Items/Weapons/stunbaton.ogg"/>
<RequiredItem name="Battery Cell" type="Contained" msg="Loaded Battery Cell required"/>
<Explosion range="100.0" force="0.1" shockwave="false" flames="false" camerashake="5.0"/>
</StatusEffect>
<StatusEffect type="OnUse" target="Contained,Character" Condition="-15.0" stun="30.0" disabledeltatime="true" sound="Content/Items/Weapons/stunbaton.ogg">
<StatusEffect type="OnUse" target="Contained,Character" Condition="-15.0" stun="30.0" disabledeltatime="true">
<sound file="Content/Items/Weapons/stunbaton.ogg"/>
<RequiredItem name="Fulgurium Battery Cell" type="Contained" msg="Loaded Battery Cell required"/>
<Explosion range="100.0" force="0.5" shockwave="false" flames="false" camerashake="5.0"/>
</StatusEffect>
@@ -26,6 +26,7 @@ namespace Barotrauma
private List<ParticleEmitter> particleEmitters;
private Sound sound;
private bool loopSound;
#endif
public string[] propertyNames;
@@ -132,11 +133,10 @@ namespace Barotrauma
case "duration":
duration = ToolBox.GetAttributeFloat(attribute, 0.0f);
break;
#if CLIENT
case "sound":
sound = Sound.Load(attribute.Value.ToString());
DebugConsole.ThrowError("Error in StatusEffect " + element.Parent.Name.ToString() +
" - sounds should be defined as child elements of the StatusEffect, not as attributes.");
break;
#endif
default:
propertyAttributes.Add(attribute);
break;
@@ -181,6 +181,10 @@ namespace Barotrauma
case "particleemitter":
particleEmitters.Add(new ParticleEmitter(subElement));
break;
case "sound":
sound = Sound.Load(subElement);
loopSound = ToolBox.GetAttributeBool(subElement, "loop", false);
break;
#endif
}
}
@@ -227,7 +231,24 @@ namespace Barotrauma
protected void Apply(float deltaTime, Entity entity, List<IPropertyObject> targets)
{
#if CLIENT
if (sound != null) sound.Play(1.0f, 1000.0f, entity.WorldPosition);
if (sound != null)
{
if (loopSound)
{
if (!Sounds.SoundManager.IsPlaying(sound))
{
sound.Play(entity.WorldPosition);
}
else
{
sound.UpdatePosition(entity.WorldPosition);
}
}
else
{
sound.Play(entity.WorldPosition);
}
}
#endif
if (useItem)
@@ -53,8 +53,30 @@ namespace Barotrauma
{
this.ParticleEmitter = new ParticleEmitter(prefab.ParticleEmitterPrefab);
}
#endif
if (prefab.SoundElement != null)
{
Sound = Sound.Load(prefab.SoundElement, true);
}
#endif
}
public Vector2 LocalToWorld(Vector2 localPosition, float swingState = 0.0f)
{
Vector2 emitterPos = localPosition * Scale;
if (Rotation != 0.0f || Prefab.SwingAmount != 0.0f)
{
float rot = Rotation + swingState * Prefab.SwingAmount;
var ca = (float)Math.Cos(rot);
var sa = (float)Math.Sin(rot);
emitterPos = new Vector2(
ca * emitterPos.X + sa * emitterPos.Y,
-sa * emitterPos.X + ca * emitterPos.Y);
}
return new Vector2(Position.X, Position.Y) + emitterPos;
}
}
@@ -97,6 +97,10 @@ namespace Barotrauma
ParticleEmitterPrefab = new Particles.ParticleEmitterPrefab(subElement);
EmitterPosition = ToolBox.GetAttributeVector2(subElement, "position", Vector2.Zero);
break;
case "sound":
SoundElement = subElement;
SoundPosition = ToolBox.GetAttributeVector2(subElement, "position", Vector2.Zero);
break;
#endif
}
}