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

[L4D2] Charger mid-charge buff


Post New Thread Reply   
 
Thread Tools Display Modes
Geel9
Senior Member
Join Date: Mar 2009
Old 03-30-2010 , 20:07   Re: [L4D2] Charge Protection
Reply With Quote #11

Fixed all the problems.
Geel9 is offline
.silence.
Member
Join Date: Sep 2009
Location: Chicago
Old 03-30-2010 , 23:05   Re: [L4D2] Charge Assurance
Reply With Quote #12

Quote:
Originally Posted by Geel9 View Post
There can only be one charger at a time.
There can be multiple if you set "sm_cvar z_charger_limit 1" to something more than one (I think, I have not tried it.)
.silence. is offline
Geel9
Senior Member
Join Date: Mar 2009
Old 04-01-2010 , 21:07   Re: [L4D2] Charge Assurance
Reply With Quote #13

Quote:
Originally Posted by .silence. View Post
There can be multiple if you set "sm_cvar z_charger_limit 1" to something more than one (I think, I have not tried it.)
It supports multiple chargers anyways.
Geel9 is offline
IronWarrior
Veteran Member
Join Date: Jan 2010
Old 04-01-2010 , 22:09   Re: [L4D2] Charge Assurance
Reply With Quote #14

Quote:
Originally Posted by Geel9 View Post
It supports multiple chargers anyways.
Funny that, when I asked that in the first page, you said it didn't.

Anyway good to know, great plugin! good job!

Last edited by IronWarrior; 04-02-2010 at 02:43.
IronWarrior is offline
dirka_dirka
Veteran Member
Join Date: Nov 2009
Old 04-02-2010 , 14:05   Re: [L4D2] Charger mid-charge buff
Reply With Quote #15

it looks like he added the ability (silently)... the above post being his mention of the "update"
dirka_dirka is offline
Geel9
Senior Member
Join Date: Mar 2009
Old 04-02-2010 , 16:07   Re: [L4D2] Charger mid-charge buff
Reply With Quote #16

Quote:
Originally Posted by dirka_dirka View Post
it looks like he added the ability (silently)... the above post being his mention of the "update"
Correct
Geel9 is offline
Geel9
Senior Member
Join Date: Mar 2009
Old 04-15-2010 , 04:52   Re: [L4D2] Charger mid-charge buff
Reply With Quote #17

I wonder, what would you guys think about having people with custom flags be able to heal MORE?
Geel9 is offline
dirka_dirka
Veteran Member
Join Date: Nov 2009
Old 06-03-2010 , 18:51   Re: [L4D2] Charger mid-charge buff
Reply With Quote #18

I finally got around to add this to my server and..

Issues with the plugin:
Uses MAXPLAYERS not MAXPLAYERS+1
Doesn't check for client disconnect mid charge
Doesn't check for invalid clients.
Doesn't properly account for damage done mid charge.

As a result. I rewrote it a bit so I could use it.
PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>

#define PLUGIN_VERSION        "1.2"

/*
    Version 1.2:
        Fixed MAXPLAYERS to MAXPLAYERS+1
        Added plugin version & cvar: charge_assurance_ver
        Renamed the only cvar the plugin originally had to sm_charge_boosthealth
        Added a check for Left 4 Dead 2... fail otherwise.
        Added check for if a client disconnects mid-charge.. remove the boost.
        Added check for invalid charger client.
        Added a min to the health boost.. also that min is effectively a way to disable this: 0 = off.
        Added a hook to the boost cvar so it can be changed on the fly (and turned on/off).
        Changed the health restore function.. Will now set health to 1 if the charger would have otherwise died without the boost.
        Cleaned up the code a bit.
        Unified the name of the plugin internally - author calls it something like 4 or 5 different things throughout the code and on his plugin post.
*/

new    bool:    g_bIsCharging[MAXPLAYERS+1]    =    { false, ... };
new    
Handle:    g_hConVarHealth                =    INVALID_HANDLE;
new            
g_iConVarHealth;

