Explosions now use Character.Controlled.WorldPosition to determine camera shake

This commit is contained in:
juanjp600
2018-09-19 14:57:22 -03:00
parent a7515cc400
commit e578cbc077
2 changed files with 7 additions and 6 deletions
@@ -46,7 +46,7 @@
<Sound file="Content/Items/Weapons/harpoon1.ogg" type="OnUse"/> <Sound file="Content/Items/Weapons/harpoon1.ogg" type="OnUse"/>
<Sound file="Content/Items/Weapons/harpoon2.ogg" type="OnUse"/> <Sound file="Content/Items/Weapons/harpoon2.ogg" type="OnUse"/>
<StatusEffect type="OnUse"> <StatusEffect type="OnUse">
<Explosion range="150.0" force="5" shockwave="false" smoke="false" flames="false" flash="false" sparks="false" camerashake="5.0"/> <Explosion range="150.0" force="5" shockwave="false" smoke="false" flames="false" flash="false" sparks="false" camerashake="6.0"/>
</StatusEffect> </StatusEffect>
<RequiredItems name="Spear" type="Contained" msg="Spear required to shoot"/> <RequiredItems name="Spear" type="Contained" msg="Spear required to shoot"/>
<RequiredSkill name="Weapons" level="30"/> <RequiredSkill name="Weapons" level="30"/>
@@ -130,7 +130,7 @@
<RangedWeapon barrelpos="14,6" spread="0" unskilledspread="2"> <RangedWeapon barrelpos="14,6" spread="0" unskilledspread="2">
<Sound file="Content/Items/Weapons/revolver.ogg" type="OnUse" range="3000"/> <Sound file="Content/Items/Weapons/revolver.ogg" type="OnUse" range="3000"/>
<StatusEffect type="OnUse"> <StatusEffect type="OnUse">
<Explosion range="150.0" force="5" shockwave="false" smoke="false" flames="false" sparks="false" camerashake="5.0"/> <Explosion range="150.0" force="5" shockwave="false" smoke="false" flames="false" sparks="false" camerashake="6.0"/>
</StatusEffect> </StatusEffect>
<RequiredItems name="Revolver Round" type="Contained" msg="Out of ammo"/> <RequiredItems name="Revolver Round" type="Contained" msg="Out of ammo"/>
<RequiredSkill name="Weapons" level="40"/> <RequiredSkill name="Weapons" level="40"/>
@@ -230,12 +230,12 @@
<StatusEffect type="OnUse" target="Contained,Character" Condition="-25.0" stun="15.0" disabledeltatime="true"> <StatusEffect type="OnUse" target="Contained,Character" Condition="-25.0" stun="15.0" disabledeltatime="true">
<sound file="Content/Items/Weapons/stunbaton.ogg"/> <sound file="Content/Items/Weapons/stunbaton.ogg"/>
<RequiredItem name="Battery Cell" type="Contained" msg="Loaded Battery Cell required"/> <RequiredItem name="Battery Cell" type="Contained" msg="Loaded Battery Cell required"/>
<Explosion range="100.0" force="0.1" shockwave="false" flames="false" smoke="false" camerashake="5.0"/> <Explosion range="100.0" force="0.1" shockwave="false" flames="false" smoke="false" camerashake="6.0"/>
</StatusEffect> </StatusEffect>
<StatusEffect type="OnUse" target="Contained,Character" Condition="-15.0" stun="30.0" disabledeltatime="true"> <StatusEffect type="OnUse" target="Contained,Character" Condition="-15.0" stun="30.0" disabledeltatime="true">
<sound file="Content/Items/Weapons/stunbaton.ogg"/> <sound file="Content/Items/Weapons/stunbaton.ogg"/>
<RequiredItem name="Fulgurium Battery Cell" type="Contained" msg="Loaded Battery Cell required"/> <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"/> <Explosion range="100.0" force="0.5" shockwave="false" flames="false" camerashake="6.0"/>
</StatusEffect> </StatusEffect>
</MeleeWeapon> </MeleeWeapon>
@@ -63,7 +63,8 @@ namespace Barotrauma
float displayRange = attack.Range; float displayRange = attack.Range;
if (displayRange < 0.1f) return; if (displayRange < 0.1f) return;
float cameraDist = Vector2.Distance(GameMain.GameScreen.Cam.Position, worldPosition) / 2.0f; Vector2 cameraPos = Character.Controlled != null ? Character.Controlled.WorldPosition : GameMain.GameScreen.Cam.Position;
float cameraDist = Vector2.Distance(cameraPos, worldPosition) / 2.0f;
GameMain.GameScreen.Cam.Shake = CameraShake * Math.Max((displayRange - cameraDist) / displayRange, 0.0f); GameMain.GameScreen.Cam.Shake = CameraShake * Math.Max((displayRange - cameraDist) / displayRange, 0.0f);
if (attack.GetStructureDamage(1.0f) > 0.0f) if (attack.GetStructureDamage(1.0f) > 0.0f)