View Single Post
bibu
Veteran Member
Join Date: Sep 2010
Old 08-16-2022 , 04:01   Re: how to make bot aim miss target?
Reply With Quote #2

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 << CSW_SMOKEGRENADE << CSW_HEGRENADE << CSW_FLASHBANG << CSW_C4

new g_iMaxPlayersboolg_bHamRegisteredbool:bIsUserBotMAX_PLAYERS ]

new 
bool:g_weaponMortalHeadshotMAX_WEAPONS ]

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_TraceAttackid"HamTraceAttack" )
     }
}

public 
client_disconnected(id)
{
    
bIsUserBot[id] = false
}

public 
HamTraceAttackvictimattackerFloat:damageFloat:tr[3], traceresult/*, dmgbits*/ )
{
    if( !
IsPlayerattacker ) || victim == attacker || !bIsUserBot[attacker] )
        return 
HAM_IGNORED
    
    
if( g_weaponMortalHeadshotget_user_weaponattacker ) ] && get_tr2traceresult TR_iHitgroup ) == HIT_HEAD )
    {
        
set_tr2(traceresultTR_iHitgroupHIT_CHEST)
    }
    
    return 
HAM_IGNORED
}

public 
ConsoleCommand_MortalHeadshotidlevelcid )
{
    if( !
cmd_accessidlevelcid)  ) 
    { 
        return 
PLUGIN_HANDLED
    

    
    new 
szWeapon32 ] = "weapon_"
        
    
read_argv1szWeapon], charsmaxszWeapon ) -)
    
    new 
weaponid get_weaponidszWeapon )
        
    if( 
weaponid && ~( << weaponid ) & bitsNotAllowedWeapons )
    {
        new 
szValue]
        
read_argv2szValuecharsmaxszValue ) )
        
        
g_weaponMortalHeadshotweaponid ] = szValue] == '0' false true            
                
        console_print
id"%s reduced headshot chance: %s"szWeaponszValue] == '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.

Last edited by bibu; 08-17-2022 at 08:16.
bibu is offline