#reserved
edit: sooo...
In the previous post I showed you how to get the camera position of a specified entity.
We now need our viewangles(yaw and pitch[roll is not used in most fps). S4 provides the camera directions in vectors.
PHP Code:
v55 = sub_20240E0();
v67 = sub_20240E0();
v53 = sub_20240E0();
v10 = *(float *)(v55 + 516); // z
v11 = *(float *)(v67 + 512); // y
v12 = *(float *)(v53 + 508); // x
just grab them. now you can just leave them as unit vectors or you can convert them to "real" angles. For w2s you will just need the unit vectors in a matrix. Coming back soon.
I ripped this function to convert unit vectors to angles from the source engine sdk - because math.. fuck it.
PHP Code:
void VectorAngles(Vector forward, QAngle angles)
{
Assert(s_bMathlibInitialized);
float tmp, yaw, pitch;
if (forward[1] == 0 && forward[0] == 0)
{
yaw = 0;
if (forward[2] > 0)
pitch = 270;
else
pitch = 90;
}
else
{
yaw = (atan2(forward[1], forward[0]) * 180 / M_PI);
if (yaw < 0)
yaw += 360;
tmp = sqrt(forward[0] * forward[0] + forward[1] * forward[1]);
pitch = (atan2(-forward[2], tmp) * 180 / M_PI);
if (pitch < 0)
pitch += 360;
}
angles[0] = pitch;
angles[1] = yaw;
angles[2] = 0;
}
ps: forward vector is mostly 'z' or '-z' component. You may need to omit the clamping and
reorienting to s4's coordinate system.