Yes, that should work. I have edited the plugin based upon following code:
https://forums.alliedmods.net/showthread.php?t=163585
Try this:
PHP Code:
#include < amxmodx >
#include < amxmisc >
#include < fakemeta >
#include < hamsandwich >
#define IsPlayer(%1) (1<= %1 <= g_iMaxPlayers)
#define MAX_WEAPONS CSW_P90
#define MAX_PLAYERS 32
const bitsNotAllowedWeapons = 1 << CSW_SMOKEGRENADE | 1 << CSW_HEGRENADE | 1 << CSW_FLASHBANG | 1 << CSW_C4
new g_iMaxPlayers, bool: g_bHamRegistered, bool:bIsUserBot[ MAX_PLAYERS + 1 ]
new bool:g_weaponMortalHeadshot[ MAX_WEAPONS + 1 ]
public plugin_init()
{
register_plugin( "Bot Headshot Chance", "0.1", "eXtrem / AMXX Community" )
register_concmd( "bhc_chance", "ConsoleCommand_MortalHeadshot", ADMIN_KICK )
g_iMaxPlayers = get_maxplayers()
}
public client_putinserver(id)
{
if(is_user_bot(id))
bIsUserBot[id] = true
if(!g_bHamRegistered)
{
g_bHamRegistered = true
RegisterHamFromEntity( Ham_TraceAttack, id, "HamTraceAttack" )
}
}
public client_disconnected(id)
{
bIsUserBot[id] = false
}
public HamTraceAttack( victim, attacker, Float:damage, Float:tr[3], traceresult/*, dmgbits*/ )
{
if( !IsPlayer( attacker ) || victim == attacker || !bIsUserBot[attacker] )
return HAM_IGNORED
if( g_weaponMortalHeadshot[ get_user_weapon( attacker ) ] && get_tr2( traceresult , TR_iHitgroup ) == HIT_HEAD )
{
set_tr2(traceresult, TR_iHitgroup, HIT_CHEST)
}
return HAM_IGNORED
}
public ConsoleCommand_MortalHeadshot( id, level, cid )
{
if( !cmd_access( id, level, cid, 1 ) )
{
return PLUGIN_HANDLED
}
new szWeapon[ 32 ] = "weapon_"
read_argv( 1, szWeapon[ 7 ], charsmax( szWeapon ) -7 )
new weaponid = get_weaponid( szWeapon )
if( weaponid && ~( 1 << weaponid ) & bitsNotAllowedWeapons )
{
new szValue[ 2 ]
read_argv( 2, szValue, charsmax( szValue ) )
g_weaponMortalHeadshot[ weaponid ] = szValue[ 0 ] == '0' ? false : true
console_print( id, "%s reduced headshot chance: %s", szWeapon, szValue[ 0 ] == '0' ? "disabled" : "enabled" )
}
return PLUGIN_HANDLED
}
You can customize the weapons, which should have the effect. I have renamed the cvar name as you can see. The damage gets divided by 3, you may want to adjust that.
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.