Cult spells update (#607)

* - add: CultSystem.BloodSpells.

* - add: Cleanup.
This commit is contained in:
Aviu00
2024-08-11 10:55:01 +00:00
committed by GitHub
parent 00a58cf850
commit e14b6cb948
26 changed files with 290 additions and 72 deletions

View File

@@ -28,6 +28,7 @@ using Content.Shared._White.Antag;
using Content.Shared._White.Cult.Components;
using Content.Shared._White.Cult.Systems;
using Content.Shared._White.Mood;
using Content.Shared.Alert;
using Content.Shared.Cloning;
using Content.Shared.Mind;
using Content.Shared.NPC.Systems;
@@ -55,6 +56,7 @@ public sealed class CultRuleSystem : GameRuleSystem<CultRuleComponent>
[Dependency] private readonly BloodSpearSystem _bloodSpear = default!;
[Dependency] private readonly ContainerSystem _container = default!;
[Dependency] private readonly HandsSystem _hands = default!;
[Dependency] private readonly AlertsSystem _alertsSystem = default!;
private const int PlayerPerCultist = 10;
private int _minStartingCultists;
@@ -95,7 +97,6 @@ public sealed class CultRuleSystem : GameRuleSystem<CultRuleComponent>
private void OnGetBriefing(Entity<CultistRoleComponent> ent, ref GetBriefingEvent args)
{
args.Append(Loc.GetString("cult-role-briefing-short"));
args.Append(Loc.GetString("cult-role-briefing-hint"));
}
private void OnStartAttempt(RoundStartAttemptEvent ev)
@@ -166,6 +167,7 @@ public sealed class CultRuleSystem : GameRuleSystem<CultRuleComponent>
private void OnCultistComponentInit(EntityUid uid, CultistComponent component, ComponentInit args)
{
RaiseLocalEvent(uid, new MoodEffectEvent("CultFocused"));
_alertsSystem.ShowAlert(uid, AlertType.BloodSpells);
var query = QueryActiveRules();
while (query.MoveNext(out _, out var cult, out _))
@@ -213,6 +215,7 @@ public sealed class CultRuleSystem : GameRuleSystem<CultRuleComponent>
RemoveAllCultistItems(uid);
RemoveCultistAppearance(uid);
RaiseLocalEvent(uid, new MoodRemoveEffectEvent("CultFocused"));
_alertsSystem.ClearAlert(uid, AlertType.BloodSpells);
}
_bloodSpear.DetachSpearFromUser((uid, component));

View File

@@ -6,12 +6,9 @@ public sealed partial class CultStunHandComponent : BaseMagicHandComponent
[DataField]
public TimeSpan Duration = TimeSpan.FromSeconds(16);
[DataField]
public TimeSpan HaloDuration = TimeSpan.FromSeconds(1.5);
[DataField]
public TimeSpan MuteDuration = TimeSpan.FromSeconds(12);
[DataField]
public TimeSpan HaloMuteDuration = TimeSpan.FromSeconds(1);
public float PentagramDurationMultiplier = 0.1f;
}

View File

@@ -245,11 +245,18 @@ public sealed class MagicHandSystem : EntitySystem
return;
}
var halo = HasComp<PentagramComponent>(args.User);
var stunDuration = comp.Duration;
var muteDuration = comp.MuteDuration;
_statusEffects.TryAddStatusEffect(target, "Muted", halo ? comp.HaloMuteDuration : comp.MuteDuration, true,
"Muted", status);
_stun.TryParalyze(target, halo ? comp.HaloDuration : comp.Duration, true, status);
if (HasComp<PentagramComponent>(args.User))
{
var multiplier = comp.PentagramDurationMultiplier;
stunDuration *= multiplier;
muteDuration *= multiplier;
}
_statusEffects.TryAddStatusEffect(target, "Muted", muteDuration, true, "Muted", status);
_stun.TryParalyze(target, stunDuration, true, status);
}
private void Popup(string msg, EntityUid user, PopupType type = PopupType.Small)

View File

