From 1ce6e2e7fd84366af3f201ba0ff34afbf3babc53 Mon Sep 17 00:00:00 2001 From: Kirus59 <145689588+Kirus59@users.noreply.github.com> Date: Sat, 28 Dec 2024 18:23:26 +0300 Subject: [PATCH] Add warning anouncement --- .../CultYogg/Altar/CultYoggAltarSystem.cs | 8 ++-- .../NyarlathotepTargetSearcherSystem.cs | 21 --------- .../Rules/Components/CultYoggRuleComponent.cs | 9 +++- .../GameTicking/Rules/CultYoggRuleSystem.cs | 43 ++++++++++++++----- .../Systems/CultYoggSummonConditionSystem.cs | 2 +- .../CultYogg/Altar/CultYoggAltarComponent.cs | 3 -- .../SS220/CultYogg/Cultists/CultYoggEvents.cs | 4 ++ .../game-ticking/game-presets/preset-cult.ftl | 1 + 8 files changed, 50 insertions(+), 41 deletions(-) diff --git a/Content.Server/SS220/CultYogg/Altar/CultYoggAltarSystem.cs b/Content.Server/SS220/CultYogg/Altar/CultYoggAltarSystem.cs index c4c62669f00017..fb81f0ab63e83f 100644 --- a/Content.Server/SS220/CultYogg/Altar/CultYoggAltarSystem.cs +++ b/Content.Server/SS220/CultYogg/Altar/CultYoggAltarSystem.cs @@ -42,12 +42,12 @@ private void OnDoAfter(Entity ent, ref MiGoSacrificeDoAf int stage = 0; var query = EntityQueryEnumerator(); - while (query.MoveNext(out _, out var cultRule)) + while (query.MoveNext(out var uid, out _, out var cultRule)) { - stage = ++cultRule.AmountOfSacrifices; + var ev = new CultYoggSacrificedTargetEvent(ent); + RaiseLocalEvent(uid, ref ev); - if (cultRule.AmountOfSacrifices == cultRule.ReqAmountOfSacrifices) - Spawn(ent.Comp.GodEnt, Transform(ent).Coordinates); + stage = cultRule.AmountOfSacrifices; } //sending all cultists updating stage event diff --git a/Content.Server/SS220/CultYogg/Nyarlathotep/NyarlathotepTargetSearcherSystem.cs b/Content.Server/SS220/CultYogg/Nyarlathotep/NyarlathotepTargetSearcherSystem.cs index 8064ebc687c753..2954c8ab389ef2 100644 --- a/Content.Server/SS220/CultYogg/Nyarlathotep/NyarlathotepTargetSearcherSystem.cs +++ b/Content.Server/SS220/CultYogg/Nyarlathotep/NyarlathotepTargetSearcherSystem.cs @@ -23,14 +23,6 @@ public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnSearchMapInit); - - SubscribeLocalEvent(OnCompInit); - } - - private void OnCompInit(Entity uid, ref ComponentStartup args) - { - var ev = new CultYoggSummonedEvent(uid); - RaiseLocalEvent(uid, ref ev, true); } /// @@ -78,19 +70,6 @@ public override void Update(float frameTime) } } -/// -/// Raised when god summoned to markup winning -/// -[ByRefEvent, Serializable] -public sealed class CultYoggSummonedEvent : EntityEventArgs -{ - public readonly EntityUid Entity; - - public CultYoggSummonedEvent(EntityUid entity) - { - Entity = entity; - } -} /// /// Component for entities to be attacked by Nyarlathotep. /// diff --git a/Content.Server/SS220/GameTicking/Rules/Components/CultYoggRuleComponent.cs b/Content.Server/SS220/GameTicking/Rules/Components/CultYoggRuleComponent.cs index c4e2fc798be888..97adb537af1284 100644 --- a/Content.Server/SS220/GameTicking/Rules/Components/CultYoggRuleComponent.cs +++ b/Content.Server/SS220/GameTicking/Rules/Components/CultYoggRuleComponent.cs @@ -4,6 +4,7 @@ using Robust.Shared.Audio; using Robust.Shared.Prototypes; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; +using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; namespace Content.Server.SS220.GameTicking.Rules.Components; @@ -14,7 +15,10 @@ public sealed partial class CultYoggRuleComponent : Component /// General requirements /// [DataField] - public int ReqAmountOfSacrifices = 3; + public int AmountOfSacrificesToGodSummon = 3; + + [DataField] + public int AmountOfSacrificesToWarningAnouncement = 2; [DataField] public int ReqAmountOfMiGo = 3; @@ -62,6 +66,9 @@ public sealed partial class CultYoggRuleComponent : Component [ValidatePrototypeId] public string MindCultYoggAntagId = "MindRoleCultYogg"; + [DataField(customTypeSerializer: typeof(PrototypeIdSerializer))] + public string GodPrototype = "MobNyarlathotep"; + //telephaty channel [DataField] public string TelepathyChannel = "TelepathyChannelYoggSothothCult"; diff --git a/Content.Server/SS220/GameTicking/Rules/CultYoggRuleSystem.cs b/Content.Server/SS220/GameTicking/Rules/CultYoggRuleSystem.cs index 6f82cb2db4fdb0..1c1ae1a6660f7e 100644 --- a/Content.Server/SS220/GameTicking/Rules/CultYoggRuleSystem.cs +++ b/Content.Server/SS220/GameTicking/Rules/CultYoggRuleSystem.cs @@ -38,6 +38,9 @@ using Content.Server.Pinpointer; using Content.Server.Audio; using Robust.Shared.Audio.Systems; +using Content.Server.AlertLevel; +using Robust.Shared.Player; +using Robust.Shared.Map; namespace Content.Server.SS220.GameTicking.Rules; @@ -58,6 +61,7 @@ public sealed class CultYoggRuleSystem : GameRuleSystem [Dependency] private readonly NavMapSystem _navMap = default!; [Dependency] private readonly ServerGlobalSoundSystem _sound = default!; [Dependency] private readonly SharedAudioSystem _audio = default!; + [Dependency] private readonly AlertLevelSystem _alertLevel = default!; private List> _sacraficialTiers = []; public TimeSpan DefaultShuttleArriving { get; set; } = TimeSpan.FromSeconds(85); @@ -72,7 +76,7 @@ public override void Initialize() SubscribeLocalEvent(SacraficialReplacement); - SubscribeLocalEvent(OnGodSummoned); + SubscribeLocalEvent(OnTargetSacrificed); SubscribeLocalEvent(SendCultAnounce); } @@ -254,6 +258,25 @@ private List GetAliveNoneCultHumans()//maybe add here sacraficials an #endregion #region Sacraficials Events + private void OnTargetSacrificed(Entity entity, ref CultYoggSacrificedTargetEvent args) + { + var (_, comp) = entity; + var (altar, altarComp) = args.Altar; + comp.AmountOfSacrifices++; + + if (comp.AmountOfSacrifices == comp.AmountOfSacrificesToWarningAnouncement) + { + foreach (var station in _station.GetStations()) + { + _chat.DispatchStationAnnouncement(station, Loc.GetString("cult-yogg-cultists-warning"), playSound: false, colorOverride: Color.Red); + _audio.PlayGlobal("/Audio/Misc/notice1.ogg", Filter.Broadcast(), true); + _alertLevel.SetLevel(station, "gamma", true, true, true); + } + } + + if (comp.AmountOfSacrifices == comp.AmountOfSacrificesToGodSummon) + SummonGod(entity, Transform(altar).Coordinates); + } private void SacraficialReplacement(ref SacraficialReplacementEvent args) { @@ -415,27 +438,25 @@ private void SendCultAnounce(ref CultYoggAnouncementEvent args) #endregion #region RoundEnding - private void OnGodSummoned(ref CultYoggSummonedEvent args) + private void SummonGod(Entity entity, EntityCoordinates coordinates) { - GetCultGameRule(out var cultRuleComp); - - if (cultRuleComp == null) - return; + var (_, comp) = entity; + var godUid = Spawn(comp.GodPrototype, coordinates); foreach (var station in _station.GetStations()) { - _chat.DispatchStationAnnouncement(station, Loc.GetString("cult-yogg-shuttle-call", ("location", FormattedMessage.RemoveMarkupOrThrow(_navMap.GetNearestBeaconString(args.Entity)))), colorOverride: Color.Crimson); + _chat.DispatchStationAnnouncement(station, Loc.GetString("cult-yogg-shuttle-call", ("location", FormattedMessage.RemoveMarkupOrThrow(_navMap.GetNearestBeaconString(godUid)))), colorOverride: Color.Crimson); + _alertLevel.SetLevel(station, "delta", true, true, true); } _roundEnd.RequestRoundEnd(DefaultShuttleArriving, null); - var selectedSong = _audio.GetSound(cultRuleComp.SummonMusic); + var selectedSong = _audio.GetSound(comp.SummonMusic); if (!string.IsNullOrEmpty(selectedSong)) - _sound.DispatchStationEventMusic(args.Entity, selectedSong, StationEventMusicType.Nuke);//should i rename somehow? + _sound.DispatchStationEventMusic(godUid, selectedSong, StationEventMusicType.Nuke);//should i rename somehow? - cultRuleComp.Summoned = true;//Win EndText + comp.Summoned = true;//Win EndText } - #endregion #region EndText diff --git a/Content.Server/SS220/Objectives/Systems/CultYoggSummonConditionSystem.cs b/Content.Server/SS220/Objectives/Systems/CultYoggSummonConditionSystem.cs index 9e8efc264e6b48..8d7c26118fe40e 100644 --- a/Content.Server/SS220/Objectives/Systems/CultYoggSummonConditionSystem.cs +++ b/Content.Server/SS220/Objectives/Systems/CultYoggSummonConditionSystem.cs @@ -67,7 +67,7 @@ private void TaskNumberUpdate(Entity ent) if (ruleComp is null) return; - ent.Comp.reqSacrAmount = ruleComp.ReqAmountOfSacrifices; + ent.Comp.reqSacrAmount = ruleComp.AmountOfSacrificesToGodSummon; } private void SacraficialsUpdate(Entity ent) { diff --git a/Content.Shared/SS220/CultYogg/Altar/CultYoggAltarComponent.cs b/Content.Shared/SS220/CultYogg/Altar/CultYoggAltarComponent.cs index cddf05f08739f1..d3cdfe8544a905 100644 --- a/Content.Shared/SS220/CultYogg/Altar/CultYoggAltarComponent.cs +++ b/Content.Shared/SS220/CultYogg/Altar/CultYoggAltarComponent.cs @@ -19,9 +19,6 @@ public sealed partial class CultYoggAltarComponent : Component [DataField] public bool Used = false; - [DataField] - public string GodEnt = "Nyarlathotep"; - [Serializable, NetSerializable] public enum CultYoggAltarVisuals { diff --git a/Content.Shared/SS220/CultYogg/Cultists/CultYoggEvents.cs b/Content.Shared/SS220/CultYogg/Cultists/CultYoggEvents.cs index dc73bbb7e3249d..db654b9d7bdbd8 100644 --- a/Content.Shared/SS220/CultYogg/Cultists/CultYoggEvents.cs +++ b/Content.Shared/SS220/CultYogg/Cultists/CultYoggEvents.cs @@ -1,4 +1,6 @@ // © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt +using Content.Shared.SS220.CultYogg.Altar; + namespace Content.Shared.SS220.CultYogg.Cultists; /// @@ -32,3 +34,5 @@ public CultYoggDeCultingEvent(EntityUid entity) [ByRefEvent, Serializable] public record struct CultYoggForceAscendingEvent; +[ByRefEvent, Serializable] +public record struct CultYoggSacrificedTargetEvent(Entity Altar); diff --git a/Resources/Locale/ru-RU/ss220/game-ticking/game-presets/preset-cult.ftl b/Resources/Locale/ru-RU/ss220/game-ticking/game-presets/preset-cult.ftl index 35d5b91406c95c..a8e4bfa162dcea 100644 --- a/Resources/Locale/ru-RU/ss220/game-ticking/game-presets/preset-cult.ftl +++ b/Resources/Locale/ru-RU/ss220/game-ticking/game-presets/preset-cult.ftl @@ -21,4 +21,5 @@ objective-cult-yogg-sacrafice-start = Призовите темного бога objective-cult-yogg-sacrafice-task-job = в должности objective-condition-cult-yogg-sacrafice-person = {$targetName}, в должности {CAPITALIZE($job)} +cult-yogg-cultists-warning = Внимание! На станции зафиксировано множественное размножение грибов-паразитов. Совокупность данных с сенсоров подтверждает угрозу культа, ликвидируйте её любой ценой! cult-yogg-shuttle-call = Датчики станции зафиксировали { $location } гигантский подвижный объект. Аварийный шаттл был отправлен для эвакуации оставшегося персонала.