RCS Not Writing Angles

Posts 1–10 of 10 · Page 1 of 1
RCS Not Writing Angles
"My" RCS Code
Code:
void NormalizeAngles(Vector &vecAngle)
{


	if (!std::isfinite(vecAngle.x))
		vecAngle.x = 0.0f;
	if (!std::isfinite(vecAngle.y))
		vecAngle.y = 0.0f;

	while (vecAngle.y < -180.0f)
		vecAngle.y += 360.0f;
	while (vecAngle.y > 180.0f)
		vecAngle.y -= 360.0f;

	if (vecAngle.x > 89.0f)
		vecAngle.x = 89.0f;
	if (vecAngle.x < -89.0f)
		vecAngle.x = -89.0f;

	vecAngle.z = 0.0f;
}

void RCS()
{
	DrawString("RCS running", menux + 250, menuy, MenuR, MenuG, MenuB, pFontSmall);
	if (RCSEnabled)
	{
		DrawString("RCS enabled", menux + 250, menuy + 20, MenuR, MenuG, MenuB, pFontSmall);
		static Vector vecOldPunchAngle = Vector(0, 0, 0);

		Vector vecPunchAngles = Nsane.Read<Vector>(LocalBase + Punch);
		Vector vecViewAngles = Nsane.Read<Vector>(dwClientState + ViewAngle);

		if (GetAsyncKeyState(VK_LBUTTON) & 0x8000)
		{
			DrawString("RCS button pressed", menux + 250, menuy + 40, MenuR, MenuG, MenuB, pFontSmall);
			Vector vecCurrent = { vecPunchAngles.x - vecOldPunchAngle.x, vecPunchAngles.y - vecOldPunchAngle.y, 0 };

			vecViewAngles.x = vecViewAngles.x - (vecCurrent.x * 2);
			vecViewAngles.y = vecViewAngles.y - (vecCurrent.y * 2);

			//NormalizeAngles(vecViewAngles);

			Nsane.Write<Vector>(dwClientState + ViewAngle, vecViewAngles);
			//Nsane.Write<Vector>(dwClientState + ViewAngle, (0, 0, 0)); // Works
		}

		vecOldPunchAngle = vecPunchAngles;
	}
}
and before you ask, yes my offsets are up to date.

so im having a problem, i have strings saying that everything is running but the angles are not being written. any help?

Epik helped me write this and he said it should 100% work
Not even looking at your code. Please separate that cancer normalization statement into normalization and clamping functions.
Quote Originally Posted by d4rkW View Post
Not even looking at your code. Please separate that cancer normalization statement into normalization and clamping functions.
not trying to be ignorant but why do i need to do that? if i have to call both of them anyways why not just make them into one function
Quote Originally Posted by ImWhacky View Post
not trying to be ignorant but why do i need to do that? if i have to call both of them anyways why not just make them into one function
Because you don't always want to do both at the same time? Once you go internal you will see why sometimes you need one or the other, but not both, also it's just good programming practice imo.
Quote Originally Posted by d4rkW View Post
Because you don't always want to do both at the same time? Once you go internal you will see why sometimes you need one or the other, but not both, also it's just good programming practice imo.
ok that makes sense, since i basically had Epik write this for me what should be in clamp just this?

Code:
while (vecAngle.y < -180.0f)
	vecAngle.y += 360.0f;
while (vecAngle.y > 180.0f)
	vecAngle.y -= 360.0f;
if (vecAngle.x > 89.0f)
	vecAngle.x = 89.0f;
if (vecAngle.x < -89.0f)
	vecAngle.x = -89.0f;
Quote Originally Posted by ImWhacky View Post
ok that makes sense, since i basically had Epik write this for me what should be in clamp just this?

Code:
while (vecAngle.y < -180.0f)
    vecAngle.y += 360.0f;
while (vecAngle.y > 180.0f)
    vecAngle.y -= 360.0f;
if (vecAngle.x > 89.0f)
    vecAngle.x = 89.0f;
if (vecAngle.x < -89.0f)
    vecAngle.x = -89.0f;
Code:
inline float NormalizeAngle(float flAng)
{
    if(!std::isfinite(flAng))
    {
        return 0.0f;
    }
 
    return std::remainder(flAng, 360.0f);
}
Code:
inline void ClampViewAngles(Vector3_t& vecAng)
{
    vecAng.x = std::max(-89.0f, std::min(89.0f, NormalizeAngle(vecAng.x)));
    vecAng.y = NormalizeAngle(vecAng.y);
    vecAng.z = 0.0f;
}
Quote Originally Posted by ImWhacky View Post
not trying to be ignorant but why do i need to do that? if i have to call both of them anyways why not just make them into one function
You should normalize your vector whenever you did any operation with them. This will prevent you from quadrant errors. Clamping has to be done once before writing the angles. If you're calling the normalize function whenever you're doing any operation with your vector, you're clamping your angles before you want them to be clamped, resulting in values that might be cut off before you finished doing operations with them.

Quote Originally Posted by ImWhacky View Post
ok that makes sense, since i basically had Epik write this for me what should be in clamp just this?

Code:
while (vecAngle.y < -180.0f)
	vecAngle.y += 360.0f;
while (vecAngle.y > 180.0f)
	vecAngle.y -= 360.0f;
if (vecAngle.x > 89.0f)
	vecAngle.x = 89.0f;
if (vecAngle.x < -89.0f)
	vecAngle.x = -89.0f;
That's still normalization + clamp.
shouldn't it be in a loop :S
also i'd use if shotsfired >= 1 instead
Quote Originally Posted by ImWhacky View Post
//Nsane.Write<Vector>(dwClientState + ViewAngle, (0, 0, 0)); // Works
If that did work, then set
Code:
Vector vecOldPunchAngle;
Outside the loop.

If nothing still works, add me on skype. (signature)

-------

Quote Originally Posted by voziak View Post
shouldn't it be in a loop :S
also i'd use if shotsfired >= 1 instead
This is also something to consider,
Code:
If (Shotfired > 1)
Will set the recoil for only automatic weapons and not on awp,scout,pistol... if you don't set up a weapon check.
1 week has passed and no further replies have been made by the OP. Assuming solved.

/Closed.
Posts 1–10 of 10 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us