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

How to make extra spawned bot survivors to start at 50hp instead of 100?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Alex101192
Senior Member
Join Date: Aug 2018
Old 07-21-2020 , 00:46   How to make extra spawned bot survivors to start at 50hp instead of 100?
Reply With Quote #1

Superversus from merudo https://forums.alliedmods.net/showthread.php?p=2393931 makes extra survivors spawn with 100hp in coop. It handles the exploit where people quit and rejoin to gain health well during the match. If you quit and rejoin, it will tell you there is no bots available and you must wait to be rescued.

However the plugin doesn't keep track of this during level transition at ending saferoom. This means that the player can quit the game right after everybody is got in saferoom, and then join back after the map is changed to next. The plugin does not keep track in this case of the quit (I guess because map change reset it), so the guy is now spawned at 100 hp in the next level.

An easy way to fix that is by just making it so that extra survivors are spawned with 50hp by default. This is perfect since on my servers there is saferoom nap plugin which makes survivors start at 50 hp by default if they have less.

So by doing this exploit in this situation, he would get the same amount of hp that he would have got by not quitting. Is it possible to implement this change of hp to 50 for extra spawned survivor bots?

Last edited by Alex101192; 07-21-2020 at 00:54.
Alex101192 is offline
HarryPotter
Veteran Member
Join Date: Sep 2017
Location: Taiwan, Asia
Old 07-22-2020 , 10:29   Re: How to make extra spawned bot survivors to start at 50hp instead of 100?
Reply With Quote #2

Quote:
Originally Posted by Alex101192 View Post
Is it possible to implement this change of hp to 50 for extra spawned survivor bots?
In Original source code, edit and add the following code
line 372
PHP Code:
void SpawnFakeSurvivorClient()
{
    ...
    ...
    
DispatchSpawn(Bot);
    if(
DispatchSpawn(Bot) == false)
    {
        return;
    }

    
float Buff GetEntDataFloatBotFindSendPropInfo"CTerrorPlayer""m_healthBuffer" ) );
    
int BonusHP 50//permanent health you set
    
int BuffHP 20//temporary health you set

    
SetEntPropBotProp_Send"m_iHealth"BonusHP);
    
SetEntDataFloatBotFindSendPropInfo"CTerrorPlayer""m_healthBuffer" ), Buff BuffHPtrue );


    
// Kick the "SurvivorBot" so it becomes a regular bot
    
if(IsClientInGame(Bot) && IsFakeClient(Bot) && !GetIdlePlayer(Bot))
        
KickClient(Bot"Kicking Fake Client.");

save and recompile
__________________

Last edited by HarryPotter; 07-22-2020 at 10:33.
HarryPotter is offline
Alex101192
Senior Member
Join Date: Aug 2018
Old 07-22-2020 , 14:03   Re: How to make extra spawned bot survivors to start at 50hp instead of 100?
Reply With Quote #3

Quote:
Originally Posted by fbef0102 View Post
In Original source code, edit and add the following code
line 372
PHP Code:
void SpawnFakeSurvivorClient()
{
    ...
    ...
    
DispatchSpawn(Bot);
    if(
DispatchSpawn(Bot) == false)
    {
        return;
    }

    
float Buff GetEntDataFloatBotFindSendPropInfo"CTerrorPlayer""m_healthBuffer" ) );
    
int BonusHP 50//permanent health you set
    
int BuffHP 20//temporary health you set

    
SetEntPropBotProp_Send"m_iHealth"BonusHP);
    
SetEntDataFloatBotFindSendPropInfo"CTerrorPlayer""m_healthBuffer" ), Buff BuffHPtrue );


    
// Kick the "SurvivorBot" so it becomes a regular bot
    
if(IsClientInGame(Bot) && IsFakeClient(Bot) && !GetIdlePlayer(Bot))
        
KickClient(Bot"Kicking Fake Client.");

