-
Автор темы
- #1
Код:
#pragma once
#include "../../render.hpp"
#include "../../helpers/math.hpp"
#include "../../valve_sdk/csgostructs.hpp"
#include "../../options.hpp"
#include "../../render.hpp"
#include <vector>
class MovementRe
{
public:
void MovementR(CUserCmd* cmd);
bool MovementP(CUserCmd* cmd);
void MovementD();
private:
struct UserCmd
{
QAngle viewAngles;
float forwardmove;
float sidemove;
float upmove;
int buttons;
Vector position;
}
Vector startVec;
std::vector<UserCmd> CmdTmp;
UserCmd tempcmd;
bool f2 = true;
bool f1 = true;
bool isPlayingback = false;
};
extern MovementRe g_MovementRecorder;
C++:
#include "movement_recorder.h"
MovementRe g_MovementRecorder;
void MovementRe::MovementR(CUserCmd* cmd)
{
if (GetAsyncKeyState(g_Options.movement_recorder))
{
if (f2)
{
CmdTmp = {};
startVec = g_LocalPlayer->abs_origin();//Set where recording starts
}
tempcmd.position = csgo->local->abs_origin();
tempcmd.buttons = cmd->buttons;
tempcmd.forwardmove = cmd->forwardmove;
tempcmd.sidemove = cmd->sidemove;
tempcmd.upmove = cmd->upmove;
tempcmd.viewAngles = cmd->viewangles;
CmdTmp.push_back(tmpcmd);
f2 = false;
}
else
{
f2 = true;
}
}
void VectorSubtract(const Vector& a, Vector& b, Vector& c)
{
CHECK_VALID(a);
CHECK_VALID(b);
c.x = a.x - b.x;
c.y = a.y - b.y;
c.z = a.z - b.z;
}
bool MovementRe::MovementP(CUserCmd* cmd)
{
bool ret = false;
if (GetAsyncKeyState(g_Options.movement_play))
{
ret = true;
if (!isPlayingback)
{
float dist = Math::VectorDistance(g_LocalPlayer->abs_origin(), startVec);
if (dist < 1)
{
iDist = Color(0, 255, 0);
isPlayingback = true; //start playback
}
else
{
Vector finalVec;
VectorSubtract(startVec, g_LocalPlayer->abs_origin(), finalVec);
Math::VectorAngles(finalVec, cmd->viewangles);
cmd->forwardmove = dist;
}
}
else
{
//playback
if (i >= CmdTmp.size())
{
i = 0;//reset
isPlayingback = false;
}
else
{
cmd->buttons = CmdTmp[i].buttons;
cmd->forwardmove = CmdTmp[i].forwardmove;
cmd->sidemove = CmdTmp[i].sidemove;
cmd->upmove = CmdTmp[i].upmove;
cmd->viewangles = CmdTmp[i].viewangles;
i++;
}
}
}
else
{
i = 0;//reset
isPlayingback = false;//stop playback
}
return ret;
}
void MovementRe::MovementD()
{
if (!g_Options.movement_recording)
return;
if (!g_EngineClient->IsInGame() && !g_EngineClient->IsConnected())
return;
if (g_LocalPlayer->m_vecOrigin().DistTo(startVec) <= 4000)
{
Render::Get().RenderCircle3D(startVec, 90.f, 20.f, iDist);
Render::Get().RenderCircle3D(startVec, 90.f, 105.f, iDist);
}
if (GetAsyncKeyState(g_Options.movement_recorder))
{
int w, h;
g_EngineClient->GetScreenSize(w, h);
Render::Get().RenderText("RECORDING", ImVec2(w - 120, 700), 25.f, Color(255,0,0), false, true);
}
if (GetAsyncKeyState(g_Options.movement_play))
{
int w, h;
g_EngineClient->GetScreenSize(w, h);
Render::Get().RenderText("RE-PLAYING", ImVec2(w - 130, 716), 25.f, Color(0, 255, 0), false, true);
}
//Drawing the path
for (int i = 0; i < movement_recorder.items.CmdFinal.size(); i++) {
auto tracer = movement_recorder.items.CmdFinal.at(i);
if (csgo->local->GetOrigin().DistTo(tracer.position) <= 120)
if (Math::WorldToScreen(tracer.position, to_world) && Math::WorldToScreen(last_pos, last_w2s))
Drawing::DrawLine(to_world.x, to_world.y, last_w2s.x, last_w2s.y, Color(255,0,0));
last_pos = tracer.position;
}
}
abs_origin = GetOrigin or m_vecOrigin;