-
Автор темы
- #1
C++:
void C_RageBot::PerformRevolverTime( C_BasePlayer* pPlayer, CUserCmd* pCmd )
{
m_RevolverData.m_TickRecord[ pCmd->m_nCommand % MULTIPLAYER_BACKUP ] = pPlayer->m_nTickBase( );
m_RevolverData.m_InAttack[ pCmd->m_nCommand % MULTIPLAYER_BACKUP ] = pCmd->m_nButtons & 0x801;
m_RevolverData.m_CanFire[ pCmd->m_nCommand % MULTIPLAYER_BACKUP ] = pPlayer->CanFire( );
C_BaseCombatWeapon* pCombatWeapon = pPlayer->m_hActiveWeapon( ).Get( );
if ( pPlayer->m_hActiveWeapon( ).Get( ) )
return;
float flPostponeFireReadyTime = FLT_MAX;
if ( pCombatWeapon->m_ItemDefinitionIndex( ) == WEAPON_REVOLVER )
{
int nLowestCommand = pCmd->m_nCommand - ( g_Globals->m_nTickRate >> 1 );
int nCheckCommand = pCmd->m_nCommand - 1;
int nFireCommand = 0;
while ( nCheckCommand > nLowestCommand )
{
nFireCommand = nCheckCommand;
if ( !m_RevolverData.m_InAttack[ nCheckCommand % MULTIPLAYER_BACKUP ] )
break;
if ( !m_RevolverData.m_CanFire[ nCheckCommand % MULTIPLAYER_BACKUP ] )
break;
nCheckCommand--;
}
}
if ( nFireCommand )
{
int nOffset = 1 - ( -0.03348f / g_Globals->m_IntervalPerTick );
if ( pCombatWeapon->m_iItemDefinitionIndex( ) == WEAPON_REVOLVER )
{
if ( nCommand - nFireCommand >= nOffset )
flPostponeFireReadyTime = TICKS_TO_TIME( m_RevolverData.m_TickRecord[ ( nFireCommand + nOffset ) % MULTIPLAYER_BACKUP ] ) + 0.2f;
}
}
pCombatWeapon->m_flPostponeFireReadyTime( ) = flPostponeFireReadyTime;
}
void __fastcall C_Hooks::hkRunCommand( LPVOID pEcx, uint32_t, C_BasePlayer* pPlayer, CUserCmd* pCmd, C_MoveHelper* pMoveHelper )
{
if ( !pPlayer || !pPlayer->IsPlayer( ) || !pPlayer->IsAlive( ) || pPlayer->EntIndex( ) - 1 > 63 || pPlayer != g_Globals->m_LocalPlayer )
return o_RunCommand( pEcx, pPlayer, pCmd, pMoveHelper );
if ( g_Tickbase->HasInvalidTick( pCmd->m_nTickCount ) )
{
pCmd->m_bHasBeenPredicted = true;
return;
}
g_RageBot->PerformRevolverTime( pPlayer, pCmd );
return o_RunCommand( pEcx, pPlayer, pCmd, pMoveHelper );
}