View Single Post
_KaszpiR_
AMX Mod X Beta Tester
Join Date: Feb 2004
Location: Warsaw, Poland
Old 03-29-2009 , 16:36   Re: [TF2] detecting if the current shot is critical or not
Reply With Quote #3

TF2_CalcIsAttackCritical is just for setting the critical shot or not
it does not show if the current shot is critical or not - ried with debug messages:

PHP Code:
public Action:TF2_CalcIsAttackCritical(clientweaponString:weaponname[], &bool:result)
{
    if(
b_critenabled && crits_enabled[client])
    { 
//is plugin enabled?
#if defined DEBUG
        
new String:name[MAX_NAME_LENGTH]
        
GetClientName(clientnamesizeof(name))
#endif 
        
new Float:r=GetRandomFloat(0.01.0);
        if ( 
crits_percent[client]) // if the generated random number is less than percent then set the crit, so 1.0 means always make crit, 0.0 means never crit
        
{
#if defined DEBUG
          
PrintToChat(client"RAW %s : r=%f cp=%f => %d"namer,crits_percent[client],FloatCompare(r,crits_percent[client]))
#endif 
          
result true;

        }
        else {
#if defined DEBUG
          
PrintToChat(client"RAW %s : r=%f cp=%f => %d"namer,crits_percent[client],FloatCompare(r,crits_percent[client]))
#endif 
          
result false;
        }

        if(
result
        {
            
crits_count[client]++
        }
        else 
        {
            
nocrits_count[client]++
        }

#if defined DEBUG2
          
PrintToChat(client"+CRIT/NOCRITS: %d / %d"crits_count[client],nocrits_count[client] )
#endif 

        
return Plugin_Handled;

}
    if(
result)
    {
        
crits_count[client]++
    }
    else 
    {
        
nocrits_count[client]++
    }
#if defined DEBUG2
          
PrintToChat(client"-CRIT/NOCRITS: %d / %d / %b"crits_count[client],nocrits_count[client], result )
#endif 


    
return Plugin_Continue;


__________________
= Ave Cesar, morituri Te salutant. = http://nvt.prv.pl = http://hlds.pl/
_KaszpiR_ is offline