Skip to content

Commit

Permalink
[Tweak|Fix] Blood Cult (#169)
Browse files Browse the repository at this point in the history
* fixs: blood cult

* fix

* fix: tupo
  • Loading branch information
Spatison authored Dec 22, 2024
1 parent 1b458aa commit f25e700
Show file tree
Hide file tree
Showing 34 changed files with 474 additions and 132 deletions.
14 changes: 12 additions & 2 deletions Content.Server/WhiteDream/BloodCult/BloodCultChatSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Content.Shared.Chat;
using Content.Shared.Language;
using Content.Shared.WhiteDream.BloodCult.BloodCultist;
using Content.Shared.WhiteDream.BloodCult.Constructs;
using Robust.Shared.Network;
using Robust.Shared.Player;
using Robust.Shared.Utility;
Expand All @@ -23,10 +24,19 @@ public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<BloodCultistComponent, EntitySpokeEvent>(OnSpeak);
SubscribeLocalEvent<BloodCultistComponent, EntitySpokeEvent>(OnCultistSpeak);
SubscribeLocalEvent<ConstructComponent, EntitySpokeEvent>(OnConstructSpeak);
}

private void OnSpeak(EntityUid uid, BloodCultistComponent component, EntitySpokeEvent args)
private void OnCultistSpeak(EntityUid uid, BloodCultistComponent component, EntitySpokeEvent args)
{
if (args.Source != uid || args.Language.ID != component.CultLanguageId || args.IsWhisper)
return;

SendMessage(args.Source, args.Message, false, args.Language);
}

private void OnConstructSpeak(EntityUid uid, ConstructComponent component, EntitySpokeEvent args)
{
if (args.Source != uid || args.Language.ID != component.CultLanguageId || args.IsWhisper)
return;
Expand Down
13 changes: 13 additions & 0 deletions Content.Server/WhiteDream/BloodCult/Constructs/ConstructSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Server.Actions;
using Content.Server.WhiteDream.BloodCult.Gamerule;
using Content.Shared.Mobs;
using Content.Shared.WhiteDream.BloodCult;
using Content.Shared.WhiteDream.BloodCult.Constructs;
using Robust.Server.GameObjects;
Expand All @@ -17,6 +18,7 @@ public override void Initialize()

SubscribeLocalEvent<ConstructComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<ConstructComponent, ComponentShutdown>(OnComponentShutdown);
SubscribeLocalEvent<ConstructComponent, MobStateChangedEvent>(OnMobStateChanged);
}

public override void Update(float frameTime)
Expand Down Expand Up @@ -63,4 +65,15 @@ private void OnComponentShutdown(Entity<ConstructComponent> construct, ref Compo
while (cultistRule.MoveNext(out _, out var rule))
rule.Constructs.Remove(construct);
}

