Skip to content

Commit

Permalink
cull exploding behaviour from LightningTarget, use Explosive instead
Browse files Browse the repository at this point in the history
  • Loading branch information
WarMechanic committed Jul 13, 2024
1 parent 6df2db8 commit 722cb4b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 48 deletions.
39 changes: 1 addition & 38 deletions Content.Server/Lightning/Components/LightningTargetComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,49 +17,12 @@ public sealed partial class LightningTargetComponent : Component
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
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.
/// </summary>
[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;

/// <summary>
/// How much intensity can be applied per tile?
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float MaxTileIntensity = 5f;

/// <summary>
/// how much structural damage the object takes from a lightning strike
/// </summary>
[DataField]
public FixedPoint2 DamageFromLightning = 1;
}
2 changes: 1 addition & 1 deletion Content.Server/Lightning/LightningSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public void ShootRandomLightnings(EntityUid user, float lightningRadius, int lig
bool allowLooping = false,
string lightningPrototype = "Lightning",
bool electrocute = true,
bool explode = false
bool explode = true
)
{
LightningContext context = new LightningContext()
Expand Down
16 changes: 7 additions & 9 deletions Content.Server/Lightning/LightningTargetSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Server.Electrocution;
using Content.Server.Explosion.Components;
using Content.Server.Explosion.EntitySystems;
using Content.Server.Lightning;
using Content.Server.Lightning.Components;
Expand Down Expand Up @@ -31,19 +32,16 @@ private void OnHitByLightning(Entity<LightningTargetComponent> uid, ref HitByLig

if (args.Context.Explode(args.Discharge, args.Context))
{
/*
DamageSpecifier damage = new();
damage.DamageDict.Add("Structural", uid.Comp.DamageFromLightning);
_damageable.TryChangeDamage(uid, damage, true);
*/

if (uid.Comp.LightningExplode)
{
_explosionSystem.QueueExplosion(
Transform(uid).MapPosition,
uid.Comp.ExplosionPrototype,
uid.Comp.TotalIntensity, uid.Comp.Dropoff,
uid.Comp.MaxTileIntensity,
canCreateVacuum: false);
}
if (!TryComp<ExplosiveComponent>(args.Target, out var comp))
return;

_explosionSystem.TriggerExplosive(args.Target, comp, true);
}
}
}

0 comments on commit 722cb4b

Please sign in to comment.