save and recompile
I switched to having survivors spawn dead and having to be rescued from closet instead of just spawning directly. This fixes not only this issue here but also another issue in which survivors would somehow spawn alive even though there was a dead bot space.

This solution here could be useful to someone else though and to me also if I decide to go back to direct spawning.

Last edited by Alex101192; 07-22-2020 at 14:03.
Alex101192 is offline
HarryPotter
Veteran Member
Join Date: Sep 2017
Location: Taiwan, Asia
Old 07-23-2020 , 06:56   Re: How to make extra spawned bot survivors to start at 50hp instead of 100?
Reply With Quote #4

a dummy solution here.

If there are more than 4 survivors, where a player spawns, detect if he has 100 hp,
if Yes, set his hp.
PHP Code:
#pragma semicolon 1
#pragma newdecls required //強制1.7以後的新語法

#include <sourcemod>
#include <sdktools>

ConVar hCvar_RespawnHP,hCvar_RespawnBuffHP;
int BufferHP = -1;

public 
Plugin myinfo =
{
    
name "",
    
author "Harry Potter",
    
description "",
    
version "1.0",
    
url "https://forums.alliedmods.net/showthread.php?t=326168"
};

public 
void OnPluginStart()
{
    
BufferHP FindSendPropInfo"CTerrorPlayer""m_healthBuffer" );
    
hCvar_RespawnHP         CreateConVar("l4d_extra_spawn_respawnhp",     "30",     "Amount of HP a Survivor will respawn with (Def 30)"FCVAR_NOTIFYtrue0.0);
    
hCvar_RespawnBuffHP     CreateConVar("l4d_extra_pawn_respawnbuffhp",     "20",     "Amount of buffer HP a Survivor will respawn with (Def 20)"FCVAR_NOTIFYtrue0.0);
    
HookEvent("player_spawn"evtPlayerSpawn);
    
AutoExecConfigtrue"extra_spawn_hp" );
}
public 
Action evtPlayerSpawn(Event event, const char[] namebool dontBroadcast
{
    
int client GetClientOfUserId(event.GetInt("userid"));

    if (
client && client <=MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2)
    {
        if(
GetClientHealth(client) == 100 && CheckSurvivorPlayers_InSV() > 4)
        {
            
SetHealth(client);
        }
    }
}

void SetHealthint client )
{
    
float Buff GetEntDataFloatclientBufferHP );
    
int BonusHP hCvar_RespawnHP.IntValue;
    
int BuffHP hCvar_RespawnBuffHP.IntValue;

    
SetEntPropclientProp_Send"m_iHealth"BonusHP);
    
SetEntDataFloatclientBufferHPBuff BuffHPtrue );
}

int CheckSurvivorPlayers_InSV()
{
    
int iPlayersInAliveSurvivors=0;
    for (
int i 1MaxClients+1i++)
        if(
IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == )
            
iPlayersInAliveSurvivors++;
    return 
iPlayersInAliveSurvivors;

__________________
HarryPotter is offline
Alex101192
Senior Member
Join Date: Aug 2018
Old 07-23-2020 , 08:45   Re: How to make extra spawned bot survivors to start at 50hp instead of 100?
Reply With Quote #5

Quote:
Originally Posted by fbef0102 View Post
a dummy solution here.

If there are more than 4 survivors, where a player spawns, detect if he has 100 hp,
if Yes, set his hp.
PHP Code:
#pragma semicolon 1
#pragma newdecls required //強制1.7以後的新語法

#include <sourcemod>
#include <sdktools>

ConVar hCvar_RespawnHP,hCvar_RespawnBuffHP;
int BufferHP = -1;

public 
Plugin myinfo =
{
    
name "",
    
author "Harry Potter",
    
description "",
    
version "1.0",
    
url "https://forums.alliedmods.net/showthread.php?t=326168"
};

public 
void OnPluginStart()
{
    
BufferHP FindSendPropInfo"CTerrorPlayer""m_healthBuffer" );
    
hCvar_RespawnHP         CreateConVar("l4d_extra_spawn_respawnhp",     "30",     "Amount of HP a Survivor will respawn with (Def 30)"FCVAR_NOTIFYtrue0.0);
    
hCvar_RespawnBuffHP     CreateConVar("l4d_extra_pawn_respawnbuffhp",     "20",     "Amount of buffer HP a Survivor will respawn with (Def 20)"FCVAR_NOTIFYtrue0.0);
    
HookEvent("player_spawn"evtPlayerSpawn);
    
AutoExecConfigtrue"extra_spawn_hp" );
}
public 
Action evtPlayerSpawn(Event event, const char[] namebool dontBroadcast
{
    
int client GetClientOfUserId(event.GetInt("userid"));

    if (
client && client <=MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2)
    {
        if(
GetClientHealth(client) == 100 && CheckSurvivorPlayers_InSV() > 4)
        {
            
SetHealth(client);
        }
    }
}

void SetHealthint client )
{
    
float Buff GetEntDataFloatclientBufferHP );
    
