diff --git a/Commands/Cuff.cs b/Commands/Cuff.cs new file mode 100644 index 0000000..248d3c4 --- /dev/null +++ b/Commands/Cuff.cs @@ -0,0 +1,78 @@ +using System; +using CommandSystem; +using Exiled.API.Features; +using UnityEngine; + +namespace VeryUsualDay.Commands +{ + [CommandHandler(typeof(ClientCommandHandler))] + public class Cuff : ICommand + { + public string Command => "vcuff"; + public string[] Aliases => new string[] { }; + public string Description => "Связывает человека. Для Foundation-X."; + + public bool Execute(ArraySegment arguments, ICommandSender sender, out string response) + { + if (!VeryUsualDay.Instance.IsEnabledInRound) + { + response = "Режим FX не включён!"; + return false; + } + + var playerSender = Player.Get(sender); + if (playerSender.CustomName == null || (!playerSender.CustomName.Contains("ОВБ") && + !playerSender.CustomName.Contains("ГОР") && + !playerSender.CustomName.Contains("Глава Охраны"))) + { + response = "У вас нет прав использовать эту команду!"; + return false; + } + + if (!playerSender.CurrentItem.IsWeapon) + { + response = "Вы не держите в руках оружие!"; + return false; + } + + var layerMask = 1 << 8; + if (!Physics.Raycast(new Ray(playerSender.CameraTransform.position + playerSender.CameraTransform.forward, playerSender.CameraTransform.forward), out RaycastHit raycastHit, maxDistance: 3f, layerMask: ~layerMask)) + { + response = "Вы не смотрите ни на кого, либо вы недостаточно близко."; + return false; + } + + Player cuffed = null; + var hub = raycastHit.transform?.GetComponentInParent(); + if (hub == null || !Player.TryGet(hub, out cuffed) || cuffed == playerSender) + { + response = "Не получилось связать никого, попробуйте подойти ближе / отойти дальше!"; + return false; + } + + var cuffer = ""; + if (playerSender.CustomName.Contains("ОВБ")) + { + cuffer = "Агентом ОВБ"; + } + else if (playerSender.CustomName.Contains("ГОР")) + { + cuffer = "Бойцом ГОР"; + } + else if (playerSender.CustomName.Contains("Глава Охраны")) + { + cuffer = "Главой Охраны"; + } + + if (cuffed.IsCuffed) + { + response = "Игрок уже связан!"; + return false; + } + cuffed.Handcuff(); + cuffed.Broadcast(7, $"Вы были связаны {cuffer}"); + response = "Игрок успешно связан!"; + return true; + } + } +} \ No newline at end of file diff --git a/Commands/PluginEnable.cs b/Commands/PluginEnable.cs index 83df50d..5353114 100644 --- a/Commands/PluginEnable.cs +++ b/Commands/PluginEnable.cs @@ -39,23 +39,26 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s Timing.KillCoroutines("_joining"); Timing.KillCoroutines("_prisonTimer"); Timing.KillCoroutines("_chaos"); - foreach (var player in Player.List) + if (VeryUsualDay.Instance.Config.AuthToken != "") { - if (player.TryGetSessionVariable("isInPrison", out bool prisonState) && prisonState) + foreach (var player in Player.List) { - player.TryGetSessionVariable("prisonReason", out string reason); - player.TryGetSessionVariable("prisonTime", out Int32 time); - VeryUsualDay.SendToPrison(player, time, reason); - // Log.Info($"Игроку {player.UserId} осталось в тюрьме {time} секунд. СОД закончен."); - Timing.CallDelayed(3f, () => + if (player.TryGetSessionVariable("isInPrison", out bool prisonState) && prisonState) { - player.UnMute(); - player.DisableEffect(EffectType.SilentWalk); - player.Role.Set(RoleTypeId.Tutorial); - player.SessionVariables.Remove("isInPrison"); - player.SessionVariables.Remove("prisonTime"); - player.SessionVariables.Remove("prisonReason"); - }); + player.TryGetSessionVariable("prisonReason", out string reason); + player.TryGetSessionVariable("prisonTime", out Int32 time); + VeryUsualDay.SendToPrison(player, time, reason); + // Log.Info($"Игроку {player.UserId} осталось в тюрьме {time} секунд. СОД закончен."); + Timing.CallDelayed(3f, () => + { + player.UnMute(); + player.DisableEffect(EffectType.SilentWalk); + player.Role.Set(RoleTypeId.Tutorial); + player.SessionVariables.Remove("isInPrison"); + player.SessionVariables.Remove("prisonTime"); + player.SessionVariables.Remove("prisonReason"); + }); + } } } response = "Режим FX выключен."; @@ -78,20 +81,24 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s { VeryUsualDay.Instance.SupplyBoxCoords = Room.Get(RoomType.EzGateB).Position + new Vector3(-6.193f, 2.243f, -5.901f); }); - foreach (var player in Player.List) + if (VeryUsualDay.Instance.Config.AuthToken != "") { - var userData = (ITuple)VeryUsualDay.CheckIfPlayerInPrison(player); - if ((bool)userData[0]) + foreach (var player in Player.List) { - player.Mute(); - player.EnableEffect(EffectType.SilentWalk, 255); - player.Teleport(VeryUsualDay.PrisonPosition); - player.SessionVariables.Add("isInPrison", true); - player.SessionVariables.Add("prisonTime", (Int32)userData[1]); - player.SessionVariables.Add("prisonReason", (string)userData[2]); - // Log.Info($"Игрок {player.UserId} будет находиться в тюрьме {(Int32)userData[1]} секунд."); + var userData = (ITuple)VeryUsualDay.CheckIfPlayerInPrison(player); + if ((bool)userData[0]) + { + player.Mute(); + player.EnableEffect(EffectType.SilentWalk, 255); + player.Teleport(VeryUsualDay.PrisonPosition); + player.SessionVariables.Add("isInPrison", true); + player.SessionVariables.Add("prisonTime", (Int32)userData[1]); + player.SessionVariables.Add("prisonReason", (string)userData[2]); + // Log.Info($"Игрок {player.UserId} будет находиться в тюрьме {(Int32)userData[1]} секунд."); + } } } + response = "Режим FX включён."; } return true; diff --git a/Commands/VudMedic.cs b/Commands/VudMedic.cs new file mode 100644 index 0000000..34b22a2 --- /dev/null +++ b/Commands/VudMedic.cs @@ -0,0 +1,69 @@ +using System; +using System.Linq; +using CommandSystem; +using Exiled.API.Enums; +using Exiled.API.Features; +using Exiled.CustomItems.API.Features; +using MEC; +using PlayerRoles; +using UnityEngine; + +namespace VeryUsualDay.Commands +{ + [CommandHandler(typeof(RemoteAdminCommandHandler))] + public class VudMedic : ICommand + { + public string Command => "vudmedic"; + public string[] Aliases => new string[] { }; + public string Description => "Спавнит Медика Реагирования. Для Foundation-X."; + + public bool Execute(ArraySegment arguments, ICommandSender sender, out string response) + { + if (!VeryUsualDay.Instance.IsEnabledInRound) + { + response = "Режим FX не включён!"; + return false; + } + if (arguments.Count < 1) + { + response = "Формат команды: vudmedic ."; + return false; + } + + foreach (var id in arguments.ToArray()) + { + if (Player.TryGet(id, out var medic)) + { + medic.Role.Set(RoleTypeId.FacilityGuard, reason: SpawnReason.ForceClass, spawnFlags: RoleSpawnFlags.AssignInventory); + Timing.CallDelayed(2f, () => + { + medic.MaxHealth = 200f; + medic.Health = 200f; + medic.Scale = new Vector3(1.03f, 1.03f, 1.03f); + medic.ClearInventory(); + medic.AddItem(ItemType.GunCrossvec); + medic.AddItem(ItemType.KeycardGuard); + medic.AddItem(ItemType.ArmorCombat); + medic.AddItem(ItemType.Radio); + medic.AddItem(ItemType.Painkillers); + medic.AddItem(ItemType.Painkillers); + medic.AddAmmo(AmmoType.Nato9, 60); + CustomItem.TryGive(medic, "MG-119"); + medic.EnableEffect(EffectType.BodyshotReduction, 10); + medic.EnableEffect(EffectType.DamageReduction, 10); + medic.EnableEffect(EffectType.MovementBoost, 2); + medic.CustomInfo = "Медик Реагирования"; + medic.Broadcast(10, "Вы стали медиком СБ! Вы прошли обучение в мед. центре Фонда, и теперь готовы защищать сотрудников от аномалий."); + }); + } + else + { + response = "Не удалось найти игрока с таким ID!"; + return false; + } + } + response = "Игроки заспавнены."; + return true; + } + } +} \ No newline at end of file diff --git a/Config.cs b/Config.cs index f03c8df..0066859 100644 --- a/Config.cs +++ b/Config.cs @@ -199,23 +199,23 @@ public class Config : IConfig }, { "Младший сержант", - 100f + 150f }, { "Сержант", - 100f + 175f }, { "Старший сержант", - 100f + 200f }, { "Лейтенант", - 170f + 225f }, { "Старший лейтенант", - 200f + 250f }, { "Глава", @@ -873,6 +873,7 @@ public class Config : IConfig ---------------FOUNDATION-X--------------- ВСЕ КОМАНДЫ ВВОДЯТСЯ В КОНСОЛЬ НА [`] ИЛИ [~] С ТОЧКОЙ (ПРИМЕР - .help) [help] - Это сообщение. + [vcuff] - Связать человека напротив. Доступно для ГОР, Главы Охраны и Агентов ОВБ. Нужно оружие в руках. [classd] - Встать в очередь на спавн за Испытуемого. Доступно в башне. [checkcode] - Узнать текущий код. [boom] - Взорваться. Доступно, если на вас надет пояс шахида. diff --git a/Handlers/Player.cs b/Handlers/Player.cs index 6b40480..4dc63bb 100644 --- a/Handlers/Player.cs +++ b/Handlers/Player.cs @@ -19,6 +19,12 @@ public static void OnTriggeringTesla(TriggeringTeslaEventArgs ev) ev.IsTriggerable = false; ev.IsAllowed = false; } + + public static void OnHandcuffing(HandcuffingEventArgs ev) + { + ev.IsAllowed = false; + ev.Target.Handcuff(); + } public static void OnChangingRole(ChangingRoleEventArgs ev) { diff --git a/VeryUsualDay.cs b/VeryUsualDay.cs index 9171f9c..9794c92 100644 --- a/VeryUsualDay.cs +++ b/VeryUsualDay.cs @@ -28,7 +28,7 @@ public class VeryUsualDay : Plugin public override string Author => "JustMarfix"; public override string Name => "VeryUsualDay (FX Version)"; - public override Version Version => new Version(4, 5, 1); + public override Version Version => new Version(4, 6, 0); public bool IsEnabledInRound { get; set; } public bool IsLunchtimeActive { get; set; } @@ -106,6 +106,7 @@ public override void OnEnabled() PlayerHandler.Verified += Player.OnVerified; PlayerHandler.Hurt += Player.OnHurt; PlayerHandler.Healed += Player.OnHealed; + PlayerHandler.Handcuffing += Player.OnHandcuffing; ServerHandler.WaitingForPlayers += Server.OnWaitingForPlayers; ServerHandler.RoundStarted += Server.OnRoundStarted; base.OnEnabled(); @@ -124,6 +125,7 @@ public override void OnDisabled() PlayerHandler.Verified -= Player.OnVerified; PlayerHandler.Hurt -= Player.OnHurt; PlayerHandler.Healed -= Player.OnHealed; + PlayerHandler.Handcuffing -= Player.OnHandcuffing; ServerHandler.WaitingForPlayers -= Server.OnWaitingForPlayers; ServerHandler.RoundStarted -= Server.OnRoundStarted; Instance = null; diff --git a/VeryUsualDay.csproj b/VeryUsualDay.csproj index 885d366..5cdabde 100644 --- a/VeryUsualDay.csproj +++ b/VeryUsualDay.csproj @@ -76,6 +76,7 @@ + @@ -102,6 +103,7 @@ +