//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- bool CTFWeaponBaseMelee::CalcIsAttackCriticalHelper( void ) { CTFPlayer *pPlayer = ToTFPlayer( GetPlayerOwner() ); if ( !pPlayer ) return false; int nCvarValue = tf_weapon_criticals_melee.GetInt(); if ( nCvarValue == 0 ) return false; if ( nCvarValue == 1 && !tf_weapon_criticals.GetBool() ) return false; float flPlayerCritMult = pPlayer->GetCritMult(); float flCritChance = TF_DAMAGE_CRIT_CHANCE_MELEE * flPlayerCritMult; CALL_ATTRIB_HOOK_FLOAT( flCritChance, mult_crit_chance ); // If the chance is 0, just bail. if ( flCritChance == 0.0f ) return false; return ( RandomInt( 0, WEAPON_RANDOM_RANGE-1 ) <= flCritChance * WEAPON_RANDOM_RANGE ); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- bool CTFWeaponBaseMelee::CalcIsAttackCriticalHelper( void ) { CTFPlayer *pPlayer = ToTFPlayer( GetPlayerOwner() ); if ( !pPlayer ) return false; float flPlayerCritMult = pPlayer->GetCritMult(); return ( RandomInt( 0, WEAPON_RANDOM_RANGE-1 ) <= ( TF_DAMAGE_CRIT_CHANCE_MELEE * flPlayerCritMult ) * WEAPON_RANDOM_RANGE ); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- bool CTFWeaponBaseMelee::CalcIsAttackCriticalHelper( void ) { CTFPlayer *pPlayer = ToTFPlayer( GetPlayerOwner() ); if ( !pPlayer ) return false; int iShouldCrit = tf_weapon_criticals_melee.GetInt(); if ( iShouldCrit == 0 ) return false; if ( iShouldCrit == 1 && !tf_weapon_criticals.GetBool() ) return false; float flPlayerCritMult = pPlayer->GetCritMult(); return ( RandomInt( 0, WEAPON_RANDOM_RANGE-1 ) <= ( TF_DAMAGE_CRIT_CHANCE_MELEE * flPlayerCritMult ) * WEAPON_RANDOM_RANGE ); }