Raised This Month: $ Target: $400
 0% 

[L4D2]How can I increase my BOT?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
phoenix0001
Senior Member
Join Date: Apr 2010
Location: China
Old 07-30-2018 , 00:26   [L4D2]How can I increase my BOT?
Reply With Quote #1

Both parties can have 8 BOT.
I want 8 survivors and 8 infected people to do VS.
The problem now is that he will not have redundant BOT.
I need extra BOT to fill it up to 8VS8.

PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#define CVAR_FLAGS                    FCVAR_PLUGIN|FCVAR_NOTIFY
#pragma newdecls required

bool TeleportReady;

public 
Plugin myinfo =
{
    
name "L4D2 MultiSlots",
    
description "Handles bots in a 4+ coop game.",
    
author "SwiftReal, MI 5",
    
version "3.7.8",
    
url "https://forums.alliedmods.net/showthread.php?t=132408&page=19"
};

public 
void OnPluginStart()
{
    
RegConsoleCmd("sm_away"JoinTeam1,     "Attempt to join spectator."0);
    
RegConsoleCmd("sm_join"JoinTeam2,     "Attempt to join survivors."0);
    
RegConsoleCmd("sm_joinz"JoinTeam3,     "Attempt to join zombie."0);

    
HookEvent("player_activate"ePlayerActivate);
    
HookEvent("bot_player_replace"bot_player_replace);
    
HookEvent("finale_vehicle_leaving"eFinaleVehicleLeaving);
    
HookEvent("player_bot_replace"evtBotReplacedPlayer);
    
HookEvent("player_first_spawn"eplayer_first_spawn);
}

public 
Action JoinTeam1(int clientint args)
{
    if (
client)
    {
        
ChangeClientTeam(client1);
    }
    return 
Plugin_Handled;
}

public 
Action JoinTeam3(int clientint args)
{
    if (
client)
    {
        
ChangeClientTeam(client3);
    }
    return 
Plugin_Handled;
}

public 
void OnMapStart()
{
    
TweakSettings();
    
TeleportReady false;
    
CreateTimer(60.0TimerUnblockTeleport_TIMER_FLAG_NO_MAPCHANGE);
}

public 
Action TimerUnblockTeleport(Handle timer)
{
    
TeleportReady true;
}

public 
Action JoinTeam2(int clientint args)
{
    if (!
IsClientInGame(client) || IsFakeClient(client))
        return 
Plugin_Handled;

    if (
IsClientInGame(client))
    {
        if (
GetClientTeam(client) == 3)
        {
            
ChangeClientTeam(client1);
        }

        if (
GetClientTeam(client) == || IsClientIdle(client))
        {
            return 
Plugin_Handled;
        }

        if (
TotalFreeBots() == 0)
            {
                
SpawnFakeClient();
                
CreateTimer(1.5Timer_AutoJoinTeamPAclientTIMER_FLAG_NO_MAPCHANGE);
            }
        else
            {
                
TakeOverBot(clientfalse);
            }
    }
    return 
Plugin_Handled;
}

public 
Action ePlayerActivate(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(GetEventInt(event"userid"));
    if (
client)
    {
        if (
IsClientInGame(client))
        {
            if (
GetClientTeam(client) != && !IsFakeClient(client) && !IsClientIdle(client) && GetClientTeam(client) != 3)
            {
                
CreateTimer(5.0Timer_AutoJoinTeamPAclientTIMER_FLAG_NO_MAPCHANGE);
            }
        }
    }
    return 
Plugin_Continue;
}

public 
Action bot_player_replace(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(GetEventInt(event"player"));

    if (!
client || !IsClientInGame(client) || GetClientTeam(client) != || IsFakeClient(client) || !IsPlayerAlive(client))
        return 
Plugin_Continue;

    if (
TeleportReady)
    {
        
CreateTimer(1.0Timer_CheckClientclientTIMER_FLAG_NO_MAPCHANGE);
    }
    return 
Plugin_Continue;
}

public 
Action eplayer_first_spawn(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(GetEventInt(event"userid"));

    if (!
client || !IsClientInGame(client) || GetClientTeam(client) != || IsFakeClient(client) || !IsPlayerAlive(client))
        return 
Plugin_Continue;

    if (
TeleportReady)
    {
        
CreateTimer(10.0Timer_CheckClientclientTIMER_FLAG_NO_MAPCHANGE);
    }
    return 
Plugin_Continue;
}

