Начинающий
Начинающий
- Статус
- Оффлайн
- Регистрация
- 31 Янв 2026
- Сообщения
- 14
- Реакции
- 0
Я чёт решил сделать жёсткий скид нла на bullet tracer а получился какой то я не знаю что, я смотрю на это и у меня руки дрожат, помогите сделать норм Bullet Tracer
Только подготовьтесь там пздц по коду
Только подготовьтесь там пздц по коду
Подготовтесь:
#pragma once
#include "bullettracer.h"
#include "../../core/interfaces.h"
#include "../../core/variables.h"
#include "../../core/sdk.h"
#include "../../sdk/entity.h"
#include "../../sdk/interfaces/i_engine_client.h"
#include "../../../dependencies/imgui/imgui.h"
#include <vector>
#include <algorithm>
namespace F::VISUALS::BULLETTRACER
{
struct BulletTrace_t
{
Vector_t start;
Vector_t end;
float time;
Color_t color;
};
std::vector<BulletTrace_t> g_bulletTraces;
const float TRACE_LIFETIME = 1.0f;
bool Setup()
{
g_bulletTraces.clear();
return true;
}
void Shutdown()
{
g_bulletTraces.clear();
}
void ClearTraces()
{
g_bulletTraces.clear();
}
void OnBulletImpact(const Vector_t& start, const Vector_t& end)
{
if (!C_GET(bool, Vars.bBulletTracer) || !I::GlobalVars)
return;
BulletTrace_t trace;
trace.start = start;
trace.end = end;
trace.time = I::GlobalVars->flCurrentTime;
trace.color = C_GET(Color_t, Vars.colBulletTracer);
g_bulletTraces.push_back(trace);
}
bool WorldToScreen(const Vector_t& world, ImVec2& screen)
{
ViewMatrix_t viewMatrix = SDK::ViewMatrix;
float w = viewMatrix[3][0] * world.x + viewMatrix[3][1] * world.y + viewMatrix[3][2] * world.z + viewMatrix[3][3];
if (w < 0.001f)
return false;
ImGuiIO& io = ImGui::GetIO();
float invw = 1.0f / w;
screen.x = (io.DisplaySize.x * 0.5f) + (0.5f * ((viewMatrix[0][0] * world.x + viewMatrix[0][1] * world.y + viewMatrix[0][2] * world.z + viewMatrix[0][3]) * invw) * io.DisplaySize.x + 0.5f);
screen.y = (io.DisplaySize.y * 0.5f) - (0.5f * ((viewMatrix[1][0] * world.x + viewMatrix[1][1] * world.y + viewMatrix[1][2] * world.z + viewMatrix[1][3]) * invw) * io.DisplaySize.y + 0.5f);
return true;
}
void Render()
{
if (!C_GET(bool, Vars.bBulletTracer) || !I::Engine || !I::Engine->IsInGame() || !I::GlobalVars)
return;
float currentTime = I::GlobalVars->flCurrentTime;
g_bulletTraces.erase(
std::remove_if(g_bulletTraces.begin(), g_bulletTraces.end(),
[currentTime](const BulletTrace_t& trace) {
return (currentTime - trace.time) > TRACE_LIFETIME;
}),
g_bulletTraces.end()
);
ImDrawList* drawList = ImGui::GetForegroundDrawList();
for (const auto& trace : g_bulletTraces)
{
float age = currentTime - trace.time;
float alpha = 1.0f - (age / TRACE_LIFETIME);
alpha = std::max(0.0f, std::min(1.0f, alpha));
const int segments = 20;
for (int i = 0; i < segments; i++)
{
float t1 = (float)i / segments;
float t2 = (float)(i + 1) / segments;
Vector_t p1, p2;
p1.x = trace.start.x + (trace.end.x - trace.start.x) * t1;
p1.y = trace.start.y + (trace.end.y - trace.start.y) * t1;
p1.z = trace.start.z + (trace.end.z - trace.start.z) * t1;
p2.x = trace.start.x + (trace.end.x - trace.start.x) * t2;
p2.y = trace.start.y + (trace.end.y - trace.start.y) * t2;
p2.z = trace.start.z + (trace.end.z - trace.start.z) * t2;
ImVec2 screen1, screen2;
if (WorldToScreen(p1, screen1) && WorldToScreen(p2, screen2))
{
ImU32 outerGlow = IM_COL32(trace.color.r, trace.color.g, trace.color.b, static_cast<int>(15 * alpha));
drawList->AddLine(screen1, screen2, outerGlow, 6.0f);
ImU32 middleGlow = IM_COL32(trace.color.r, trace.color.g, trace.color.b, static_cast<int>(40 * alpha));
drawList->AddLine(screen1, screen2, middleGlow, 3.0f);
ImU32 innerGlow = IM_COL32(trace.color.r, trace.color.g, trace.color.b, static_cast<int>(100 * alpha));
drawList->AddLine(screen1, screen2, innerGlow, 1.5f);
ImU32 centerLine = IM_COL32(trace.color.r, trace.color.g, trace.color.b, static_cast<int>(255 * alpha));
drawList->AddLine(screen1, screen2, centerLine, 0.8f);
}
}
}
}
}
