Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=========================================================
- bool __stdcall ShouldCalculateNewCritCommands ( void )
- {
- if ( cl.curtime >= cl.crit.fNextCrit )
- return true;
- if ( cl.crit.wpnIndex != cl.crit.lastWeapon )
- return true;
- if ( cl.crit.playerIndex != cl.crit.lastPlayer )
- return true;
- return false;
- }
- //=========================================================
- bool __stdcall IsShotCritical ( int iSeed )
- {
- int index = (cl.crit.wpnIndex << 8) | cl.crit.playerIndex;
- if ( cl.pWeapon->IsMelee() )
- index <<= 8;
- tf2hook->RandomSeed ( index ^ iSeed );
- return ( tf2hook->RandomInt ( 0, 9999 ) < 100 );
- }
- //=========================================================
- void __stdcall ForceCriticalHit ( CUserCmd* cmd )
- {
- int i, cmdNum, iSeed, critCmd, best;
- cl.crit.wpnIndex = cl.pWeapon->GetClientNetworkable()->entindex();
- cl.crit.playerIndex = cl.player->GetClientNetworkable()->entindex();
- if ( !tf2hook->IsCritBoosted ( cl.player->GetTFPlayerShared() ) && cl.pWeapon->CanFireCriticalShot() )
- {
- if ( ShouldCalculateNewCritCommands() )
- {
- // make sure we use a seed with the lowest spread possible (while critting).
- best = cl.pWeapon->GetBestSpreadSeed();
- for ( i = 0, cmdNum = cmd->commandNumber; i < MAX_CRIT_CMDS; cmdNum++ )
- {
- iSeed = tf2hook->MD5_PseudoRandom ( cmdNum ) & 0x7FFFFFFF;
- if ( best != -1 ) {
- if ( (iSeed & 255) != best )
- continue;
- }
- if ( !IsShotCritical ( iSeed ) )
- continue;
- // cache dat command_number.
- cl.crit.cmds[ i++ ] = cmdNum;
- }
- // set the time for us to recalculate.
- cl.crit.fNextCrit = cl.curtime + CRIT_INTERVAL;
- }
- // force dat seed.
- critCmd = cl.crit.cmds[ (cl.crit.cmdIndex++) % MAX_CRIT_CMDS ];
- cmd->commandNumber = critCmd;
- cmd->randomSeed = tf2hook->MD5_PseudoRandom ( critCmd ) & 0x7FFFFFFF;
- }
- cl.crit.lastWeapon = cl.crit.wpnIndex;
- cl.crit.lastPlayer = cl.crit.playerIndex;
- }
- //=========================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement