Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a notification to players of SCP-106 when a human leaves the pocket dimension #9

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
6 changes: 6 additions & 0 deletions Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ namespace coin_pocket_escape
{
public class Config
{
[Description("Toggle forced coin spawns in the beginning of the Round")]
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Round -> 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;

Expand Down
53 changes: 48 additions & 5 deletions Plugin.cs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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,
Expand All @@ -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<LockerChamber>().Length;
var spawnPosition = Object.FindObjectsOfType<LockerChamber>();
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)
leo-ger marked this conversation as resolved.
Show resolved Hide resolved
{
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)
{
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 additionall coins should spawn.

you can set the amount of additionall coins.
David-Floy marked this conversation as resolved.
Show resolved Hide resolved

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
Expand Down
1 change: 1 addition & 0 deletions coin-pocket-escape.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
<Content Include="References\Assembly-CSharp-firstpass.dll" />
<Content Include="References\Assembly-CSharp.dll" />
<Content Include="References\Mirror.dll" />
<Content Include="References\mscorlib.dll" />
<Content Include="References\UnityEngine.CoreModule.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down