-
Автор темы
- #1
Код:
local function lerp_hsv(h_start, s_start, v_start, h_end, s_end, v_end, t)
local h = (h_end - h_start) * t + h_start
local s = (s_end - s_start) * t + s_start
local v = (v_end - v_start) * t + v_start
return h, s, v
end
local function get_lerp_time(entity)
local v6 = 0
local v7 = 0
local v8 = 0
local v10 = 0
local net_channel = {
[1] = utils.net_channel(),
[2] = utils.net_channel()
}
if entity ~= nil and entity:is_alive() then
net_channel[1] = utils.net_channel()
net_channel[2] = net_channel[1]
if net_channel[1] then
v8 = net_channel[1].sequence_nr[0]
v8 = net_channel[2].sequence_nr[1] + v8
v6 = v8
v10 = v6 / math.min(math.max(0 - (100 * -0.001) + 0, 0.001), 0.2)
return math.clamp(-1.7014636e38, math.min(math.max(v10, 0), 1), v10) -- clamped value to hsv-lerp
end
end
end
local function on_render()
local me = entity.get_local_player()
if me == nil or not me:is_alive() then
return
end
local h_start, s_start, v_start = color(255, 255, 255):to_hsv()
local h_end, s_end, v_end = color(151, 175, 54):to_hsv()
local ping_color = color(); do
local h, s, v = lerp_hsv(h_start, s_start, v_start, h_end, s_end, v_end, get_lerp_time(me))
ping_color:as_hsv(h, s, v, 255)
end
-- render things
end