View Single Post
slipvyne
Junior Member
Join Date: Jun 2009
Old 06-22-2009 , 07:50   Re: [TF2] change crit of a person.
Reply With Quote #6

Thanks and I do see that now. I updated the mod and retested the plugin and it still does not crit normalyl when bool var is turned off.

The new code looks like:
PHP Code:
public Action:TF2_CalcIsAttackCritical(clientweaponString:weaponname[], &bool:result)  //over-writes the native soucemod function for our own purposes.
{
    if(
GetConVarBool(turn_crit_on) == 0)
    {
        
PrintToServer("true");
        return 
Plugin_Continue;  //if set to 0, use the normal source crit check.  if set to 1, use my checks.
    
}
    else
    {
        if(
gCritBool[client] == 1)
        {
            
result true;
            return 
Plugin_Handled;
        }
        else if(
classcheck(TF2_GetPlayerClass(client)))
        {
            
//PrintToServer("true");
            
result true;  //result true = crit
            
return Plugin_Handled;  //plugin is then exited.
        
}
        else if(
GetConVarFloat(crit_rate) > GetRandomFloat(0.01.0)) //if not solider, gets the crit change rate, and gets a random number between 0 and 1 to check against.  if our crit rate is bigger, crit is ture and exited.
        
{
            
result true;
            return 
Plugin_Handled;    
        }
        else 
//else, since we are not a solider, and we did not "roll" a succsessful crit, it is obivously not a crit, and exited so source engine will use it's calc.
        
{
            return 
Plugin_Continue;
        }
    }

ignore the print to server, i was testing to make sure it was entering the correct tree. We did some more testing and found backstabs and ambass crits, lol. But sadly, it does not crit as it should without a plugin.

Any more thoughts or concerns?

**EDIT**

I have tried a couple different ways to work around the problem. First i was digging through other's code and saw that everytime they wanted the engine to handle the crits, it was in it's own if statement, looking like this:

PHP Code:
public Action:TF2_CalcIsAttackCritical(clientweaponString:weaponname[], &bool:result)  //over-writes the native soucemod function for our own purposes.
{
    if(
GetConVarBool(turn_crit_on) == 0)
    {
        return 
Plugin_Continue;  
    }
    if(
GetConVarBool(turn_crit_on) == 1)
    {
        if(
gCritBool[client] == 1)
        {
            
result true;
            return 
Plugin_Handled;
        }
        else if(
classcheck(TF2_GetPlayerClass(client)))
        {
            
//PrintToServer("true");
            
result true;  //result true = crit
            
return Plugin_Handled;  //plugin is then exited.
        
}
        else if(
GetConVarFloat(crit_rate) > GetRandomFloat(0.01.0)) //if not solider, gets the crit change rate, and gets a random number between 0 and 1 to check against.  if our crit rate is bigger, crit is ture and exited.
        
{
            
result true;
            return 
Plugin_Handled;    
        }
        else 
//else, since we are not a solider, and we did not "roll" a succsessful crit, it is obivously not a crit, and exited so source engine will use it's calc.
        
{
            return 
Plugin_Continue;
        }
    }

This did not work. And while on the MIRC channel asking for advice, some1 had suggested i get rid of that step completely and have it look like this:

PHP Code:
public Action:TF2_CalcIsAttackCritical(clientweaponString:weaponname[], &bool:result)  //over-writes the native soucemod function for our own purposes.
{
    if(
GetConVarBool(turn_crit_on) == 1)
    {
        if(
gCritBool[client] == 1)
        {
            
result true;
            return 
Plugin_Handled;
        }
        else if(
classcheck(TF2_GetPlayerClass(client)))
        {
            
//PrintToServer("true");
            
result true;  //result true = crit
            
return Plugin_Handled;  //plugin is then exited.
        
}
        else if(
GetConVarFloat(crit_rate) > GetRandomFloat(0.01.0)) //if not solider, gets the crit change rate, and gets a random number between 0 and 1 to check against.  if our crit rate is bigger, crit is ture and exited.
        
{
            
result true;
            return 
Plugin_Handled;    
        }
        else 
//else, since we are not a solider, and we did not "roll" a succsessful crit, it is obivously not a crit, and exited so source engine will use it's calc.
        
{
            return 
Plugin_Handled;
        }
    }
    return 
Plugin_Continue;

this also did not work. Granted i did test it by myself, but noticed that when testing with others, if the heavy did not uppercut with the KGB, it was not a critical. no uppercuts on either of these iterations.

Last edited by slipvyne; 06-22-2009 at 08:37.
slipvyne is offline
Send a message via AIM to slipvyne Send a message via MSN to slipvyne