public 
Action eFinaleVehicleLeaving(Event event, const char[] namebool dontBroadcast)
{
    
int edict_index FindEntityByClassname(-1"info_survivor_position");
    if (
edict_index != -1)
        {
            
float pos[3];
            
GetEntPropVector(edict_indexProp_Send"m_vecOrigin"pos);
            for (
int i 1<= MaxClientsi++)
                {
                    if(
IsClientInGame(i))
                        {
                            if (!
IsFakeClient(i))
                                {
                                    if(
GetClientTeam(i) == && IsPlayerAlive(i))
                                        {
                                            
TeleportEntity(iposNULL_VECTORNULL_VECTOR);
                                        }
                                }
                        }
                }
        }
}

public 
Action Timer_AutoJoinTeamPA(Handle timerint client)
{
    if (
client)
    {
        if(
IsClientInGame(client))
        {
            if (!
IsFakeClient(client) && GetClientTeam(client) != 3)
            {
                if (
GetClientTeam(client) != || !IsClientIdle(client))
                {
                    
JoinTeam2(client0);
                }
            }
        }
    }
}

public 
Action evtBotReplacedPlayer(Event event, const char[] namebool dontBroadcast)
{
    
int bot GetClientOfUserId(GetEventInt(event"bot"));
    
int client GetClientOfUserId(GetEventInt(event"player"));
    
    if(
GetClientTeam(bot) == && client)
        {
            
CreateTimer(5.0Timer_KickNoNeededBotbot);
        }
}

public 
Action Timer_KickNoNeededBot(Handle timerint bot)
{
    if(
IsClientInGame(bot) && TotalSurvivors() > 4)
    {
        
char BotName[100];
        
GetClientName(botBotNamesizeof(BotName));
        if(
StrEqual(BotName"FakeClient"true))
            return;

        if(!
HasIdlePlayer(bot) && GetClientTeam(bot) == 2)
        {
            
KickClient(bot"Kicking No Needed Bot");
        }
    }
}

public 
Action Timer_KickFakeBot(Handle timerint userid)
{
    
int fakeclient GetClientOfUserId(userid);
    if (
fakeclient && IsClientInGame(fakeclient))
    {
        
KickClient(fakeclient"Kicking FakeClient");
    }
}

public 
Action Timer_CheckClient(Handle timerint client)
{
    if (
IsClientInGame(client))
    {
        if (
IsPlayerAlive(client) && !IsFakeClient(client) && GetClientTeam(client) == 2)
        {
            for (
int i 1<= MaxClientsi++)
            {
                if (
IsClientInGame(i) && IsPlayerAlive(i) && !IsFakeClient(i) && GetClientTeam(i) == && GetClientTeam(i) != && client != i)
                {
                    
SetEntProp(clientProp_Data"m_takedamage"01);
                    
SetEntProp(iProp_Data"m_takedamage"01);

                    
CreateTimer(5.0Mortalclient);
                    
CreateTimer(5.0Mortali);

                    
float pos[3] = 0.0;
                    
GetClientAbsOrigin(ipos);
                    
TeleportEntity(clientposNULL_VECTORNULL_VECTOR);
                    return;
                }
            }
        }
    }
}

public 
Action Mortal(Handle timerint client)
{
    if (
IsClientInGame(client) && GetClientTeam(client) == 2)
    {
        
SetEntProp(clientProp_Data"m_takedamage"21);
    }
}

void TweakSettings()
{
    
SetConVarInt(FindConVar("z_spawn_flow_limit"), 50000);
}

void TakeOverBot(int clientbool completely)
{
    if (
IsClientInGame(client))
    {
        if (!
IsFakeClient(client))
        {
            if (
GetClientTeam(client) != 2)
            {
                
int bot FindBotToTakeOver();
                if (
bot==0)
                {
                    
LogMessage("'There are no survivor bots to take over %N'"client);
                    return;
                }

                
Handle hSetHumanSpec;
                if (!
hSetHumanSpec)
                {
                    
Handle hGameConf LoadGameConfigFile("multislots");
                    
StartPrepSDKCall(SDKCall_Player);
                    
PrepSDKCall_SetFromConf(hGameConfSDKConf_Signature"SetHumanSpec");
                    
PrepSDKCall_AddParameter(SDKType_CBasePlayerSDKPass_Pointer);
                    
hSetHumanSpec EndPrepSDKCall();
                }
                
Handle hTakeOverBot;
                if (!
hTakeOverBot)
                {
                    
Handle hGameConf LoadGameConfigFile("multislots");
                    
StartPrepSDKCall(SDKCall_Player);
                    
PrepSDKCall_SetFromConf(hGameConfSDKConf_Signature"TakeOverBot");
                    
PrepSDKCall_AddParameter(SDKType_BoolSDKPass_Plain);
                    
hTakeOverBot EndPrepSDKCall();
                }
                if (
completely)
                {
                    
SDKCall(hSetHumanSpecbotclient);
                    
SDKCall(hTakeOverBotclienttrue);
                }
                else
                {
                    
SDKCall(hSetHumanSpecbotclient);
                    
SetEntProp(clientProp_Send"m_iObserverMode"5);
                }
            }
        }
    }
}

