Raised This Month: $ Target: $400
 0% 

Solved [L4D2] Damage Reduction when equip riotshield


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
ddd123
Senior Member
Join Date: May 2021
Old 10-04-2022 , 09:44   Re: [L4D2] Damage Reduction when equip riotshield
Reply With Quote #7

Quote:
Originally Posted by moschinovac View Post
Here's "Lazy" version modify from that plugin. Haven't tested
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#pragma semicolon 1


Handle l4d_shield_damage_from_ci;
Handle l4d_shield_damage_from_si;
Handle l4d_shield_damage_from_tankwitch;


public 
void OnPluginStart()
{
    
    
l4d_shield_damage_from_ci CreateConVar("l4d_shield_damage_from_ci""0.0""ci damage to survivor with shield[0.0, 100.0]" );
      
l4d_shield_damage_from_si CreateConVar("l4d_shield_damage_from_si""10.0""si damage to survivor with shield[0.0, 100.0]" );
      
l4d_shield_damage_from_tankwitch CreateConVar("l4d_shield_damage_from_tankwitch""20.0""tank or witch damage to survivor with shield[0.0, 100.0]" );


    
AutoExecConfig(true"shield_l4d_snipset");
    
}

public 
void OnClientPutInServer(int client)
{
    if(
IsValidClient(client))
    {
        
SDKHook(clientSDKHook_OnTakeDamagePlayerOnTakeDamage);
    }
}

HoldShieldWeapon(client)
{
    
int ent=GetEntPropEnt(clientProp_Send"m_hActiveWeapon");
    if(
ent>0)
    {
        
decl String:item[64];
        
GetEdictClassname(ent,  itemsizeof(item));
        if(
StrEqual(item"weapon_melee"))
        {
            
GetEntPropString(entProp_Data"m_ModelName"itemsizeof(item));
            if(
StrContains(item"shield")>0)
            {
                return 
ent;
            }
        }
    }
    return 
0;
}


public 
Action PlayerOnTakeDamage(int victimint &attackerint &inflictorfloat &damageint &damagetype)
{
    if(
victim<=0)return Plugin_Continue;
    
    if(
GetClientTeam(victim) != 2) return Plugin_Continue;
    
    if(!
HoldShieldWeapon(victim)) return Plugin_Continue;
    
    
float damageFactor=100.0;
    
    if(
attacker>&& attacker<=MaxClients)
    {
        if(
GetEntProp(attackerProp_Send"m_zombieClass") == 8)
        {
            
damageFactor=GetConVarFloat(l4d_shield_damage_from_tankwitch);
        }
        else 
            
damageFactor=GetConVarFloat(l4d_shield_damage_from_si);
    }
    else
    {
        
char name[64];
        
GetEdictClassname(attackername64);
        if(
StrEqual(name"infected"))
        {
            
damageFactor=GetConVarFloat(l4d_shield_damage_from_ci);
        }
        else if(
StrEqual(name"tank_rock"))
        {
            
damageFactor=GetConVarFloat(l4d_shield_damage_from_tankwitch);
        }
        else 
            return 
Plugin_Continue;
    }

    

    
damageFactor=damageFactor*0.01;


    
damage=damage*damageFactor;

    return 
Plugin_Changed;
}


bool IsValidClient(int client)
{
    if (
client || client MaxClients
        return 
false;
    
    if (!
IsClientConnected(client)) 
        return 
false;
    
    if (!
IsClientInGame(client)) 
        return 
false;
    
    return 
true;

Thank you very much for a modify plugin moschinovac! Tested and it work looking fine!

Last edited by ddd123; 10-04-2022 at 09:44.
ddd123 is offline
 


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


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