diff --git a/OneSCPRound.sln b/OneSCPRound.sln new file mode 100644 index 0000000..142e70d --- /dev/null +++ b/OneSCPRound.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29403.142 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OneSCPRound", "OneSCPRound\OneSCPRound.csproj", "{E86FA4C1-50C0-4BA7-84B3-D7FC81AF7AA0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E86FA4C1-50C0-4BA7-84B3-D7FC81AF7AA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E86FA4C1-50C0-4BA7-84B3-D7FC81AF7AA0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E86FA4C1-50C0-4BA7-84B3-D7FC81AF7AA0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E86FA4C1-50C0-4BA7-84B3-D7FC81AF7AA0}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A3445CC3-25C8-4255-B125-7C796B87202B} + EndGlobalSection +EndGlobal diff --git a/OneSCPRound/MiscEventHandler.cs b/OneSCPRound/MiscEventHandler.cs new file mode 100644 index 0000000..d0c58cd --- /dev/null +++ b/OneSCPRound/MiscEventHandler.cs @@ -0,0 +1,14 @@ +using Smod2.EventHandlers; +using Smod2.Events; + +namespace OneSCPRound { + class MiscEventHandler : IEventHandlerWaitingForPlayers { + private readonly OSRPlugin plugin; + + public MiscEventHandler(OSRPlugin plugin) => this.plugin = plugin; + + public void OnWaitingForPlayers(WaitingForPlayersEvent ev) { + if (plugin.GetConfigBool("osr_disable")) plugin.PluginManager.DisablePlugin(plugin); + } + } +} diff --git a/OneSCPRound/OSRPlugin.cs b/OneSCPRound/OSRPlugin.cs new file mode 100644 index 0000000..66b63d6 --- /dev/null +++ b/OneSCPRound/OSRPlugin.cs @@ -0,0 +1,35 @@ +using Smod2; +using Smod2.Attributes; +using Smod2.Config; +using Smod2.EventHandlers; + +namespace OneSCPRound { + [PluginDetails( + author = "djakkalap", + name = "One SCP Round", + description = "This plugin gives a chance for a round with multiple of one type of SCP.", + id = "djakkalap.osrplugin", + configPrefix = "osr", + version = "0.1", + SmodMajor = 3, + SmodMinor = 5, + SmodRevision = 0 + )] + + public class OSRPlugin : Plugin { + public override void OnEnable() {} + + public override void OnDisable() {} + + // Register the parts of the plugin. + public override void Register() { + AddConfig(new ConfigSetting("osr_disable", false, true, "This boolean determines whether to disable the plugin.")); + AddConfig(new ConfigSetting("osr_round_chance", 0.2f, true, "This number is the chance of an OSR round happening.")); + AddConfig(new ConfigSetting("osr_players_threshold", 20, true, "This number is the amount of players needed on the server for an OSR to be possible.")); + AddConfig(new ConfigSetting("osr_scps_disallowed", new string[] { }, true, "This list contains the names of SCPs that are not allowed to spawn for a OSR round.")); + + AddEventHandler(typeof(IEventHandlerRoundStart), new StartOSR(this)); + AddEventHandler(typeof(IEventHandlerWaitingForPlayers), new MiscEventHandler(this)); + } + } +} diff --git a/OneSCPRound/OneSCPRound.csproj b/OneSCPRound/OneSCPRound.csproj new file mode 100644 index 0000000..41244c4 --- /dev/null +++ b/OneSCPRound/OneSCPRound.csproj @@ -0,0 +1,56 @@ + + + + + Debug + AnyCPU + {E86FA4C1-50C0-4BA7-84B3-D7FC81AF7AA0} + Library + Properties + OneSCPRound + OneSCPRound + v4.7.2 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + C:\csharpdlls\Assembly-CSharp.dll + + + C:\csharpdlls\Smod2.dll + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OneSCPRound/Properties/AssemblyInfo.cs b/OneSCPRound/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..04dc024 --- /dev/null +++ b/OneSCPRound/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OneSCPRound")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("OneSCPRound")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("e86fa4c1-50c0-4ba7-84b3-d7fc81af7aa0")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OneSCPRound/StartOSR.cs b/OneSCPRound/StartOSR.cs new file mode 100644 index 0000000..ae89df9 --- /dev/null +++ b/OneSCPRound/StartOSR.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +using Smod2.API; +using Smod2.EventHandlers; +using Smod2.Events; + +namespace OneSCPRound { + class StartOSR : IEventHandlerRoundStart { + private readonly OSRPlugin plugin; + + public StartOSR(OSRPlugin plugin) => this.plugin = plugin; + + public void OnRoundStart(RoundStartEvent ev) { + Random rnd = new Random(); + + // Chance of a OSR. (One SCP Round) + if (rnd.NextDouble() < plugin.GetConfigFloat("osr_round_chance") && ev.Server.NumPlayers >= plugin.GetConfigInt("osr_players_threshold")) + { + List scpPlayers = ev.Server.GetPlayers(Smod2.API.Team.SCP); + List allSCPS = new List { Role.SCP_049, Role.SCP_096, Role.SCP_106, Role.SCP_173, Role.SCP_939_53, Role.SCP_939_89 }; + List allowedSCPS = new List(); + + // Filter disallowed SCPs from list. + foreach (Role scpRole in allSCPS) + { + if (!plugin.GetConfigList("osr_scps_disallowed").Contains(scpRole.ToString())) + { + allowedSCPS.Add(scpRole); + } + } + + Role newScpRole = allowedSCPS[rnd.Next(allowedSCPS.Count)]; + + foreach (Player scpPlayer in scpPlayers) + { + scpPlayer.ChangeRole(newScpRole); + } + } + } + } +}