-
Автор темы
- #1
адаптация скит версии, улучшен экстраполейт, вроде что-то как-то пофиксил, не помню, включать в меню ЕСП


Код:
local debug_overlay do
debug_overlay = { }
local Vector = ffi.typeof [[struct {float x, y, z;}]]
local Color = ffi.typeof [[struct {uint8_t r, g, b, a;}]]
local native_AddBoxOverlayNew = utils.get_vfunc(
"engine.dll", "VDebugOverlay004", 21, "void(__thiscall*)(void *thisptr, const $ &origin, const $ &mins, const $ &maxs, const $ &angles, $ *face_color, $ *edge_color, float duration)", Vector, Vector, Vector, Vector, Color, Color
)
function debug_overlay.box_new(origin, mins, maxs, angles, face_color, edge_color, duration)
origin = Vector(origin:unpack())
mins = Vector(mins:unpack())
maxs = Vector(maxs:unpack())
angles = Vector(angles:unpack())
face_color = Color(face_color:unpack())
edge_color = Color(edge_color:unpack())
native_AddBoxOverlayNew(origin, mins, maxs, angles, face_color, edge_color, duration)
end
end
local data = {
simulation = {},
network = {},
esp = {},
}
local function player_move(player, origin, ticks)
if player == nil or not player:is_alive() then
return
end
local m_pred_velocity = player.m_vecVelocity
local from, to, normal = vector(), vector(), vector();
local tr;
local gravity = m_pred_velocity.z and -cvar.sv_gravity:float() or cvar.sv_jump_impulse:float()
gravity = gravity
from = origin
to = vector(
from.x + (m_pred_velocity.x * (globals.tickinterval * ticks)),
from.y + (m_pred_velocity.y * (globals.tickinterval * ticks)),
from.z + ((m_pred_velocity.z+gravity) * (globals.tickinterval * ticks))
)
tr = utils.trace_hull(from, to, player.m_vecMins, player.m_vecMaxs)
if tr.fraction ~= 1 then
for i = 1, 2 do
if m_pred_velocity:length() == 0 then
break
end
m_pred_velocity = m_pred_velocity - tr.plane.normal * m_pred_velocity:dot(tr.plane.normal)
local adjust = m_pred_velocity:dot(tr.plane.normal)
if adjust < 0 then
m_pred_velocity = m_pred_velocity - (tr.plane.normal * adjust)
end
from = tr.end_pos
to = from + (m_pred_velocity * (globals.tickinterval * (1 - tr.fraction)))
tr = utils.trace_hull(from, to, player.m_vecMins, player.m_vecMaxs)
if tr.fraction == 1 then
break
end
end
end
return tr.end_pos
end
local function update_record()
local players = entity.get_players(false, true)
if #players == 0 then
return
end
for i = 1, #players do
local player = players[i]
local idx = player:get_index()
local prev_record = data.simulation[idx]
if not player:is_alive() or player:is_dormant() then
data.simulation[idx] = nil
data.network[idx] = nil
else
local origin = player:get_origin()
local sim = to_ticks(player:get_simulation_time().current)
if prev_record ~= nil then
local delta = sim - prev_record.tick
if delta < 0 or (delta > 0 and delta < 64) then
local flags = player.m_fFlags
local origin_delta = origin - prev_record.origin
local teleport_distance = origin_delta:lengthsqr()
local extrapolated = player_move(player, origin, delta - 1)
if delta < 0 then
data.esp[idx] = 1
end
data.network[idx] = {
tick = delta - 1,
origin = extrapolated,
shifting = delta < 0,
lagcomp = teleport_distance > 4096
}
end
end
if data.esp[idx] == nil then
data.esp[idx] = 0
end
data.simulation[idx] = {
tick = sim,
origin = origin
}
end
end
end
local function on_render(ent)
if ent == nil or not ent:is_alive() then
return
end
local index = ent:get_index()
for idx, network in pairs(data.network) do
if ent == nil or not ent:is_alive() then
return
end
local delta = network.tick
if idx == index and (delta < 0 or (delta > 0 and delta < 64)) then
local is_lagcomp = network.lagcomp
local shifting = network.shifting
if is_lagcomp then
local predicted = network.origin
local min, max = ent.m_vecMins, ent.m_vecMaxs
local origin = ent:get_origin()
local w2s, w2s_min = origin:to_screen(), (min + predicted):to_screen()
if w2s ~= nil and w2s_min ~= nil then
render.line(w2s, w2s_min, color(47, 117, 221, 255))
end
debug_overlay.box_new(
predicted,
min,
max,
vector(),
color(0, 0, 0, 0),
color(47, 117, 221, 255),
globals.tickinterval * 2
)
end
local alpha = 0
if data.esp[idx] > 0 then
data.esp[idx] = data.esp[idx] - globals.frametime * 4
data.esp[idx] = data.esp[idx] < 0 and 0 or data.esp[idx]
alpha = data.esp[idx]
end
local tb = shifting or data.esp[idx] > 0
local lc = is_lagcomp
if not tb or lc then
local bbox = ent:get_bbox()
if bbox ~= nil then
alpha = bbox.alpha
end
end
local hashed = color(255, 45, 45, alpha * 255):to_hex()
local prefix = "\a" .. hashed
local text = ""
if tb then
text = prefix .. "SHIFTING TICKBASE"
end
if lc then
text = prefix .. "LAG COMP BREAKER"
end
return text
end
end
return ""
end
esp.enemy:new_text("TICKBASE MODE", "LAG COMP BREAKER", on_render)
events.net_update_end(update_record)