View Single Post
Make BOT more client-like (Changing CBasePlayer::random_seed variable)
Old
  (#1)
Immortal_BLG
Member
 
Status: Offline
Posts: 171
Join Date: Nov 2007
Location: Russian Federation
Default Make BOT more client-like (Changing CBasePlayer::random_seed variable) - 13-02-2011

Intro: This is needed to randomize bot shoot vector, random_seed value for bot is always 0, so weapon spread offset for bot is constant!!!! (spread offset is: [x=-0.481522, -0.558304])

My solution (need to hook pfnCmdStart function):
Without metamod:
Code:
void CmdStart (const edict_t *const player, const struct usercmd_s *const command, unsigned int randomSeed)
{
	if (player->v.flags & FL_FAKECLIENT)
		randomSeed = RANDOM_LONG (0u, 0x7FFFFFFFu);

	(*g_DLLFunctionTable.pfnCmdStart) (player, command, randomSeed);
}
With metamod:
Code:
void CmdStart_Post (const edict_t *const player, const struct usercmd_s *const command, unsigned int randomSeed)
{
	if (player->v.flags & FL_FAKECLIENT)
		static_cast <unsigned int *> (player->pvPrivateData)[96]/*player->pvPrivateData->random_seed*/ = RANDOM_LONG (0u, 0x7FFFFFFFu);

	RETURN_META (MRES_IGNORED);
}
P.S. SORRY FOR BAD ENGLISH!!!
  
Reply With Quote