Skip to content

Commit

Permalink
Haunt now plays a noise and disorients witnesses
Browse files Browse the repository at this point in the history
  • Loading branch information
TGRCdev committed Sep 19, 2024
1 parent fb692c4 commit 8441460
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 6 deletions.
23 changes: 21 additions & 2 deletions Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
using Content.Shared.Interaction.Components;
using Robust.Shared.Player;
using Content.Shared.StatusEffect;
using Content.Shared.Flash.Components;
using Content.Shared.Flash;
using Robust.Shared.Audio.Systems;

namespace Content.Server.Revenant.EntitySystems;

Expand All @@ -51,6 +54,7 @@ public sealed partial class RevenantSystem
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
[Dependency] private readonly RevenantAnimatedSystem _revenantAnimated = default!;
[Dependency] private readonly EntityLookupSystem _entityLookup = default!;
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;

[ValidatePrototypeId<StatusEffectPrototype>]
private const string RevenantEssenceRegen = "EssenceRegen";
Expand Down Expand Up @@ -238,7 +242,7 @@ private void OnHauntAction(EntityUid uid, RevenantComponent comp, RevenantHauntA
args.Handled = true;

// This is probably not the right way to do this...
var witnesses = new HashSet<NetEntity>(Filter.PvsExcept(uid).RemoveWhere(player =>
var witnessAndRevenantFilter = Filter.Pvs(uid).RemoveWhere(player =>
{
if (player.AttachedEntity == null)
return true;
Expand All @@ -251,7 +255,22 @@ private void OnHauntAction(EntityUid uid, RevenantComponent comp, RevenantHauntA
var haunted = _interact.InRangeUnobstructed((uid, Transform(uid)), (ent, Transform(ent)), range: 0, collisionMask: CollisionGroup.Impassable);
Log.Debug($"{ent} haunted: {haunted}");
return !haunted;
}).Recipients.Select(ply => GetNetEntity(ply.AttachedEntity!.Value)));
});

var witnesses = new HashSet<NetEntity>(witnessAndRevenantFilter.RemovePlayerByAttachedEntity(uid).Recipients.Select(ply => GetNetEntity(ply.AttachedEntity!.Value)));

// Give the witnesses a spook!
_audioSystem.PlayGlobal(comp.HauntSound, witnessAndRevenantFilter, true);

foreach (var witness in witnesses)
{
_statusEffects.TryAddStatusEffect<FlashedComponent>(GetEntity(witness),
SharedFlashSystem.FlashedKey,
comp.HauntFlashDuration,
false
);
}


// TODO: Maybe an eyeball icon above witnesses on the revenant's client

Expand Down
15 changes: 11 additions & 4 deletions Content.Shared/Revenant/Components/RevenantComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Content.Shared.FixedPoint;
using Content.Shared.Store;
using Content.Shared.Whitelist;
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
Expand Down Expand Up @@ -96,18 +97,24 @@ public sealed partial class RevenantComponent : Component
// essence regeneration for each crewmate that witnesses it
#region Haunt Ability

[DataField("hauntDebuffs")]
[DataField("hauntDebuffs"), ViewVariables(VVAccess.ReadWrite)]
public Vector2 HauntDebuffs = new(2, 6);

[DataField("hauntStolenEssencePerWitness")]
[DataField("hauntStolenEssencePerWitness"), ViewVariables(VVAccess.ReadWrite)]
public FixedPoint2 HauntStolenEssencePerWitness = 2.5;

[DataField("hauntEssenceRegenPerWitness")]
[DataField("hauntEssenceRegenPerWitness"), ViewVariables(VVAccess.ReadWrite)]
public FixedPoint2 HauntEssenceRegenPerWitness = 0.5;

[DataField("hauntEssenceRegenDuration")]
[DataField("hauntEssenceRegenDuration"), ViewVariables(VVAccess.ReadWrite)]
public TimeSpan HauntEssenceRegenDuration = TimeSpan.FromSeconds(10);

[DataField("hauntSound"), ViewVariables(VVAccess.ReadWrite)]
public SoundSpecifier? HauntSound = new SoundCollectionSpecifier("RevenantHaunt");

[DataField("hauntFlashDuration"), ViewVariables(VVAccess.ReadWrite)]
public TimeSpan HauntFlashDuration = TimeSpan.FromSeconds(2);

#endregion

//In the nearby radius, causes various objects to be thrown, messed with, and containers opened
Expand Down
24 changes: 24 additions & 0 deletions Resources/Audio/Effects/Revenant/attributions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
- files: ["haunt0.ogg"]
license: "CC-BY-SA-3.0"
copyright: "Sound originally derived from SCP: Containment breach."
source: "https://github.com/Regalis11/scpcb/blob/edb8fe0840b78f14d1aef3a0bf6174630e7be296/SFX/Horror/Horror0.ogg"

- files: ["haunt1.ogg"]
license: "CC-BY-SA-3.0"
copyright: "Sound originally derived from SCP: Containment breach."
source: "https://github.com/Regalis11/scpcb/blob/edb8fe0840b78f14d1aef3a0bf6174630e7be296/SFX/Horror/Horror4.ogg"

- files: ["haunt2.ogg"]
license: "CC-BY-SA-3.0"
copyright: "Sound originally derived from SCP: Containment breach."
source: "https://github.com/Regalis11/scpcb/blob/edb8fe0840b78f14d1aef3a0bf6174630e7be296/SFX/Horror/Horror6.ogg"

- files: ["haunt3.ogg"]
license: "CC-BY-SA-3.0"
copyright: "Sound originally derived from SCP: Containment breach."
source: "https://github.com/Regalis11/scpcb/blob/edb8fe0840b78f14d1aef3a0bf6174630e7be296/SFX/Horror/Horror11.ogg"

- files: ["haunt4.ogg"]
license: "CC-BY-SA-3.0"
copyright: "Sound originally derived from SCP: Containment breach. Edited down to a shorter length by TGRCDev."
source: "https://github.com/Regalis11/scpcb/blob/edb8fe0840b78f14d1aef3a0bf6174630e7be296/SFX/Horror/Horror12.ogg"
Binary file added Resources/Audio/Effects/Revenant/haunt0.ogg
Binary file not shown.
Binary file added Resources/Audio/Effects/Revenant/haunt1.ogg
Binary file not shown.
Binary file added Resources/Audio/Effects/Revenant/haunt2.ogg
Binary file not shown.
Binary file added Resources/Audio/Effects/Revenant/haunt3.ogg
Binary file not shown.
Binary file added Resources/Audio/Effects/Revenant/haunt4.ogg
Binary file not shown.
8 changes: 8 additions & 0 deletions Resources/Prototypes/SoundCollections/revenant.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- type: soundCollection
id: RevenantHaunt
files:
- /Audio/Effects/Revenant/haunt0.ogg
- /Audio/Effects/Revenant/haunt1.ogg
- /Audio/Effects/Revenant/haunt2.ogg
- /Audio/Effects/Revenant/haunt3.ogg
- /Audio/Effects/Revenant/haunt4.ogg

0 comments on commit 8441460

Please sign in to comment.