-
Автор темы
- #1
добавил в свою пасту норм бхоп, но почему-то крашит после const auto delta = math::NormalizeYaw(orig.y - RAD2DEG2(atan2(g_ctx.local()->GetVelocity().y, g_ctx.local()->GetVelocity().x))); в чем может быть проблема?
Код:
// This is an independent project of an individual developer. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com
#include "bunnyhop.h"
#include "prediction_system.h"
#define PI 3.14159265358979323846
#define RAD2DEG2(x) ((float)(x) * (float)(180.0f / (float)(PI)))
void bunnyhop::Run(Vector& orig)
{
if (g_ctx.local()->get_move_type() == MoveType_t::MOVETYPE_NOCLIP || g_ctx.local()->get_move_type() == MoveType_t::MOVETYPE_LADDER)
return;
if (g_cfg.misc.bunnyhop) {
static bool bLastJumped = false;
static bool bShouldFake = false;
if (!bLastJumped && bShouldFake)
{
bShouldFake = false;
g_ctx.get_command()->m_buttons |= IN_JUMP;
}
else if (g_ctx.get_command()->m_buttons & IN_JUMP)
{
if (g_ctx.local()->m_fFlags() & FL_ONGROUND)
{
bShouldFake = bLastJumped = true;
}
else
{
g_ctx.get_command()->m_buttons &= ~IN_JUMP;
bLastJumped = false;
}
}
else
{
bShouldFake = bLastJumped = false;
}
}
if (g_ctx.get_command()->m_buttons & IN_SPEED || !g_cfg.misc.airstrafe || g_ctx.local()->m_vecVelocity().Length2D() < 10.f)
return; // doesn't allow strafe when you hold shift and you're not moving
static float yaw_add = 0.f;
static const auto cl_sidespeed = m_cvar()->FindVar(crypt_str("cl_sidespeed"));
if (!(g_ctx.local()->m_fFlags() & FL_ONGROUND))
{
bool back = g_ctx.get_command()->m_buttons & IN_BACK;
bool forward = g_ctx.get_command()->m_buttons & IN_FORWARD;
bool right = g_ctx.get_command()->m_buttons & IN_MOVELEFT;
bool left = g_ctx.get_command()->m_buttons & IN_MOVERIGHT;
if (back) {
yaw_add = -180.f;
if (right)
yaw_add -= 45.f;
else if (left)
yaw_add += 45.f;
}
else if (right) {
yaw_add = 90.f;
if (back)
yaw_add += 45.f;
else if (forward)
yaw_add -= 45.f;
}
else if (left) {
yaw_add = -90.f;
if (back)
yaw_add -= 45.f;
else if (forward)
yaw_add += 45.f;
}
else {
yaw_add = 0.f;
}
orig.y += yaw_add;
g_ctx.get_command()->m_forwardmove = 0.f;
g_ctx.get_command()->m_sidemove = 0.f;
const auto delta = math::NormalizeYaw(orig.y - RAD2DEG2(atan2(g_ctx.local()->GetVelocity().y, g_ctx.local()->GetVelocity().x)));
g_ctx.get_command()->m_sidemove = delta > 0.f ? -cl_sidespeed->GetFloat() : cl_sidespeed->GetFloat();
orig.y = math::NormalizeYaw(orig.y - delta);
}
}