-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The Lightning-Factor #543
The Lightning-Factor #543
Changes from all commits
8960987
e5c2f55
4270666
aa37867
cd93f05
2064a49
a3e2b4c
51006c6
adfe78b
f52115b
907a689
06a0132
6df2db8
722cb4b
89218fd
fb470db
37da556
ac5c8fe
f8d23b3
c902785
6cda0e0
af55fa7
4e56c75
a9b7126
de543cb
40b32d4
b6b4b72
02db056
228590a
3584d28
3eb4a4f
07fcfe3
71162d7
301f951
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -12,6 +12,7 @@ | |||||
using Content.Shared.Damage.Prototypes; | ||||||
using Content.Shared.Database; | ||||||
using Content.Shared.Electrocution; | ||||||
using Content.Shared.FixedPoint; | ||||||
using Content.Shared.IdentityManagement; | ||||||
using Content.Shared.Interaction; | ||||||
using Content.Shared.Inventory; | ||||||
|
@@ -203,6 +204,20 @@ | |||||
TryDoElectrifiedAct(uid, args.User, siemens, electrified); | ||||||
} | ||||||
|
||||||
/* | ||||||
im pretty sure this was removed in a cherry-pick, but id like to keep it around for future overvoltage stuff | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
-WarMechanic | ||||||
*/ | ||||||
public 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 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These should be arguments on the function |
||||||
|
||||||
return DamageShift + MathF.Log(power * LogGrowth) * CeilingCoefficent; | ||||||
} | ||||||
|
||||||
public bool TryDoElectrifiedAct(EntityUid uid, EntityUid targetUid, | ||||||
float siemens = 1, | ||||||
ElectrifiedComponent? electrified = null, | ||||||
|
@@ -290,16 +305,29 @@ | |||||
} | ||||||
} | ||||||
|
||||||
public bool TryDoElectrocution( | ||||||
EntityUid uid, EntityUid? sourceUid, FixedPoint2 shockDamage, TimeSpan time, bool refresh, float siemensCoefficient = 1f, | ||||||
StatusEffectsComponent? statusEffects = null, bool ignoreInsulation = false) | ||||||
{ | ||||||
var damage = new DamageSpecifier(); | ||||||
damage.DamageDict.Add("Shock", shockDamage.Value); | ||||||
|
||||||
return TryDoElectrocution( | ||||||
uid, sourceUid, damage, time, refresh, siemensCoefficient, | ||||||
statusEffects, ignoreInsulation | ||||||
); | ||||||
} | ||||||
|
||||||
/// <inheritdoc/> | ||||||
public override bool TryDoElectrocution( | ||||||
EntityUid uid, EntityUid? sourceUid, int shockDamage, TimeSpan time, bool refresh, float siemensCoefficient = 1f, | ||||||
EntityUid uid, EntityUid? sourceUid, DamageSpecifier damageSpecifier, TimeSpan time, bool refresh, float siemensCoefficient = 1f, | ||||||
StatusEffectsComponent? statusEffects = null, bool ignoreInsulation = false) | ||||||
{ | ||||||
if (!DoCommonElectrocutionAttempt(uid, sourceUid, ref siemensCoefficient, ignoreInsulation) | ||||||
|| !DoCommonElectrocution(uid, sourceUid, shockDamage, time, refresh, siemensCoefficient, statusEffects)) | ||||||
|| !DoCommonElectrocution(uid, sourceUid, damageSpecifier, time, refresh, siemensCoefficient, statusEffects)) | ||||||
return false; | ||||||
|
||||||
RaiseLocalEvent(uid, new ElectrocutedEvent(uid, sourceUid, siemensCoefficient, shockDamage), true); | ||||||
Check failure on line 330 in Content.Server/Electrocution/ElectrocutionSystem.cs GitHub Actions / build (ubuntu-latest)
Check failure on line 330 in Content.Server/Electrocution/ElectrocutionSystem.cs GitHub Actions / build (ubuntu-latest)
Check failure on line 330 in Content.Server/Electrocution/ElectrocutionSystem.cs GitHub Actions / Test Packaging
Check failure on line 330 in Content.Server/Electrocution/ElectrocutionSystem.cs GitHub Actions / Test Packaging
Check failure on line 330 in Content.Server/Electrocution/ElectrocutionSystem.cs GitHub Actions / build (ubuntu-latest)
Check failure on line 330 in Content.Server/Electrocution/ElectrocutionSystem.cs GitHub Actions / build (ubuntu-latest)
Check failure on line 330 in Content.Server/Electrocution/ElectrocutionSystem.cs GitHub Actions / YAML Linter
|
||||||
return true; | ||||||
} | ||||||
|
||||||
|
@@ -370,48 +398,54 @@ | |||||
} | ||||||
|
||||||
private bool DoCommonElectrocution(EntityUid uid, EntityUid? sourceUid, | ||||||
int? shockDamage, TimeSpan time, bool refresh, float siemensCoefficient = 1f, | ||||||
FixedPoint2? shockDamage, TimeSpan time, bool refresh, float siemensCoefficient = 1f, | ||||||
StatusEffectsComponent? statusEffects = null) | ||||||
{ | ||||||
var damage = new DamageSpecifier(); | ||||||
if (shockDamage.HasValue) | ||||||
damage.DamageDict.Add("Shock", shockDamage.Value); | ||||||
|
||||||
return DoCommonElectrocution(uid, sourceUid, damage, time, refresh, siemensCoefficient, statusEffects); | ||||||
} | ||||||
|
||||||
private bool DoCommonElectrocution(EntityUid uid, EntityUid? sourceUid, | ||||||
DamageSpecifier? damageSpecifier, TimeSpan time, bool refresh, float siemensCoefficient = 1f, | ||||||
StatusEffectsComponent? statusEffects = null) | ||||||
{ | ||||||
if (siemensCoefficient <= 0) | ||||||
return false; | ||||||
|
||||||
if (shockDamage != null) | ||||||
var checkDamage = false; | ||||||
if (damageSpecifier != null) | ||||||
{ | ||||||
shockDamage = (int) (shockDamage * siemensCoefficient); | ||||||
damageSpecifier *= siemensCoefficient; | ||||||
var actual = _damageable.TryChangeDamage(uid, damageSpecifier, origin: sourceUid); | ||||||
|
||||||
if (shockDamage.Value <= 0) | ||||||
return false; | ||||||
if (actual != null && actual.DamageDict.Values.Sum() > FixedPoint2.Zero) | ||||||
{ | ||||||
_adminLogger.Add(LogType.Electrocution, | ||||||
$"{ToPrettyString(uid):entity} received {actual.GetTotal():damage} powered electrocution damage{(sourceUid != null ? " from " + ToPrettyString(sourceUid.Value) : ""):source}"); | ||||||
|
||||||
checkDamage = true; | ||||||
} | ||||||
} | ||||||
|
||||||
if (!Resolve(uid, ref statusEffects, false) || | ||||||
!_statusEffects.CanApplyEffect(uid, StatusEffectKey, statusEffects)) | ||||||
var checkStun = false; | ||||||
if (siemensCoefficient > 0.5f | ||||||
&& Resolve(uid, ref statusEffects, false) | ||||||
&& _statusEffects.CanApplyEffect(uid, StatusEffectKey, statusEffects) | ||||||
&& _statusEffects.TryAddStatusEffect<ElectrocutedComponent>(uid, StatusEffectKey, time, refresh, statusEffects)) | ||||||
{ | ||||||
return false; | ||||||
_stun.TryParalyze(uid, time * ParalyzeTimeMultiplier, refresh, statusEffects); | ||||||
|
||||||
checkStun = true; | ||||||
} | ||||||
|
||||||
if (!_statusEffects.TryAddStatusEffect<ElectrocutedComponent>(uid, StatusEffectKey, time, refresh, statusEffects)) | ||||||
if (!checkDamage && !checkStun) | ||||||
return false; | ||||||
|
||||||
var shouldStun = siemensCoefficient > 0.5f; | ||||||
|
||||||
if (shouldStun) | ||||||
_stun.TryParalyze(uid, time * ParalyzeTimeMultiplier, refresh, statusEffects); | ||||||
|
||||||
// TODO: Sparks here. | ||||||
|
||||||
if (shockDamage is { } dmg) | ||||||
{ | ||||||
var actual = _damageable.TryChangeDamage(uid, | ||||||
new DamageSpecifier(_prototypeManager.Index<DamageTypePrototype>(DamageType), dmg), origin: sourceUid); | ||||||
|
||||||
if (actual != null) | ||||||
{ | ||||||
_adminLogger.Add(LogType.Electrocution, | ||||||
$"{ToPrettyString(uid):entity} received {actual.GetTotal():damage} powered electrocution damage{(sourceUid != null ? " from " + ToPrettyString(sourceUid.Value) : ""):source}"); | ||||||
} | ||||||
} | ||||||
|
||||||
_stuttering.DoStutter(uid, time * StutteringTimeMultiplier, refresh, statusEffects); | ||||||
_jittering.DoJitter(uid, time * JitterTimeMultiplier, refresh, JitterAmplitude, JitterFrequency, true, statusEffects); | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -403,7 +403,11 @@ private void RollMalfunction(Entity<ActiveMicrowaveComponent, MicrowaveComponent | |||||||||||||
} | ||||||||||||||
|
||||||||||||||
if (_random.Prob(ent.Comp2.LightningChance)) | ||||||||||||||
_lightning.ShootRandomLightnings(ent, 1.0f, 2, MalfunctionSpark, triggerLightningEvents: false); | ||||||||||||||
_lightning.ShootRandomLightnings(ent, 1.0f, 2, 5000f, | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
lightningPrototype: MalfunctionSpark, | ||||||||||||||
electrocute: false, | ||||||||||||||
explode: false | ||||||||||||||
); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
/// <summary> | ||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -13,60 +13,31 @@ namespace Content.Server.Lightning.Components; | |||||||||
public sealed partial class LightningTargetComponent : Component | ||||||||||
{ | ||||||||||
/// <summary> | ||||||||||
/// The probability that this target will not be ignored by a lightning strike. This is necessary for Tesla's balance. | ||||||||||
/// The probability weighting of being stuck by lightning, compared against other nearby lightning targets. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
/// </summary> | ||||||||||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||||||||||
public float HitProbability = 1f; | ||||||||||
|
||||||||||
/// <summary> | ||||||||||
/// Priority level for selecting a lightning target. | ||||||||||
/// </summary> | ||||||||||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||||||||||
public int Priority; | ||||||||||
[DataField] | ||||||||||
public float Weighting = 1f; | ||||||||||
|
||||||||||
/// <summary> | ||||||||||
/// Lightning has a number of bounces into neighboring targets. | ||||||||||
/// This number controls how many bounces the lightning bolt has left after hitting that target. | ||||||||||
/// At high values, the lightning will not travel farther than that entity. | ||||||||||
/// For the love of god, do not make this number negative. | ||||||||||
/// </summary> | ||||||||||
Comment on lines
+25
to
26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||||||||||
public int LightningResistance = 1; //by default, reduces the number of bounces from this target by 1 | ||||||||||
|
||||||||||
// BOOM PART | ||||||||||
|
||||||||||
/// <summary> | ||||||||||
/// Will the entity explode after being struck by lightning? | ||||||||||
/// </summary> | ||||||||||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||||||||||
public bool LightningExplode = true; | ||||||||||
|
||||||||||
/// <summary> | ||||||||||
/// The explosion prototype to spawn | ||||||||||
/// </summary> | ||||||||||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||||||||||
public ProtoId<ExplosionPrototype> ExplosionPrototype = "Default"; | ||||||||||
|
||||||||||
/// <summary> | ||||||||||
/// The total amount of intensity an explosion can achieve | ||||||||||
/// </summary> | ||||||||||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||||||||||
public float TotalIntensity = 25f; | ||||||||||
|
||||||||||
/// <summary> | ||||||||||
/// How quickly does the explosion's power slope? Higher = smaller area and more concentrated damage, lower = larger area and more spread out damage | ||||||||||
/// </summary> | ||||||||||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||||||||||
public float Dropoff = 2f; | ||||||||||
[DataField] | ||||||||||
public int LightningArcReduction = 0; | ||||||||||
|
||||||||||
/// <summary> | ||||||||||
/// How much intensity can be applied per tile? | ||||||||||
/// Lightning has a charge that gauges its energy. | ||||||||||
/// This number subtracts residual charge after absorption. | ||||||||||
/// </summary> | ||||||||||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||||||||||
public float MaxTileIntensity = 5f; | ||||||||||
[DataField] | ||||||||||
public float LightningChargeReduction = 0f; | ||||||||||
|
||||||||||
/// <summary> | ||||||||||
/// how much structural damage the object takes from a lightning strike | ||||||||||
/// Lightning has a charge that gauges its energy. | ||||||||||
/// This number multiplies residual charge after absorption. | ||||||||||
/// </summary> | ||||||||||
[DataField] | ||||||||||
public FixedPoint2 DamageFromLightning = 1; | ||||||||||
public float LightningChargeMultiplier = 1f; | ||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.