Solved Coding a nospread.

  • CSGO recently moved logic from 'client_panorama.dll' to 'client.dll', you must update all code that uses 'client_panorama.dll' and replace it with 'client.dll' or the code will not work.
Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

legit_player

Newbie
Full Member
Aug 12, 2015
11
94
0
Whats up guys, i was never into hvh stuff but now i am bored and wanna do nospread. i know it will not work on valve servers because of random seed. I looked on some sources and then i tried to rewrite it by myself but for some reason its not working any ideas? Indexes are right i checked them.

C++:
void CNoSpread::RollSpread(int seed, CUserCmd*cmd, Vector3& pflInAngles)
{
	CPlayer* pLocal = Interfaces.EntList->GetClientEntity<CPlayer>(Interfaces.Engine->GetLocalPlayer());

	static CBaseWeapon* localWeap;
	localWeap = pLocal->GetWeap();

	localWeap->UpdateAccuracyPenalty();

	Random->SetSeed((seed & 0xFF) + 1);

	cmd->random_seed = MD5_PseudoRandom(cmd->command_number) & 0x7FFFFFFF;

	float fRand1 = Random->RandomFloat(0.f, 1.f);
	float fRandPi1 = Random->RandomFloat(0.f, 2.f * (float)PI);
	float fRand2 = Random->RandomFloat(0.f, 1.f);
	float fRandPi2 = Random->RandomFloat(0.f, 2.f * (float)PI);

	if (localWeap->GetItemDefinitionIndex() == 64 && cmd->buttons & IN_ATTACK2)
	{
		fRand1 = 1.f - fRand1 * fRand1;
		fRand2 = 1.f - fRand2 * fRand2;
	}

	float fRandInaccuracy = fRand1 * localWeap->InAccuracy();
	float fRandSpread = fRand2 * localWeap->WeaponSpread();

	Vector3 vForward, vRight, vUp, vDir;
	Vector3 vView, vSpread, flIdentity[3];
	float flRoll, flCross;

	vSpread.x = cos(fRandPi1) * fRandInaccuracy + cos(fRandPi2) * fRandSpread;
	vSpread.y = sin(fRandPi1) * fRandInaccuracy + sin(fRandPi2) * fRandSpread;

	Vector3 qViewAngles = pflInAngles;

	vSpread[0] = -vSpread[0];
	vSpread[1] = -vSpread[1];

	Hack.Misc->AngleVectors2(qViewAngles, &vForward, &vRight, &vUp);

	vDir[0] = vForward.x + (vRight.x * vSpread[0]) + (vUp.x * vSpread[1]);
	vDir[1] = vForward.y + (vRight.y * vSpread[0]) + (vUp.y * vSpread[1]);
	vDir[2] = vForward.z + (vRight.z * vSpread[0]) + (vUp.z * vSpread[1]);

	vDir.NormalizeInPlace();

	flIdentity[2][0] = 1.0f;
	flIdentity[2][1] = -vSpread[0];
	flIdentity[2][2] = vSpread[1];

	flIdentity[2].NormalizeInPlace();

	flIdentity[0][0] = 0.0f;
	flIdentity[0][1] = -vSpread[0];
	flIdentity[0][2] = (1.0f / vSpread[1]) + (1.0f / flIdentity[2][2]) + vSpread[1];

	if (vSpread[0] > 0.0f && vSpread[1] < 0.0f)
	{
		if (flIdentity[0][1] < 0.0f)
			flIdentity[0][1] = -flIdentity[0][1];
	}
	else if (vSpread[0] < 0.0f && vSpread[1] < 0.0f)
	{
		if (flIdentity[0][1] > 0.0f)
			flIdentity[0][1] = -flIdentity[0][1];
	}

	if (flIdentity[0][2] < 0.0f)
		flIdentity[0][2] = -flIdentity[0][2];

	flIdentity[0].NormalizeInPlace();

	flIdentity[1].CrossProduct(flIdentity[0], flIdentity[2]);

	flIdentity[1].NormalizeInPlace();

	flCross = (flIdentity[1][1] * flIdentity[2][0]) - (flIdentity[1][0] * flIdentity[2][1]);

	if (qViewAngles[0] > 84.0f || qViewAngles[0] < -84.0f)
		flRoll = RAD2DEG(atan2f(flIdentity[1][2], sseSqrt(flCross)));
	else
		flRoll = RAD2DEG(atan2f(flIdentity[1][2], flCross));

	if (flRoll < 0.0f)
		flRoll += 360.0f;

	VectorAngles(vDir, vUp, pflInAngles);
	pflInAngles[2] += flRoll;
}
 

