Raised This Month: $32 Target: $400
 8% 

[L4D2] Tank HP for Versus


Post New Thread Reply   
 
Thread Tools Display Modes
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 07-06-2018 , 19:44   Re: [L4D2] Tank HP for Versus
Reply With Quote #11

Do you use SuperVersus by any chance?
__________________
Psyk0tik is offline
SilentBr
Veteran Member
Join Date: Jan 2009
Old 07-06-2018 , 20:55   Re: [L4D2] Tank HP for Versus
Reply With Quote #12

Quote:
Originally Posted by Crasher_3637 View Post
Do you use SuperVersus by any chance?
Yes, but the tank hp cvar from the plugin is set to 0.
SilentBr is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 07-06-2018 , 21:36   Re: [L4D2] Tank HP for Versus
Reply With Quote #13

Based on past experiences with SuperVersus, the Tank's HP can still get bugged even if the plugin's Tank HP modifier cvar is disabled.
__________________
Psyk0tik is offline
SilentBr
Veteran Member
Join Date: Jan 2009
Old 07-07-2018 , 12:19   Re: [L4D2] Tank HP for Versus
Reply With Quote #14

Quote:
Originally Posted by Crasher_3637 View Post
Based on past experiences with SuperVersus, the Tank's HP can still get bugged even if the plugin's Tank HP modifier cvar is disabled.
:/

Do you know how to fix the code that I posted on this thread so can restore the HP if a bot assumed the tank control?
SilentBr is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 07-08-2018 , 20:04   Re: [L4D2] Tank HP for Versus
Reply With Quote #15

Untested.

PHP Code:
#include <sourcemod>
#pragma semicolon 1
#pragma newdecls required

public Plugin myinfo =
{
    
name "[L4D & L4D2] Consistent Tank HP",
    
author "Psyk0tik (Crasher_3637) and SilentBr",
    
description "Keeps the Tank HP consistent across bots and players.",
    
version "1.0",
    
url "https://forums.alliedmods.net/showthread.php?t=308812",
};

public 
APLRes AskPluginLoad2(Handle myselfbool latechar[] errorint err_max)
{
    
EngineVersion evEngine GetEngineVersion();
    if (
evEngine != Engine_Left4Dead && evEngine != Engine_Left4Dead2)
    {
        
strcopy(errorerr_max"The plugin only supports Left 4 Dead 1 & 2.");
        return 
APLRes_SilentFailure;
    }
    return 
APLRes_Success;
}

ConVar g_cvCTHCvar[2];
int g_iTankHealth[MAXPLAYERS 1];

public 
void OnPluginStart()
{
    
g_cvCTHCvar[0] = CreateConVar("cth_enable""1""Enable \"Consistent Tank HP\"?\n0: OFF\n1: ON"_true0.0true1.0);
    
g_cvCTHCvar[1] = CreateConVar("cth_health""22000""Value to set Tank's HP to."_true1.0true62400.0);
    
AutoExecConfig(true"consistent_tank_hp");
    
HookEvent("tank_spawn"eEventTankSpawn);
    
HookEvent("tank_frustrated"eEventTankFrustrated);
    
HookEvent("player_bot_replace"eEventPlayerBotReplaceEventHookMode_Post);
}

public 
Action eEventTankSpawn(Event event, const char[] namebool dontBroadcast)
{
    
int iUserId event.GetInt("userid");
    
int iTank GetClientOfUserId(iUserId);
    if (
bIsValidClient(iTank))
    {
        
CreateTimer(0.1tTimerSetHealthiUserIdTIMER_FLAG_NO_MAPCHANGE);
    }
}

public 
Action eEventTankFrustrated(Event event, const char[] namebool dontBroadcast)
{
    
int iUserId event.GetInt("userid");
    
int iTank GetClientOfUserId(iUserId);
    if (
bIsValidClient(iTank))
    {
        
g_iTankHealth[iTank] = GetClientHealth(iTank);
    }
}

public 
Action eEventPlayerBotReplace(Event event, const char[] namebool dontBroadcast)
{
    
int iPlayer event.GetInt("player");
    
int iBot event.GetInt("bot");
    if (
bIsValidClient(iPlayer) && bIsValidClient(iBot))
    {
        
SetEntityHealth(iBotg_iTankHealth[iPlayer]);
    }
}

public 
Action tTimerSetHealth(Handle timerany userid)
{
    
int iTank GetClientOfUserId(userid);
    if (
bIsValidClient(iTank))
    {
        
SetEntityHealth(iTankg_cvCTHCvar[1].IntValue);
    }
}

stock bool bIsValidClient(int client)
{
    return 
client && client <= MaxClients && IsClientInGame(client) && !IsClientInKickQueue(client);

Attached Files
File Type: sp Get Plugin or Get Source (consistent_tank_hp.sp - 276 views - 2.4 KB)
__________________
Psyk0tik is offline
SilentBr
Veteran Member
Join Date: Jan 2009
Old 07-12-2018 , 14:03   Re: [L4D2] Tank HP for Versus
Reply With Quote #16

Quote:
Originally Posted by Crasher_3637 View Post
Untested.
Thank you very much.

I've tested the plugin and found two bugs:

1- Bot become with full HP :/
2- sm plugins list stopped working after this plugins is loaded O_O
SilentBr is offline
midnight9
Senior Member
Join Date: Nov 2012
Old 07-12-2018 , 14:15   Re: [L4D2] Tank HP for Versus
Reply With Quote #17

Quote:
Originally Posted by SilentBr View Post
Thank you very much.

I've tested the plugin and found two bugs:

1- Bot become with full HP :/
2- sm plugins list stopped working after this plugins is loaded O_O
I think it would be better to find out why sm_cvar z_tank_health 14666.7 is not working for you in the first place, rather than trying to use plugin to set tanks health when you already have variable for setting tanks health.
midnight9 is offline
Skyy
AlliedModders Donor
Join Date: Jan 2010
Location: Toronto, Canada
Old 07-16-2018 , 02:28   Re: [L4D2] Tank HP for Versus
Reply With Quote #18

Just a heads-up; Unless you use instanced health pools, there is a hard-cap on health pool limits.
Skyy is offline
Reply


Thread Tools
Display Modes

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 16:22.


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