Cvars:
- rasd_enabled - Enables/disables plugin (default 1)
- rasd_chatenabled - Enables/disables chat message to shooter letting him know of damage reduction (default 1)
The below cvars set the damage factor based on no scope or scope level. The total damage inflicted is multiplied by this multiplier. Note: Total damage inflicted is not the same as loss in hp to the victim.
- rasd_noscopedamagefactor - Damage factor when no scoping (default 0.75, 25% reduction)
- rasd_scope1damagefactor - Damage factor when scoping level 1 (default 0.5, 50% reduction)
- rasd_scope2damagefactor - Damage factor when scoping level 2 (default 0.25, 75% reduction)
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <cstrike>
#define MAX_PLAYERS 32
enum ScopeLevel
{
SL_NONE,
SL_NOSCOPE,
SL_SCOPE_1,
SL_SCOPE_2
}
new const g_szScopeType[ ScopeLevel ][] =
{
"",
"No scope",
"Scope 1",
"Scope 2"
};
new ScopeLevel:g_slCurrentScope[ MAX_PLAYERS + 1 ];
new Float:g_fDamageReduction[ ScopeLevel ];
new g_pEnabled , g_pChatMsg , g_pNoScopeDamage , g_pScope1Damage , g_pScope2Damage;
public plugin_init()
{
register_plugin( "Reduce Auto Sniper Damage" , "0.1" , "bugsy" );
RegisterHam( Ham_TakeDamage , "player" , "HamTakeDamage_Pre" );
register_event( "CurWeapon" , "EvCurWeapon" , "b" , "1=1" , "2=24" );
g_pEnabled = register_cvar("rasd_enabled" , "1" );
g_pChatMsg = register_cvar("rasd_chatenabled" , "1" );
g_pNoScopeDamage = register_cvar("rasd_noscopedamagefactor" , "0.75" );
g_pScope1Damage = register_cvar("rasd_scope1damagefactor" , "0.5" );
g_pScope2Damage = register_cvar("rasd_scope2damagefactor" , "0.25" );
g_fDamageReduction[ SL_NOSCOPE ] = get_pcvar_float( g_pNoScopeDamage );
g_fDamageReduction[ SL_SCOPE_1 ] = get_pcvar_float( g_pScope1Damage );
g_fDamageReduction[ SL_SCOPE_2 ] = get_pcvar_float( g_pScope2Damage );
}
public HamTakeDamage_Pre( this , iInflictor , iAttacker , Float:fDamage, DamageBits )
{
if ( ( iInflictor == iAttacker ) && get_pcvar_num( g_pEnabled ) && is_user_connected( iAttacker ) && ( get_user_weapon( iAttacker ) == CSW_G3SG1 ) )
{
SetHamParamFloat( 4 , fDamage * g_fDamageReduction[ g_slCurrentScope[ iAttacker ] ] );
if ( get_pcvar_num( g_pChatMsg ) )
{
client_print( iAttacker , print_chat , "* Your damage was reduced by %d%% since you are using auto sniper [%s]!" , floatround( 100.0 * ( 1.0 - g_fDamageReduction[ g_slCurrentScope[ iAttacker ] ] ) ) , g_szScopeType[ g_slCurrentScope[ iAttacker ] ] );
}
return HAM_HANDLED;
}
return HAM_IGNORED;
}
public EvCurWeapon( id )
{
g_slCurrentScope[ id ] = ScopeLevel:cs_get_user_zoom( id );
}
__________________