diff --git a/ShootingRange/API/SpectatorRange.cs b/ShootingRange/API/SpectatorRange.cs index f55013d..06f56a8 100644 --- a/ShootingRange/API/SpectatorRange.cs +++ b/ShootingRange/API/SpectatorRange.cs @@ -9,7 +9,6 @@ using Exiled.API.Enums; using Exiled.API.Features; using Exiled.API.Features.Toys; -using Exiled.API.Extensions; using Exiled.CustomItems.API.Features; using Object = UnityEngine.Object; @@ -18,9 +17,9 @@ namespace ShootingRange.API { public class SpectatorRange { - private Vector3 _smallBound = new(205, 997.25f, -52); - private Vector3 _bigBound = new(237, 1015, -37); - public Vector3 Spawn { get; } = new(218.5f, 999.1f, -43.0f); + private Vector3 _smallBound = new(-173.7f, 1003.4f, -45); + private Vector3 _bigBound = new(-143.7f, 1006.8f, -37.9f); + public Vector3 Spawn { get; } = new(-161.1f, 1004.9f, -42.1f); public bool IsOpen => Round.IsStarted && Respawn.TimeUntilRespawn > 20; public SpectatorRange() { } @@ -45,7 +44,7 @@ public bool HasPlayer(Player plyr) } public bool TryAdmit(Player player) { - if (!(IsOpen && player.IsDead && !PluginMain.Singleton.EventHandler.FreshlyDead.Contains(player))) + if (!(IsOpen && player.IsDead)) return false; player.SetRole(RoleType.Tutorial); @@ -70,7 +69,6 @@ public bool TryAdmit(Player player) player.Position = Spawn; player.Health = 100000; - player.ChangeAppearance(RoleType.ChaosConscript); player.Broadcast(PluginMain.Singleton.Config.RangeGreeting); }); return true; @@ -122,14 +120,16 @@ public void SpawnPrimitives() prims[i].Type = PrimitiveType.Cube; } } + public void SpawnBench() { Quaternion rot = Quaternion.Euler(0, 180, 0); Vector3 pos = new((_bigBound.x + _smallBound.x) / 2, _smallBound.y + 0.25f, _bigBound.z - 1); - GameObject benchPrefab = NetworkClient.prefabs[System.Guid.Parse("307eb9b0-d080-9dc4-78e6-673847876412")]; + GameObject benchPrefab = NetworkClient.prefabs[Guid.Parse("307eb9b0-d080-9dc4-78e6-673847876412")]; NetworkServer.Spawn(Object.Instantiate(benchPrefab, pos, rot)); } + public void RemovePlayer(Player plyr) { plyr.ClearInventory(); diff --git a/ShootingRange/Config.cs b/ShootingRange/Config.cs index 43b2020..f9aed9c 100644 --- a/ShootingRange/Config.cs +++ b/ShootingRange/Config.cs @@ -20,7 +20,13 @@ public class Config : IConfig [Description("Determines whether the \".range\" permission is required to use the .range command (this will not affect automatically teleported players)")] public bool RequirePermission { get; set; } = false; [Description("Alternative range location. The \"w\" will determine the radius of the sphere (cube) that forms the boundaries.")] - public Vector4 RangeLocation { get; set; } = default; + public Vector4 RangeLocation { get; set; } = new Vector4() + { + w = 10, + x = -156.2f, + y = 1024.3f, + z = -58.5f, + }; [Description("Determines if the above location will be used or not")] public bool UseRangeLocation { get; set; } = false; [Description("The items one will spawn with on the range (may be ItemType or the name of a CustomItem")] diff --git a/ShootingRange/EventHandlers.cs b/ShootingRange/EventHandlers.cs index 96ba0a1..d2f4477 100644 --- a/ShootingRange/EventHandlers.cs +++ b/ShootingRange/EventHandlers.cs @@ -42,27 +42,8 @@ public void OnVerified(VerifiedEventArgs ev) ev.Player.Broadcast(PluginMain.Singleton.Config.DeathBroadcast); }); } - public void OnDied(DiedEventArgs ev) => Timing.RunCoroutine(OnDiedCoroutine(ev.Target, ev.Killer != null && ev.Killer.Role == RoleType.Scp049)); - private IEnumerator OnDiedCoroutine(Player plyr, bool byDoctor) - { - if (byDoctor) - { - FreshlyDead.Add(plyr); - yield return Timing.WaitForSeconds(10f); - FreshlyDead.Remove(plyr); - } - - if (_plugin.Config.ForceSpectators) - { - yield return Timing.WaitForSeconds(0.5f); - _plugin.ActiveRange.TryAdmit(plyr); - } - else - { - yield return Timing.WaitForSeconds(5f); - plyr.Broadcast(_plugin.Config.DeathBroadcast); - } - } + public void OnDied(DiedEventArgs ev) => Timing.RunCoroutine(OnDiedCoroutine(ev.Target)); + public void OnShooting(ShootingEventArgs ev) { if (_plugin.ActiveRange.HasPlayer(ev.Shooter)) @@ -91,5 +72,25 @@ public IEnumerator WaitForRespawnCoroutine() break; } } + private IEnumerator OnDiedCoroutine(Player plyr) + { + FreshlyDead.Add(plyr); + + if (_plugin.Config.ForceSpectators) + { + yield return Timing.WaitForSeconds(0.5f); + _plugin.ActiveRange.TryAdmit(plyr); + } + + yield return Timing.WaitForSeconds(30f); + FreshlyDead.Remove(plyr); + + if (plyr.IsDead) + plyr.Broadcast(_plugin.Config.DeathBroadcast); + } + public void OnFinishingRecall(FinishingRecallEventArgs ev) + { + ev.IsAllowed |= FreshlyDead.Contains(ev.Target) && _plugin.ActiveRange.HasPlayer(ev.Target); + } } } diff --git a/ShootingRange/PluginMain.cs b/ShootingRange/PluginMain.cs index 95a79ae..9b9b893 100644 --- a/ShootingRange/PluginMain.cs +++ b/ShootingRange/PluginMain.cs @@ -6,6 +6,7 @@ using Player = Exiled.Events.Handlers.Player; using Server = Exiled.Events.Handlers.Server; +using Scp049 = Exiled.Events.Handlers.Scp049; namespace ShootingRange { @@ -43,6 +44,7 @@ public void RegisterEvents() Player.Shooting += EventHandler.OnShooting; Player.DroppingItem += EventHandler.OnDroppingItem; Server.RoundStarted += EventHandler.OnRoundStarted; + Scp049.FinishingRecall += EventHandler.OnFinishingRecall; } public void UnregisterEvents() { @@ -51,6 +53,7 @@ public void UnregisterEvents() Player.Died -= EventHandler.OnDied; Player.Shooting -= EventHandler.OnShooting; Player.DroppingItem -= EventHandler.OnDroppingItem; + Scp049.FinishingRecall -= EventHandler.OnFinishingRecall; } } }