-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
209 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{E86FA4C1-50C0-4BA7-84B3-D7FC81AF7AA0}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>OneSCPRound</RootNamespace> | ||
<AssemblyName>OneSCPRound</AssemblyName> | ||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<Deterministic>true</Deterministic> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Assembly-CSharp"> | ||
<HintPath>C:\csharpdlls\Assembly-CSharp.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Smod2"> | ||
<HintPath>C:\csharpdlls\Smod2.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="MiscEventHandler.cs" /> | ||
<Compile Include="OSRPlugin.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="StartOSR.cs" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Player> scpPlayers = ev.Server.GetPlayers(Smod2.API.Team.SCP); | ||
List<Role> allSCPS = new List<Role> { Role.SCP_049, Role.SCP_096, Role.SCP_106, Role.SCP_173, Role.SCP_939_53, Role.SCP_939_89 }; | ||
List<Role> allowedSCPS = new List<Role>(); | ||
|
||
// 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); | ||
} | ||
} | ||
} | ||
} | ||
} |