Armor price calculations (#11417)
Co-authored-by: CommieFlowers <rasmus.cedergren@hotmail.com> fixes https://github.com/space-wizards/space-station-14/issues/11299
This commit is contained in:
parent
7b434354fd
commit
6a497d3f55
|
|
@ -2,14 +2,20 @@ using Content.Shared.Damage;
|
|||
using Content.Server.Examine;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Shared.Utility;
|
||||
using Content.Server.Cargo.Systems;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Content.Shared.Damage.Prototypes;
|
||||
using Content.Shared.Inventory;
|
||||
|
||||
namespace Content.Server.Armor
|
||||
{
|
||||
public sealed class ArmorSystem : EntitySystem
|
||||
{
|
||||
const double CoefDefaultPrice = 2; // default price of 1% protection against any type of damage
|
||||
const double FlatDefaultPrice = 10; //default price of 1 damage protection against a certain type of damage
|
||||
|
||||
[Dependency] private readonly ExamineSystem _examine = default!;
|
||||
[Dependency] private readonly IPrototypeManager _protoManager = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
|
|
@ -17,6 +23,43 @@ namespace Content.Server.Armor
|
|||
|
||||
SubscribeLocalEvent<ArmorComponent, InventoryRelayedEvent<DamageModifyEvent>>(OnDamageModify);
|
||||
SubscribeLocalEvent<ArmorComponent, GetVerbsEvent<ExamineVerb>>(OnArmorVerbExamine);
|
||||
SubscribeLocalEvent<ArmorComponent, PriceCalculationEvent>(GetArmorPrice);
|
||||
}
|
||||
|
||||
private void GetArmorPrice(EntityUid uid, ArmorComponent component, ref PriceCalculationEvent args)
|
||||
{
|
||||
if (component.Modifiers == null)
|
||||
return;
|
||||
|
||||
double price = 0;
|
||||
|
||||
foreach (var modifier in component.Modifiers.Coefficients)
|
||||
{
|
||||
_protoManager.TryIndex(modifier.Key, out DamageTypePrototype? damageType);
|
||||
|
||||
if (damageType != null)
|
||||
{
|
||||
price += damageType.ArmorPriceCoefficient * 100 * (1 - modifier.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
price += CoefDefaultPrice * 100 * (1 - modifier.Value);
|
||||
}
|
||||
}
|
||||
foreach (var modifier in component.Modifiers.FlatReduction)
|
||||
{
|
||||
_protoManager.TryIndex(modifier.Key, out DamageTypePrototype? damageType);
|
||||
|
||||
if (damageType != null)
|
||||
{
|
||||
price += damageType.ArmorPriceFlat * modifier.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
price += FlatDefaultPrice * modifier.Value;
|
||||
}
|
||||
}
|
||||
args.Price += price;
|
||||
}
|
||||
|
||||
private void OnDamageModify(EntityUid uid, ArmorComponent component, InventoryRelayedEvent<DamageModifyEvent> args)
|
||||
|
|
|
|||
|
|
@ -12,5 +12,17 @@ namespace Content.Shared.Damage.Prototypes
|
|||
{
|
||||
[IdDataFieldAttribute]
|
||||
public string ID { get; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// The price for each 1% damage reduction in armors
|
||||
/// </summary>
|
||||
[DataField("armorCoefficientPrice")]
|
||||
public double ArmorPriceCoefficient { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The price for each flat damage reduction in armors
|
||||
/// </summary>
|
||||
[DataField("armorFlatPrice")]
|
||||
public double ArmorPriceFlat { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
sprite: Clothing/Head/Helmets/bombsuit.rsi
|
||||
state: icon
|
||||
product: CrateEmergencyExplosive
|
||||
cost: 500
|
||||
cost: 650
|
||||
category: Emergency
|
||||
group: market
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
sprite: Objects/Misc/fire_extinguisher.rsi
|
||||
state: fire_extinguisher_closed
|
||||
product: CrateEmergencyFire
|
||||
cost: 1000
|
||||
cost: 1200
|
||||
category: Emergency
|
||||
group: market
|
||||
|
||||
|
|
@ -34,7 +34,7 @@
|
|||
sprite: Structures/Wallmounts/signs.rsi
|
||||
state: radiation
|
||||
product: CrateEmergencyRadiation
|
||||
cost: 500
|
||||
cost: 900
|
||||
category: Emergency
|
||||
group: market
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
sprite: Clothing/OuterClothing/Vests/oldarmor.rsi
|
||||
state: icon
|
||||
product: CrateSecurityArmor
|
||||
cost: 500
|
||||
cost: 700
|
||||
category: Security
|
||||
group: market
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
sprite: Clothing/Head/Helmets/security.rsi
|
||||
state: icon
|
||||
product: CrateSecurityHelmet
|
||||
cost: 500
|
||||
cost: 550
|
||||
category: Security
|
||||
group: market
|
||||
|
||||
|
|
@ -44,7 +44,7 @@
|
|||
sprite: Clothing/OuterClothing/Armor/riot.rsi
|
||||
state: icon
|
||||
product: CrateSecurityRiot
|
||||
cost: 2000
|
||||
cost: 2800
|
||||
category: Security
|
||||
group: market
|
||||
|
||||
|
|
|
|||
|
|
@ -3,41 +3,66 @@
|
|||
# Usually healed automatically if entity can breathe
|
||||
- type: damageType
|
||||
id: Asphyxiation
|
||||
armorCoefficientPrice: 5
|
||||
armorFlatPrice: 50
|
||||
|
||||
|
||||
# Damage representing not having enough blood.
|
||||
# Represents there not enough blood to supply oxygen (or equivalent).
|
||||
- type: damageType
|
||||
id: Bloodloss
|
||||
armorCoefficientPrice: 5
|
||||
armorFlatPrice: 50
|
||||
|
||||
- type: damageType
|
||||
id: Blunt
|
||||
|
||||
armorCoefficientPrice: 2
|
||||
armorFlatPrice: 10
|
||||
|
||||
- type: damageType
|
||||
id: Cellular
|
||||
armorCoefficientPrice: 5
|
||||
armorFlatPrice: 30
|
||||
|
||||
- type: damageType
|
||||
id: Cold
|
||||
armorCoefficientPrice: 2.5
|
||||
armorFlatPrice: 20
|
||||
|
||||
- type: damageType
|
||||
id: Heat
|
||||
armorCoefficientPrice: 2.5
|
||||
armorFlatPrice: 20
|
||||
|
||||
- type: damageType
|
||||
id: Piercing
|
||||
armorCoefficientPrice: 2
|
||||
armorFlatPrice: 10
|
||||
|
||||
# Poison damage. Generally caused by various reagents being metabolised.
|
||||
- type: damageType
|
||||
id: Poison
|
||||
armorCoefficientPrice: 10
|
||||
armorFlatPrice: 60
|
||||
|
||||
- type: damageType
|
||||
id: Radiation
|
||||
armorCoefficientPrice: 2.5
|
||||
armorFlatPrice: 16
|
||||
|
||||
- type: damageType
|
||||
id: Shock
|
||||
armorCoefficientPrice: 2.5
|
||||
armorFlatPrice: 20
|
||||
|
||||
- type: damageType
|
||||
id: Slash
|
||||
armorCoefficientPrice: 2
|
||||
armorFlatPrice: 10
|
||||
|
||||
# Damage represent structures internal integrity.
|
||||
# Exclusive for structures such as walls, airlocks and others.
|
||||
- type: damageType
|
||||
id: Structural
|
||||
armorCoefficientPrice: 1
|
||||
armorFlatPrice: 1
|
||||
|
|
|
|||
Loading…
Reference in New Issue