Explosion damage is reduced if there are walls or other solid obstacles between an explosion and a character
This commit is contained in:
@@ -3,6 +3,7 @@ using Barotrauma.Lights;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
using FarseerPhysics;
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
@@ -116,6 +117,11 @@ namespace Barotrauma
|
|||||||
|
|
||||||
foreach (Character c in Character.CharacterList)
|
foreach (Character c in Character.CharacterList)
|
||||||
{
|
{
|
||||||
|
Vector2 explosionPos = worldPosition;
|
||||||
|
if (c.Submarine != null) explosionPos -= c.Submarine.Position;
|
||||||
|
|
||||||
|
explosionPos = ConvertUnits.ToSimUnits(explosionPos);
|
||||||
|
|
||||||
foreach (Limb limb in c.AnimController.Limbs)
|
foreach (Limb limb in c.AnimController.Limbs)
|
||||||
{
|
{
|
||||||
float dist = Vector2.Distance(limb.WorldPosition, worldPosition);
|
float dist = Vector2.Distance(limb.WorldPosition, worldPosition);
|
||||||
@@ -129,6 +135,9 @@ namespace Barotrauma
|
|||||||
|
|
||||||
float distFactor = 1.0f - dist / range;
|
float distFactor = 1.0f - dist / range;
|
||||||
|
|
||||||
|
//solid obstacles between the explosion and the limb reduce the effect of the explosion by 90%
|
||||||
|
if (Submarine.CheckVisibility(limb.SimPosition, explosionPos) != null) distFactor *= 0.1f;
|
||||||
|
|
||||||
c.AddDamage(limb.WorldPosition, DamageType.None,
|
c.AddDamage(limb.WorldPosition, DamageType.None,
|
||||||
damage / c.AnimController.Limbs.Length * distFactor, 0.0f, stun * distFactor, false);
|
damage / c.AnimController.Limbs.Length * distFactor, 0.0f, stun * distFactor, false);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user