[ValidatePrototypeId<DamageTypePrototype>]
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;
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,
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;
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);