using Content.Shared.Inventory;
using Content.Shared.Jittering;
using Content.Shared.Maps;
-using Content.Shared.Mobs;
using Content.Shared.Popups;
using Content.Shared.Speech.EntitySystems;
using Content.Shared.StatusEffect;
private void UpdateElectrocutions(float frameTime)
{
var query = EntityQueryEnumerator<ElectrocutionComponent, PowerConsumerComponent>();
- while (query.MoveNext(out var uid, out var electrocution, out var consumer))
+ while (query.MoveNext(out var uid, out var electrocution, out _))
{
var timePassed = Math.Min(frameTime, electrocution.TimeLeft);
electrocution.TimeLeft -= timePassed;
- electrocution.AccumulatedDamage += electrocution.BaseDamage * (consumer.ReceivedPower / consumer.DrawRate) * timePassed;
if (!MathHelper.CloseTo(electrocution.TimeLeft, 0))
continue;
- if (EntityManager.EntityExists(electrocution.Electrocuting))
- {
- // TODO: damage should be scaled by shock damage multiplier
- // TODO: better paralyze/jitter timing
- var damage = new DamageSpecifier(_prototypeManager.Index<DamageTypePrototype>(DamageType), (int) electrocution.AccumulatedDamage);
+ // We tried damage scaling based on power in the past and it really wasn't good.
+ // Various scaling types didn't fix tiders and HV grilles instantly critting players.
- var actual = _damageable.TryChangeDamage(electrocution.Electrocuting, damage, origin: electrocution.Source);
- if (actual != null)
- {
- _adminLogger.Add(LogType.Electrocution,
- $"{ToPrettyString(electrocution.Electrocuting):entity} received {actual.GetTotal():damage} powered electrocution damage from {ToPrettyString(electrocution.Source):source}");
- }
- }
QueueDel(uid);
}
}
if (!_meleeWeapon.GetDamage(args.Used, args.User).Any())
return;
- DoCommonElectrocution(args.User, uid, component.UnarmedHitShock, component.UnarmedHitStun, false, 1);
+ DoCommonElectrocution(args.User, uid, component.UnarmedHitShock, component.UnarmedHitStun, false);
}
private void OnElectrifiedInteractUsing(EntityUid uid, ElectrifiedComponent electrified, InteractUsingEvent args)
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,
}
var node = PoweredNode(uid, electrified, nodeContainer);
- if (node?.NodeGroup is not IBasePowerNet powerNet)
- return false;
-
- var net = powerNet.NetworkNode;
- var supp = net.LastCombinedMaxSupply;
-
- if (supp <= 0f)
+ if (node?.NodeGroup is not IBasePowerNet)
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 = CalculateElectrifiedDamageScale(supp);
- if (damageScale <= 0f)
- return false;
+ var (damageScalar, timeScalar) = node.NodeGroupID switch
+ {
+ NodeGroupID.HVPower => (electrified.HighVoltageDamageMultiplier, electrified.HighVoltageTimeMultiplier),
+ NodeGroupID.MVPower => (electrified.MediumVoltageDamageMultiplier, electrified.MediumVoltageTimeMultiplier),
+ _ => (1f, 1f)
+ };
{
var lastRet = true;
entity,
uid,
node,
- (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)),
+ (int) (electrified.ShockDamage * MathF.Pow(RecursiveDamageMultiplier, depth) * damageScalar),
+ TimeSpan.FromSeconds(electrified.ShockTime * MathF.Pow(RecursiveTimeMultiplier, depth) * timeScalar),
true,
electrified.SiemensCoefficient);
}