-
Автор темы
- #1
Здрасте, хочу разобраться почему не работает мувмент рекодер. Не жду ответов по типу: "Выучи плюсы" и т.д. Я сам это знаю и понемногу их изучаю.
Гайд по мувменту брал от
Буду благодарен за помощь от всего сердца!
recoder != recorder)))
Гайд по мувменту брал от
Пожалуйста, авторизуйтесь для просмотра ссылки.
. Сам сурс моей
Пожалуйста, авторизуйтесь для просмотра ссылки.
. В архиве есть длл, вот
Пожалуйста, авторизуйтесь для просмотра ссылки.
.Буду благодарен за помощь от всего сердца!
recoder != recorder)))
recoder.cpp:
#include "recoder.hpp"
#include "../../utilities/math/math.hpp"
#include "E:\Downloads\trollsdk_v2-master\troll_sdk\menu\menu.hpp"
#include "../../sdk/Engine.h"
#include "../../sdk/Interfaces.h"
class Engine;
class Surface;
vec3_t movePositions[100000]; //Max 100000 Frame
namespace recoder {
bool gotostartpos = false;
struct Frame
{
float viewangles[2];
float forwardmove;
float sidemove;
float upmove;
int buttons;
unsigned char impulse;
short mousedx;
short mousedy;
Frame(c_usercmd* cmd)
{
this->viewangles[0] = cmd->viewangles.x;
this->viewangles[1] = cmd->viewangles.y;
this->forwardmove = cmd->forwardmove;
this->sidemove = cmd->sidemove;
this->upmove = cmd->upmove;
this->buttons = cmd->buttons;
this->impulse = cmd->impulse;
this->mousedx = cmd->mousedx;
this->mousedy = cmd->mousedy;
}
void Replay(c_usercmd* cmd)
{
cmd->viewangles.x = this->viewangles[0];
cmd->viewangles.y = this->viewangles[1];
cmd->forwardmove = this->forwardmove;
cmd->sidemove = this->sidemove;
cmd->upmove = this->upmove;
cmd->buttons = this->buttons;
cmd->impulse = this->impulse;
cmd->mousedx = this->mousedx;
cmd->mousedy = this->mousedy;
}
};
typedef std::vector<Frame> FrameContainer;
vec3_t startVec;
class Recorder
{
private:
bool is_recording_active = false;
bool is_rerecording_active = false;
size_t rerecording_start_frame;
FrameContainer recording_frames;
FrameContainer rerecording_frames;
public:
void StartRecording()
{
startVec = g_local->get_abs_origin();
this->is_recording_active = true;
}
void StopRecording()
{
this->is_recording_active = false;
}
bool IsRecordingActive() const
{
return this->is_recording_active;
}
void StartRerecording(size_t start_frame) {
this->is_rerecording_active = true;
this->rerecording_start_frame = start_frame;
}
void StopRerecording(bool merge = false) {
if (merge) {
this->recording_frames.erase(this->recording_frames.begin() + (this->rerecording_start_frame + 1), this->recording_frames.end());
this->recording_frames.reserve(this->recording_frames.size() + this->rerecording_frames.size());
this->recording_frames.insert(this->recording_frames.end(), this->rerecording_frames.begin(), this->rerecording_frames.end());
this->rerecording_frames.clear();
this->rerecording_start_frame = 0;
}
this->is_rerecording_active = false;
this->rerecording_frames.clear();
this->rerecording_start_frame = 0;
}
bool IsRerecordingActive() const {
return this->is_rerecording_active;
}
FrameContainer& GetActiveRerecording() {
return this->rerecording_frames;
}
FrameContainer& GetActiveRecording()
{
return this->recording_frames;
}
};
class Playback
{
private:
bool is_playback_active = false;
size_t current_frame = 0;
FrameContainer active_demo = FrameContainer();
public:
void StartPlayback(FrameContainer& frames)
{
this->is_playback_active = true;
this->active_demo = frames;
};
void StopPlayback()
{
this->is_playback_active = false;
this->current_frame = 0;
};
bool IsPlaybackActive() const
{
return this->is_playback_active;
}
size_t GetCurrentFrame() const
{
return this->current_frame;
};
void SetCurrentFrame(size_t frame)
{
this->current_frame = frame;
};
FrameContainer GetActiveDemo() const {
return this->active_demo;
}
};
Playback playback;
Recorder recorder;
void DrawRecorder()
{
if (g_vars.misc.Recorder)
return;
FrameContainer frames;
ImGuiWindowFlags windowFlags = ImGuiWindowFlags_NoCollapse;
if (!menu::opened) windowFlags |= ImGuiWindowFlags_NoInputs;
ImGui::Begin("Recorder");
{
ImGui::Columns(2, NULL, true);
{
if (ImGui::Button("Begin recording (3)", ImVec2(-1, 20))) { recorder.StartRecording(); }
if (ImGui::Button("Stop recording (4)", ImVec2(-1, 20))) { recorder.StopRecording(); }
if (ImGui::Button("Begin playback (X)", ImVec2(-1, 20))) { playback.StartPlayback(recorder.GetActiveRecording()); }
if (ImGui::Button("Stop playback (C)", ImVec2(-1, 20))) { playback.StopPlayback(); }
if (ImGui::Button("Clear frames (ALT)", ImVec2(-1, 20))) { recorder.GetActiveRecording().clear(); }
if (recorder.IsRecordingActive()) {
}
else if (recorder.IsRerecordingActive()) {
if (ImGui::Button("Save Re-recording (5)"))
recorder.StopRerecording(true);
if (ImGui::Button("Clear Re-recording (6)"))
recorder.StopRerecording(false);
}
else {
}
}
ImGui::NextColumn();
{
FrameContainer& recording = recorder.GetActiveRecording();
int currentFrame = playback.GetCurrentFrame();
int maxFrames = recording.size();
ImGui::Text(std::string("Current frame: " + std::to_string(currentFrame) + " / " + std::to_string(maxFrames)).c_str());
ImGui::Text(recorder.IsRecordingActive() ? "Recording: yes" : "Recording: no");
ImGui::Text(recorder.IsRerecordingActive() ? "ReRecording: yes" : "ReRecording: no");
ImGui::Text(playback.IsPlaybackActive() ? "Playing: yes" : "Playing: no");
}
ImGui::Columns(1);
}
ImGui::End();
}
static bool worldToScreen(const vec3_t& in, ImVec2& out) noexcept
{
const auto& matrix = interfaces->engine->worldToScreenMatrix();
const auto w = matrix._41 * in.x + matrix._42 * in.y + matrix._43 * in.z + matrix._44;
if (w < 0.001f)
return false;
out = ImGui::GetIO().DisplaySize;
out.x *= 1.0f + (matrix._11 * in.x + matrix._12 * in.y + matrix._13 * in.z + matrix._14) / w;
out.y *= 1.0f - (matrix._21 * in.x + matrix._22 * in.y + matrix._23 * in.z + matrix._24) / w;
return true;
}
void HookRecorder(c_usercmd* cmd) noexcept
{
if (!g_vars.misc.Recorder)
return;
bool isPlaybackActive = playback.IsPlaybackActive();
bool isRecordingActive = recorder.IsRecordingActive();
FrameContainer& recording = recorder.GetActiveRecording();
bool is_rerecording_active = recorder.IsRerecordingActive();
FrameContainer& rerecording = recorder.GetActiveRerecording();
if (GetAsyncKeyState(0x33)) //Key: 3 Start Recording
if (recording.empty())
recorder.StartRecording();
if (GetAsyncKeyState(0x34)) //Key: 4 Stop Recording
recorder.StopRecording();
if (GetAsyncKeyState(0x58)) //Key: X Start Playback
gotostartpos = true;
if (gotostartpos)
{
auto dist = g_local->get_abs_origin().dist_to(startVec);
if (cmd->buttons != 0)
gotostartpos = false;
if (dist < 1)
{
playback.StartPlayback(recorder.GetActiveRecording());
gotostartpos = false;
}
}
if (GetAsyncKeyState(0x43)) //Key: C Stop Playback
playback.StopPlayback();
if (GetAsyncKeyState(VK_MENU)) //Key: ALT Clear frames
recorder.GetActiveRecording().clear();
if (GetAsyncKeyState(0x35)) //Key: 5 Save Rerecording
{
if (recorder.IsRerecordingActive())
{
recorder.StopRerecording(true);
playback.StopPlayback();
}
}
if (GetAsyncKeyState(0x36)) //Key: 6 Clear Rerecording
{
if (recorder.IsRerecordingActive())
{
recorder.StopRerecording(false);
playback.StopPlayback();
}
}
if (isRecordingActive)
{
const size_t current_recording_frame = recording.size();
movePositions[current_recording_frame] = g_local->get_abs_origin(); //To visualize the movement
recording.push_back({ cmd });
}
else if (is_rerecording_active)
rerecording.push_back({ cmd });
if (isPlaybackActive)
{
const size_t current_playback_frame = playback.GetCurrentFrame();
if (cmd->buttons != 0) {
recorder.StartRerecording(current_playback_frame);
playback.StopPlayback();
}
try
{
recording.at(current_playback_frame).Replay(cmd);
interfaces->engine->setViewAngles(cmd->viewangles); //You can make a config bool for lock the view or not
if (current_playback_frame + 1 == recording.size())
{
playback.StopPlayback();
}
else
{
playback.SetCurrentFrame(current_playback_frame + 1);
}
}
catch (std::out_of_range)
{
playback.StopPlayback();
}
}
}
}
recoder.hpp:
#pragma once
namespace recoder {
void DrawRecorder();
}
Последнее редактирование: