diff --git a/Content.Server/Electrocution/ElectrocutionSystem.cs b/Content.Server/Electrocution/ElectrocutionSystem.cs index aac500f34f..f71f8b6974 100644 --- a/Content.Server/Electrocution/ElectrocutionSystem.cs +++ b/Content.Server/Electrocution/ElectrocutionSystem.cs @@ -62,9 +62,7 @@ public sealed class ElectrocutionSystem : SharedElectrocutionSystem [ValidatePrototypeId] private const string DamageType = "Shock"; - // Yes, this is absurdly small for a reason. - private const float ElectrifiedScalePerWatt = 1E-6f; - + // Multiply and shift the log scale for shock damage. private const float RecursiveDamageMultiplier = 0.75f; private const float RecursiveTimeMultiplier = 0.8f; @@ -214,6 +212,16 @@ public sealed class ElectrocutionSystem : SharedElectrocutionSystem TryDoElectrifiedAct(uid, args.User, siemens, electrified); } + private float CalculateElectrifiedDamageScale(float power) + { + // A logarithm allows a curve of damage that grows quickly, but slows down dramatically past a value. This keeps the damage to a reasonable range. + const float DamageShift = 1.67f; // Shifts the curve for an overall higher or lower damage baseline + const float CeilingCoefficent = 1.35f; // Adjusts the approach to maximum damage, higher = Higher top damage + const float LogGrowth = 0.00001f; // Adjusts the growth speed of the curve + + return DamageShift + MathF.Log(power * LogGrowth) * CeilingCoefficent; + } + public bool TryDoElectrifiedAct(EntityUid uid, EntityUid targetUid, float siemens = 1, ElectrifiedComponent? electrified = null, @@ -264,7 +272,9 @@ public sealed class ElectrocutionSystem : SharedElectrocutionSystem return false; // Initial damage scales off of the available supply on the principle that the victim has shorted the entire powernet through their body. - var damageScale = supp * ElectrifiedScalePerWatt; + var damageScale = CalculateElectrifiedDamageScale(supp); + if (damageScale <= 0f) + return false; { var lastRet = true; @@ -275,7 +285,7 @@ public sealed class ElectrocutionSystem : SharedElectrocutionSystem entity, uid, node, - (int) (electrified.ShockDamage * damageScale * MathF.Pow(RecursiveDamageMultiplier, depth)), + (int) MathF.Ceiling(electrified.ShockDamage * damageScale * MathF.Pow(RecursiveDamageMultiplier, depth)), TimeSpan.FromSeconds(electrified.ShockTime * MathF.Min(1f + MathF.Log2(1f + damageScale), 3f) * MathF.Pow(RecursiveTimeMultiplier, depth)), true, electrified.SiemensCoefficient);