CS 1.6 horrible “autostrafer”
1) no loose speed on turns
2) work good on any aa (sv_airaccelerate)
3) fully invisible (dunno why u use viewangles, if you already strafing with sidemove and forwardmove)
4) work on any direction (also have auto direction)
Btw, author of algorithm is Terazoid. In another thing its just basic physics.
P.S. Sorry for bad English
rc(strafe_dir, "strafe_dir", "1");
rc(strafe_speed, "strafe_speed", "69.0");
rc(strafe_fps, "strafe_fps", "1");
rc(strafe_fastrun, "strafe_fastrun", "1");
rc(strafe_sidemove, "strafe_sidemove", "437.8928");
rc(strafe_angle, "strafe_angle", "30.0");
void StrafeHack(float frametime, struct usercmd_s *cmd)
{
if(func.bStrafe && !(g_Local.ppmove->flags & FL_ONGROUND) && (g_Local.ppmove->movetype != 5) && !g_Local.bSlowDown)
{
float dir = 0.0f;
int dir_value = cvar.strafe_dir->value;
if(dir_value == 1)dir = 0 * M_PI / 180.0f;
else if(dir_value == 2) dir = 90 * M_PI / 180.0f;
else if(dir_value == 3) dir = 180 * M_PI / 180.0f;
else if(dir_value == 4) dir = -90 * M_PI / 180.0f;
if(g_Local.fSpeed < 15.0f)
{
if(cmd->buttons&IN_FORWARD)
{
if(cmd->buttons&IN_MOVELEFT)
{
cmd->forwardmove = 900;
cmd->sidemove = -900;
}
else if(cmd->buttons&IN_MOVERIGHT)
{
cmd->forwardmove = 900;
cmd->sidemove = 900;
}
else
cmd->forwardmove = 900;
}
else if(cmd->buttons&IN_BACK)
{
if(cmd->buttons&IN_MOVELEFT)
{
cmd->forwardmove = -900;
cmd->sidemove = -900;
}
else if(cmd->buttons&IN_MOVERIGHT)
{
cmd->forwardmove = -900;
cmd->sidemove = 900;
}
else
cmd->forwardmove = -900;
}
else if(cmd->buttons&IN_MOVELEFT)
cmd->sidemove = -900;
else if(cmd->buttons&IN_MOVERIGHT)
cmd->sidemove = 900;
else
cmd->forwardmove = 900;
}
else
{
float va_speed = atan2(g_Local.ppmove->velocity.y, g_Local.ppmove->velocity.x);
float va[3] = {};
g_Engine.GetViewAngles(va);
float adif = va_speed - va[1] * M_PI / 180.0f - dir;
adif = sin(adif);
adif = atan2(adif, sqrt(1 - adif*adif));
cmd->sidemove = (cvar.strafe_sidemove->value)*(adif > 0 ? 1 : -1);
cmd->forwardmove = 0;
float angle;
float osin, ocos, nsin, ncos;
angle = cmd->viewangles.y * M_PI / 180.0f;
osin = sin(angle);
ocos = cos(angle);
angle = 2.0f * cmd->viewangles.y * M_PI / 180.0f - va_speed + dir;
nsin = sin(angle);
ncos = cos(angle);
cmd->forwardmove = cmd->sidemove * (osin * ncos - ocos * nsin);
cmd->sidemove *= osin * nsin + ocos * ncos;
float fs = 0;
if(atan2(cvar.strafe_angle->value / g_Local.fSpeed, 1.0f) >= abs(adif))
{
Vector vBodyDirection;
if(dir_value & 1)
vBodyDirection = g_Local.vForward;
else
vBodyDirection = g_Local.vRight;
vBodyDirection[2] = 0;
vBodyDirection = vBodyDirection.Normalize();
float vel = POW(vBodyDirection[0] * g_Local.ppmove->velocity[0]) + POW(vBodyDirection[1] * g_Local.ppmove->velocity[1]);
fs = sqrt(cvar.strafe_speed->value * 100000 / vel);
}
cmd->forwardmove += fs;
}
float sdmw = cmd->sidemove;
float fdmw = cmd->forwardmove;
switch((int)cvar.strafe_dir->value)
{
case 1:
cmd->forwardmove = fdmw;
cmd->sidemove = sdmw;
break;
case 2:
cmd->forwardmove = -sdmw;
cmd->sidemove = fdmw;
break;
case 3:
cmd->forwardmove = -fdmw;
cmd->sidemove = -sdmw;
break;
case 4:
cmd->forwardmove = sdmw;
cmd->sidemove = -fdmw;
break;
}
}
}
|