diff --git a/ChangeLog.md b/ChangeLog.md index 5b6fd29..90777c0 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,12 +1 @@ -># Update 3.1.0 -> ->>## SCP-1289 (formerly 'Coin') ->>> #### Renamed the coin ->>> #### Added death and winning notes ->>>> Due to a limitation of Exiled only the player who gets killed by the coin can see the new effects added by yours truly ->> ->>## Tranq ->>> Made the player who got tranqed invulnerable but unable to use any items (humans) ->> ->>## Genaral code ->>> Added some notes in the 'Util.cs' file for those who want to add on to this +>#Update 3.2.1 diff --git a/Commands/CustomKeycard b/Commands/CustomKeycard deleted file mode 100644 index b49144f..0000000 --- a/Commands/CustomKeycard +++ /dev/null @@ -1,80 +0,0 @@ -using CommandSystem; -using Exiled.API.Features; - -namespace ExtendedItems.Commands -{ - [CommandHandler(typeof(ClientCommandHandler))] - class CustomKeycardColor : ICommand - { - public CustomKeycardColor Instance { get; } = new(); - public string Command => "KeycardColor"; - - public string[] Aliases => ["CKCC", "KColor"]; - string title; - string name; - string titleColor = "000000"; - string nameColor = "FFFFFF"; - string dotColor = "000000"; - string tintColor = "FFFFFF"; - - public string Description => "Detonate command for C4 charges that you have placed"; - - public bool Execute(ArraySegment arguments, ICommandSender sender, out string response) - { - if (arguments.Count == 0 || arguments.Count > 6) - { - response = "Invalid Syntax! Use: CustomKeycardColor <Name> <TitleColor> <NameColor> <DotColor> <TintColor>"; - return false; - } - - string title = ""; - string name = sender.Name; - string titleColor = "000000"; - string nameColor = "FFFFFF"; - string dotColor = "000000"; - string tintColor = "FFFFFF"; - - switch (arguments.Count) - { - case 1: - title = arguments.At(0); - break; - case 2: - title = arguments.At(0); - name = arguments.At(1); - break; - case 3: - title = arguments.At(0); - name = arguments.At(1); - titleColor = arguments.At(2); - break; - case 4: - title = arguments.At(0); - name = arguments.At(1); - titleColor = arguments.At(2); - nameColor = arguments.At(3); - break; - case 5: - title = arguments.At(0); - name = arguments.At(1); - titleColor = arguments.At(2); - nameColor = arguments.At(3); - dotColor = arguments.At(4); - break; - case 6: - title = arguments.At(0); - name = arguments.At(1); - titleColor = arguments.At(2); - nameColor = arguments.At(3); - dotColor = arguments.At(4); - tintColor = arguments.At(5); - break; - } - - CustomItem::Give(player); - - response = $"Keycard customized: Title={title}, Name={name}, TitleColor={titleColor}, NameColor={nameColor}, DotColor={dotColor}, TintColor={tintColor}"; - return true; - } - } -} diff --git a/Commands/Debug/AdminPlastic.cs b/Commands/Debug/AdminPlastic.cs index a968462..e1f48f0 100644 --- a/Commands/Debug/AdminPlastic.cs +++ b/Commands/Debug/AdminPlastic.cs @@ -6,7 +6,7 @@ namespace ExtendedItems.Commands.Debug [CommandHandler(typeof(ClientCommandHandler))] class PlasticDebug : ICommand { - + public string Command => "Ddetonate"; public string[] Aliases => ["Ddet", "Dd", "Dboom"]; diff --git a/Commands/Debug/Debug.cs b/Commands/Debug/Debug.cs index 96c6533..95abbf7 100644 --- a/Commands/Debug/Debug.cs +++ b/Commands/Debug/Debug.cs @@ -1,6 +1,5 @@ using CommandSystem; using Exiled.API.Features; -using ExtendedItems.Commands.GuideBook; namespace ExtendedItems.Commands.Debug { @@ -11,7 +10,7 @@ internal sealed class Debug : ParentCommand public static Debug Instance { get; } = new(); public override string Command => "Debug"; - public override string[] Aliases => [ "db" ]; + public override string[] Aliases => ["db"]; public override string Description => "Overlord command for debugging the ExtendedItems plugin"; public override void LoadGeneratedCommands() @@ -20,7 +19,7 @@ public override void LoadGeneratedCommands() } protected override bool ExecuteParent(ArraySegment<string> arguments, ICommandSender sender, out string response) { - if(!sender.CheckPermission(Plugin.Instance!.Config.DebugPermissions)) + if (!sender.CheckPermission(Plugin.Instance!.Config.DebugPermissions)) { response = "<color=red>Permission Denied.</color>"; Log.Error($"{sender} tried to access admin commands!"); diff --git a/Commands/Debug/Locate.cs b/Commands/Debug/Locate.cs index c5d13f5..f6d948a 100644 --- a/Commands/Debug/Locate.cs +++ b/Commands/Debug/Locate.cs @@ -1,11 +1,7 @@ -using System.Text; using CommandSystem; - using Exiled.API.Features; -using Exiled.API.Features.Pools; -using Exiled.CustomItems; -using Exiled.CustomItems.API; using Exiled.CustomItems.API.Features; +using System.Text; namespace ExtendedItems.Commands.Debug @@ -13,7 +9,7 @@ namespace ExtendedItems.Commands.Debug internal sealed class Locate : ICommand { public static Locate Instance { get; } = new(); - public Locate() {} + public Locate() { } public string Command => "Locate"; public string[] Aliases => ["loc", "find"]; public string Description => "Locates all (unless a valid ID is given) Custom Items"; diff --git a/Commands/GuideBook/Coin.cs b/Commands/GuideBook/Coin.cs index b923244..98c2863 100644 --- a/Commands/GuideBook/Coin.cs +++ b/Commands/GuideBook/Coin.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CommandSystem; +using CommandSystem; namespace ExtendedItems.Commands.GuideBook { @@ -13,7 +8,7 @@ private Coinc() { } public static Coinc Instance { get; } = new(); public string Command => "coin"; - public string[] Aliases => [ "1289" ]; + public string[] Aliases => ["1289"]; public string Description => "Information on SCP-1289 (aka \"Coin\" or \"Colin\") "; public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response) { diff --git a/Commands/GuideBook/Help.cs b/Commands/GuideBook/Help.cs index 80eeac8..31acf87 100644 --- a/Commands/GuideBook/Help.cs +++ b/Commands/GuideBook/Help.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CommandSystem; +using CommandSystem; namespace ExtendedItems.Commands.GuideBook { diff --git a/Commands/GuideBook/Sniper.cs b/Commands/GuideBook/Sniper.cs index ec012d1..329d87f 100644 --- a/Commands/GuideBook/Sniper.cs +++ b/Commands/GuideBook/Sniper.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CommandSystem; +using CommandSystem; namespace ExtendedItems.Commands.GuideBook { diff --git a/Commands/Main.cs b/Commands/Main.cs index 7627857..f6e5d9c 100644 --- a/Commands/Main.cs +++ b/Commands/Main.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CommandSystem; +using CommandSystem; namespace ExtendedItems.Commands { @@ -13,7 +8,7 @@ internal sealed class Main : ParentCommand public Main() { LoadGeneratedCommands(); } public override string Command => "ExtendedItems"; - public override string[] Aliases => [ "ei", "extendeditems", "eis" ]; + public override string[] Aliases => ["ei", "extendeditems", "eis"]; public override string Description => "Overlord command for the ExtendedItems plugin"; public override void LoadGeneratedCommands() diff --git a/Commands/Plastic.cs b/Commands/Plastic.cs index 58feaf7..4802996 100644 --- a/Commands/Plastic.cs +++ b/Commands/Plastic.cs @@ -4,6 +4,7 @@ namespace ExtendedItems.Commands { [CommandHandler(typeof(ClientCommandHandler))] + class Plastic : ICommand { public string Command => "detonate"; @@ -15,6 +16,7 @@ class Plastic : ICommand public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response) { Player ply = Player.Get(sender); + Log.Debug($"Player: {ply.Nickname} executed the detonate command."); if (!Items.Plastic.PlacedCharges.ContainsValue(ply)) { response = "\n<color=red>You've haven't placed any C4 charges!</color>"; @@ -24,12 +26,12 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s int i = 0; foreach (var charge in Items.Plastic.PlacedCharges.ToList()) { - float posy = charge.Key.Position.y; + float posy = charge.Key.Position.y; if (charge.Value != ply) continue; - - if (ply.Position.y >= posy - 100 && ply.Position.y <= posy + 100 ) + + if (ply.Position.y >= posy - 100 && ply.Position.y <= posy + 100) { - Items.Plastic.Instance.Handler(charge.Key, Items.Plastic.C4RemoveMethod.Detonate); + Items.Plastic.Instance.Handler(charge.Key, Items.Plastic.C4RemoveMethod.Detonate, ply); i++; } else diff --git a/Config.cs b/Config.cs index 8cc8fe4..8d35752 100644 --- a/Config.cs +++ b/Config.cs @@ -1,17 +1,24 @@ -using ExtendedItems.Items; -using ExtendedItems.Keycards; +using Exiled.API.Enums; using Exiled.API.Interfaces; +using ExtendedItems.Items; using System.ComponentModel; +using UnityEngine; namespace ExtendedItems { public class Config : IConfig { public bool IsEnabled { get; set; } = true; - public bool Debug { get; set; } = false; + public bool Debug { get; set; } = true; #region Config Settings + [Description("Where SCP-1162 spawns")] + public RoomType Scp1162Room { get; set; } = RoomType.Lcz173; + + [Description("The offset from Scp1162Room Origin point")] + public Vector3 SpawnOffset = new(16.68f, 11.6f, 8.11f); + [Description("Weather a tranqed target hold the item they had when they were tranqed")] public bool ReholdItems = false; @@ -49,15 +56,12 @@ public class Config : IConfig #region Custom Items setup public Coin Coin { get; set; } = new(); - public Scp1162 Scp1162 { get; set; } = new(); public Scp1499 Scp1499 { get; set; } = new(); public GrenadeLauncher GrenadeLauncher { get; set; } = new(); public Sniper Sniper { get; set; } = new(); public Tranquilizer Tranquilizer { get; set; } = new(); public Plastic Plastic { get; set; } = new(); public AdminAbuse AdminAbuse { get; set; } = new(); - public Site02Card Site02Card { get; set; } = new(); - public TaskForceCard TaskForceCard { get; set; } = new(); #endregion diff --git a/ExtendedItems.csproj b/ExtendedItems.csproj index 45d5aed..804ae5e 100644 --- a/ExtendedItems.csproj +++ b/ExtendedItems.csproj @@ -9,6 +9,10 @@ <RestorePackagesWithLockFile>true</RestorePackagesWithLockFile> </PropertyGroup> + <PropertyGroup> + <NoWarn>$(NoWarn);MSB3270</NoWarn> + </PropertyGroup> + <ItemGroup> <PackageReference Include="ExMod.Exiled" Version="9.6.0" /> <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3"> diff --git a/Items/AdminAbuse.cs b/Items/AdminAbuse.cs index af5ec45..dc7df05 100644 --- a/Items/AdminAbuse.cs +++ b/Items/AdminAbuse.cs @@ -5,12 +5,12 @@ using Exiled.API.Features.Items; using Exiled.API.Features.Spawn; using Exiled.CustomItems.API.Features; +using Exiled.Events.EventArgs.Item; using Exiled.Events.EventArgs.Player; -using E = ExtendedItems.Utils; using InventorySystem.Items.Firearms.Attachments; -using ItemEvents = Exiled.Events.Handlers.Item; -using Exiled.Events.EventArgs.Item; using System.ComponentModel; +using E = ExtendedItems.Utils; +using ItemEvents = Exiled.Events.Handlers.Item; namespace ExtendedItems.Items { @@ -20,7 +20,7 @@ public class AdminAbuse : CustomWeapon { [Description("thanks to hayden for the idea on buckshot or else it wouldnt have worked")] public override uint Id { get; set; } = 799; - public override string Name { get; set; } = "Regert"; + public override string Name { get; set; } = "Regert (dont use this because it crashes the server)"; public override string Description { get; set; } = "you asked for it!"; public override float Weight { get; set; } = 0f; public override float Damage { get; set; } = 0; @@ -52,6 +52,7 @@ private void OnChangingAttachments(ChangingAttachmentsEventArgs ev) { if (!Check(ev.Item) || ev.Player.NetId < 2) return; + Log.Debug($"Player {ev.Player.Nickname} tried to change attachments for {Name}"); ev.IsAllowed = false; ev.Player.ShowHint("You are not allowed to change the attachment for this weapon."); } @@ -63,7 +64,7 @@ protected override void SubscribeEvents() base.SubscribeEvents(); } - + protected override void UnsubscribeEvents() { ItemEvents.ChangingAttachments -= OnChangingAttachments; @@ -75,7 +76,7 @@ private static IEnumerator<float> Detonate(Throwable throwable) for (; ; ) { float comp = -2; - var yVelocity = throwable.Projectile.Rigidbody.velocity.y - comp; + var yVelocity = throwable.Projectile.Rigidbody.linearVelocity.y - comp; Log.Info(yVelocity); } diff --git a/Items/Coin.cs b/Items/Coin.cs index ee56a0e..d27d268 100644 --- a/Items/Coin.cs +++ b/Items/Coin.cs @@ -1,12 +1,12 @@ -using System.ComponentModel; -using ExtendedItems.Types; using Exiled.API.Enums; +using Exiled.API.Features; using Exiled.API.Features.Attributes; using Exiled.API.Features.Spawn; using Exiled.CustomItems.API.Features; using Exiled.Events.EventArgs.Player; +using ExtendedItems.Types; using MEC; - +using System.ComponentModel; using PlayerEvents = Exiled.Events.Handlers.Player; namespace ExtendedItems.Items @@ -60,8 +60,9 @@ protected override void UnsubscribeEvents() private void OnFlippingCoin(FlippingCoinEventArgs ev) { if (!Check(ev.Item)) return; - - Timing.CallDelayed(2f, () => { + + Timing.CallDelayed(2f, () => + { if (ev.IsTails && !ev.Player.IsDead) { ev.Player.IsGodModeEnabled = false; @@ -71,6 +72,7 @@ private void OnFlippingCoin(FlippingCoinEventArgs ev) } ev.Player.ShowHint($"{Plugin.Instance?.Config.WinHints.RandomItem()}"); + Effects.ForEach((effect) => { ev.Player.EnableEffect(effect.Type, effect.Intensity, effect.Duration, true); }); }); } diff --git a/Items/GrenadeLauncher.cs b/Items/GrenadeLauncher.cs index 4a5d181..d974ab1 100644 --- a/Items/GrenadeLauncher.cs +++ b/Items/GrenadeLauncher.cs @@ -8,9 +8,9 @@ using Exiled.Events.EventArgs.Item; using Exiled.Events.EventArgs.Player; using InventorySystem.Items.Firearms.Attachments; - -using ItemEvents = Exiled.Events.Handlers.Item; +using YamlDotNet.Serialization; using E = ExtendedItems.Utils; +using ItemEvents = Exiled.Events.Handlers.Item; namespace ExtendedItems.Items @@ -23,9 +23,9 @@ public class GrenadeLauncher : CustomWeapon public override string Name { get; set; } = "Grenade Launcher"; public override string Description { get; set; } = "A modified Chaos Insergency LMG that fires High Explisove Grenades"; public override float Weight { get; set; } = 10f; - public override float Damage { get; set; } = 0f; public override byte ClipSize { get; set; } = 1; + [YamlIgnore] public override AttachmentName[] Attachments { get; set; } = [AttachmentName.Laser, AttachmentName.IronSights, AttachmentName.ShortBarrel]; public override SpawnProperties? SpawnProperties { get; set; } = new() @@ -45,12 +45,12 @@ protected override void OnShooting(ShootingEventArgs ev) { var throwable = ev.Player.ThrowGrenade(ProjectileType.FragGrenade); ushort ammo = E.Subtract((ushort)ev.Firearm.MagazineAmmo); - + throwable.Projectile.GameObject.AddComponent<CollisionHandler>().Init(ev.Player.GameObject, throwable.Projectile.Base); - + ev.Firearm.MagazineAmmo = 0; ev.Firearm.BarrelAmmo = 0; - + ev.Player.AddAmmo(AmmoType.Nato762, ammo); base.OnShooting(ev); @@ -64,7 +64,7 @@ protected override void OnReloading(ReloadingWeaponEventArgs ev) ev.Player.RemoveItem(ev.Player.Items.First(it => it.Type == ItemType.GrenadeHE)); base.OnReloading(ev); } - + else { ev.IsAllowed = false; @@ -92,8 +92,9 @@ protected override void UnsubscribeEvents() private void OnChangingAttachments(ChangingAttachmentsEventArgs ev) { - if(!Check(ev.Item)) { ev.IsAllowed = true; return; } - + if (!Check(ev.Item) || ev.Player.NetId < 2) return; + + Log.Debug($"Player {ev.Player.Nickname} tried to change attachments for {Name}"); ev.Player.Broadcast(5, "You can't change the attachments on this weapon"); ev.IsAllowed = false; } @@ -103,8 +104,8 @@ private static IEnumerator<float> Detonate(Throwable throwable) for (; ; ) { float comp = -2; - var yVelocity = throwable.Projectile.Rigidbody.velocity.y - comp; - + var yVelocity = throwable.Projectile.Rigidbody.linearVelocity.y - comp; + Log.Info(yVelocity); } } diff --git a/Items/Plastic.cs b/Items/Plastic.cs index b4865d2..79ed3de 100644 --- a/Items/Plastic.cs +++ b/Items/Plastic.cs @@ -1,4 +1,5 @@ -using Exiled.API.Enums; +// Exiled imports +using Exiled.API.Enums; using Exiled.API.Features; using Exiled.API.Features.Attributes; using Exiled.API.Features.Items; @@ -9,12 +10,18 @@ using Exiled.Events.EventArgs.Player; using Exiled.Events.EventArgs.Server; +// Non-System or Exiled imports using InventorySystem.Items.ThrowableProjectiles; -using MEC; using UnityEngine; using YamlDotNet.Serialization; +// System imports + +// shortcuted imports using PlayerEvent = Exiled.Events.Handlers.Player; +using ServerEvent = Exiled.Events.Handlers.Server; + + namespace ExtendedItems.Items @@ -30,10 +37,12 @@ public class Plastic : CustomGrenade public override bool ExplodeOnCollision { get; set; } = false; public override float FuseTime { get; set; } = 999f; public static Dictionary<Pickup, Player> PlacedCharges { get; } = []; + public static Dictionary<ushort, Player> Charges { get; } = []; public static Plastic Instance { get; private set; } = null!; public override SpawnProperties? SpawnProperties { get; set; } = new() + { - Limit = 3, + Limit = 2, RoomSpawnPoints = [ new RoomSpawnPoint() { Room = RoomType.HczNuke, Chance = 50 }, @@ -47,39 +56,47 @@ public class Plastic : CustomGrenade }, ], }; + public enum C4RemoveMethod { Remove = 0, Detonate = 1, Drop = 2, } - + [YamlIgnore] public override ItemType Type { get; set; } = ItemType.GrenadeHE; - public void Handler(Pickup? charge, C4RemoveMethod method = C4RemoveMethod.Drop) + public void Handler(Pickup? charge, C4RemoveMethod method = C4RemoveMethod.Drop, Player? detonator = null) { if (charge?.Position is null) return; - + + if (detonator == null && charge != null) { method = C4RemoveMethod.Drop; } + else { detonator = Charges.TryGetValue(charge.Serial, out var foundPlayer) ? foundPlayer : null; } + + switch (method) { case C4RemoveMethod.Detonate: - { - ExplosiveGrenade grenade = (ExplosiveGrenade)Item.Create(Type); - grenade.FuseTime = 0.1f; - - grenade.SpawnActive(charge.Position); - break; - } - + { + ExplosiveGrenade grenade = (ExplosiveGrenade)Item.Create(Type); + grenade.FuseTime = 0.1f; + grenade.SpawnActive(charge.Position, detonator); + break; + } case C4RemoveMethod.Drop: - { - TrySpawn(Id, charge.Position, out _); - break; - } + { + TrySpawn(Id, charge.Position, out _); + break; + } + case C4RemoveMethod.Remove: + { + charge.Destroy(); + break; + } } - + PlacedCharges.Remove(charge); charge.Destroy(); } @@ -91,7 +108,8 @@ protected override void SubscribeEvents() PlayerEvent.Destroying += OnDestroying; PlayerEvent.Died += OnDied; PlayerEvent.Shooting += OnShooting; - Exiled.Events.Handlers.Server.RoundEnded += OnRoundEnded; + + ServerEvent.RoundEnded += OnRoundEnded; base.SubscribeEvents(); } @@ -102,6 +120,7 @@ protected override void UnsubscribeEvents() PlayerEvent.Destroying -= OnDestroying; PlayerEvent.Died -= OnDied; PlayerEvent.Shooting -= OnShooting; + ServerEvent.RoundEnded -= OnRoundEnded; base.UnsubscribeEvents(); } @@ -114,49 +133,39 @@ protected override void OnWaitingForPlayers() protected override void OnThrownProjectile(ThrownProjectileEventArgs ev) { - if(!PlacedCharges.ContainsKey(ev.Projectile)) PlacedCharges.Add(ev.Pickup, ev.Player); - + Log.Debug("Executing OnThrownProjectile method."); + if (!PlacedCharges.ContainsKey(ev.Projectile)) + { + PlacedCharges.Add(ev.Pickup, ev.Player); + Charges.Add(ev.Projectile.Serial, ev.Player); + } + base.OnThrownProjectile(ev); } protected override void OnExploding(ExplodingGrenadeEventArgs ev) { - /*Player[] players = ev.TargetsToAffect.ToArray();*/ - /*float maxArtificialHealth = 0;*/ + Log.Debug("Executing OnExploding method."); + PlacedCharges.Remove(ev.Projectile); - foreach (Player pl in Player.List) - { - float damage = 0; - /*if(pl.Role.Team == ev.Player.Role.Team && ev.Player.Role.Team != PlayerRoles.Team.SCPs) - { - maxArtificialHealth = pl.MaxArtificialHealth; - }*/ - - Timing.CallDelayed(0.2f, () => - { - if(pl.ArtificialHealth < 300) damage = 300 - pl.ArtificialHealth; - pl.AddAhp(-300); - pl.Hurt(ev.Player, damage, DamageType.Firearm, null); - }); - } - PlacedCharges.Remove(Pickup.Get(ev.Projectile.Base)); } private void OnDestroying(DestroyingEventArgs ev) { - foreach (var charge in PlacedCharges.ToList()) + Log.Debug("Executing OnDestoying method."); + foreach (KeyValuePair<Pickup, Player> charge in PlacedCharges.ToList()) { if (charge.Value == ev.Player) Handler(charge.Key, C4RemoveMethod.Remove); } } - void OnDied(DiedEventArgs ev) + private void OnDied(DiedEventArgs ev) { - foreach (var charge in PlacedCharges.ToList()) + foreach (KeyValuePair<Pickup, Player> charge in PlacedCharges.ToList()) { if (charge.Value == ev.Player) { - Handler(charge.Key); + Handler(charge.Key, C4RemoveMethod.Drop); } } } @@ -165,13 +174,13 @@ private void OnShooting(ShootingEventArgs ev) { Vector3 forward = ev.Player.CameraTransform.forward; - if (!Physics.Raycast(ev.Player.CameraTransform.position + forward, forward, out var hit, 500)) + if (!Physics.Raycast(ev.Player.CameraTransform.position + forward, forward, out RaycastHit hit, 500)) return; - + EffectGrenade grenade = hit.collider.gameObject.GetComponentInParent<EffectGrenade>(); - + if (grenade == null) return; - if (PlacedCharges.ContainsKey(Pickup.Get(grenade))) + if (PlacedCharges.ContainsKey(Pickup.Get(grenade))) { Handler(Pickup.Get(grenade), C4RemoveMethod.Remove); } diff --git a/Items/Scp1162.cs b/Items/Scp1162.cs deleted file mode 100644 index f38b77a..0000000 --- a/Items/Scp1162.cs +++ /dev/null @@ -1,127 +0,0 @@ -using Exiled.API.Enums; -using Exiled.API.Features; -using Exiled.API.Features.Attributes; -using Exiled.API.Features.Items; -using Exiled.API.Features.Spawn; -using Exiled.CustomItems.API.Features; -using Exiled.Events.EventArgs.Player; -using InventorySystem.Items.Usables; -using System.ComponentModel; -using UnityEngine; -using YamlDotNet.Serialization; -using Random = System.Random; -using ServerEvents = Exiled.Events.Handlers.Server; - -namespace ExtendedItems.Items -{ - [CustomItem(ItemType.SCP500)] - public class Scp1162 : CustomItem { - public override string Name { get; set; } = "SCP-1162"; - public override uint Id { get; set; } = 7825; - public override string Description { get; set; } = "Hold an item and pick it up to get another."; - public override float Weight { get; set; } = 0f; - public override Vector3 Scale { get; set; } = new(5f, 5f, 5f); - - [Description("Chance from 0 to 1 that the item will be destroyed.")] - public float LoseChance { get; set; } = 0.15f; - - public override SpawnProperties? SpawnProperties { get; set; } - [YamlIgnore] private readonly Random _rng = new(); - - [Description("Types of items that can be traded from SCP-1162.")] - public ItemType[] ItemTypes { get; set; } = - [ - ItemType.KeycardJanitor, - ItemType.KeycardZoneManager, - ItemType.KeycardScientist, - ItemType.KeycardContainmentEngineer, - ItemType.KeycardResearchCoordinator, - ItemType.KeycardMTFPrivate, - ItemType.KeycardMTFOperative, - ItemType.KeycardMTFCaptain, - ItemType.KeycardFacilityManager, - ItemType.KeycardChaosInsurgency, - ItemType.KeycardO5, - ItemType.SurfaceAccessPass, - ItemType.GunCOM15, - ItemType.GunCOM18, - ItemType.Painkillers, - ItemType.Medkit, - ItemType.Adrenaline, - ItemType.SCP500, - ItemType.SCP207, - ItemType.AntiSCP207, - ItemType.GrenadeHE, - ItemType.GrenadeFlash, - ItemType.Coin, - ItemType.Flashlight, - ItemType.Radio, - - ]; - - private void OnRoundStarted() - { - var room = Room.Get(RoomType.Lcz173); - var globalPos = Utils.GetGlobalCords(RoomType.Lcz173, new Vector3(16.68f, 11.6f, 8.11f)); - - var rotation = room.Rotation; - var rot = new Vector3(0f, 1f, 0.0f); - var quaternion = Quaternion.Euler(rot.x, rotation.eulerAngles.y + rot.y, rot.z); - - var item = Spawn(globalPos)!; - - item.Rotation = quaternion; - item.Rigidbody.useGravity = false; - item.Rigidbody.detectCollisions = false; - } - - protected override void SubscribeEvents() - { - ServerEvents.RoundStarted += OnRoundStarted; - - base.SubscribeEvents(); - } - - protected override void UnsubscribeEvents() - { - ServerEvents.RoundStarted -= OnRoundStarted; - - base.UnsubscribeEvents(); - } - - protected override void OnPickingUp(PickingUpItemEventArgs ev) - { - ev.IsAllowed = false; - - try { - var item = ev.Player.CurrentItem; - if (item == null) - { - ev.Player.EnableEffect(EffectType.SeveredHands, byte.MaxValue); - } - else { - if(item.Type == ItemType.SCP330) - { - ev.IsAllowed = false; - ev.Player.ShowHint("You can't trade SCP-330 with SCP-1162.", 5); - return; - } - ev.Player.RemoveItem(item); - if (_rng.NextDouble() < LoseChance) return; - item = ev.Player.AddItem(ItemTypes[_rng.Next(0, ItemTypes.Length)]); - - - - ev.Player.CurrentItem = item; - - } - return; - } - catch { - // ignored - } - - base.OnPickingUp(ev); - } - } -} diff --git a/Items/Scp1499.cs b/Items/Scp1499.cs index 78e481c..6c2e2c9 100644 --- a/Items/Scp1499.cs +++ b/Items/Scp1499.cs @@ -1,4 +1,3 @@ -using System.ComponentModel; using Exiled.API.Enums; using Exiled.API.Features; using Exiled.API.Features.Attributes; @@ -6,6 +5,7 @@ using Exiled.CustomItems.API.Features; using Exiled.Events.EventArgs.Player; using MEC; +using System.ComponentModel; using UnityEngine; using YamlDotNet.Serialization; using PlayerEvents = Exiled.Events.Handlers.Player; @@ -13,37 +13,38 @@ namespace ExtendedItems.Items { [CustomItem(ItemType.SCP268)] - public class Scp1499 : CustomItem { - public override uint Id { get; set; } = 803; - public override string Name { get; set; } = "SCP-1499"; - public override string Description { get; set; } = "<i>A breath away from oblivion.</i>"; - public override float Weight { get; set; } = 5f; - - [Description("Room to teleport player to after using SCP-1499.")] - public RoomType TeleportRoom { get; set; } = RoomType.Hcz106; - - [Description("Relative position of room mentioned above to teleport player to after using SCP-1499.")] - public Vector3 RelativePosition = new(5.75f, 10f, -10.75f); - - [Description("Time for player to wander in seconds.")] - public float Duration { get; set; } = 15f; - - [YamlIgnore] - private readonly Dictionary<uint, (Vector3, Lift?, CoroutineHandle)> _lastPositions = []; - - public override SpawnProperties? SpawnProperties { get; set; } = new() + public class Scp1499 : CustomItem + { + public override uint Id { get; set; } = 803; + public override string Name { get; set; } = "SCP-1499"; + public override string Description { get; set; } = "<i>A breath away from oblivion.</i>"; + public override float Weight { get; set; } = 5f; + + [Description("Room to teleport player to after using SCP-1499.")] + public RoomType TeleportRoom { get; set; } = RoomType.Hcz106; + + [Description("Relative position of room mentioned above to teleport player to after using SCP-1499.")] + public Vector3 RelativePosition = new(5.75f, 10f, -10.75f); + + [Description("Time for player to wander in seconds.")] + public float Duration { get; set; } = 15f; + + [YamlIgnore] + private readonly Dictionary<uint, (Vector3, Lift?, CoroutineHandle)> _lastPositions = []; + + public override SpawnProperties? SpawnProperties { get; set; } = new() { - Limit = 1, - RoomSpawnPoints = + Limit = 1, + RoomSpawnPoints = [ - new RoomSpawnPoint() { Room = RoomType.EzGateB, Chance = 100 } - ] - }; + new RoomSpawnPoint() { Room = RoomType.EzGateB, Chance = 100 } + ] + }; private void OnUsingItem(UsingItemEventArgs ev) { - if (!Check(ev.Item)) return; - if(ev.Player.IsInPocketDimension) + if (!Check(ev.Item)) return; + if (ev.Player.IsInPocketDimension) { ev.Player.ShowHint("You put on the gas mask but nothing happens.\nIt seems that this SCP item has its limits."); ev.IsAllowed = false; @@ -51,58 +52,58 @@ private void OnUsingItem(UsingItemEventArgs ev) } } - private void OnUsedItem(UsedItemEventArgs ev) + private void OnUsedItem(UsedItemEventArgs ev) { - if (!Check(ev.Item)) return; - - ev.Player.DisableEffect(EffectType.Invisible); - ev.Player.EnableEffect(EffectType.DamageReduction, byte.MaxValue, Duration); - - var handle = Timing.CallDelayed(Duration, () => TeleportPrevious(ev.Player.NetId)); - - _lastPositions.Add(ev.Player.NetId, (ev.Player.Position, ev.Player.Lift, handle)); - ev.Player.Teleport(Utils.GetGlobalCords(TeleportRoom, RelativePosition)); - } - - private void TeleportPrevious(uint netId) + if (!Check(ev.Item)) return; + + ev.Player.DisableEffect(EffectType.Invisible); + ev.Player.EnableEffect(EffectType.DamageReduction, byte.MaxValue, Duration); + + var handle = Timing.CallDelayed(Duration, () => TeleportPrevious(ev.Player.NetId)); + + _lastPositions.Add(ev.Player.NetId, (ev.Player.Position, ev.Player.Lift, handle)); + ev.Player.Teleport(Utils.GetGlobalCords(TeleportRoom, RelativePosition)); + } + + private void TeleportPrevious(uint netId) { - if (!Player.TryGet(netId, out var player)) return; - if (!_lastPositions.TryGetValue(netId, out var lastPos)) return; + if (!Player.TryGet(netId, out var player)) return; + if (!_lastPositions.TryGetValue(netId, out var lastPos)) return; - if (lastPos.Item2 != null) - player.Teleport(lastPos.Item2.Position + Vector3.up * 2f); - else - player.Teleport(lastPos.Item1); + if (lastPos.Item2 != null) + player.Teleport(lastPos.Item2.Position + Vector3.up * 2f); + else + player.Teleport(lastPos.Item1); - _lastPositions.Remove(netId); - Timing.KillCoroutines(lastPos.Item3); - } + _lastPositions.Remove(netId); + Timing.KillCoroutines(lastPos.Item3); + } - protected override void SubscribeEvents() + protected override void SubscribeEvents() { - PlayerEvents.UsedItem += OnUsedItem; + PlayerEvents.UsedItem += OnUsedItem; PlayerEvents.UsingItem += OnUsingItem; base.SubscribeEvents(); - } + } - protected override void UnsubscribeEvents() + protected override void UnsubscribeEvents() { - PlayerEvents.UsedItem -= OnUsedItem; + PlayerEvents.UsedItem -= OnUsedItem; PlayerEvents.UsingItem -= OnUsingItem; base.UnsubscribeEvents(); - } + } - protected override void OnDroppingItem(DroppingItemEventArgs ev) + protected override void OnDroppingItem(DroppingItemEventArgs ev) { - if (!Check(ev.Item)) return; - if (!_lastPositions.ContainsKey(ev.Player.NetId)) return; - - ev.IsAllowed = false; - TeleportPrevious(ev.Player.NetId); - - base.OnDroppingItem(ev); - } + if (!Check(ev.Item)) return; + if (!_lastPositions.ContainsKey(ev.Player.NetId)) return; + + ev.IsAllowed = false; + TeleportPrevious(ev.Player.NetId); + + base.OnDroppingItem(ev); + } } } \ No newline at end of file diff --git a/Items/Sniper.cs b/Items/Sniper.cs index 896c05a..9bbba4c 100644 --- a/Items/Sniper.cs +++ b/Items/Sniper.cs @@ -1,4 +1,5 @@ using Exiled.API.Enums; +using Exiled.API.Features; using Exiled.API.Features.Attributes; using Exiled.API.Features.Spawn; using Exiled.CustomItems.API.Features; @@ -15,28 +16,20 @@ public class Sniper : CustomWeapon { public override uint Id { get; set; } = 802; public override string Name { get; set; } = "SR-118"; - public override string Description { get; set; } = "A modified E-11 that fires 5.56 at supersonic velocity that deals significantly more damage"; - - public override float Weight { get; set; } = 8f; + public override float Weight { get; set; } = 5f; public override float Damage { get; set; } = 112f; public override byte ClipSize { get; set; } = 1; - [YamlIgnore] - public override AttachmentName[] Attachments { get; set; } = + public override AttachmentName[] Attachments { get; set; } = [ - AttachmentName.LowcapMagAP, - AttachmentName.Foregrip, - AttachmentName.DotSight, - AttachmentName.RecoilReducingStock, - AttachmentName.RifleBody, - AttachmentName.SoundSuppressor + AttachmentName.LowcapMagAP, AttachmentName.Foregrip, AttachmentName.DotSight, AttachmentName.RecoilReducingStock, AttachmentName.CarbineBody, AttachmentName.MuzzleBrake ]; public override SpawnProperties? SpawnProperties { get; set; } = new() { Limit = 1, - RoomSpawnPoints = + RoomSpawnPoints = [ new RoomSpawnPoint() { Room = RoomType.HczArmory, Chance = 100 } ] @@ -65,7 +58,8 @@ protected override void UnsubscribeEvents() private void OnChangingAttachments(ChangingAttachmentsEventArgs ev) { if (!Check(ev.Item) || ev.Player.NetId < 2) return; - + + Log.Debug($"Player {ev.Player.Nickname} tried to change attachments for {Name}"); ev.IsAllowed = false; ev.Player.ShowHint("You are not allowed to change the attachment for this weapon."); } diff --git a/Items/Tranquilizer.cs b/Items/Tranquilizer.cs index 9e310bc..d948427 100644 --- a/Items/Tranquilizer.cs +++ b/Items/Tranquilizer.cs @@ -1,24 +1,27 @@ -using System.ComponentModel; using Exiled.API.Enums; using Exiled.API.Features; using Exiled.API.Features.Attributes; using Exiled.API.Features.Spawn; using Exiled.CustomItems.API.Features; +using Exiled.CustomRoles.API; using Exiled.Events.EventArgs.Player; using MEC; +using Mirror; using PlayerRoles; using PlayerRoles.PlayableScps.Scp096; using PlayerStatsSystem; +using System.ComponentModel; using UnityEngine; using YamlDotNet.Serialization; +using PlayerEvents = Exiled.Events.Handlers.Player; using Random = System.Random; using Scp096Role = Exiled.API.Features.Roles.Scp096Role; -using PlayerEvents = Exiled.Events.Handlers.Player; namespace ExtendedItems.Items { [CustomItem(ItemType.GunCOM15)] - public class Tranquilizer : CustomWeapon { + public class Tranquilizer : CustomWeapon + { public override string Name { get; set; } = "Tranquilizer"; public override uint Id { get; set; } = 801; @@ -49,7 +52,8 @@ public class Tranquilizer : CustomWeapon { [YamlIgnore] private readonly Dictionary<uint, float> _resistances = []; public ItemType[] Inventory { get; set; } = []; - public override SpawnProperties? SpawnProperties { get; set; } = new() { + public override SpawnProperties? SpawnProperties { get; set; } = new() + { Limit = 1, RoomSpawnPoints = [ new RoomSpawnPoint() { Room = RoomType.LczCafe, Chance = 25 }, @@ -88,41 +92,41 @@ protected override void OnShot(ShotEventArgs ev) if (AdrenalineBuff && targetActiveEffect.name == "Invigorated") Affected = false; } if (!Affected) return; - + Exiled.API.Features.Items.Item? item = null; - - if((bool)(Plugin.Instance.Config.ReholdItems!)) + + if ((bool)(Plugin.Instance.Config.ReholdItems!)) { item = ev.Target.CurrentItem; } - - var rand = _rng.NextDouble(); + + double rand = _rng.NextDouble(); _resistances.TryGetValue(ev.Target.NetId, out float tResistance); - - var effective = ev.Target.IsScp ? rand < ScpChance - tResistance : rand < HumanChance - tResistance; - + + bool effective = ev.Target.IsScp ? rand < ScpChance - tResistance : rand < HumanChance - tResistance; + if ((ev.Target.Role == RoleTypeId.Scp173 && !EffectiveOn173) || !effective) - { - base.OnShot(ev); + { + base.OnShot(ev); return; } - var lift = ev.Player.Lift; - + Lift lift = ev.Player.Lift; + ev.Target.Scale = Vector3.zero; - _resistances[ev.Target.NetId] = tResistance + Resistance; - + _resistances[ev.Target.NetId] = tResistance + (_rng.Next(1,10)/100); + ev.Target.EnableEffect(EffectType.Ensnared, byte.MaxValue); ev.Target.EnableEffect(EffectType.Flashed, byte.MaxValue); ev.Target.EnableEffect(EffectType.Deafened, byte.MaxValue); - + ev.Target.IsGodModeEnabled = true; Ragdoll? ragdoll = null; - + if (ev.Target.IsHuman) - { - ev.Target.CurrentItem = null; - ev.Target.Inventory.enabled = false; + { + ev.Target.CurrentItem = null; + ev.Target.Inventory.enabled = false; ev.Target.EnableEffect(EffectType.AmnesiaItems, byte.MaxValue); } else @@ -130,37 +134,37 @@ protected override void OnShot(ShotEventArgs ev) if (ev.Target.Role != RoleTypeId.Scp106) { ragdoll = Ragdoll.CreateAndSpawn(ev.Target.Role.Type, ev.Target.DisplayNickname, new CustomReasonDamageHandler("Tranquilized."), ev.Target.Position, ev.Target.Rotation, ev.Target); - } - if (ev.Target.Role == RoleTypeId.Scp096) - { + } + if (ev.Target.Role == RoleTypeId.Scp096) + { var crybaby = (Scp096Role)ev.Target.Role; if (crybaby.RageState is Scp096RageState.Enraged or Scp096RageState.Distressed) { crybaby.RageManager.ServerEndEnrage(); - } + } } } Timing.CallDelayed(5, () => - { - ev.Target.Inventory.enabled = true; - ev.Target.IsGodModeEnabled = false; - ev.Target.DisableEffect(EffectType.Ensnared); - ev.Target.DisableEffect(EffectType.Flashed); - ev.Target.DisableEffect(EffectType.Deafened); - ev.Target.DisableEffect(EffectType.AmnesiaItems); - ev.Target.CurrentItem = item; - if (lift != null) ev.Target.Teleport(lift.Position + Vector3.up * 2f); - else ev.Target.Teleport(ev.Target.Position + Vector3.up * 2f); ev.Target.Scale = Vector3.one; + { + ev.Target.Inventory.enabled = true; + ev.Target.IsGodModeEnabled = false; + ev.Target.DisableEffect(EffectType.Ensnared); + ev.Target.DisableEffect(EffectType.Flashed); + ev.Target.DisableEffect(EffectType.Deafened); + ev.Target.DisableEffect(EffectType.AmnesiaItems); + ev.Target.CurrentItem = item; + if (lift != null) ev.Target.Teleport(lift.Position + Vector3.up * 2f); + else ev.Target.Teleport(ev.Target.Position + Vector3.up * 2f); ev.Target.Scale = Vector3.one; ragdoll?.Destroy(); }); - + base.OnShot(ev); } protected override void OnShooting(ShootingEventArgs ev) { - if(!Check(ev.Item)) return; - if(ev.Firearm.MagazineAmmo >= 4) + if (!Check(ev.Item)) return; + if (ev.Firearm.MagazineAmmo >= 4) { ev.Firearm.MagazineAmmo = 2; } diff --git a/Keycards/Site02Card.cs b/Keycards/Site02Card.cs deleted file mode 100644 index f669259..0000000 --- a/Keycards/Site02Card.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Exiled.API.Enums; -using Exiled.API.Features.Attributes; -using Exiled.API.Features.Items; -using Exiled.API.Features.Spawn; -using Exiled.CustomItems.API.Features; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using UnityEngine; -using LabApi.Features.Wrappers; - -namespace ExtendedItems.Keycards -{ - [CustomItem(ItemType.KeycardCustomSite02)] - public class Site02Card : CustomKeycard - { - public override uint Id { get; set; } = 90; - public override string Name { get; set; } = "Site-02 Keycard"; - public override string Description { get; set; } = "A base keycard that is used to give a person a keycard with the right name and for custom colors via a command"; - public override float Weight { get; set; } = 0.01f; - public override string KeycardLabel { get; set; } = "Great_Value"; - public override Color32? KeycardLabelColor { get; set; } = new(255, 255, 255, 255); - public override string KeycardName { get; set; } = "Valued Shopper"; - public override Color32? KeycardPermissionsColor { get; set; } = new(0, 0, 0, 255); - public override KeycardPermissions Permissions { get; set; } = KeycardPermissions.ContainmentLevelOne; - public override Color32? TintColor { get; set; } = new(255, 255, 255, 255); - public override ItemType Type { get; set; } = ItemType.KeycardCustomSite02; - - public override SpawnProperties? SpawnProperties { get; set; } = new() - - { - Limit = 0, - }; - - protected override void SubscribeEvents() - { - base.SubscribeEvents(); - } - - protected override void UnsubscribeEvents() - { - base.UnsubscribeEvents(); - } - - - } -} \ No newline at end of file diff --git a/Keycards/TaskForceCard.cs b/Keycards/TaskForceCard.cs deleted file mode 100644 index 8c6058a..0000000 --- a/Keycards/TaskForceCard.cs +++ /dev/null @@ -1,47 +0,0 @@ -using Exiled.API.Enums; -using Exiled.API.Features.Attributes; -using Exiled.API.Features.Items; -using Exiled.API.Features.Spawn; -using Exiled.CustomItems.API.Features; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using UnityEngine; -using LabApi.Features.Wrappers; - -namespace ExtendedItems.Keycards -{ - [CustomItem(ItemType.KeycardCustomTaskForce)] - public class TaskForceCard : CustomKeycard - { - public override uint Id { get; set; } = 91; - public override string Name { get; set; } = "TaskForce Keycard"; - public override string Description { get; set; } = "A base keycard that is used to give a person a keycard with the right name and for custom colors via a command"; - public override float Weight { get; set; } = 0.01f; - public override string KeycardLabel { get; set; } = "Great_Value"; - public override Color32? KeycardLabelColor { get; set; } = new(255, 255, 255, 255); - public override string KeycardName { get; set; } = "Valued Shopper"; - public override Color32? KeycardPermissionsColor { get; set; } = new(0, 0, 0, 255); - public override KeycardPermissions Permissions { get; set; } = KeycardPermissions.ContainmentLevelOne; - public override Color32? TintColor { get; set; } = new(255, 255, 255, 255); - public override ItemType Type { get; set; } = ItemType.KeycardCustomTaskForce; - - public override SpawnProperties? SpawnProperties { get; set; } = new() - - { - Limit = 0, - }; - - protected override void SubscribeEvents() - { - base.SubscribeEvents(); - } - - protected override void UnsubscribeEvents() - { - base.UnsubscribeEvents(); - } - } -} \ No newline at end of file diff --git a/Plugin.cs b/Plugin.cs index f4a773e..6f2ff40 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -3,33 +3,33 @@ namespace ExtendedItems { - public class Plugin : Plugin<Config> + public class Plugin : Plugin<Config> { public override string Prefix => "Cactus Patch"; public override string Name => "Extended Items"; public override string Author => "Noobest1001"; - public override Version Version => new(3, 1, 0); + public override Version Version => new(3, 2, 1); public override Version RequiredExiledVersion => new(9, 6, 0); public static Plugin? Instance; - public override void OnEnabled() { + public override void OnEnabled() + { Instance = this; - + Log.Info("Registering items"); CustomItem.RegisterItems(overrideClass: Config); - CustomKeycard.RegisterItems(overrideClass: Config); - - + + base.OnEnabled(); } - public override void OnDisabled() { - Instance = null; - + public override void OnDisabled() + { Log.Info("Unregistering items"); CustomItem.UnregisterItems(); - CustomKeycard.UnregisterItems(); - + + Instance = null; + base.OnDisabled(); } } diff --git a/PreviousChangeLogs/v3.1.0.md b/PreviousChangeLogs/v3.1.0.md new file mode 100644 index 0000000..9db1e8b --- /dev/null +++ b/PreviousChangeLogs/v3.1.0.md @@ -0,0 +1,12 @@ +># Update 3.1.0 +> +>>## SCP-1289 (formerly <i>'Coin'</i>) +>>> #### Renamed the coin +>>> #### Added death and winning notes +>>>> Due to a limitation of Exiled only the player who gets killed by the coin can see the new effects added by yours truly +>> +>>## Tranq +>>> Made the player who got tranqed invulnerable but unable to use any items (humans) +>> +>>## Genaral code +>>> Added some notes in the 'Util.cs' file for those who want to add on to this \ No newline at end of file diff --git a/README.md b/README.md index aa15615..571c7b0 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,6 @@ Currently, there are 6 items available: - Coin - Gives player effect bonuses if lands on heads, ~~**_[redacted]_**~~ if on tails. -- SCP-1162 - - Spawns in Lcz173, hold an item and interact to trade for another. - SCP-1499 - A gas mask that temporarily teleports you to a location. - Sniper diff --git a/Types/CoinEffect.cs b/Types/CoinEffect.cs index 887e8f6..e55ab1e 100644 --- a/Types/CoinEffect.cs +++ b/Types/CoinEffect.cs @@ -2,7 +2,8 @@ namespace ExtendedItems.Types { - public class CoinEffect { + public class CoinEffect + { public EffectType Type { get; set; } public float Duration { get; set; } public byte Intensity { get; set; } diff --git a/Utils.cs b/Utils.cs index ba8077b..7024ff2 100644 --- a/Utils.cs +++ b/Utils.cs @@ -1,14 +1,13 @@ using Exiled.API.Enums; +using Exiled.API.Extensions; using Exiled.API.Features; -using Exiled.Events.EventArgs.Player; -using PlayerStatsSystem; +using Exiled.API.Features.Items; +using Exiled.Events.Handlers; +using InventorySystem.Items.Usables.Scp330; using UnityEngine; -using Lab = LabApi.Features.Wrappers; +using CK = Exiled.CustomItems.API.Features; using EP = Exiled.API.Features.Player; using ExItem = Exiled.API.Features.Items; // Exiled.API.Features.Items not ExtededItems -using CK = Exiled.CustomItems.API.Features; -using Exiled.API.Extensions; -using Exiled.CustomItems.API.Features; namespace ExtendedItems { @@ -22,10 +21,10 @@ public static class Utils /// <returns>Vector3</returns> public static Vector3 GetGlobalCords(RoomType roomType, Vector3 localPos) { - var room = Room.Get(roomType); + Room room = Room.Get(roomType); - var rotation = room.Rotation; - var roomPos = room.Position; + Quaternion rotation = room.Rotation; + Vector3 roomPos = room.Position; double offsetY = Math.Round(Math.Abs(rotation.eulerAngles.y / 90f)); @@ -73,16 +72,6 @@ public static ushort Subtract(ushort input, int m = 1) return (ushort)temp; } - /// <summary> - /// Creates a custom death message - /// </summary> - /// <param name="deathMessage"></param> - /// <returns>CustomReasonDamageHandler</returns> - public static CustomReasonDamageHandler CustomDeath(string deathMessage) - { - return new CustomReasonDamageHandler(deathMessage); - } - /// <summary> /// Converts a hexadecimal color string to a <see cref="Color32"/> object. /// </summary> @@ -97,13 +86,15 @@ public static CustomReasonDamageHandler CustomDeath(string deathMessage) /// Green, Blue, and Alpha components (e.g., "FF00FF80").</description></item> </list></param> /// <returns>A <see cref="Color32"/> object representing the parsed color. If the input is null, empty, or invalid, the /// method returns a default black color with full opacity (<c>Color32(0, 0, 0, 255)</c>).</returns> + [Obsolete("Until NW fixes their keycards this essentially dosnt work")] public static Color32 Hex2Color(string hex) { if (string.IsNullOrWhiteSpace(hex)) return new Color32(0, 0, 0, 255); hex = hex.TrimStart('#'); - byte r = 0, g = 0, b = 0, a = 255; + byte g = 0, b = 0, a = 255; + byte r; try { @@ -139,14 +130,14 @@ public static Color32 Hex2Color(string hex) return new Color32(r, g, b, a); } - //I finally got to use the ternary operator ٩( ๑╹ ꇴ╹)۶ + // I finally got to use the ternary operator ٩( ๑╹ ꇴ╹)۶ // I swear to god if this gets removed I will find you and beat you with a hammer // You can also see where I said fuck it and started naming methods like Microsoft public static ExItem.Item GetHeldOrFirst(EP player, ExItem.Item item) => item = player.CurrentItem.Type.ToString().ToLower().Contains("keycard") - ? player.CurrentItem - : player.Items.FirstOrDefault(i => i.Type.ToString().ToLower().Contains("keycard")); + ? player.CurrentItem : player.Items.FirstOrDefault(i => i.Type.ToString().ToLower().Contains("keycard")); + [Obsolete("This isnt in use atm because NW fucked up Custom key cards")] public static void CustomKeycardSetup(CK.CustomKeycard keycard, string name, string label, string labelColor, string permissionsColor, string tintColor) { keycard.KeycardName = name; @@ -156,14 +147,177 @@ public static void CustomKeycardSetup(CK.CustomKeycard keycard, string name, str keycard.TintColor = Hex2Color(tintColor); } - public static List<string> GetProperties(EP player) + public static CandyKindID AddCandy(int candy) { - List<string> response = []; - var helditem = GetHeldOrFirst(player, player.Items.FirstOrDefault(i => i.Type == ItemType.KeycardFacilityManager)); - helditem.CopyProperties(response); - return response; + return candy switch + { + 0 => CandyKindID.Pink, + 1 => CandyKindID.Blue, + 2 => CandyKindID.Green, + 3 => CandyKindID.Yellow, + 4 => CandyKindID.Purple, + 5 => CandyKindID.Rainbow, + _ => CandyKindID.Red, + }; + } + public static string CandytoString(int candy) + { + return candy switch + { + 0 => "<color=#FFC0CB>Pink</color>", + 1 => "<color=#0000FF>Blue</color>", + 2 => "<color=#008000>Green</color>", + 3 => "<color=#FFFF00>Yellow</color>", + 4 => "<color=#800080>Purple</color>", + 5 => "<color=#FF0000>R</color><color=#FF7F00>a</color><color=#FFFF00>i</color><color=#00FF00>n</color><color=#0000FF>b</color><color=#4B0082>o</color><color=#8A2BE2>w</color>", + _ => "<color=#FF0000>Red</color>", + }; } - + /// <summary> + /// Gives and equips an item to a player + /// </summary> + /// <param name="item"></param> + /// <param name="player"></param> + public static void GiveEquip(ExItem.Item item, EP player) + { + player.AddItem(item); + player.CurrentItem = item; + } + + public static void GiveEquip(ItemType itemType, EP player) + { + ExItem.Item item = ExItem.Item.Create(itemType); + GiveEquip(item, player); + } + + public static string GetItemName(ExItem.Item item) + { + return item.Type switch + { + ItemType.KeycardJanitor => "Janitor Keycard", + ItemType.KeycardScientist => "Scientist Keycard", + ItemType.KeycardResearchCoordinator => "Research Coordinator Keycard", + ItemType.KeycardZoneManager => "Zone Manager Keycard", + ItemType.KeycardGuard => "Guard Keycard", + ItemType.KeycardMTFPrivate => "MTF Private Keycard", + ItemType.KeycardContainmentEngineer => "Containment Engineer Keycard", + ItemType.KeycardMTFOperative => "MTF Operative Keycard", + ItemType.KeycardMTFCaptain => "MTF Captain Keycard", + ItemType.KeycardFacilityManager => "Facility Manager Keycard", + ItemType.KeycardChaosInsurgency => "Chaos Insurgency Keycard", + ItemType.KeycardO5 => "O5 Keycard", + ItemType.Radio => "Radio", + ItemType.GunCOM15 => "COM-15", + ItemType.Medkit => "Medkit", + ItemType.Flashlight => "Flashlight", + ItemType.MicroHID => "Micro HID", + ItemType.SCP500 => "SCP-500", + ItemType.SCP207 => "SCP-207", + ItemType.Ammo12gauge => "12-Gauge", + ItemType.GunE11SR => "E-11", + ItemType.GunCrossvec => "Crossvec", + ItemType.Ammo556x45 => "5.56mm", + ItemType.GunFSP9 => "FSP-9", + ItemType.GunLogicer => "Logicer", + ItemType.GrenadeHE => "Grenade", + ItemType.GrenadeFlash => "Flashbang", + ItemType.Ammo44cal => ".44mm", + ItemType.Ammo762x39 => "7.62mm", + ItemType.Ammo9x19 => "9mm Parabellum", + ItemType.GunCOM18 => "COM-18", + ItemType.SCP018 => "SCP-018", + ItemType.SCP268 => "SCP-268", + ItemType.Adrenaline => "Adrenaline", + ItemType.Painkillers => "Painkillers", + ItemType.Coin => "American Quarter", + ItemType.ArmorLight => "Light Armor", + ItemType.ArmorCombat => "Combat Armor", + ItemType.ArmorHeavy => "Heavy Armor", + ItemType.GunRevolver => "Revolver", + ItemType.GunAK => "AK-15", + ItemType.GunShotgun => "Shotgun", + ItemType.SCP2176 => "SCP-2176", + ItemType.SCP244a => "SCP-244-A", + ItemType.SCP244b => "SCP-244-B", + ItemType.SCP1853 => "SCP-1853", + ItemType.ParticleDisruptor => "Particle Disruptor", + ItemType.GunCom45 => "Glockinator", + ItemType.SCP1576 => "SCP-1576", + ItemType.Jailbird => "Jailbird", + ItemType.AntiSCP207 => "SCP-207?", + ItemType.GunFRMG0 => "Captains' gun", + ItemType.GunA7 => "AK74SU", + ItemType.Lantern => "Lantern", + ItemType.SCP1344 => "SCP-1344-6", + ItemType.SurfaceAccessPass => "Surface Access Pass", + ItemType.GunSCP127 => "SCP-127", + _ => throw new ArgumentException($"Unknown item type: {item.Type}"), + }; + } + public static string GetItemName(ItemType item) + { + return item switch + { + ItemType.KeycardJanitor => "Janitor Keycard", + ItemType.KeycardScientist => "Scientist Keycard", + ItemType.KeycardResearchCoordinator => "Research Coordinator Keycard", + ItemType.KeycardZoneManager => "Zone Manager Keycard", + ItemType.KeycardGuard => "Guard Keycard", + ItemType.KeycardMTFPrivate => "MTF Private Keycard", + ItemType.KeycardContainmentEngineer => "Containment Engineer Keycard", + ItemType.KeycardMTFOperative => "MTF Operative Keycard", + ItemType.KeycardMTFCaptain => "MTF Captain Keycard", + ItemType.KeycardFacilityManager => "Facility Manager Keycard", + ItemType.KeycardChaosInsurgency => "Chaos Insurgency Keycard", + ItemType.KeycardO5 => "O5 Keycard", + ItemType.Radio => "Radio", + ItemType.GunCOM15 => "COM-15", + ItemType.Medkit => "Medkit", + ItemType.Flashlight => "Flashlight", + ItemType.MicroHID => "Micro HID", + ItemType.SCP500 => "SCP-500", + ItemType.SCP207 => "SCP-207", + ItemType.Ammo12gauge => "12-Gauge", + ItemType.GunE11SR => "E-11", + ItemType.GunCrossvec => "Crossvec", + ItemType.Ammo556x45 => "5.56mm", + ItemType.GunFSP9 => "FSP-9", + ItemType.GunLogicer => "Logicer", + ItemType.GrenadeHE => "Grenade", + ItemType.GrenadeFlash => "Flashbang", + ItemType.Ammo44cal => ".44mm", + ItemType.Ammo762x39 => "7.62mm", + ItemType.Ammo9x19 => "9mm Parabellum", + ItemType.GunCOM18 => "COM-18", + ItemType.SCP018 => "SCP-018", + ItemType.SCP268 => "SCP-268", + ItemType.Adrenaline => "Adrenaline", + ItemType.Painkillers => "Painkillers", + ItemType.Coin => "American Quarter", + ItemType.ArmorLight => "Light Armor", + ItemType.ArmorCombat => "Combat Armor", + ItemType.ArmorHeavy => "Heavy Armor", + ItemType.GunRevolver => "Revolver", + ItemType.GunAK => "AK-15", + ItemType.GunShotgun => "Shotgun", + ItemType.SCP2176 => "SCP-2176", + ItemType.SCP244a => "SCP-244-A", + ItemType.SCP244b => "SCP-244-B", + ItemType.SCP1853 => "SCP-1853", + ItemType.ParticleDisruptor => "Particle Disruptor", + ItemType.GunCom45 => "Glockinator", + ItemType.SCP1576 => "SCP-1576", + ItemType.Jailbird => "Jailbird", + ItemType.AntiSCP207 => "SCP-207?", + ItemType.GunFRMG0 => "Captains' gun", + ItemType.GunA7 => "AK74SU", + ItemType.Lantern => "Lantern", + ItemType.SCP1344 => "SCP-1344-6", + ItemType.SurfaceAccessPass => "Surface Access Pass", + ItemType.GunSCP127 => "SCP-127", + _ => throw new ArgumentException($"Unknown item type: {item}"), + }; + } } } \ No newline at end of file