Spellblade update (#346)

* - tweak: Don't close eui too quickly.

* - add: Spellblade update.

* - fix: Cult teleport spell.
This commit is contained in:
Aviu00
2024-06-11 20:07:47 +00:00
committed by GitHub
parent ee41166fc0
commit 4d09ed9245
31 changed files with 583 additions and 65 deletions

View File

@@ -1,3 +1,4 @@
using Content.Server._White.Wizard.SpellBlade;
using Content.Server.Administration.Logs;
using Content.Server.Atmos.Components;
using Content.Server.IgnitionSource;
@@ -49,6 +50,7 @@ namespace Content.Server.Atmos.EntitySystems
[Dependency] private readonly UseDelaySystem _useDelay = default!;
[Dependency] private readonly AudioSystem _audio = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SpellBladeSystem _spellBlade = default!; // WD
public const float MinimumFireStacks = -10f;
public const float MaximumFireStacks = 20f;
@@ -84,13 +86,19 @@ namespace Content.Server.Atmos.EntitySystems
private void OnMeleeHit(EntityUid uid, IgniteOnMeleeHitComponent component, MeleeHitEvent args)
{
// WD START
var fireStacks = component.FireStacks;
if (args.Direction != null) // Heavy attack
fireStacks *= 0.5f;
// WD END
foreach (var entity in args.HitEntities)
{
if (!TryComp<FlammableComponent>(entity, out var flammable))
continue;
AdjustFireStacks(entity, component.FireStacks, flammable);
if (component.FireStacks >= 0)
AdjustFireStacks(entity, fireStacks, flammable); // WD EDIT
if (fireStacks >= 0) // WD EDIT
Ignite(entity, args.Weapon, flammable, args.User);
}
}
@@ -203,8 +211,15 @@ namespace Content.Server.Atmos.EntitySystems
if (!flammable.OnFire && !otherFlammable.OnFire)
return; // Neither are on fire
// WD START
var weHold = _spellBlade.IsHoldingItemWithComponent<FireAspectComponent>(uid);
var theyHold = _spellBlade.IsHoldingItemWithComponent<FireAspectComponent>(otherUid);
// WD END
if (flammable.OnFire && otherFlammable.OnFire)
{
if (weHold && !theyHold || theyHold && !weHold) // WD
return;
// Both are on fire -> equalize fire stacks.
var avg = (flammable.FireStacks + otherFlammable.FireStacks) / 2;
flammable.FireStacks = flammable.CanExtinguish ? avg : Math.Max(flammable.FireStacks, avg);
@@ -217,6 +232,8 @@ namespace Content.Server.Atmos.EntitySystems
// Only one is on fire -> attempt to spread the fire.
if (flammable.OnFire)
{
if (theyHold) // WD
return;
otherFlammable.FireStacks += flammable.FireStacks / 2;
Ignite(otherUid, uid, otherFlammable);
if (flammable.CanExtinguish)
@@ -227,6 +244,8 @@ namespace Content.Server.Atmos.EntitySystems
}
else
{
if (weHold) // WD
return;
flammable.FireStacks += otherFlammable.FireStacks / 2;
Ignite(uid, otherUid, flammable);
if (otherFlammable.CanExtinguish)
@@ -436,7 +455,8 @@ namespace Content.Server.Atmos.EntitySystems
if (TryComp(uid, out TemperatureComponent? temp))
_temperatureSystem.ChangeHeat(uid, 12500 * damageScale, false, temp);
_damageableSystem.TryChangeDamage(uid, flammable.Damage * damageScale, interruptsDoAfters: false);
if (!_spellBlade.IsHoldingItemWithComponent<FireAspectComponent>(uid)) // WD EDIT
_damageableSystem.TryChangeDamage(uid, flammable.Damage * damageScale, interruptsDoAfters: false);
AdjustFireStacks(uid, flammable.FirestackFade * (flammable.Resisting ? 10f : 1f), flammable);
}

View File

@@ -1,4 +1,5 @@
using System.Linq;
using Content.Server._White.Wizard.SpellBlade;
using Content.Server.Administration.Logs;
using Content.Server.Atmos.Components;
using Content.Server.Atmos.EntitySystems;
@@ -22,6 +23,7 @@ public sealed class TemperatureSystem : EntitySystem
[Dependency] private readonly AtmosphereSystem _atmosphere = default!;
[Dependency] private readonly DamageableSystem _damageable = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly SpellBladeSystem _spellBlade = default!; // WD
/// <summary>
/// All the components that will have their damage updated at the end of the tick.
@@ -266,6 +268,17 @@ public sealed class TemperatureSystem : EntitySystem
if (temperature.CurrentTemperature >= heatDamageThreshold)
{
// WD START
if (_spellBlade.IsHoldingItemWithComponent<FireAspectComponent>(uid))
{
if (!temperature.TakingDamage)
return;
_adminLogger.Add(LogType.Temperature,
$"{ToPrettyString(uid):entity} stopped taking temperature damage");
temperature.TakingDamage = false;
return;
}
// WD END
if (!temperature.TakingDamage)
{
_adminLogger.Add(LogType.Temperature, $"{ToPrettyString(uid):entity} started taking high temperature damage");
@@ -278,7 +291,8 @@ public sealed class TemperatureSystem : EntitySystem
}
else if (temperature.CurrentTemperature <= coldDamageThreshold)
{
if (TryComp(uid, out VoidAdaptationComponent? voidAdaptation)) // WD
// WD START
if (TryComp(uid, out VoidAdaptationComponent? voidAdaptation))
{
if (temperature.TakingDamage)
{
@@ -291,6 +305,17 @@ public sealed class TemperatureSystem : EntitySystem
return;
}
if (_spellBlade.IsHoldingItemWithComponent<FrostAspectComponent>(uid))
{
if (!temperature.TakingDamage)
return;
_adminLogger.Add(LogType.Temperature,
$"{ToPrettyString(uid):entity} stopped taking temperature damage");
temperature.TakingDamage = false;
return;
}
// WD END
if (!temperature.TakingDamage)
{
_adminLogger.Add(LogType.Temperature, $"{ToPrettyString(uid):entity} started taking low temperature damage");

View File

@@ -1,3 +1,4 @@
using Content.Server._White.Wizard.SpellBlade;
using Content.Server.Temperature.Components;
using Content.Server.Temperature.Systems;
using Content.Shared.Changeling;
@@ -10,6 +11,7 @@ namespace Content.Server._White.ChangeTemperatureOnCollide;
public sealed class LowTemperatureSlowdownSystem : EntitySystem
{
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifierSystem = default!;
[Dependency] private readonly SpellBladeSystem _spellBlade = default!;
public override void Initialize()
{
@@ -22,7 +24,8 @@ public sealed class LowTemperatureSlowdownSystem : EntitySystem
private void OnMoveSpeedRefresh(EntityUid uid, TemperatureComponent component,
RefreshMovementSpeedModifiersEvent args)
{
var modifier = HasComp<GodmodeComponent>(uid) || HasComp<VoidAdaptationComponent>(uid) || !component.Slowdown
var modifier = _spellBlade.IsHoldingItemWithComponent<FrostAspectComponent>(uid) ||
HasComp<GodmodeComponent>(uid) || HasComp<VoidAdaptationComponent>(uid) || !component.Slowdown
? 1f
: GetSpeedModifier(component.CurrentTemperature);
args.ModifySpeed(modifier, modifier);
@@ -32,7 +35,7 @@ public sealed class LowTemperatureSlowdownSystem : EntitySystem
OnTemperatureChangeEvent args)
{
// ReSharper disable once CompareOfFloatsByEqualityOperator
if(GetSpeedModifier(args.LastTemperature) == GetSpeedModifier(args.CurrentTemperature))
if (GetSpeedModifier(args.LastTemperature) == GetSpeedModifier(args.CurrentTemperature))
return;
_movementSpeedModifierSystem.RefreshMovementSpeedModifiers(uid, component);

View File

@@ -148,7 +148,7 @@ public partial class CultSystem
_bloodstreamSystem.TryModifyBloodLevel(uid, -5, bloodstream, createPuddle: false);
var eui = new TeleportSpellEui(args.Performer, args.Target);
var eui = new CultTeleportSpellEui(args.Performer, args.Target);
_euiManager.OpenEui(eui, actor.PlayerSession);
eui.StateDirty();

View File

@@ -631,6 +631,18 @@ public sealed partial class CultSystem : EntitySystem
}
private bool Teleport(EntityUid rune, EntityUid user, List<EntityUid>? victims = null)
{
if (!OpenTeleportUi(user, rune))
return false;
_entityManager.EnsureComponent<CultTeleportRuneProviderComponent>(user, out var providerComponent);
providerComponent.Targets = victims;
providerComponent.BaseRune = rune;
return true;
}
private bool OpenTeleportUi(EntityUid user, EntityUid? exceptRune = null)
{
var runesQuery = EntityQueryEnumerator<CultRuneTeleportComponent>();
var list = new List<int>();
@@ -641,7 +653,7 @@ public sealed partial class CultSystem : EntitySystem
if (teleportComponent.Label == null)
continue;
if (runeUid == rune)
if (runeUid == exceptRune)
continue;
if (!int.TryParse(runeUid.ToString(), out var intValue))
@@ -665,10 +677,6 @@ public sealed partial class CultSystem : EntitySystem
return false;
}
_entityManager.EnsureComponent<CultTeleportRuneProviderComponent>(user, out var providerComponent);
providerComponent.Targets = victims;
providerComponent.BaseRune = rune;
_ui.SetUiState(ui, new TeleportRunesListWindowBUIState(list, labels));
if (_ui.IsUiOpen(user, ui.UiKey))

View File

@@ -10,7 +10,7 @@ using Robust.Shared.Timing;
namespace Content.Server._White.Cult.UI;
public sealed class TeleportSpellEui : BaseEui
public sealed class CultTeleportSpellEui : BaseEui
{
[Dependency] private readonly EntityManager _entityManager = default!;
private readonly SharedTransformSystem _transformSystem;
@@ -22,7 +22,7 @@ public sealed class TeleportSpellEui : BaseEui
private bool _used;
public TeleportSpellEui(EntityUid performer, EntityUid target)
public CultTeleportSpellEui(EntityUid performer, EntityUid target)
{
IoCManager.InjectDependencies(this);
@@ -39,7 +39,7 @@ public sealed class TeleportSpellEui : BaseEui
public override EuiStateBase GetNewState()
{
var runesQuery = _entityManager.EntityQueryEnumerator<CultRuneTeleportComponent>();
var state = new TeleportSpellEuiState();
var state = new CultTeleportSpellEuiState();
while (runesQuery.MoveNext(out var runeUid, out var rune))
{
@@ -110,4 +110,4 @@ public sealed class TeleportSpellEui : BaseEui
_transformSystem.SetCoordinates(_target, runeTransform.Coordinates);
Close();
}
}
}

View File

@@ -105,7 +105,7 @@ public sealed class WizardSpellsSystem : EntitySystem
if (!TryComp(msg.Performer, out ActorComponent? actor))
return;
var eui = new TeleportSpellEui(msg.Performer);
var eui = new WizardTeleportSpellEui(msg.Performer);
_euiManager.OpenEui(eui, actor.PlayerSession);
eui.StateDirty();

View File

@@ -0,0 +1,6 @@
namespace Content.Server._White.Wizard.SpellBlade;
[RegisterComponent]
public sealed partial class FireAspectComponent : Component
{
}

View File

@@ -0,0 +1,13 @@
using Content.Shared.Atmos;
namespace Content.Server._White.Wizard.SpellBlade;
[RegisterComponent]
public sealed partial class FrostAspectComponent : Component
{
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float TemperatureOnHit = 100;
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float MinTemperature = Atmospherics.TCMB;
}

View File

@@ -0,0 +1,22 @@
namespace Content.Server._White.Wizard.SpellBlade;
[RegisterComponent]
public sealed partial class LightningAspectComponent : Component
{
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float Range = 2f;
[DataField, ViewVariables(VVAccess.ReadWrite)]
public int BoltCount = 3;
[DataField, ViewVariables(VVAccess.ReadWrite)]
public string LightningPrototype = "WeakWizardLightning";
[DataField, ViewVariables(VVAccess.ReadWrite)]
public int ArcDepth = 2;
[DataField, ViewVariables(VVAccess.ReadWrite)]
public TimeSpan ShockRate = TimeSpan.FromSeconds(10);
public TimeSpan NextShock;
}

View File

@@ -0,0 +1,79 @@
using Content.Server.Atmos.Components;
using Content.Server.Lightning;
using Content.Server.Temperature.Components;
using Content.Server.Temperature.Systems;
using Content.Shared._White.Wizard.SpellBlade;
using Content.Shared.Weapons.Melee.Events;
using Robust.Shared.Timing;
namespace Content.Server._White.Wizard.SpellBlade;
public sealed class SpellBladeSystem : SharedSpellBladeSystem
{
[Dependency] private readonly TemperatureSystem _temperature = default!;
[Dependency] private readonly LightningSystem _lightning = default!;
[Dependency] private readonly IGameTiming _timing = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<FrostAspectComponent, MeleeHitEvent>(OnFrostMeleeHit);
SubscribeLocalEvent<LightningAspectComponent, MeleeHitEvent>(OnLightningMeleeHit);
}
private void OnLightningMeleeHit(Entity<LightningAspectComponent> ent, ref MeleeHitEvent args)
{
if (args.Direction != null || args.HitEntities.Count != 1)
return;
if (ent.Comp.NextShock > _timing.CurTime)
return;
ent.Comp.NextShock = _timing.CurTime + ent.Comp.ShockRate;
_lightning.ShootRandomLightnings(args.HitEntities[0], ent.Comp.Range, ent.Comp.BoltCount,
ent.Comp.LightningPrototype, ent.Comp.ArcDepth, false, args.User);
}
private void OnFrostMeleeHit(Entity<FrostAspectComponent> ent, ref MeleeHitEvent args)
{
var temp = ent.Comp.TemperatureOnHit;
if (args.Direction != null) // Heavy attack
temp *= 0.5f;
foreach (var entity in args.HitEntities)
{
if (!TryComp<TemperatureComponent>(entity, out var temperature))
continue;
var curTemp = temperature.CurrentTemperature;
var newTemp = curTemp - temp;
newTemp = curTemp < ent.Comp.MinTemperature
? MathF.Min(curTemp, newTemp)
: Math.Max(newTemp, ent.Comp.MinTemperature);
_temperature.ForceChangeTemperature(entity, newTemp, temperature);
}
}
protected override void ApplyFireAspect(EntityUid uid)
{
var ignite = EnsureComp<IgniteOnMeleeHitComponent>(uid);
ignite.FireStacks = 2f;
EnsureComp<FireAspectComponent>(uid);
}
protected override void ApplyFrostAspect(EntityUid uid)
{
var ignite = EnsureComp<IgniteOnMeleeHitComponent>(uid);
ignite.FireStacks = -5f;
EnsureComp<FrostAspectComponent>(uid);
}
protected override void ApplyLightningAspect(EntityUid uid)
{
EnsureComp<LightningAspectComponent>(uid);
}
}

View File

@@ -1,14 +1,12 @@
using System.Linq;
using Content.Server.EUI;
using Content.Server.EUI;
using Content.Server.Popups;
using Content.Shared._White.Wizard.Teleport;
using Content.Shared.Eui;
using Robust.Shared.Timing;
using TeleportSpellEuiState = Content.Shared._White.Wizard.Teleport.TeleportSpellEuiState;
namespace Content.Server._White.Wizard.Teleport;
public sealed class TeleportSpellEui : BaseEui
public sealed class WizardTeleportSpellEui : BaseEui
{
[Dependency] private readonly EntityManager _entityManager = default!;
private readonly SharedTransformSystem _transformSystem;
@@ -19,7 +17,7 @@ public sealed class TeleportSpellEui : BaseEui
private bool _used;
public TeleportSpellEui(EntityUid performer)
public WizardTeleportSpellEui(EntityUid performer)
{
IoCManager.InjectDependencies(this);
@@ -29,13 +27,13 @@ public sealed class TeleportSpellEui : BaseEui
_performer = performer;
Timer.Spawn(TimeSpan.FromSeconds(10), Close);
Timer.Spawn(TimeSpan.FromSeconds(60), Close);
}
public override EuiStateBase GetNewState()
{
var locationQuery = _entityManager.EntityQueryEnumerator<TeleportLocationComponent, TransformComponent>();
var state = new TeleportSpellEuiState();
var state = new WizardTeleportSpellEuiState();
while (locationQuery.MoveNext(out var locationUid, out var locationComponent, out var transformComponent))
{