Raised This Month: $51 Target: $400
 12% 

[L4D2]How can I increase my BOT?


Post New Thread Reply   
 
Thread Tools Display Modes
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
Spirit_12
Veteran Member
Join Date: Dec 2012
Location: Toronto, CA
Old 07-30-2018 , 17:49   Re: [L4D2]How can I increase my BOT?
Reply With Quote #2

Use SuperVersus. There is no point in maintaining two plugins for the same task.
__________________
Spirit_12 is offline
phoenix0001
Senior Member
Join Date: Apr 2010
Location: China
Old 07-31-2018 , 02:43   Re: [L4D2]How can I increase my BOT?
Reply With Quote #3

Quote:
Originally Posted by Spirit_12 View Post
Use SuperVersus. There is no point in maintaining two plugins for the same task.
SuperVersus. will cause plugin conflicts, especially serious, a small number of plugins are all invalid.
I have tested all the versions of SuperVersus. All of them will cause conflicts.
So I will use the plugin above to reach 8VS8. And the above plugin will not cause any conflict.
__________________
I like this BBS sharing of spirit

I come from China, my English is poor
phoenix0001 is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 07-31-2018 , 05:00   Re: [L4D2]How can I increase my BOT?
Reply With Quote #4

Have you tried ABM?

https://forums.alliedmods.net/showthread.php?t=291562
__________________
Psyk0tik is offline
phoenix0001
Senior Member
Join Date: Apr 2010
Location: China
Old 07-31-2018 , 08:50   Re: [L4D2]How can I increase my BOT?
Reply With Quote #5

Quote:
Originally Posted by Crasher_3637 View Post
Damn!!!
I don't know about this plugin!!
I will go to test it soon~~ Thank you very much!!!
__________________
I like this BBS sharing of spirit

I come from China, my English is poor
phoenix0001 is offline
phoenix0001
Senior Member
Join Date: Apr 2010
Location: China
Old 07-31-2018 , 12:28   Re: [L4D2]How can I increase my BOT?
Reply With Quote #6

I tested ABM. He has too many features.
In order to reduce plugin conflicts, I only need to fill 8VS8.
__________________
I like this BBS sharing of spirit

I come from China, my English is poor
phoenix0001 is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 07-31-2018 , 13:11   Re: [L4D2]How can I increase my BOT?
Reply With Quote #7

All of the features are optional. He has cvars for all of them.
__________________
Psyk0tik is offline
Spirit_12
Veteran Member
Join Date: Dec 2012
Location: Toronto, CA
Old 07-31-2018 , 18:18   Re: [L4D2]How can I increase my BOT?
Reply With Quote #8

SuperVersus does not conflict with anything. Provide logs to support your claim.
__________________
Spirit_12 is offline
phoenix0001
Senior Member
Join Date: Apr 2010
Location: China
Old 08-01-2018 , 01:03   Re: [L4D2]How can I increase my BOT?
Reply With Quote #9

L4d_superversus, this version can be used, but can not generate plugins, there are several errors, who can help fix it, thank you.
Please help delete the following features, thank you
1. Delete l4d_XtraHP "0" Give extra survivors HP packs? (1 for extra medpacks)
2. Delete l4d_killreservation "0" Should we clear Lobby reservaton? (For use with Left4DownTown extension ONLY)
3. Delete l4d_supertank "0" Set tanks HP based on Survivor Count
4. Delete l4d_tank_hpmulti "0.25" Tanks HP Multiplier (multi*(survivors-4))

In this case, the plugin only retains the 8VS8 functionality.

Keep 3 commands
1.sm_jointeam3
2.sm_jointeam2
Can I add an AWAY command?
3.sm_away
Attached Files
File Type: sp Get Plugin or Get Source (l4d_superversus.sp - 223 views - 19.9 KB)
__________________
I like this BBS sharing of spirit

I come from China, my English is poor

Last edited by phoenix0001; 08-01-2018 at 01:08. Reason: Keep 3 commands
phoenix0001 is offline
phoenix0001
Senior Member
Join Date: Apr 2010
Location: China
Old 08-01-2018 , 01:12   Re: [L4D2]How can I increase my BOT?
Reply With Quote #10

Quote:
Originally Posted by Crasher_3637 View Post
All of the features are optional. He has cvars for all of them.
I saw that ABM actually has up to 5000+ lines, the function is too rich, the function I need is very simple, so I gave up ABM.
Thank you very much for telling me about the ABM plugin.
I only want a simple 8vs8. and 3 commands to join the game.
__________________
I like this BBS sharing of spirit

I come from China, my English is poor
phoenix0001 is offline
Reply



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 19:08.


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