private void OnMobStateChanged(EntityUid uid, ConstructComponent component, MobStateChangedEvent args)
{
if (args.NewMobState != MobState.Dead)
return;

var xform = Transform(uid);
Spawn(component.SpawnOnDeathPrototype, xform.Coordinates);

QueueDel(uid);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Content.Shared.Chat;

namespace Content.Server.WhiteDream.BloodCult.Items.BaseAura;

public abstract partial class BaseAuraComponent : Component
{
[DataField]
public string? Speech;

[DataField]
public InGameICChatType ChatType = InGameICChatType.Whisper;
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using Content.Server.Actions;
using Content.Server.Hands.Systems;
using Content.Server.Projectiles;
using Content.Server.Stunnable;
using Content.Shared.Humanoid;
using Content.Shared.Item;
using Content.Shared.Projectiles;
using Content.Shared.WhiteDream.BloodCult.BloodCultist;
using Content.Shared.WhiteDream.BloodCult.Spells;
using Robust.Server.Audio;
using Robust.Server.GameObjects;

namespace Content.Server.WhiteDream.BloodCult.Items.BloodSpear;

Expand All @@ -16,6 +18,8 @@ public sealed class BloodSpearSystem : EntitySystem
[Dependency] private readonly AudioSystem _audio = default!;
[Dependency] private readonly HandsSystem _hands = default!;
[Dependency] private readonly StunSystem _stun = default!;
[Dependency] private readonly TransformSystem _transform = default!;
[Dependency] private readonly ProjectileSystem _projectile = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -66,6 +70,16 @@ private void OnSpearRecalled(Entity<BloodCultistComponent> cultist, ref BloodSpe
if (!spearUid.HasValue || !TryComp(spearUid, out BloodSpearComponent? spear))
return;

var spearXform = Transform(spearUid.Value);
var cultistCoords = _transform.GetWorldPosition(cultist);

if (TryComp<EmbeddableProjectileComponent>(spearUid, out var embeddableProjectile)
&& embeddableProjectile.Target.HasValue)
_projectile.RemoveEmbed(spearUid.Value, embeddableProjectile);

_transform.AttachToGridOrMap(spearUid.Value, spearXform);
_transform.SetWorldPosition(spearXform, cultistCoords);

_hands.TryForcePickupAnyHand(cultist, spearUid.Value);
_audio.PlayPvs(spear.RecallAudio, spearUid.Value);
args.Handled = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Content.Server.WhiteDream.BloodCult.Items.BaseAura;
using Robust.Shared.Prototypes;

namespace Content.Server.WhiteDream.BloodCult.Items.ShadowShacklesAura;

[RegisterComponent]
public sealed partial class ShadowShacklesAuraComponent : BaseAuraComponent
{
[DataField]
public EntProtoId ShacklesProto = "ShadowShackles";

[DataField]
public TimeSpan MuteDuration = TimeSpan.FromSeconds(5);

[DataField]
public TimeSpan KnockdownDuration = TimeSpan.FromSeconds(1);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System.Linq;
using Content.Server.Chat.Systems;
using Content.Server.Cuffs;
using Content.Server.Stunnable;
using Content.Shared.Speech.Muting;
using Content.Shared.StatusEffect;
using Content.Shared.Stunnable;
using Content.Shared.Weapons.Melee.Events;
using Content.Shared.WhiteDream.BloodCult.BloodCultist;
using Robust.Server.GameObjects;


namespace Content.Server.WhiteDream.BloodCult.Items.ShadowShacklesAura;

public sealed class ShadowShacklesAuraSystem : EntitySystem
{
[Dependency] private readonly StatusEffectsSystem _statusEffects = default!;
[Dependency] private readonly StunSystem _stun = default!;
[Dependency] private readonly ChatSystem _chat = default!;
[Dependency] private readonly TransformSystem _transform = default!;
[Dependency] private readonly CuffableSystem _cuffable = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<ShadowShacklesAuraComponent, MeleeHitEvent>(OnMeleeHit);
}

private void OnMeleeHit(EntityUid uid, ShadowShacklesAuraComponent component, MeleeHitEvent args)
{
if (!args.HitEntities.Any())
return;

var target = args.HitEntities.First();
if (uid == target
|| !HasComp<StunnedComponent>(target)
|| HasComp<BloodCultistComponent>(target))
return;

if (component.Speech != null)
_chat.TrySendInGameICMessage(args.User, component.Speech, component.ChatType, false);

var shuckles = Spawn(component.ShacklesProto, _transform.GetMapCoordinates(args.User));
if (!_cuffable.TryAddNewCuffs(target, args.User, shuckles))
{
QueueDel(shuckles);
return;
}

_stun.TryKnockdown(target, component.KnockdownDuration, true);
_statusEffects.TryAddStatusEffect<MutedComponent>(target, "Muted", component.MuteDuration, true);
QueueDel(uid);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Content.Server.WhiteDream.BloodCult.Items.BaseAura;
using Content.Shared.Chat;

namespace Content.Server.WhiteDream.BloodCult.Items.StunAura;

[RegisterComponent]
public sealed partial class StunAuraComponent : BaseAuraComponent
{
[DataField]
public TimeSpan ParalyzeDuration = TimeSpan.FromSeconds(16);

[DataField]
public TimeSpan MuteDuration = TimeSpan.FromSeconds(12);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System.Linq;
using Content.Server.Chat.Systems;
using Content.Server.Stunnable;
using Content.Shared.Speech.Muting;
using Content.Shared.StatusEffect;
using Content.Shared.Weapons.Melee.Events;
using Content.Shared.WhiteDream.BloodCult.BloodCultist;
using Content.Shared.WhiteDream.BloodCult.Constructs;

namespace Content.Server.WhiteDream.BloodCult.Items.StunAura;

public sealed class StunAuraSystem : EntitySystem
{
[Dependency] private readonly StatusEffectsSystem _statusEffects = default!;
[Dependency] private readonly StunSystem _stun = default!;
[Dependency] private readonly ChatSystem _chat = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<StunAuraComponent, MeleeHitEvent>(OnMeleeHit);
}

private void OnMeleeHit(EntityUid uid, StunAuraComponent component, MeleeHitEvent args)
{
if (!args.HitEntities.Any())
return;

var target = args.HitEntities.First();
if (uid == target
|| HasComp<BloodCultistComponent>(target)
|| HasComp<ConstructComponent>(target))
return;

if (component.Speech != null)
_chat.TrySendInGameICMessage(args.User, component.Speech, component.ChatType, false);

_statusEffects.TryAddStatusEffect<MutedComponent>(target, "Muted", component.MuteDuration, true);
_stun.TryParalyze(target, component.ParalyzeDuration, true);
QueueDel(uid);
}
}
6 changes: 4 additions & 2 deletions Content.Server/WhiteDream/BloodCult/Pylon/PylonSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
using Content.Shared.Humanoid;
using Content.Shared.Interaction;
using Content.Shared.Maps;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.WhiteDream.BloodCult;
using Content.Shared.WhiteDream.BloodCult.BloodCultist;
using Content.Shared.WhiteDream.BloodCult.Components;
using Content.Shared.WhiteDream.BloodCult.Constructs;
using Robust.Server.Audio;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
Expand Down Expand Up @@ -125,11 +127,11 @@ private void HealInRange(Entity<PylonComponent> pylon)
{
var pylonPosition = Transform(pylon).Coordinates;
var targets =
_lookup.GetEntitiesInRange<HumanoidAppearanceComponent>(pylonPosition, pylon.Comp.HealingAuraRange);
_lookup.GetEntitiesInRange<MobStateComponent>(pylonPosition, pylon.Comp.HealingAuraRange);

foreach (var target in targets)
{
if (HasComp<BloodCultistComponent>(target) && !_mobState.IsDead(target))
if ((HasComp<BloodCultistComponent>(target) || HasComp<ConstructComponent>(target)) && !_mobState.IsDead(target))
_damageable.TryChangeDamage(target, pylon.Comp.Healing, true);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using Content.Server.Actions;
using Content.Server.Cuffs;
using Content.Server.DoAfter;
using Content.Server.Emp;
using Content.Server.Hands.Systems;
using Content.Server.Popups;
using Content.Server.Stunnable;
using Content.Shared.Abilities.Psionics;
using Content.Shared.Actions;
using Content.Shared.Actions.Events;
Expand All @@ -14,7 +12,6 @@
using Content.Shared.Mindshield.Components;
using Content.Shared.Popups;
using Content.Shared.RadialSelector;
using Content.Shared.Speech.Muting;
using Content.Shared.StatusEffect;
using Content.Shared.Verbs;
using Content.Shared.WhiteDream.BloodCult.Spells;
Expand All @@ -30,14 +27,12 @@ public sealed class BloodCultSpellsSystem : EntitySystem

[Dependency] private readonly ActionsSystem _actions = default!;
[Dependency] private readonly DoAfterSystem _doAfter = default!;
[Dependency] private readonly CuffableSystem _cuffable = default!;
[Dependency] private readonly EmpSystem _empSystem = default!;
[Dependency] private readonly HandsSystem _hands = default!;
[Dependency] private readonly InventorySystem _inventory = default!;
[Dependency] private readonly TransformSystem _transform = default!;
[Dependency] private readonly PopupSystem _popup = default!;
[Dependency] private readonly StatusEffectsSystem _statusEffects = default!;
[Dependency] private readonly StunSystem _stun = default!;
[Dependency] private readonly UserInterfaceSystem _ui = default!;

public override void Initialize()
Expand All @@ -53,9 +48,7 @@ public override void Initialize()
SubscribeLocalEvent<BloodCultSpellsHolderComponent, RadialSelectorSelectedMessage>(OnSpellSelected);
SubscribeLocalEvent<BloodCultSpellsHolderComponent, CreateSpeellDoAfterEvent>(OnSpellCreated);

SubscribeLocalEvent<BloodCultStunEvent>(OnStun);
SubscribeLocalEvent<BloodCultEmpEvent>(OnEmp);
SubscribeLocalEvent<BloodCultShacklesEvent>(OnShackles);
SubscribeLocalEvent<SummonEquipmentEvent>(OnSummonEquipment);
}

Expand Down Expand Up @@ -170,16 +163,6 @@ private void OnSpellCreated(Entity<BloodCultSpellsHolderComponent> cultist, ref

#region SpellsHandlers

private void OnStun(BloodCultStunEvent ev)
{
if (ev.Handled)
return;

_statusEffects.TryAddStatusEffect<MutedComponent>(ev.Target, "Muted", ev.MuteDuration, true);
_stun.TryParalyze(ev.Target, ev.ParalyzeDuration, true);
ev.Handled = true;
}

private void OnEmp(BloodCultEmpEvent ev)
{
if (ev.Handled)
Expand All @@ -189,20 +172,6 @@ private void OnEmp(BloodCultEmpEvent ev)
ev.Handled = true;
}

private void OnShackles(BloodCultShacklesEvent ev)
{
if (ev.Handled)
return;

var shuckles = Spawn(ev.ShacklesProto);
if (!_cuffable.TryAddNewCuffs(ev.Target, ev.Performer, shuckles))
return;

_stun.TryKnockdown(ev.Target, ev.KnockdownDuration, true);
_statusEffects.TryAddStatusEffect<MutedComponent>(ev.Target, "Muted", ev.MuteDuration, true);
ev.Handled = true;
}

private void OnSummonEquipment(SummonEquipmentEvent ev)
{
if (ev.Handled)
Expand All @@ -211,7 +180,14 @@ private void OnSummonEquipment(SummonEquipmentEvent ev)
foreach (var (slot, protoId) in ev.Prototypes)
{
var entity = Spawn(protoId, _transform.GetMapCoordinates(ev.Performer));
_hands.TryPickupAnyHand(ev.Performer, entity);
if (!_hands.TryPickupAnyHand(ev.Performer, entity) && !ev.Force)
{
_popup.PopupEntity(Loc.GetString("cult-magic-no-empty-hand"), ev.Performer, ev.Performer);
_actions.SetCooldown(ev.Action, TimeSpan.FromSeconds(1));
QueueDel(entity);
return;
}

if (!TryComp(entity, out ClothingComponent? _))
continue;

Expand Down
4 changes: 2 additions & 2 deletions Content.Shared/Actions/SharedActionsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -867,8 +867,8 @@ public void RemoveAction(EntityUid performer, EntityUid? actionId, ActionsCompon
Dirty(actionId.Value, action);
Dirty(performer, comp);
ActionRemoved(performer, actionId.Value, comp, action);
if (action.Temporary)
QueueDel(actionId.Value);
if (action.Temporary && GameTiming.IsFirstTimePredicted) // WD EDIT
Del(actionId.Value); // WD EDIT
}

/// <summary>
Expand Down
Loading

0 comments on commit f25e700

Please sign in to comment.