JustinAJ
9 years ago
4 changed files with 307 additions and 0 deletions
@ -0,0 +1,85 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup Label="ProjectConfigurations"> |
|||
<ProjectConfiguration Include="Debug|Win32"> |
|||
<Configuration>Debug</Configuration> |
|||
<Platform>Win32</Platform> |
|||
</ProjectConfiguration> |
|||
<ProjectConfiguration Include="Release|Win32"> |
|||
<Configuration>Release</Configuration> |
|||
<Platform>Win32</Platform> |
|||
</ProjectConfiguration> |
|||
</ItemGroup> |
|||
<PropertyGroup Label="Globals"> |
|||
<ProjectGuid>{99D34DCB-A484-437C-9FC5-D4051FEDC18C}</ProjectGuid> |
|||
<RootNamespace>RenX.MinPlayers</RootNamespace> |
|||
</PropertyGroup> |
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> |
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> |
|||
<ConfigurationType>Application</ConfigurationType> |
|||
<UseDebugLibraries>true</UseDebugLibraries> |
|||
<PlatformToolset>v140</PlatformToolset> |
|||
<CharacterSet>MultiByte</CharacterSet> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> |
|||
<ConfigurationType>DynamicLibrary</ConfigurationType> |
|||
<UseDebugLibraries>false</UseDebugLibraries> |
|||
<PlatformToolset>v140</PlatformToolset> |
|||
<WholeProgramOptimization>true</WholeProgramOptimization> |
|||
<CharacterSet>Unicode</CharacterSet> |
|||
</PropertyGroup> |
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> |
|||
<ImportGroup Label="ExtensionSettings"> |
|||
</ImportGroup> |
|||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> |
|||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |
|||
</ImportGroup> |
|||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |
|||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |
|||
</ImportGroup> |
|||
<PropertyGroup Label="UserMacros" /> |
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |
|||
<OutDir>$(SolutionDir)$(Configuration)\Plugins\</OutDir> |
|||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> |
|||
</PropertyGroup> |
|||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> |
|||
<ClCompile> |
|||
<WarningLevel>Level3</WarningLevel> |
|||
<Optimization>Disabled</Optimization> |
|||
<SDLCheck>true</SDLCheck> |
|||
</ClCompile> |
|||
<Link> |
|||
<GenerateDebugInformation>true</GenerateDebugInformation> |
|||
</Link> |
|||
</ItemDefinitionGroup> |
|||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |
|||
<ClCompile> |
|||
<WarningLevel>Level3</WarningLevel> |
|||
<Optimization>MaxSpeed</Optimization> |
|||
<FunctionLevelLinking>true</FunctionLevelLinking> |
|||
<IntrinsicFunctions>true</IntrinsicFunctions> |
|||
<SDLCheck>true</SDLCheck> |
|||
<AdditionalIncludeDirectories>../Bot;../Jupiter;../RenX.Core</AdditionalIncludeDirectories> |
|||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
|||
</ClCompile> |
|||
<Link> |
|||
<GenerateDebugInformation>true</GenerateDebugInformation> |
|||
<EnableCOMDATFolding>true</EnableCOMDATFolding> |
|||
<OptimizeReferences>true</OptimizeReferences> |
|||
</Link> |
|||
</ItemDefinitionGroup> |
|||
<ItemGroup> |
|||
<ClInclude Include="RenX_MinPlayers.h" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ClCompile Include="RenX_MinPlayers.cpp" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Library Include="..\Jupiter\Release\Jupiter.lib" /> |
|||
<Library Include="..\Release\Bot.lib" /> |
|||
<Library Include="..\Release\Plugins\RenX.Core.lib" /> |
|||
</ItemGroup> |
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> |
|||
<ImportGroup Label="ExtensionTargets"> |
|||
</ImportGroup> |
|||
</Project> |
@ -0,0 +1,38 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<Filter Include="Source Files"> |
|||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> |
|||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> |
|||
</Filter> |
|||
<Filter Include="Header Files"> |
|||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> |
|||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions> |
|||
</Filter> |
|||
<Filter Include="Resource Files"> |
|||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> |
|||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> |
|||
</Filter> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ClInclude Include="RenX_MinPlayers.h"> |
|||
<Filter>Header Files</Filter> |
|||
</ClInclude> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ClCompile Include="RenX_MinPlayers.cpp"> |
|||
<Filter>Source Files</Filter> |
|||
</ClCompile> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Library Include="..\Release\Plugins\RenX.Core.lib"> |
|||
<Filter>Resource Files</Filter> |
|||
</Library> |
|||
<Library Include="..\Release\Bot.lib"> |
|||
<Filter>Resource Files</Filter> |
|||
</Library> |
|||
<Library Include="..\Jupiter\Release\Jupiter.lib"> |
|||
<Filter>Resource Files</Filter> |
|||
</Library> |
|||
</ItemGroup> |
|||
</Project> |
@ -0,0 +1,134 @@ |
|||
/**
|
|||
* Copyright (C) 2015 Justin James. |
|||
* |
|||
* This license must be preserved. |
|||
* Any applications, libraries, or code which make any use of any |
|||
* component of this program must not be commercial, unless explicit |
|||
* permission is granted from the original author. The use of this |
|||
* program for non-profit purposes is permitted. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|||
* |
|||
* In the event that this license restricts you from making desired use of this program, contact the original author. |
|||
* Written by Justin James <justin.aj@hotmail.com> |
|||
*/ |
|||
|
|||
#include "Jupiter/IRC_Client.h" |
|||
#include "Jupiter/INIFile.h" |
|||
#include "RenX_Server.h" |
|||
#include "RenX_PlayerInfo.h" |
|||
#include "RenX_MinPlayers.h" |
|||
|
|||
using namespace Jupiter::literals; |
|||
|
|||
RenX_MinPlayersPlugin::RenX_MinPlayersPlugin() |
|||
{ |
|||
RenX_MinPlayersPlugin::player_threshold = Jupiter::IRC::Client::Config->getInt(this->getName(), "PlayerThreshold"_jrs, 20); |
|||
} |
|||
|
|||
void RenX_MinPlayersPlugin::RenX_OnMapStart(RenX::Server *server, const Jupiter::ReadableString &map) |
|||
{ |
|||
if (server->players.size() < RenX_MinPlayersPlugin::player_threshold) |
|||
server->send(Jupiter::StringS::Format("addbots %d", RenX_MinPlayersPlugin::player_threshold - server->players.size())); |
|||
} |
|||
|
|||
void RenX_MinPlayersPlugin::RenX_OnJoin(RenX::Server *server, const RenX::PlayerInfo *player) |
|||
{ |
|||
if (server->players.size() > RenX_MinPlayersPlugin::player_threshold) |
|||
++RenX_MinPlayersPlugin::phase_bots; |
|||
} |
|||
|
|||
void RenX_MinPlayersPlugin::RenX_OnPart(RenX::Server *server, const RenX::PlayerInfo *player) |
|||
{ |
|||
if (server->players.size() <= player_threshold) |
|||
{ |
|||
switch (player->team) |
|||
{ |
|||
case RenX::TeamType::GDI: |
|||
server->send("addredbots 1"_jrs); |
|||
break; |
|||
case RenX::TeamType::Nod: |
|||
server->send("addbluebots 1"_jrs); |
|||
break; |
|||
case RenX::TeamType::None: |
|||
break; |
|||
default: |
|||
server->send("addbots 1"_jrs); |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
|
|||
void RenX_MinPlayersPlugin::AnyDeath(RenX::Server *server, const RenX::PlayerInfo *player) |
|||
{ |
|||
if (RenX_MinPlayersPlugin::phase_bots != 0 && player->isBot && server->players.size() != 0) |
|||
{ |
|||
size_t gdi_count = 0, nod_count = 0; |
|||
for (Jupiter::DLList<RenX::PlayerInfo>::Node *node = server->players.getNode(0); node != nullptr; node = node->next) |
|||
{ |
|||
switch (node->data->team) |
|||
{ |
|||
case RenX::TeamType::GDI: |
|||
++gdi_count; |
|||
break; |
|||
case RenX::TeamType::Nod: |
|||
++nod_count; |
|||
break; |
|||
default: |
|||
break; |
|||
} |
|||
} |
|||
|
|||
if (gdi_count > nod_count) |
|||
{ |
|||
if (player->team != RenX::TeamType::Nod) |
|||
{ |
|||
server->kickPlayer(player, "Bot Phasing"_jrs); |
|||
--RenX_MinPlayersPlugin::phase_bots; |
|||
} |
|||
} |
|||
else if (nod_count > gdi_count) |
|||
{ |
|||
if (player->team != RenX::TeamType::GDI) |
|||
{ |
|||
server->kickPlayer(player, "Bot Phasing"_jrs); |
|||
--RenX_MinPlayersPlugin::phase_bots; |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
server->kickPlayer(player, "Bot Phasing"_jrs); |
|||
--RenX_MinPlayersPlugin::phase_bots; |
|||
} |
|||
} |
|||
} |
|||
|
|||
void RenX_MinPlayersPlugin::RenX_OnSuicide(RenX::Server *server, const RenX::PlayerInfo *player, const Jupiter::ReadableString &damageType) |
|||
{ |
|||
this->AnyDeath(server, player); |
|||
} |
|||
|
|||
void RenX_MinPlayersPlugin::RenX_OnKill(RenX::Server *server, const RenX::PlayerInfo *player, const RenX::PlayerInfo *victim, const Jupiter::ReadableString &damageType) |
|||
{ |
|||
this->AnyDeath(server, player); |
|||
} |
|||
|
|||
void RenX_MinPlayersPlugin::RenX_OnKill(RenX::Server *server, const Jupiter::ReadableString &killer, const RenX::TeamType &killerTeam, const RenX::PlayerInfo *victim, const Jupiter::ReadableString &damageType) |
|||
{ |
|||
this->AnyDeath(server, victim); |
|||
} |
|||
|
|||
void RenX_MinPlayersPlugin::RenX_OnDie(RenX::Server *server, const RenX::PlayerInfo *player, const Jupiter::ReadableString &damageType) |
|||
{ |
|||
this->AnyDeath(server, player); |
|||
} |
|||
|
|||
// Plugin instantiation and entry point.
|
|||
RenX_MinPlayersPlugin pluginInstance; |
|||
|
|||
extern "C" __declspec(dllexport) Jupiter::Plugin *getPlugin() |
|||
{ |
|||
return &pluginInstance; |
|||
} |
@ -0,0 +1,50 @@ |
|||
/**
|
|||
* Copyright (C) 2015 Justin James. |
|||
* |
|||
* This license must be preserved. |
|||
* Any applications, libraries, or code which make any use of any |
|||
* component of this program must not be commercial, unless explicit |
|||
* permission is granted from the original author. The use of this |
|||
* program for non-profit purposes is permitted. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|||
* |
|||
* In the event that this license restricts you from making desired use of this program, contact the original author. |
|||
* Written by Justin James <justin.aj@hotmail.com> |
|||
*/ |
|||
|
|||
#if !defined _RENX_MINPLAYERS_H_HEADER |
|||
#define _RENX_MINPLAYERS_H_HEADER |
|||
|
|||
#include "Jupiter/Plugin.h" |
|||
#include "Jupiter/Reference_String.h" |
|||
#include "RenX_Plugin.h" |
|||
|
|||
class RenX_MinPlayersPlugin : public RenX::Plugin |
|||
{ |
|||
public: |
|||
void RenX_OnMapStart(RenX::Server *server, const Jupiter::ReadableString &map) override; |
|||
void RenX_OnJoin(RenX::Server *server, const RenX::PlayerInfo *player) override; |
|||
void RenX_OnPart(RenX::Server *server, const RenX::PlayerInfo *player) override; |
|||
|
|||
void RenX_OnSuicide(RenX::Server *server, const RenX::PlayerInfo *player, const Jupiter::ReadableString &damageType) override; |
|||
void RenX_OnKill(RenX::Server *server, const RenX::PlayerInfo *player, const RenX::PlayerInfo *victim, const Jupiter::ReadableString &damageType) override; |
|||
void RenX_OnKill(RenX::Server *server, const Jupiter::ReadableString &killer, const RenX::TeamType &killerTeam, const RenX::PlayerInfo *victim, const Jupiter::ReadableString &damageType) override; |
|||
void RenX_OnDie(RenX::Server *server, const RenX::PlayerInfo *player, const Jupiter::ReadableString &damageType) override; |
|||
|
|||
const Jupiter::ReadableString &getName() override { return name; } |
|||
|
|||
RenX_MinPlayersPlugin(); |
|||
|
|||
private: |
|||
void AnyDeath(RenX::Server *server, const RenX::PlayerInfo *player); |
|||
size_t phase_bots; |
|||
|
|||
/** Configuration variables */ |
|||
size_t player_threshold; |
|||
STRING_LITERAL_AS_NAMED_REFERENCE(name, "RenX.MinPlayers"); |
|||
}; |
|||
|
|||
#endif // _RENX_MINPLAYERS_H_HEADER
|
Loading…
Reference in new issue