Skip to content

Commit

Permalink
feat: added medic and vcuff + changed cuffing mechanics
Browse files Browse the repository at this point in the history
  • Loading branch information
JustMarfix committed Aug 28, 2024
1 parent 9251481 commit 20a3b8f
Show file tree
Hide file tree
Showing 7 changed files with 195 additions and 30 deletions.
78 changes: 78 additions & 0 deletions Commands/Cuff.cs
Original file line number Diff line number Diff line change
@@ -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<string> 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<ReferenceHub>();
if (hub == null || !Player.TryGet(hub, out cuffed) || cuffed == playerSender)
{
response = "Не получилось связать никого, попробуйте подойти ближе / отойти дальше!";
return false;
}

var cuffer = "";
if (playerSender.CustomName.Contains("ОВБ"))
{
cuffer = "<color=#e34234>Агентом ОВБ</color>";
}
else if (playerSender.CustomName.Contains("ГОР"))
{
cuffer = "<color=#42aaff>Бойцом ГОР</color>";
}
else if (playerSender.CustomName.Contains("Глава Охраны"))
{
cuffer = "<color=#979aaa>Главой Охраны</color>";
}

if (cuffed.IsCuffed)
{
response = "Игрок уже связан!";
return false;
}
cuffed.Handcuff();
cuffed.Broadcast(7, $"<b>Вы были связаны {cuffer}</b>");
response = "Игрок успешно связан!";
return true;
}
}
}
55 changes: 31 additions & 24 deletions Commands/PluginEnable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,26 @@ public bool Execute(ArraySegment<string> 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 выключен.";
Expand All @@ -78,20 +81,24 @@ public bool Execute(ArraySegment<string> 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;
Expand Down
69 changes: 69 additions & 0 deletions Commands/VudMedic.cs
Original file line number Diff line number Diff line change
@@ -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<string> arguments, ICommandSender sender, out string response)
{
if (!VeryUsualDay.Instance.IsEnabledInRound)
{
response = "Режим FX не включён!";
return false;
}
if (arguments.Count < 1)
{
response = "Формат команды: vudmedic <id через пробел>.";
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 = "<b><color=#4DFFB8>Медик Реагирования</color></b>";
medic.Broadcast(10, "<b>Вы стали <color=#727472>медиком СБ</color>! Вы прошли обучение в мед. центре <color=#120a8f>Фонда</color>, и теперь готовы защищать сотрудников от <color=#ffa000>аномалий</color>.");
});
}
else
{
response = "Не удалось найти игрока с таким ID!";
return false;
}
}
response = "Игроки заспавнены.";
return true;
}
}
}
11 changes: 6 additions & 5 deletions Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,23 +199,23 @@ public class Config : IConfig
},
{
"Младший сержант",
100f
150f
},
{
"Сержант",
100f
175f
},
{
"Старший сержант",
100f
200f
},
{
"Лейтенант",
170f
225f
},
{
"Старший лейтенант",
200f
250f
},
{
"Глава",
Expand Down Expand Up @@ -873,6 +873,7 @@ public class Config : IConfig
<color=#FFFFFF>---------------</color><color=#FEA831>FOUNDATION-X</color><color=#FFFFFF>---------------</color>
<color=#FEA831>ВСЕ КОМАНДЫ ВВОДЯТСЯ В КОНСОЛЬ НА [`] ИЛИ [~] С ТОЧКОЙ (ПРИМЕР - .help)</color>
<color=#FEA831>[help]</color><color=#FFFFFF> - Это сообщение.</color>
<color=#FEA831>[vcuff]</color><color=#FFFFFF> - Связать человека напротив. Доступно для ГОР, Главы Охраны и Агентов ОВБ. Нужно оружие в руках.</color>
<color=#FEA831>[classd]</color><color=#FFFFFF> - Встать в очередь на спавн за Испытуемого. Доступно в башне.</color>
<color=#FEA831>[checkcode]</color><color=#FFFFFF> - Узнать текущий код.</color>
<color=#FEA831>[boom]</color><color=#FFFFFF> - Взорваться. Доступно, если на вас надет пояс шахида.</color>
Expand Down
6 changes: 6 additions & 0 deletions Handlers/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
4 changes: 3 additions & 1 deletion VeryUsualDay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class VeryUsualDay : Plugin<Config>
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; }
Expand Down Expand Up @@ -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();
Expand All @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions VeryUsualDay.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
<Compile Include="Commands\checkcode.cs" />
<Compile Include="Commands\checkcode_player.cs" />
<Compile Include="Commands\classd.cs" />
<Compile Include="Commands\Cuff.cs" />
<Compile Include="Commands\CustomHelp.cs" />
<Compile Include="Commands\gocomplex.cs" />
<Compile Include="Commands\lock049gate.cs" />
Expand All @@ -102,6 +103,7 @@
<Compile Include="Commands\vudclassd.cs" />
<Compile Include="Commands\vudclear.cs" />
<Compile Include="Commands\vudguard.cs" />
<Compile Include="Commands\VudMedic.cs" />
<Compile Include="Commands\VudMood.cs" />
<Compile Include="Commands\vudsupply.cs" />
<Compile Include="Commands\vudworker.cs" />
Expand Down

0 comments on commit 20a3b8f

Please sign in to comment.