public 
Plugin:myinfo = {
    
name "Charge Assurance",
    
author "Joshua Coffey & Dirka_Dirka",
    
description "Let chargers have a higher chance of survival during charges.",
    
version PLUGIN_VERSION,
    
url "http://forums.alliedmods.net/showthread.php?t=122544"
}

public 
OnPluginStart() {
    
decl String:game_name[12];
    
GetGameFolderName(game_namesizeof(game_name));
    if (!
StrEqual(game_name"left4dead2"false))
        
SetFailState("Plugin supports Left 4 Dead 2 only.");
    
    
CreateConVar(
        
"charge_assurance_ver",
        
PLUGIN_VERSION,
        
"Version of the L4D2 Charge Assurance plugin.",
        
FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_REPLICATED|FCVAR_SPONLY|FCVAR_DONTRECORD
    
);
    
    
g_hConVarHealth CreateConVar(
        
"sm_charge_boosthealth",
        
"300",
        
"The amount of health to give to a charger during a charge (and then take away afterwards).",
        
FCVAR_PLUGIN|FCVAR_NOTIFY,
        
true0.0
    
);
    
HookConVarChange(g_hConVarHealthConVarChange_Health);
    
g_iConVarHealth GetConVarInt(g_hConVarHealth);
    
    
HookEvent("charger_charge_start"Event_ChargeStart);
    
HookEvent("charger_charge_end"Event_ChargeEnd);
}

public 
ConVarChange_Health(Handle:convar, const String:oldValue[], const String:newValue[]) {
    
g_iConVarHealth GetConVarInt(g_hConVarHealth);
}

public 
OnClientPutInServer(client) {
    
g_bIsCharging[client] = false;
}

public 
OnClientDisconnect(client) {
    if (
g_bIsCharging[client]) {
        
RemoveProtection(client);
    }
}

public 
Event_ChargeStart(Handle:event, const String:name[], bool:dontBroadcast) {
    if (!
g_iConVarHealth) return;
    
    new 
charger GetClientOfUserId(GetEventInt(event"userid"));
    if (!
charger) return;
    
    new 
healthboost g_iConVarHealth GetClientHealth(charger);
    
    if (!
g_bIsCharging[charger]) {
        
SetEntityHealth(chargerhealthboost);
        
g_bIsCharging[charger] = true;
    }
}

public 
Event_ChargeEnd(Handle:event, const String:name[], bool:dontBroadcast) {
    if (!
g_iConVarHealth) return;
    
    new 
charger GetClientOfUserId(GetEventInt(event"userid"));
    if (!
charger) return;
    
    
RemoveProtection(charger);
}

stock RemoveProtection(client) {
    
g_bIsCharging[client] = false;
    
    new 
damagehealth GetClientHealth(client) - g_iConVarHealth;
    if (
damagehealth 1)
        
damagehealth 1;
    
SetEntityHealth(clientdamagehealth);

This also adds a hook to the health boost so it can be changed/turned on/off mid game. as well as a few other things.. check the comment at top for full list.

havent fully tested it yet, but this should be much improved over whats in the op.
Attached Files
File Type: sp Get Plugin or Get Source (chargeassurance.sp - 523 views - 3.3 KB)
dirka_dirka is offline
Geel9
Senior Member
Join Date: Mar 2009
Old 06-21-2010 , 08:24   Re: [L4D2] Charger mid-charge buff
Reply With Quote #19

People always hijackin' my scripts =S
Geel9 is offline
Big Myke
Senior Member
Join Date: Jan 2009
Location: Grain Belt, USA
Old 06-21-2010 , 11:53   Re: [L4D2] Charger mid-charge buff
Reply With Quote #20

Quote:
Originally Posted by Geel9 View Post
People always hijackin' my scripts =S
Be appreciative. They are there to help.
__________________
Successful Pluggins that I've Requested.
[L4D2]Blind Luck | [L4D2]Laser Sight Crosshair Removal
Big Myke 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 11:30.


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