Начинающий
-
Автор темы
- #1
Код:
// client.dll "48 81 EC ?? ?? ?? ?? F3 0F 10 09 4C 8B C9"
// server.dll "48 81 EC ? ? ? ? 8B 05 ? ? ? ? 4C 8B C1"
uint32_t GetRandomSeed( const QAngle& angles, int player_render_tick )
{
#ifdef SERVER_DLL
// sv_usercmd_custom_random_seed = false by default now.
// m_nPredictionRandomSeed = cmd->random_seed;
// m_nPredictionRandomSeedServer = sv_usercmd_custom_random_seed ? GetRngSeed() : cmd->random_seed;
if ( m_nPredictionRandomSeedServer != m_nPredictionRandomSeed )
return m_nPredictionRandomSeedServer;
#endif
struct HashBuffer
{
float pitch;
float yaw;
int tick;
};
HashBuffer buffer;
float pitch = AngleNormalize(angles.pitch);
pitch += pitch;
buffer.pitch = RoundFloat(pitch) * 0.5f;
float yaw = AngleNormalize(angles.yaw);
yaw += yaw;
buffer.yaw = RoundFloat(yaw) * 0.5f;
buffer.tick = player_render_tick;
CSHA1 sha1;
sha1.Reset( );
sha1.Update( &buffer, sizeof(buffer) );
sha1.Final();
return *reinterpret_cast<uint32_t*>(&sha1.m_digest[0]);
}
// Somewhere in CSBaseGunFire....
// ...
auto context = BacktrackLocalPlayer( weapon, weapon_mode );
auto seed = GetRandomSeed( context.angles, weapon->AdjustPausedTicks( context.player_render_tick ) );
FX_FireBullets(seed, ...);
// ...