diff --git a/Content.Server/White/NonPeacefulRoundEnd/NonPeacefulRoundEndSystem.cs b/Content.Server/White/NonPeacefulRoundEnd/NonPeacefulRoundEndSystem.cs new file mode 100644 index 0000000000..2f4ac652af --- /dev/null +++ b/Content.Server/White/NonPeacefulRoundEnd/NonPeacefulRoundEndSystem.cs @@ -0,0 +1,98 @@ +using System.Linq; +using Content.Server.Chat.Managers; +using Content.Server.GameTicking; +using Content.Server.Traits.Assorted; +using Content.Shared.CombatMode.Pacification; +using Content.Shared.GameTicking; +using Content.Shared.Hands.Components; +using Content.Shared.Hands.EntitySystems; +using Content.Shared.Humanoid; +using Content.Shared.White; +using Content.Shared.White.NonPeacefulRoundEnd; +using Robust.Server.Player; +using Robust.Shared.Audio; +using Robust.Shared.Configuration; +using Robust.Shared.Player; +using Robust.Shared.Prototypes; +using Robust.Shared.Random; + +namespace Content.Server.White.NonPeacefulRoundEnd; + +public sealed class NonPeacefulRoundEndSystem : EntitySystem +{ + [Dependency] private readonly IConfigurationManager _cfg = default!; + [Dependency] private readonly IPlayerManager _playerManager = default!; + [Dependency] private readonly IPrototypeManager _prototypeManager = default!; + [Dependency] private readonly SharedHandsSystem _handsSystem = default!; + [Dependency] private readonly IRobustRandom _robustRandom = default!; + [Dependency] private readonly IEntityManager _entityManager = default!; + [Dependency] private readonly IChatManager _chatManager = default!; + [Dependency] private readonly SharedAudioSystem _sharedAudioSystem = default!; + + private NonPeacefulRoundItemsPrototype _nonPeacefulRoundItemsPrototype = default!; + + private bool _enabled; + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnRoundEnded); + _cfg.OnValueChanged(WhiteCVars.NonPeacefulRoundEndEnabled, value => _enabled = value, true); + } + + private void OnRoundEnded(RoundEndTextAppendEvent ev) + { + if (!_enabled) + return; + + var prototypes = _prototypeManager.EnumeratePrototypes().ToList(); + + if (prototypes.Count < 1) + { + return; + } + + _nonPeacefulRoundItemsPrototype = _robustRandom.Pick(prototypes); + + foreach (var session in _playerManager.Sessions) + { + if (!session.AttachedEntity.HasValue) continue; + + RemComp(session.AttachedEntity.Value); + RemComp(session.AttachedEntity.Value); + + + GiveItem(session.AttachedEntity.Value); + } + + var announceCount = _robustRandom.Next(5,15); + + for (int i = 0; i <= announceCount; i++) + { + _chatManager.SendAdminAnnouncement("!!!РЕЗНЯ!!!"); + } + + _sharedAudioSystem.PlayGlobal("/Audio/White/RoundEnd/rezniya.ogg", Filter.Broadcast(), false); + } + + private void GiveItem(EntityUid player) + { + var item = _robustRandom.Pick(_nonPeacefulRoundItemsPrototype.Items); + + var transform = CompOrNull(player); + + if(transform == null) + return; + + if(!HasComp(player)) + + return; + if(!HasComp(player)) + return; + + + var weaponEntity = _entityManager.SpawnEntity(item, transform.Coordinates); + + _handsSystem.TryDrop(player); + _handsSystem.PickupOrDrop(player, weaponEntity); + } +} diff --git a/Content.Shared/White/NonPeacefulRoundEnd/NonPeacefulRoundItemsPrototype.cs b/Content.Shared/White/NonPeacefulRoundEnd/NonPeacefulRoundItemsPrototype.cs new file mode 100644 index 0000000000..e4276998a8 --- /dev/null +++ b/Content.Shared/White/NonPeacefulRoundEnd/NonPeacefulRoundItemsPrototype.cs @@ -0,0 +1,13 @@ +using Robust.Shared.Prototypes; +using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List; + +namespace Content.Shared.White.NonPeacefulRoundEnd; + +[Prototype("nonPeacefulRoundEndItems")] +public sealed class NonPeacefulRoundItemsPrototype : IPrototype +{ + [IdDataField] public string ID { get; } = default!; + + [DataField("items", customTypeSerializer: typeof(PrototypeIdListSerializer))] + public List Items { get; } = default!; +} diff --git a/Content.Shared/White/WhiteCVars.cs b/Content.Shared/White/WhiteCVars.cs index 14b8e146e1..e9e5be9885 100644 --- a/Content.Shared/White/WhiteCVars.cs +++ b/Content.Shared/White/WhiteCVars.cs @@ -107,4 +107,12 @@ public sealed class WhiteCVars public static readonly CVarDef StalinDiscordMinimumAge = CVarDef.Create("stalin.minimal_discord_age_minutes", 30.0f, CVar.SERVERONLY | CVar.ARCHIVE); + + /* + * NonPeaceful Round End + */ + + public static readonly CVarDef NonPeacefulRoundEndEnabled = + CVarDef.Create("white.non_peaceful_round_end_enabled", true, CVar.SERVERONLY | CVar.ARCHIVE); + } diff --git a/Resources/Audio/White/RoundEnd/rezniya.ogg b/Resources/Audio/White/RoundEnd/rezniya.ogg new file mode 100644 index 0000000000..2d0946e30f Binary files /dev/null and b/Resources/Audio/White/RoundEnd/rezniya.ogg differ diff --git a/Resources/Prototypes/White/NonPeacefulRound/NonPeacefulRoundItems.yml b/Resources/Prototypes/White/NonPeacefulRound/NonPeacefulRoundItems.yml new file mode 100644 index 0000000000..090376f7b7 --- /dev/null +++ b/Resources/Prototypes/White/NonPeacefulRound/NonPeacefulRoundItems.yml @@ -0,0 +1,45 @@ +- type: nonPeacefulRoundEndItems + name: nonPeacefulRoundEndItems + id: nonPeacefulRoundEndRange + items: + - WeaponSubMachineGunVector + - WeaponSubMachineGunWt550 + - WeaponSubMachineGunC20r + - WeaponSubMachineGunAtreides + - WeaponShotgunBulldog + - WeaponShotgunDoubleBarreled + - WeaponShotgunEnforcer + - WeaponShotgunKammerer + - WeaponShotgunSawn + - WeaponRifleAk + - WeaponRifleM90GrenadeLauncher + - WeaponRifleLecter + - WeaponRevolverDeckard + - WeaponRevolverInspector + - WeaponRevolverMateba + - WeaponRevolverPython + - WeaponRevolverPirate + - WeaponLightMachineGunL6 + - WeaponFlareGun + - Stunbaton + +- type: nonPeacefulRoundEndItems + name: nonPeacefulRoundEndItems + id: nonPeacefulRoundEndMelee + items: + - FireAxeFlaming + - CaptainSabre + - Katana + - Machete + - Claymore + - Stunbaton + - ClothingBackpackDuffelSyndicateC4tBundle + - Spear + - ButchCleaver + - CombatKnife + - SurvivalKnife + - EnergyDagger + - EnergySword + - UnholyHalberd + - EldritchBlade + - BaseBallBat