Magic fix (#404)

* - tweak: Hfrequency blade.

* - fix: Magic fixes.
This commit is contained in:
Aviu00
2024-07-01 11:23:51 +00:00
committed by GitHub
parent 65283e1c44
commit 9e6b86c5ad
6 changed files with 108 additions and 74 deletions

View File

@@ -56,23 +56,39 @@ public sealed class ChargeActionSystem : SharedChargingSystem
{ {
base.Update(frameTime); base.Update(frameTime);
if (_playerManager.LocalEntity is not { } user) if (!_timing.IsFirstTimePredicted)
return; return;
if (_playerManager.LocalEntity is not { } user)
{
Reset();
return;
}
if (!_mobState.IsAlive(user) || _statusEffects.HasStatusEffect(user, "Incorporeal")) if (!_mobState.IsAlive(user) || _statusEffects.HasStatusEffect(user, "Incorporeal"))
{
Reset();
return; return;
}
if (!_timing.IsFirstTimePredicted || _controller == null || _controller.SelectingTargetFor is not { } actionId) if (_controller == null || _controller.SelectingTargetFor is not { } actionId)
{
Reset();
return; return;
}
if (!_actionsSystem.TryGetActionData(actionId, out var baseAction) || if (!_actionsSystem.TryGetActionData(actionId, out var baseAction) ||
baseAction is not BaseTargetActionComponent action || !action.IsChargeEnabled) baseAction is not BaseTargetActionComponent action || !action.IsChargeEnabled)
{
Reset();
return; return;
}
if (!action.Enabled if (!action.Enabled
|| action is { Charges: 0, RenewCharges: false } || action is { Charges: 0, RenewCharges: false }
|| action.Cooldown.HasValue && action.Cooldown.Value.End > _timing.CurTime) || action.Cooldown.HasValue && action.Cooldown.Value.End > _timing.CurTime)
{ {
Reset();
return; return;
} }
@@ -139,6 +155,17 @@ public sealed class ChargeActionSystem : SharedChargingSystem
} }
} }
private void Reset()
{
_charging = false;
_prevCharging = false;
_chargeTime = 0f;
_chargeLevel = 0;
_prevChargeLevel = 0;
_isChargingPlaying = false;
_isChargedPlaying = false;
}
private void HandleAction(EntityUid actionId, BaseTargetActionComponent action, EntityUid user, int chargeLevel) private void HandleAction(EntityUid actionId, BaseTargetActionComponent action, EntityUid user, int chargeLevel)
{ {
var mousePos = _eyeManager.PixelToMap(_inputManager.MouseScreenPosition); var mousePos = _eyeManager.PixelToMap(_inputManager.MouseScreenPosition);

View File

@@ -164,8 +164,7 @@ public sealed class MagicSystem : EntitySystem
if (!_wizardSpells.CanCast(args)) // WD EDIT if (!_wizardSpells.CanCast(args)) // WD EDIT
return; return;
args.Handled = true; _wizardSpells.Cast(args); // WD EDIT
Speak(args);
var transform = Transform(args.Performer); var transform = Transform(args.Performer);
var coords = transform.Coordinates; var coords = transform.Coordinates;
@@ -190,9 +189,7 @@ public sealed class MagicSystem : EntitySystem
if (!_wizardSpells.CanCast(ev)) // WD EDIT if (!_wizardSpells.CanCast(ev)) // WD EDIT
return; return;
ev.Handled = true; _wizardSpells.Cast(ev); // WD EDIT
Speak(ev);
var direction = _transformSystem.GetMapCoordinates(ev.Target).Position - _transformSystem.GetMapCoordinates(ev.Performer).Position; var direction = _transformSystem.GetMapCoordinates(ev.Target).Position - _transformSystem.GetMapCoordinates(ev.Performer).Position;
var impulseVector = direction * 10000; var impulseVector = direction * 10000;

View File

@@ -1,6 +1,7 @@
using Content.Shared._White.Wizard; using Content.Shared._White.Wizard;
using Content.Shared._White.Wizard.Charging; using Content.Shared._White.Wizard.Charging;
using Content.Shared.Follower; using Content.Shared.Follower;
using Content.Shared.Mobs;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems; using Robust.Shared.Audio.Systems;
using Robust.Shared.Player; using Robust.Shared.Player;
@@ -25,10 +26,13 @@ public sealed class ChargingSystem : SharedChargingSystem
SubscribeNetworkEvent<RequestSpellChargingAudio>(OnCharging); SubscribeNetworkEvent<RequestSpellChargingAudio>(OnCharging);
SubscribeNetworkEvent<RequestSpellChargedAudio>(OnCharged); SubscribeNetworkEvent<RequestSpellChargedAudio>(OnCharged);
SubscribeNetworkEvent<RequestAudioSpellStop>(OnStop); SubscribeNetworkEvent<RequestAudioSpellStop>(OnStop);
SubscribeLocalEvent<PlayerDetachedEvent>(OnDetach); SubscribeLocalEvent<PlayerDetachedEvent>(OnDetach);
SubscribeLocalEvent<MobStateChangedEvent>(OnStateChanged);
SubscribeNetworkEvent<AddWizardChargeEvent>(Add); SubscribeNetworkEvent<AddWizardChargeEvent>(Add);
SubscribeNetworkEvent<RemoveWizardChargeEvent>(Remove); SubscribeNetworkEvent<RemoveWizardChargeEvent>(Remove);
} }
#region Audio #region Audio
@@ -103,40 +107,29 @@ public sealed class ChargingSystem : SharedChargingSystem
if (user == null) if (user == null)
return; return;
if (_chargingLoops.TryGetValue(user.Value, out var currentStream)) StopAllSounds(user.Value);
{
_audio.Stop(currentStream);
_chargingLoops.Remove(user.Value);
}
if (_chargedLoop.TryGetValue(user.Value, out var chargedLoop))
{
_audio.Stop(chargedLoop);
_chargedLoop.Remove(user.Value);
}
}
private void OnDetach(PlayerDetachedEvent msg, EntitySessionEventArgs args)
{
var user = msg.Entity;
if (_chargingLoops.TryGetValue(user, out var currentStream))
{
_audio.Stop(currentStream);
_chargingLoops.Remove(user);
}
if (_chargedLoop.TryGetValue(user, out var chargedLoop))
{
_audio.Stop(chargedLoop);
_chargedLoop.Remove(user);
}
} }
#endregion #endregion
#region Charges #region Charges
private void OnDetach(PlayerDetachedEvent msg)
{
var user = msg.Entity;
RemoveAllCharges(user);
StopAllSounds(user);
}
private void OnStateChanged(MobStateChangedEvent ev)
{
var user = ev.Target;
RemoveAllCharges(user);
StopAllSounds(user);
}
private void Add(AddWizardChargeEvent msg, EntitySessionEventArgs args) private void Add(AddWizardChargeEvent msg, EntitySessionEventArgs args)
{ {
if (args.SenderSession.AttachedEntity != null) if (args.SenderSession.AttachedEntity != null)
@@ -153,6 +146,21 @@ public sealed class ChargingSystem : SharedChargingSystem
#region Helpers #region Helpers
public void StopAllSounds(EntityUid uid)
{
if (_chargingLoops.TryGetValue(uid, out var currentStream))
{
_audio.Stop(currentStream);
_chargingLoops.Remove(uid);
}
if (_chargedLoop.TryGetValue(uid, out var chargedLoop))
{
_audio.Stop(chargedLoop);
_chargedLoop.Remove(uid);
}
}
public void AddCharge(EntityUid uid, string msgChargeProto) public void AddCharge(EntityUid uid, string msgChargeProto)
{ {
var itemEnt = Spawn(msgChargeProto, Transform(uid).Coordinates); var itemEnt = Spawn(msgChargeProto, Transform(uid).Coordinates);

View File

@@ -2,6 +2,7 @@ using System.Linq;
using System.Numerics; using System.Numerics;
using Content.Server._White.Cult; using Content.Server._White.Cult;
using Content.Server._White.IncorporealSystem; using Content.Server._White.IncorporealSystem;
using Content.Server._White.Wizard.Charging;
using Content.Server._White.Wizard.Magic.Amaterasu; using Content.Server._White.Wizard.Magic.Amaterasu;
using Content.Server._White.Wizard.Magic.Other; using Content.Server._White.Wizard.Magic.Other;
using Content.Server._White.Wizard.Magic.TeslaProjectile; using Content.Server._White.Wizard.Magic.TeslaProjectile;
@@ -80,6 +81,7 @@ public sealed class WizardSpellsSystem : EntitySystem
[Dependency] private readonly EuiManager _euiManager = default!; [Dependency] private readonly EuiManager _euiManager = default!;
[Dependency] private readonly MindSystem _mindSystem = default!; [Dependency] private readonly MindSystem _mindSystem = default!;
[Dependency] private readonly ActionContainerSystem _actionContainer = default!; [Dependency] private readonly ActionContainerSystem _actionContainer = default!;
[Dependency] private readonly ChargingSystem _charging = default!;
#endregion #endregion
@@ -125,7 +127,7 @@ public sealed class WizardSpellsSystem : EntitySystem
return; return;
} }
msg.Handled = true; Cast(msg);
} }
#endregion #endregion
@@ -143,8 +145,7 @@ public sealed class WizardSpellsSystem : EntitySystem
var comp = EnsureComp<PreventCollideComponent>(ent); var comp = EnsureComp<PreventCollideComponent>(ent);
comp.Uid = msg.Performer; comp.Uid = msg.Performer;
msg.Handled = true; Cast(msg);
Speak(msg);
} }
#endregion #endregion
@@ -187,8 +188,7 @@ public sealed class WizardSpellsSystem : EntitySystem
_standing.TryLieDown(uid); _standing.TryLieDown(uid);
_standing.TryLieDown(target); _standing.TryLieDown(target);
msg.Handled = true; Cast(msg);
Speak(msg);
SwapComponent<WizardComponent>(uid, target); SwapComponent<WizardComponent>(uid, target);
SwapComponent<RevolutionaryComponent>(uid, target); SwapComponent<RevolutionaryComponent>(uid, target);
@@ -213,8 +213,7 @@ public sealed class WizardSpellsSystem : EntitySystem
_euiManager.OpenEui(eui, actor.PlayerSession); _euiManager.OpenEui(eui, actor.PlayerSession);
eui.StateDirty(); eui.StateDirty();
msg.Handled = true; Cast(msg, false);
Speak(msg);
} }
#endregion #endregion
@@ -264,8 +263,7 @@ public sealed class WizardSpellsSystem : EntitySystem
_handsSystem.TryForcePickupAnyHand(msg.Performer, recallComponent.Item.Value); _handsSystem.TryForcePickupAnyHand(msg.Performer, recallComponent.Item.Value);
_audio.PlayPvs(recallComponent.RecallSound, msg.Performer); _audio.PlayPvs(recallComponent.RecallSound, msg.Performer);
msg.Handled = true; Cast(msg);
Speak(msg);
return; return;
} }
@@ -293,8 +291,7 @@ public sealed class WizardSpellsSystem : EntitySystem
Spawn("AdminInstantEffectSmoke3", Transform(msg.Target).Coordinates); Spawn("AdminInstantEffectSmoke3", Transform(msg.Target).Coordinates);
msg.Handled = true; Cast(msg);
Speak(msg);
} }
#endregion #endregion
@@ -317,8 +314,7 @@ public sealed class WizardSpellsSystem : EntitySystem
Spawn("AdminInstantEffectSmoke3", Transform(msg.Target).Coordinates); Spawn("AdminInstantEffectSmoke3", Transform(msg.Target).Coordinates);
msg.Handled = true; Cast(msg);
Speak(msg);
} }
#endregion #endregion
@@ -340,8 +336,7 @@ public sealed class WizardSpellsSystem : EntitySystem
Spawn("AdminInstantEffectSmoke3", Transform(msg.Target).Coordinates); Spawn("AdminInstantEffectSmoke3", Transform(msg.Target).Coordinates);
msg.Handled = true; Cast(msg);
Speak(msg);
} }
#endregion #endregion
@@ -357,8 +352,7 @@ public sealed class WizardSpellsSystem : EntitySystem
_empSystem.EmpPulse(coords, 15, 1000000, 60f); _empSystem.EmpPulse(coords, 15, 1000000, 60f);
msg.Handled = true; Cast(msg);
Speak(msg);
} }
#endregion #endregion
@@ -381,8 +375,7 @@ public sealed class WizardSpellsSystem : EntitySystem
_statusEffectsSystem.TryAddStatusEffect<IncorporealComponent>(msg.Performer, "Incorporeal", _statusEffectsSystem.TryAddStatusEffect<IncorporealComponent>(msg.Performer, "Incorporeal",
TimeSpan.FromSeconds(10), false); TimeSpan.FromSeconds(10), false);
msg.Handled = true; Cast(msg);
Speak(msg);
} }
#endregion #endregion
@@ -434,8 +427,7 @@ public sealed class WizardSpellsSystem : EntitySystem
Spawn("AdminInstantEffectSmoke3", oldCoords); Spawn("AdminInstantEffectSmoke3", oldCoords);
Spawn("AdminInstantEffectSmoke3", coords); Spawn("AdminInstantEffectSmoke3", coords);
msg.Handled = true; Cast(msg);
Speak(msg);
} }
#endregion #endregion
@@ -460,9 +452,7 @@ public sealed class WizardSpellsSystem : EntitySystem
break; break;
} }
SetCooldown(msg.Action, msg.ActionUseType); Cast(msg);
msg.Handled = true;
Speak(msg);
} }
private void ForcewallSpellDefault(ForceWallSpellEvent msg) private void ForcewallSpellDefault(ForceWallSpellEvent msg)
@@ -533,9 +523,7 @@ public sealed class WizardSpellsSystem : EntitySystem
if (!result) if (!result)
return; return;
SetCooldown(msg.Action, msg.ActionUseType); Cast(msg);
msg.Handled = true;
Speak(msg);
} }
private void CardsSpellDefault(CardsSpellEvent msg) private void CardsSpellDefault(CardsSpellEvent msg)
@@ -638,9 +626,7 @@ public sealed class WizardSpellsSystem : EntitySystem
if (!result) if (!result)
return; return;
SetCooldown(msg.Action, msg.ActionUseType); Cast(msg);
msg.Handled = true;
Speak(msg);
} }
private void FireballSpellDefault(FireballSpellEvent msg) private void FireballSpellDefault(FireballSpellEvent msg)
@@ -725,9 +711,7 @@ public sealed class WizardSpellsSystem : EntitySystem
if (!result) if (!result)
return; return;
SetCooldown(msg.Action, msg.ActionUseType); Cast(msg);
msg.Handled = true;
Speak(msg);
} }
private bool ForceSpellAlt(ForceSpellEvent msg) private bool ForceSpellAlt(ForceSpellEvent msg)
@@ -782,9 +766,7 @@ public sealed class WizardSpellsSystem : EntitySystem
if (!result) if (!result)
return; return;
SetCooldown(msg.Action, msg.ActionUseType); Cast(msg);
msg.Handled = true;
Speak(msg);
} }
private bool ArcSpellDefault(ArcSpellEvent msg) private bool ArcSpellDefault(ArcSpellEvent msg)
@@ -844,6 +826,17 @@ public sealed class WizardSpellsSystem : EntitySystem
RaiseLocalEvent(uid, new EnergyDomeClothesTurnOffEvent()); RaiseLocalEvent(uid, new EnergyDomeClothesTurnOffEvent());
} }
public void Cast(BaseActionEvent msg, bool removeAllCharges = true)
{
SetCooldown(msg.Action, msg.ActionUseType);
msg.Handled = true;
Speak(msg);
if (!removeAllCharges)
return;
_charging.RemoveAllCharges(msg.Performer);
_charging.StopAllSounds(msg.Performer);
}
public bool CanCast(BaseActionEvent msg) public bool CanCast(BaseActionEvent msg)
{ {
return !msg.Handled && CheckRequirements(msg.Action, msg.Performer) && return !msg.Handled && CheckRequirements(msg.Action, msg.Performer) &&

View File

@@ -1,4 +1,5 @@
using Content.Server.EUI; using Content.Server._White.Wizard.Charging;
using Content.Server.EUI;
using Content.Server.Popups; using Content.Server.Popups;
using Content.Shared._White.Wizard.Teleport; using Content.Shared._White.Wizard.Teleport;
using Content.Shared.Eui; using Content.Shared.Eui;
@@ -15,6 +16,7 @@ public sealed class WizardTeleportSpellEui : BaseEui
private readonly TeleportLocationSystem _teleportLocation; private readonly TeleportLocationSystem _teleportLocation;
private readonly PullingSystem _pulling; private readonly PullingSystem _pulling;
private readonly PopupSystem _popupSystem; private readonly PopupSystem _popupSystem;
private readonly ChargingSystem _charging;
private readonly EntityUid _performer; private readonly EntityUid _performer;
@@ -28,6 +30,7 @@ public sealed class WizardTeleportSpellEui : BaseEui
_pulling = _entityManager.System<PullingSystem>(); _pulling = _entityManager.System<PullingSystem>();
_teleportLocation = _entityManager.System<TeleportLocationSystem>(); _teleportLocation = _entityManager.System<TeleportLocationSystem>();
_popupSystem = _entityManager.System<PopupSystem>(); _popupSystem = _entityManager.System<PopupSystem>();
_charging = _entityManager.System<ChargingSystem>();
_performer = performer; _performer = performer;
@@ -107,6 +110,9 @@ public sealed class WizardTeleportSpellEui : BaseEui
_entityManager.SpawnEntity("AdminInstantEffectSmoke10", oldCoords); _entityManager.SpawnEntity("AdminInstantEffectSmoke10", oldCoords);
_entityManager.SpawnEntity("AdminInstantEffectSmoke10", coords); _entityManager.SpawnEntity("AdminInstantEffectSmoke10", coords);
_charging.RemoveAllCharges(_performer);
_charging.StopAllSounds(_performer);
Close(); Close();
} }
} }

View File

@@ -15,12 +15,15 @@
- type: Clothing - type: Clothing
sprite: White/Objects/Weapons/Chaplain/hfrequency.rsi sprite: White/Objects/Weapons/Chaplain/hfrequency.rsi
slots: slots:
- back - none
- suitStorage
- type: Reflect - type: Reflect
reflectProb: 0.4 reflectProb: 0.4
- type: Item - type: Item
sprite: White/Objects/Weapons/Chaplain/hfrequency.rsi sprite: White/Objects/Weapons/Chaplain/hfrequency.rsi
size: Large
storedRotation: 44
shape:
- 0, 0, 3, 0
- type: entity - type: entity
name: клинок заклинаний name: клинок заклинаний