Modifications to the damage/armor system:
- Armor values aren't reduced from the damage taken, but instead multiply the damage (e.g. an item reduces damage by 10% instead of 10 hp). Now armor doesn't make characters invulnerable to small amounts of damage. - Armoring isn't defined as a single "armor value", but instead there are "damage modifiers" which can be added to items and limbs. The modifiers can only affect specific types of damage and have separate multipliers for the damage amount and bleeding amount. - Having a fire proof item on a limb doesn't make that limb invulnerable to burn damage. Item's that protect against fire now have a damage modifier for the Burn damage type.
This commit is contained in:
@@ -5,6 +5,7 @@ using FarseerPhysics.Dynamics.Joints;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
@@ -255,7 +256,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
target.Body.ApplyLinearImpulse(item.body.LinearVelocity * item.body.Mass);
|
||||
|
||||
if (attackResult.HitArmor)
|
||||
if (attackResult.AppliedDamageModifiers != null &&
|
||||
attackResult.AppliedDamageModifiers.Any(dm => dm.DeflectProjectiles))
|
||||
{
|
||||
item.body.LinearVelocity *= 0.1f;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
@@ -27,79 +28,62 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
class Wearable : Pickable
|
||||
{
|
||||
WearableSprite[] wearableSprites;
|
||||
LimbType[] limbType;
|
||||
Limb[] limb;
|
||||
private WearableSprite[] wearableSprites;
|
||||
private LimbType[] limbType;
|
||||
private Limb[] limb;
|
||||
|
||||
private float armorValue;
|
||||
private List<DamageModifier> damageModifiers;
|
||||
|
||||
private Vector2 armorSector;
|
||||
|
||||
[Serialize(0.0f, false)]
|
||||
public float ArmorValue
|
||||
public List<DamageModifier> DamageModifiers
|
||||
{
|
||||
get { return armorValue; }
|
||||
set { armorValue = MathHelper.Clamp(value, 0.0f, 100.0f); }
|
||||
get { return damageModifiers; }
|
||||
}
|
||||
|
||||
[Serialize("0.0,360.0", false)]
|
||||
public Vector2 ArmorSector
|
||||
{
|
||||
get { return armorSector; }
|
||||
set
|
||||
{
|
||||
armorSector.X = MathHelper.ToRadians(value.X);
|
||||
armorSector.Y = MathHelper.ToRadians(value.Y);
|
||||
}
|
||||
}
|
||||
|
||||
public Vector2 ArmorSectorLimits
|
||||
{
|
||||
get { return armorSector; }
|
||||
}
|
||||
|
||||
|
||||
public Wearable (Item item, XElement element)
|
||||
: base(item, element)
|
||||
{
|
||||
this.item = item;
|
||||
|
||||
var sprites = element.Elements().Where(x => x.Name.ToString() == "sprite").ToList();
|
||||
int spriteCount = sprites.Count;
|
||||
damageModifiers = new List<DamageModifier>();
|
||||
|
||||
int spriteCount = element.Elements().Count(x => x.Name.ToString() == "sprite");
|
||||
wearableSprites = new WearableSprite[spriteCount];
|
||||
limbType = new LimbType[spriteCount];
|
||||
limb = new Limb[spriteCount];
|
||||
|
||||
int i = 0;
|
||||
foreach (XElement subElement in sprites)
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
//Rectangle sourceRect = new Rectangle(
|
||||
// ToolBox.GetAttributeInt(subElement, "sourcex", 1),
|
||||
// ToolBox.GetAttributeInt(subElement, "sourcey", 1),
|
||||
// ToolBox.GetAttributeInt(subElement, "sourcewidth", 1),
|
||||
// ToolBox.GetAttributeInt(subElement, "sourceheight", 1));
|
||||
|
||||
if (subElement.Attribute("texture") == null)
|
||||
switch (subElement.Name.ToString().ToLower())
|
||||
{
|
||||
DebugConsole.ThrowError("Item \"" + item.Name + "\" doesn't have a texture specified!");
|
||||
return;
|
||||
case "sprite":
|
||||
if (subElement.Attribute("texture") == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Item \"" + item.Name + "\" doesn't have a texture specified!");
|
||||
return;
|
||||
}
|
||||
|
||||
string spritePath = subElement.Attribute("texture").Value;
|
||||
spritePath = Path.GetDirectoryName(item.Prefab.ConfigFile) + "/" + spritePath;
|
||||
|
||||
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);
|
||||
|
||||
i++;
|
||||
break;
|
||||
case "damagemodifier":
|
||||
damageModifiers.Add(new DamageModifier(subElement));
|
||||
break;
|
||||
}
|
||||
|
||||
string spritePath = subElement.Attribute("texture").Value;
|
||||
spritePath = Path.GetDirectoryName( item.Prefab.ConfigFile)+"/"+spritePath;
|
||||
|
||||
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);
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override void Equip(Character character)
|
||||
{
|
||||
picker = character;
|
||||
@@ -107,15 +91,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
Limb equipLimb = character.AnimController.GetLimb(limbType[i]);
|
||||
if (equipLimb == null) continue;
|
||||
|
||||
//something is already on the limb -> unequip it
|
||||
//if (equipLimb.WearingItem != null && equipLimb.WearingItem != this)
|
||||
//{
|
||||
// equipLimb.WearingItem.Unequip(character);
|
||||
//}
|
||||
|
||||
//sprite[i].Depth = equipLimb.sprite.Depth - 0.001f;
|
||||
|
||||
|
||||
item.body.Enabled = false;
|
||||
|
||||
IsActive = true;
|
||||
@@ -143,20 +119,9 @@ namespace Barotrauma.Items.Components
|
||||
Limb equipLimb = character.AnimController.GetLimb(limbType[i]);
|
||||
if (equipLimb == null) continue;
|
||||
|
||||
//foreach (WearableSprite wearable in equipLimb.WearingItems)
|
||||
//{
|
||||
// if (wearable != wearableSprites[i]) continue;
|
||||
equipLimb.WearingItems.RemoveAll(w => w != null && w == wearableSprites[i]);
|
||||
|
||||
// equipLimb.WearingItems.Remove(wearableSprites[i]);
|
||||
//}
|
||||
|
||||
equipLimb.WearingItems.RemoveAll(w=> w!=null && w==wearableSprites[i]);
|
||||
|
||||
//if (equipLimb.WearingItem != this) continue;
|
||||
|
||||
limb[i] = null;
|
||||
//equipLimb.WearingItem = null;
|
||||
//equipLimb.WearingItemSprite = null;
|
||||
}
|
||||
|
||||
IsActive = false;
|
||||
|
||||
Reference in New Issue
Block a user