int FindBotToTakeOver()
{
    for (
int i 1<= MaxClientsi++)
    {
        if (
IsClientInGame(i))
        {
            if (
IsFakeClient(i) && GetClientTeam(i) == && !HasIdlePlayer(i))
            {
                return 
i;
            }
        }
    }
    return 
0;
}

int SpawnFakeClient()
{
    
int fakeclient CreateFakeClient("FakeClient");
    
bool fakeclientKicked;

    if (
fakeclient)
    {
        
ChangeClientTeam(fakeclient2);
        if (
DispatchKeyValue(fakeclient"classname""survivorbot") == true)
        {
            if (
DispatchSpawn(fakeclient) == true)
            {
                
CreateTimer(0.1Timer_KickFakeBotfakeclient);
                
fakeclientKicked true;
            }
        }
        if (
fakeclientKicked)
        {
            
KickClient(fakeclient"Kicking FakeClient");
        }
        else
        {
            
KickClient(fakeclient"Kicking FakeClient: error");
        }
    }
    return 
fakeclientKicked;
}

int TotalSurvivors()
{
    
int count 0;
    for (
int i 1<= MaxClientsi++)
    {
        if(
IsClientInGame(i))
            if (
GetClientTeam(i) == 2)
            {
                
count++;
            }
    }
    return 
count;
}

int TotalFreeBots()
{
    
int count 0;
    for(
int i 1<= MaxClientsi++)
    {
        if (
IsClientInGame(i))
        {
            if (
IsFakeClient(i) && GetClientTeam(i) == 2)
            {
                if (!
HasIdlePlayer(i))
                {
                    
count++;
                }
            }
        }
    }
    return 
count;
}

bool HasIdlePlayer(int bot)
{
    if (
IsValidEntity(bot))
    {
        
char sClass[64];
        static 
PropFieldType type;

        if (
IsClientInGame(bot))
        {
            if (
GetClientTeam(bot) == && IsPlayerAlive(bot))
            {
                
GetEntityNetClass(botsClass64);
                if (
IsFakeClient(bot) && FindSendPropInfo(sClass"m_humanSpectatorUserID"type) > 0)
                {
                    
int idler GetClientOfUserId(GetEntProp(botProp_Send"m_humanSpectatorUserID"));
                    if (
idler)
                    {
                        if (
IsClientInGame(idler) && !IsFakeClient(idler) && GetClientTeam(idler) == 1)
                        {
                            return 
true;
                        }
                    }
                }
            }
        }
    }
    return 
false;
}

bool IsClientIdle(int client)
{
    if (
IsValidEntity(client))
    {
        
char sClass[64];
        static 
PropFieldType type;
        for(
int i 1<= MaxClientsi++)
        {
            if (
IsClientInGame(i))
            {
                if (
GetClientTeam(i) == && IsPlayerAlive(i))
                {
                    
GetEntityNetClass(isClass64);
                    if (
IsFakeClient(i) && FindSendPropInfo(sClass"m_humanSpectatorUserID"type) > 0)
                    {
                        
int idler GetClientOfUserId(GetEntProp(iProp_Send"m_humanSpectatorUserID"));
                        if (
client == idler)
                        {
                            if (
IsClientInGame(idler) && !IsFakeClient(idler) && GetClientTeam(idler) == 1)
                            {
                                return 
true;
                            }
                        }
                    }
                }
            }
        }
    }
    return 
false;

__________________
I like this BBS sharing of spirit

I come from China, my English is poor

Last edited by phoenix0001; 07-30-2018 at 11:38. Reason: The title forgot to add the game name [L4D2]
phoenix0001 is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:28.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode