Новая ава блеять
-
Автор темы
- #1
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Увидел гайд Nixer и решил слить своего WalkBot'a
1.Settings.cpp:
2.Settings.h:
3.Client.cpp:
4.Misc.cpp:
5.Misc.h:
6.Hook_CreateMove:
7.Engine.cpp:
8.Engine.h:
9.Vector.hpp:
Вот и весь код.
Спастил из Astrium
1.Settings.cpp:
Код:
namespace WalkBot
{
bool WalkBot = false;
bool Bunnyhop = false;
float Distance = 0;
int Turn = 0;
}
Код:
namespace WalkBot
{
extern bool WalkBot;
extern bool Bunnyhop;
extern float Distance;
extern int Turn;
}
Код:
ImGui::Checkbox("Walkbot", &Settings::WalkBot::WalkBot);
ImGui::Checkbox("Bunnyhop", &Settings::WalkBot::Bunnyhop);
ImGui::Text("Distance to Wall");
ImGui::SliderFloat("%##float", &Settings::WalkBot::Distance, 0, 500, "%.1f", (1.0f));
ImGui::Text("Degrees Turn");
ImGui::SliderInt("%##int", &Settings::WalkBot::Turn, -180, 180, "%.1f");
Код:
void CMisc::Walkbot(CUserCmd* cmd, Vector& OrigAng)
{
bool walkbotBefore = false;
CBaseEntity* local = (CBaseEntity*)Interfaces::EntityList()->GetClientEntity(Interfaces::Engine()->GetLocalPlayer());
Vector viewangles;
Interfaces::Engine()->GetViewAngles(viewangles);
static int OldMouseX = OrigAng.y;
int mousedx = OldMouseX - OrigAng.y;
auto fDistanceToWall = [&](Vector diff = Vector(0, 0, 0))->float {
auto tmpviewangles = viewangles + diff;
trace_t tr;
Ray_t ray;
CTraceFilter filter;
filter.pSkip = local;
Vector begin = local->GetEyePosition(), t, end;
AngleVectors4(tmpviewangles, t);
NormalizeInOut(t, end);
end *= 8192.0f;
end += begin;
ray.Init(begin, end);
Interfaces::EngineTrace()->TraceRay(ray, 0x4600400B, &filter, &tr);
return (begin - tr.endpos).Size();
};
static float old1, old2, old3;
if (local->GetVelocity().Length() < 3)
{
viewangles.y += 2.0f;
}
float Distances = Settings::WalkBot::Distance;
if (fDistanceToWall() < Distances) // we are near to some wall
{
int turn = Settings::WalkBot::Turn;
float negativeDist = fDistanceToWall(Vector(0, -1, 0)), positiveDist = fDistanceToWall(Vector(0, 1, 0));
if (abs(negativeDist - positiveDist) < 1.0f)
{
viewangles.y += turn;
}
else
{
viewangles.y += positiveDist < negativeDist ? -1 : 1;
}
}
if (Settings::WalkBot::Bunnyhop)
{
if ((local->GetFlags() & FL_ONGROUND))
cmd->buttons |= IN_JUMP;
else
{
cmd->buttons |= IN_DUCK;
cmd->buttons &= ~IN_FORWARD;
}
}
if (abs(viewangles.x) > 0)
viewangles.x = 1;
while (viewangles.y > 180.0f)
viewangles.y -= 360.0f;
while (viewangles.y < -180.0f)
viewangles.y += 360.0f;
Interfaces::Engine()->SetViewAngles(viewangles);
if (!walkbotBefore)
{
cmd->forwardmove = 450.f;
walkbotBefore = true;
}
else if (walkbotBefore)
{
walkbotBefore = false;
cmd->forwardmove = 450.f;
}
}
Код:
void Walkbot(CUserCmd * cmd, Vector & OrigAng);
Код:
auto origAng = cmd->viewangles;
if (Settings::WalkBot::WalkBot)
Client::g_pMisc->Walkbot(pCmd, origAng);
Код:
void SinCos2(float a, float* s, float*c)
{
*s = sin(a);
*c = cos(a);
}
void NormalizeInOut(Vector &vIn, Vector &vOut)
{
float flLen = vIn.Length();
if (flLen == 0) {
vOut.Init(0, 0, 1);
return;
}
flLen = 1 / flLen;
vOut.Init(vIn.x * flLen, vIn.y * flLen, vIn.z * flLen);
}
void AngleVectors4(const Vector& qAngles, Vector& vecForward)
{
float sp, sy, cp, cy;
SinCos2((float)(qAngles[1] * (M_PI / 180.f)), &sy, &cy);
SinCos2((float)(qAngles[0] * (M_PI / 180.f)), &sp, &cp);
vecForward[0] = cp * cy;
vecForward[1] = cp * sy;
vecForward[2] = -sp;
}
Код:
void SinCos2(float a, float * s, float * c);
void NormalizeInOut(Vector & vIn, Vector & vOut);
void AngleVectors4(const Vector & qAngles, Vector & vecForward);
Код:
float Vector::Size()
{
return sqrt(pow(x, 2) + pow(y, 2) + pow(z, 2));
}
Спастил из Astrium