Anomxus

Jr.Coder
Full Member
Nobleman
Jun 19, 2012
59
453
2
just to be sure, are you setting "sv_usercmd_random_seed" to 0? make sure sv_cheats is 1 also.
 

Lukor

ded
Meme Tier VIP
Fleep Tier Donator
Dec 13, 2013
490
5,353
25
looks like c&p
no comments whatsoever within such a difficult function :/
 

masteraimer1

Newbie
Full Member
Nobleman
Aug 27, 2014
95
1,768
6
Look up the spread calculation in FX_Firebullet...
There are plenty ways to achieve nospread such as iterative way or roll

Iterative:

C++:
    pflInAngles.x = g_Math.NormalizeYaw( pflInAngles.x );
    pflInAngles.y = g_Math.NormalizeYaw( pflInAngles.y );

    typedef void( __cdecl* RandomSeed_t )( int );
    static RandomSeed_t pRandomSeed = 0;

    typedef float( __cdecl* RandomFloat_t )( float, float );
    static RandomFloat_t pRandomFloat = 0;

    if( !pRandomSeed )
    {
        pRandomSeed = ( RandomSeed_t ) ( GetProcAddress( GetModuleHandleA( "vstdlib" ), "RandomSeed" ) );

        if( !pRandomSeed )
            return;
    }

    if( !pRandomFloat )
    {
        pRandomFloat = ( RandomFloat_t ) ( GetProcAddress( GetModuleHandleA( "vstdlib" ), "RandomFloat" ) );

        if( !pRandomFloat )
            return;
    }

    CBaseCombatWeapon * pWeapon = pLocal->GetWeapon();

    if( !pLocal || !pWeapon )
        return;

    pWeapon->UpdateAccuracyPenalty();

    pRandomSeed( seed );

    float flA = pRandomFloat( 0.0f, 1.0f );
    float flB = pRandomFloat( 0.0f, 6.283185f );
    float flC = pRandomFloat( 0.0f, 1.0f );
    float flD = pRandomFloat( 0.0f, 6.283185f );

    if( pWeapon->GetWeaponID() == WEAPON_R8REVOLVER && ( pCmd->buttons & IN_ATTACK2 ) )
    {
        flA = 1.0 - ( flA * flA );
        flC = 1.0 - ( flC * flC );
    }
    else
        if( pWeapon->GetWeaponID() == WEAPON_NEGEV && pWeapon->GetRecoilIndex() < 3.f )
        {
            for( int i = 3; i > pWeapon->GetRecoilIndex(); --i )
            {
                flA *= flA;
                flC *= flC;
            }

            flA = 1.f - flA;
            flC = 1.f - flC;
        }

    float vForward[ 3 ], vRight[ 3 ], vUp[ 3 ];
    Vector vDir;
    Vector vView, vSpread;

    vSpread.x = ( cos( flB ) * ( flA * pWeapon->GetInaccuracy() ) ) + ( cos( flD ) * ( flC * pWeapon->GetSpread() ) );
    vSpread.y = ( sin( flB ) * ( flA * pWeapon->GetInaccuracy() ) ) + ( sin( flD ) * ( flC * pWeapon->GetSpread() ) );

    Vector vAng = pflInAngles;

    Vector qDifference;
    Vector EstimatedViewAngles;

    float fDiff = 0.0f;
    float fDiffOld = 180.0f;

    for( ;; )
    {
        AngleVector( pflInAngles, vForward, vRight, vUp );

        vDir.x = vForward[ 0 ] + vSpread.x * vRight[ 0 ] + vSpread.y * vUp[ 0 ];
        vDir.y = vForward[ 1 ] + vSpread.x * vRight[ 1 ] + vSpread.y * vUp[ 1 ];
        vDir.z = vForward[ 2 ] + vSpread.x * vRight[ 2 ] + vSpread.y * vUp[ 2 ];

        vView.x = 8192.0f * vDir.x;
        vView.y = 8192.0f * vDir.y;
        vView.z = 8192.0f * vDir.z;

        VecAngles( vView, EstimatedViewAngles );

        NormalizeVector( EstimatedViewAngles );

        qDifference = vAng - EstimatedViewAngles;

        NormalizeVector( qDifference );

        fDiff = sqrt( ( qDifference.x * qDifference.x ) + ( qDifference.y * qDifference.y ) );

        if( ( fDiff <= 0.001f ) || ( fDiff >= fDiffOld ) )
            break;

        fDiffOld = fDiff;

        pflInAngles += qDifference;

        g_Math.NormalizeVector( qDifference );
    }
 
  • Like
Reactions: Rake
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Similar threads

Community Mods