mirror of
https://github.com/ENSL/NS.git
synced 2024-11-25 14:01:03 +00:00
Fixed weapon spread for fake clients (bots). Thanks Neoptolemus!
This commit is contained in:
parent
52630598ad
commit
96a268a91f
1 changed files with 32 additions and 4 deletions
|
@ -108,8 +108,22 @@ Vector UTIL_GetRandomSpreadDir(unsigned int inSeed, int inShotNumber, const Vect
|
||||||
{
|
{
|
||||||
// Use player's random seed.
|
// Use player's random seed.
|
||||||
// get circular gaussian spread
|
// get circular gaussian spread
|
||||||
float x = UTIL_SharedRandomFloat( inSeed + inShotNumber, -0.5, 0.5 ) + UTIL_SharedRandomFloat( inSeed + ( 1 + inShotNumber ) , -0.5, 0.5 );
|
float x, y;
|
||||||
float y = UTIL_SharedRandomFloat( inSeed + ( 2 + inShotNumber ), -0.5, 0.5 ) + UTIL_SharedRandomFloat( inSeed + ( 3 + inShotNumber ), -0.5, 0.5 );
|
|
||||||
|
// Check if seed is 0 to fix bot weapon spread.
|
||||||
|
if (inSeed == 0)
|
||||||
|
{
|
||||||
|
x = g_engfuncs.pfnRandomFloat(-0.5, 0.5);
|
||||||
|
x = g_engfuncs.pfnRandomFloat(-0.5, 0.5) + x;
|
||||||
|
y = g_engfuncs.pfnRandomFloat(-0.5, 0.5);
|
||||||
|
y = g_engfuncs.pfnRandomFloat(-0.5, 0.5) + y;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x = UTIL_SharedRandomFloat(inSeed + inShotNumber, -0.5, 0.5) + UTIL_SharedRandomFloat(inSeed + (1 + inShotNumber), -0.5, 0.5);
|
||||||
|
y = UTIL_SharedRandomFloat(inSeed + (2 + inShotNumber), -0.5, 0.5) + UTIL_SharedRandomFloat(inSeed + (3 + inShotNumber), -0.5, 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
float z = x * x + y * y;
|
float z = x * x + y * y;
|
||||||
|
|
||||||
Vector theRandomDir = inBaseDirection + x * inSpread.x * inRight + y * inSpread.y * inUp;
|
Vector theRandomDir = inBaseDirection + x * inSpread.x * inRight + y * inSpread.y * inUp;
|
||||||
|
@ -122,8 +136,22 @@ Vector UTIL_GetRandomSpreadDirFrom(unsigned int inSeed, int inShotNumber, const
|
||||||
{
|
{
|
||||||
// Use player's random seed.
|
// Use player's random seed.
|
||||||
// get circular gaussian spread
|
// get circular gaussian spread
|
||||||
float x = UTIL_SharedRandomFloat( inSeed + inShotNumber, -0.5, 0.5 ) + UTIL_SharedRandomFloat( inSeed + ( 1 + inShotNumber ) , -0.5, 0.5 );
|
float x, y;
|
||||||
float y = UTIL_SharedRandomFloat( inSeed + ( 2 + inShotNumber ), -0.5, 0.5 ) + UTIL_SharedRandomFloat( inSeed + ( 3 + inShotNumber ), -0.5, 0.5 );
|
|
||||||
|
// Check if seed is 0 to fix bot weapon spread.
|
||||||
|
if (inSeed == 0)
|
||||||
|
{
|
||||||
|
x = g_engfuncs.pfnRandomFloat(-0.5, 0.5);
|
||||||
|
x = g_engfuncs.pfnRandomFloat(-0.5, 0.5) + x;
|
||||||
|
y = g_engfuncs.pfnRandomFloat(-0.5, 0.5);
|
||||||
|
y = g_engfuncs.pfnRandomFloat(-0.5, 0.5) + y;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x = UTIL_SharedRandomFloat(inSeed + inShotNumber, -0.5, 0.5) + UTIL_SharedRandomFloat(inSeed + (1 + inShotNumber), -0.5, 0.5);
|
||||||
|
y = UTIL_SharedRandomFloat(inSeed + (2 + inShotNumber), -0.5, 0.5) + UTIL_SharedRandomFloat(inSeed + (3 + inShotNumber), -0.5, 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
float z = x * x + y * y;
|
float z = x * x + y * y;
|
||||||
float xdir = x / fabs(x);
|
float xdir = x / fabs(x);
|
||||||
float ydir = y / fabs(y);
|
float ydir = y / fabs(y);
|
||||||
|
|
Loading…
Reference in a new issue