diff --git a/Config.cs b/Config.cs index e18144a..c77f93d 100644 --- a/Config.cs +++ b/Config.cs @@ -4,6 +4,12 @@ namespace coin_pocket_escape { public class Config { + [Description("Toggle forced coin spawns in the beginning of the round")] + public bool ForcedCoins { get; set; } = true; + + [Description("Changes the number of coins that will spawn at the beginning of the match")] + public int ForcedCoinsNumber { get; set; } = 10; + [Description("Set the waiting time after the coin is flipped in ms")] public int WaitingTime { get; set; } = 2000; diff --git a/Plugin.cs b/Plugin.cs index adf5ad2..78442c0 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -1,14 +1,17 @@ using System; using System.Threading.Tasks; -using Interactables.Interobjects; using InventorySystem; using MapGeneration; +using MapGeneration.Distributors; +using PlayerRoles; using PluginAPI.Core; using PluginAPI.Core.Attributes; using PluginAPI.Core.Zones; using PluginAPI.Enums; using UnityEngine; +using PluginAPI.Core.Items; using FacilityZone = MapGeneration.FacilityZone; +using Object = UnityEngine.Object; using Random = System.Random; namespace coin_pocket_escape @@ -19,7 +22,7 @@ public class Plugin [PluginConfig] public Config Config; - public const string Version = "1.1.0"; + public const string Version = "1.3.0"; [PluginPriority(LoadPriority.Highest)] [PluginEntryPoint("Coin-Pocket-Escape", Version, @@ -31,14 +34,52 @@ void LoadPlugin() PluginAPI.Events.EventManager.RegisterEvents(this); } + [PluginEvent(ServerEventType.RoundStart)] + public void OnRoundStart() + { + if (Config.ForcedCoins) + { + Random rand = new Random(); + var chamberLenght = Object.FindObjectsOfType().Length; + var spawnPosition = Object.FindObjectsOfType(); + for (int i = 0; i < Config.ForcedCoinsNumber; i++) + { + int temp = rand.Next(chamberLenght); + Vector3 lockerPosition = spawnPosition[temp].transform.position; + //Creates the ItemPickup and Spawns the Coin in a random Locker Chamber + ItemPickup coin = ItemPickup.Create(ItemType.Coin, lockerPosition, Quaternion.identity); + coin.Spawn(); + Log.Info($"&rLocker position: &6{spawnPosition[temp].transform.position}&r"); + } + Log.Info($"&rAll coins spawned&r"); + } + + } + + //Sends an hint to player of SCP-106 + private static void HintToOldMen(Player tempPlayer) + { + for (int i = 0; i <= Player.GetPlayers().Count; i++) + { + //Checks who is Scp-106 + if (Player.GetPlayers()[i].Role == RoleTypeId.Scp106) + { + //The Hint itself + Player.GetPlayers()[i].ReceiveHint($"{tempPlayer.Nickname} slipped out of dimension!", 6F); + Log.Info($"&r Hint send to: &6{Player.GetPlayers()[i].Nickname}&r"); //debug may be removed! + } + Log.Info($"&r Hint cold not be send to: &6{Player.GetPlayers()[i].Nickname}&r"); //debug may be removed! + + } + } + [PluginEvent(ServerEventType.PlayerCoinFlip)] public async void OnPlayerCoinFlip(Player player, bool isTails) { + var playerInPocket = (player.Zone == FacilityZone.Other); - Log.Info($"&rPlayer &6{player.Nickname}&r (&6{player.UserId}&r) flipped the coin. Flip result: " + $"{(isTails ? "tails" : "heads")}. Player is {(playerInPocket ? "in" : "not in")} pocket."); - // If the player is not in the pocket, do nothing if (!playerInPocket) { @@ -79,12 +120,12 @@ Selecting a room in the HeavyZone to teleport the player. } Vector3 vector = HeavyZone.Rooms[i].Position; vector.y += 1; - Log.Info($"&rPlayer gets teleported to Room &6{HeavyZone.Rooms[i].Identifier.Name}&r, " + $"Position: &6{vector.x}&r, &6{vector.y}&r, &6{vector.z}&r."); player.Position = vector; player.ReceiveHint("You were lucky!", 2F); player.ReferenceHub.inventory.ServerRemoveItem(player.CurrentItem.ItemSerial, null); + HintToOldMen(player); } // If isTails and nuke detonated, the player gets teleported to surface zone and the coin gets removed @@ -104,7 +145,9 @@ Selecting a room in the HeavyZone to teleport the player. Log.Info($"&rPlayer gets teleported to Room &6{HeavyZone.Rooms[i].Identifier.Name}&r, " + $"Position: &6{vector.x}&r, &6{vector.y}&r, &6{vector.z}&r."); player.Position = vector; + player.ReceiveHint("You were lucky!", 2F); player.ReferenceHub.inventory.ServerRemoveItem(player.CurrentItem.ItemSerial, null); + HintToOldMen(player); } // If the coin is heads, the coin just gets removed and the player stays in the pocket. diff --git a/README.md b/README.md index 88ad515..ed23cdd 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,22 @@ A plugin using the NwPluginAPI that enables you to flip a coin to escape the poc # Information Gives players a possibility to flip a coin in the pocket dimension to get out of it. -Tails teleports the player to a room in the Heavy Containment Zone and deletes the coin, heads just deletes the coin. +If successful, the player of SCP-106 will receive a message that a player has escaped with a coin. +The player is teleported to a room in the Heavy Containment Zone and the coin is deleted. +After the Nuke explodes, the players spawn at the surface zone. +If it was not successful, the coin is simply deleted. +At the beginning of the round, additional coins will spawn in lockers all over the map. +It is still possible to escape the pocket dim the normal way. + +# Spawn locations for the Coins +![SCP_SL_Coin_Spawn_1](https://github.com/leo-ger/coin-pocket-escape/assets/123889521/86b0afbe-eb27-4cca-9cd5-06175e4f9766) + +![SCP_SL_Coin_Spawn_2](https://github.com/leo-ger/coin-pocket-escape/assets/123889521/ffb97bbc-98ce-49ae-b407-a1ae0961e5da) + +![SCP_SL_Coin_Spawn_4](https://github.com/leo-ger/coin-pocket-escape/assets/123889521/d59d0de4-6c0d-4e47-afd4-9663f3f040fe) + +![SCP_SL_Coin_Spawn_6](https://github.com/leo-ger/coin-pocket-escape/assets/123889521/c7264108-7a6b-41c1-b8df-830aa29cf88f) + # Installation Place the `coin_pocket_escape.dll` in your plugin folder. @@ -13,6 +28,10 @@ Place the `coin_pocket_escape.dll` in your plugin folder. # Configuration You can set the time to wait after the coin is flipped (in ms). This lets the coin-flip animation play. +You can set if additional coins should spawn. + +you can set the amount of additional coins. + Also you can set if the result should be randomized. This means that it's randomized if heads or tails gets you out of the pocket dimension. # Contributors diff --git a/coin-pocket-escape.csproj b/coin-pocket-escape.csproj index af2209a..f997a58 100644 --- a/coin-pocket-escape.csproj +++ b/coin-pocket-escape.csproj @@ -115,6 +115,7 @@ +