More magic (#338)

* - tweak: Magic tweaks.

* - add: Rework some spells.

* - fix: Some bugfixes.

* - tweak: Less requirements.

* - add: Loc.
This commit is contained in:
Aviu00
2024-06-08 13:01:49 +00:00
committed by GitHub
parent 4fde7aedee
commit c1fe31b63b
13 changed files with 168 additions and 84 deletions

View File

@@ -1,6 +1,7 @@
using System.Linq;
using Content.Server.Beam;
using Content.Server.Beam.Components;
using Content.Server.Electrocution;
using Content.Server.Lightning.Components;
using Content.Shared.Lightning;
using Robust.Shared.Random;
@@ -45,10 +46,16 @@ public sealed class LightningSystem : SharedLightningSystem
/// <param name="target">Where the lightning fires to</param>
/// <param name="lightningPrototype">The prototype for the lightning to be created</param>
/// <param name="triggerLightningEvents">if the lightnings being fired should trigger lightning events.</param>
public void ShootLightning(EntityUid user, EntityUid target, string lightningPrototype = "Lightning", bool triggerLightningEvents = true)
public void ShootLightning(EntityUid user, EntityUid target, string lightningPrototype = "Lightning", bool triggerLightningEvents = true, EntityUid? caster = null) // WD EDIT
{
var spriteState = LightningRandomizer();
_beam.TryCreateBeam(user, target, lightningPrototype, spriteState);
var ents = _beam.TryCreateBeam(user, target, lightningPrototype, spriteState); // WD EDIT START
foreach (var ent in ents)
{
if (TryComp(ent, out ElectrifiedComponent? electrified))
electrified.Caster = caster;
}
// WD EDIT END
if (triggerLightningEvents) // we don't want certain prototypes to trigger lightning level events
{
@@ -66,7 +73,7 @@ public sealed class LightningSystem : SharedLightningSystem
/// <param name="lightningPrototype">The prototype for the lightning to be created</param>
/// <param name="arcDepth">how many times to recursively fire lightning bolts from the target points of the first shot.</param>
/// <param name="triggerLightningEvents">if the lightnings being fired should trigger lightning events.</param>
public void ShootRandomLightnings(EntityUid user, float range, int boltCount, string lightningPrototype = "Lightning", int arcDepth = 0, bool triggerLightningEvents = true)
public void ShootRandomLightnings(EntityUid user, float range, int boltCount, string lightningPrototype = "Lightning", int arcDepth = 0, bool triggerLightningEvents = true, EntityUid? caster = null) // WD EDIT
{
//To Do: add support to different priority target tablem for different lightning types
//To Do: Remove Hardcode LightningTargetComponent (this should be a parameter of the SharedLightningComponent)
@@ -89,10 +96,10 @@ public sealed class LightningSystem : SharedLightningSystem
if (!_random.Prob(curTarget.HitProbability)) //Chance to ignore target
continue;
ShootLightning(user, targets[count].Owner, lightningPrototype, triggerLightningEvents);
ShootLightning(user, targets[count].Owner, lightningPrototype, triggerLightningEvents, caster); // WD EDIT
if (arcDepth - targets[count].LightningResistance > 0)
{
ShootRandomLightnings(targets[count].Owner, range, 1, lightningPrototype, arcDepth - targets[count].LightningResistance, triggerLightningEvents);
ShootRandomLightnings(targets[count].Owner, range, 1, lightningPrototype, arcDepth - targets[count].LightningResistance, triggerLightningEvents, caster); // WD EDIT
}
shootCount++;
}