@@ -3,16 +3,14 @@ using Content.Server.Body.Components;
using Content.Shared._White.Cult;
using Content.Shared._White.Cult.Components;
using Content.Shared.DoAfter;
using Content.Shared.Verbs;
using Robust.Shared.Player;
namespace Content.Server._White.Cult.Runes.Systems;
public sealed partial class CultSystem
{
public void InitializeVerb()
public void InitializeSpells()
{
SubscribeLocalEvent<CultistComponent, GetVerbsEvent<Verb>>(OnGetVerbs);
SubscribeLocalEvent<CultistComponent, CultEmpowerSelectedBuiMessage>(OnCultistEmpowerSelected);
SubscribeLocalEvent<CultistComponent, CultEmpowerRemoveBuiMessage>(OnCultistEmpowerRemove);
SubscribeLocalEvent<CultistComponent, SpellCreatedEvent>(OnSpellCreated);
@@ -57,7 +55,7 @@ public sealed partial class CultSystem
if (comp.SelectedEmpowers.Count >= 2)
{
_popupSystem.PopupEntity(Loc.GetString("verb-spell-create-too-much"), ent, ent);
_popupSystem.PopupEntity(Loc.GetString("blood-spell-create-too-much"), ent, ent);
return;
}
@@ -71,42 +69,16 @@ public sealed partial class CultSystem
});
}
private void OnGetVerbs(Entity<CultistComponent> ent, ref GetVerbsEvent<Verb> args)
public void CreateSpell(Entity<CultistComponent> ent, ICommonSession session)
{
if (ent.Owner != args.User || !TryComp<ActorComponent>(args.User, out var actor))
return;
var createSpellVerb = new Verb
{
Text = Loc.GetString("verb-spell-create-text"),
Message = Loc.GetString("verb-spell-create-message"),
Category = VerbCategory.Cult,
Act = () =>
{
_ui.TryOpen(ent, CultEmpowerUiKey.Key, actor.PlayerSession);
}
};
var removeSpellVerb = new Verb
{
Text = Loc.GetString("verb-spell-remove-text"),
Message = Loc.GetString("verb-spell-remove-message"),
Category = VerbCategory.Cult,
Act = () =>
{
RemoveSpell(ent, actor.PlayerSession);
}
};
args.Verbs.Add(createSpellVerb);
args.Verbs.Add(removeSpellVerb);
_ui.TryOpen(ent, CultEmpowerUiKey.Key, session);
}
private void RemoveSpell(Entity<CultistComponent> ent, ICommonSession session)
public void RemoveSpell(Entity<CultistComponent> ent, ICommonSession session)
{
if (ent.Comp.SelectedEmpowers.Count == 0)
{
_popupSystem.PopupEntity(Loc.GetString("verb-spell-remove-no-spells"), ent, ent);
_popupSystem.PopupEntity(Loc.GetString("blood-spell-remove-no-spells"), ent, ent);
return;
}

View File

@@ -127,7 +127,7 @@ public sealed partial class CultSystem : EntitySystem
InitializeBarrierSystem();
InitializeConstructsAbilities();
InitializeActions();
InitializeVerb();
InitializeSpells();
}
private float _timeToDraw;

View File

@@ -0,0 +1,53 @@
using Content.Server.EUI;
using Content.Server.Popups;
using Content.Server._White.Cult.Runes.Comps;
using Content.Server._White.Cult.Runes.Systems;
using Content.Shared._White.Cult.Components;
using Content.Shared.Eui;
using Content.Shared.Popups;
using Content.Shared._White.Cult.UI;
using Content.Shared.Movement.Pulling.Components;
using Content.Shared.Movement.Pulling.Systems;
using Robust.Shared.Player;
using Robust.Shared.Timing;
namespace Content.Server._White.Cult.UI;
public sealed class CultBloodSpellsEui : BaseEui
{
private readonly IEntityManager _entityManager;
private readonly CultSystem _cult;
private readonly EntityUid _performer;
public CultBloodSpellsEui(EntityUid performer, IEntityManager entityManager)
{
_entityManager = entityManager;
_cult = _entityManager.System<CultSystem>();
_performer = performer;
}
public override void HandleMessage(EuiMessageBase msg)
{
base.HandleMessage(msg);
if (msg is not BloodSpellMessage cast || cast.State == BloodSpellMessageState.Cancel)
{
Close();
return;
}
if (!_entityManager.TryGetComponent(_performer, out CultistComponent? cultist))
{
Close();
return;
}
if (cast.State == BloodSpellMessageState.Create)
_cult.CreateSpell((_performer, cultist), Player);
else if (cast.State == BloodSpellMessageState.Remove)
_cult.RemoveSpell((_performer, cultist), Player);
Close();
}
}

View File

@@ -0,0 +1,21 @@
using Content.Server.EUI;
using Content.Shared.Alert;
using JetBrains.Annotations;
using Robust.Shared.Player;
namespace Content.Server._White.Cult.UI;
[UsedImplicitly, DataDefinition]
public sealed partial class OpenBloodSpellsUi : IAlertClick
{
public void AlertClicked(EntityUid player)
{
var euiManager = IoCManager.Resolve<EuiManager>();
var entManager = IoCManager.Resolve<IEntityManager>();
if (!entManager.TryGetComponent(player, out ActorComponent? actor))
return;
euiManager.OpenEui(new CultBloodSpellsEui(player, entManager), actor.PlayerSession);
}
}