int BonusHP hCvar_RespawnHP.IntValue;
    
int BuffHP hCvar_RespawnBuffHP.IntValue;

    
SetEntPropclientProp_Send"m_iHealth"BonusHP);
    
SetEntDataFloatclientBufferHPBuff BuffHPtrue );
}

int CheckSurvivorPlayers_InSV()
{
    
int iPlayersInAliveSurvivors=0;
    for (
int i 1MaxClients+1i++)
        if(
IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == )
            
iPlayersInAliveSurvivors++;
    return 
iPlayersInAliveSurvivors;

The hp are only set if there is more than 4 survivors?
Alex101192 is offline
HarryPotter
Veteran Member
Join Date: Sep 2017
Location: Taiwan, Asia
Old 07-23-2020 , 11:00   Re: How to make extra spawned bot survivors to start at 50hp instead of 100?
Reply With Quote #6

Quote:
Originally Posted by Alex101192 View Post
The hp are only set if there is more than 4 survivors?
Yes
__________________
HarryPotter is offline
Alex101192
Senior Member
Join Date: Aug 2018
Old 07-23-2020 , 11:59   Re: How to make extra spawned bot survivors to start at 50hp instead of 100?
Reply With Quote #7

Quote:
Originally Posted by fbef0102 View Post
Yes
Ok I will try this.
Alex101192 is offline
Alex101192
Senior Member
Join Date: Aug 2018
Old 07-23-2020 , 12:09   Re: How to make extra spawned bot survivors to start at 50hp instead of 100?
Reply With Quote #8

Quote:
Originally Posted by fbef0102 View Post
a dummy solution here.

If there are more than 4 survivors, where a player spawns, detect if he has 100 hp,
if Yes, set his hp.
PHP Code:
#pragma semicolon 1
#pragma newdecls required //強制1.7以後的新語法

#include <sourcemod>
#include <sdktools>

ConVar hCvar_RespawnHP,hCvar_RespawnBuffHP;
int BufferHP = -1;

public 
Plugin myinfo =
{
    
name "",
    
author "Harry Potter",
    
description "",
    
version "1.0",
    
url "https://forums.alliedmods.net/showthread.php?t=326168"
};

public 
void OnPluginStart()
{
    
BufferHP FindSendPropInfo"CTerrorPlayer""m_healthBuffer" );
    
hCvar_RespawnHP         CreateConVar("l4d_extra_spawn_respawnhp",     "30",     "Amount of HP a Survivor will respawn with (Def 30)"FCVAR_NOTIFYtrue0.0);
    
hCvar_RespawnBuffHP     CreateConVar("l4d_extra_pawn_respawnbuffhp",     "20",     "Amount of buffer HP a Survivor will respawn with (Def 20)"FCVAR_NOTIFYtrue0.0);
    
HookEvent("player_spawn"evtPlayerSpawn);
    
AutoExecConfigtrue"extra_spawn_hp" );
}
public 
Action evtPlayerSpawn(Event event, const char[] namebool dontBroadcast
{
    
int client GetClientOfUserId(event.GetInt("userid"));

    if (
client && client <=MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2)
    {
        if(
GetClientHealth(client) == 100 && CheckSurvivorPlayers_InSV() > 4)
        {
            
SetHealth(client);
        }
    }
}

void SetHealthint client )
{
    
float Buff GetEntDataFloatclientBufferHP );
    
int BonusHP hCvar_RespawnHP.IntValue;
    
int BuffHP hCvar_RespawnBuffHP.IntValue;

    
SetEntPropclientProp_Send"m_iHealth"BonusHP);
    
SetEntDataFloatclientBufferHPBuff BuffHPtrue );
}

int CheckSurvivorPlayers_InSV()
{
    
int iPlayersInAliveSurvivors=0;
    for (
int i 1MaxClients+1i++)
        if(
IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == )
            
iPlayersInAliveSurvivors++;
    return 
iPlayersInAliveSurvivors;

I started a game in dead center and as soon as we started, bots had 33 hp and I had 86 hp. Something ain't right here. Also the plugin should not be taking effect just with more than 4 players. If I start a lobby as 6 players, we will start the map with less hp than usual assuming it works as intended. But we can't turn it off for the first 2 minutes because then that exploit can still be done.

Wouldn't it be better to just edit merudo's code and set these hp only for the bots spawned by it instead of touching standard map bots which should not be touched?

Last edited by Alex101192; 07-23-2020 at 12:16.
Alex101192 is offline
Alex101192
Senior Member
Join Date: Aug 2018
Old 07-27-2020 , 14:04   Re: How to make extra spawned bot survivors to start at 50hp instead of 100?
Reply With Quote #9

Quote:
Originally Posted by fbef0102 View Post
In Original source code, edit and add the following code
line 372
PHP Code:
void SpawnFakeSurvivorClient()
{
    ...
    ...
    
DispatchSpawn(Bot);
    if(
DispatchSpawn(Bot) == false)
    {
        return;
    }

    
float Buff GetEntDataFloatBotFindSendPropInfo"CTerrorPlayer""m_healthBuffer" ) );
    
int BonusHP 50//permanent health you set
    
int BuffHP 20//temporary health you set

    
SetEntPropBotProp_Send"m_iHealth"BonusHP);
    
SetEntDataFloatBotFindSendPropInfo"CTerrorPlayer""m_healthBuffer" ), Buff BuffHPtrue );


    
// Kick the "SurvivorBot" so it becomes a regular bot
    
if(IsClientInGame(Bot) && IsFakeClient(Bot) && !GetIdlePlayer(Bot))
        
KickClient(Bot"Kicking Fake Client.");

save and recompile
I am trying to compile original merudo's plugin with your code, but the original code can't be compiled due to this error:

Code:
plugin.sp(1674) : error 021: symbol already defined: "PrintToConsoleAll"
Alex101192 is offline
HarryPotter
Veteran Member
Join Date: Sep 2017
Location: Taiwan, Asia
Old 07-27-2020 , 21:16   Re: How to make extra spawned bot survivors to start at 50hp instead of 100?
Reply With Quote #10

Quote:
Originally Posted by Alex101192 View Post
I am trying to compile original merudo's plugin with your code, but the original code can't be compiled due to this error:

Code:
plugin.sp(1674) : error 021: symbol already defined: "PrintToConsoleAll"
That's not my fault. I think the code needs to be rewritten today.
How could we help your request if the original plugin you post can't even be compiled?

Next time please at least make sure the script can be compiled first...
__________________

Last edited by HarryPotter; 07-27-2020 at 21:23.
HarryPotter 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 04:07.


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