ЧВК EB_LAN
-
Автор темы
- #1
code_language.lua:
local ffi = require("ffi")
ffi.cdef[[
typedef struct
{
unsigned char r, g, b;
signed char exponent;
} ColorRGBExp32;
typedef struct
{
float x;
float y;
float z;
} vec3_t;
typedef struct
{
float x;
float y;
} vec2_t;
typedef struct
{
int flags;
vec3_t origin;
float radius;
ColorRGBExp32 color;
float die;
float decay;
float minlight;
int key;
int style;
vec3_t m_Direction;
float m_InnerAngle;
float m_OuterAngle;
} dlight_t, *dlight_ptr_t;
]]
local engine_effects = memory.create_interface("engine.dll", "VEngineEffects001")
local engine_effects_class = ffi.cast(ffi.typeof("void***"), engine_effects)
local engine_effects_vtbl = engine_effects_class[0]
local alloc_dlight = ffi.cast("dlight_ptr_t(__thiscall*)(void*, int)", engine_effects_vtbl[4])
local Get = menu.find
local AddCheckbox = menu.add_checkbox
local AddSlider = menu.add_slider
local cfg_dlights = AddCheckbox("Dlights", "Toggle")
local colly = cfg_dlights:add_color_picker("bruh color")
local cfg_dlights_radius = AddSlider("Dlights", "Dlights Radius", 1.0, 500.0)
local cfg_dlights_decay = AddSlider("Dlights", "Dlights Decay", 1.0, 500.0)
local cfg_dlights_exponent = AddSlider("Dlights", "Dlights Exponent", 1, 20)
local cfg_dlights_style = AddSlider("Dlights", "Dlights Style", 0, 11)
local dlight = nil
callbacks.add(e_callbacks.PAINT, function()
local localPlayerIdx = engine.get_local_player_index()
local localEntity = entity_list.get_entity(localPlayerIdx)
if not cfg_dlights:get() or not localEntity then dlight = nil; return end
if not dlight then dlight = alloc_dlight(engine_effects_class, localPlayerIdx) end
local origin = localEntity:get_render_origin()
local color = colly:get()
local position = ffi.new("vec3_t")
position.x = origin.x
position.y = origin.y
position.z = origin.z + 7 -- Maked + 7 cuz without this magic value dlight still rendering under map and seems like a shit
dlight.flags = 0x2
dlight.style = cfg_dlights_style:get()
dlight.key = localPlayerIdx
dlight.radius = cfg_dlights_radius:get()
dlight.decay = cfg_dlights_decay:get()
dlight.origin = position
dlight.m_Direction = position
dlight.die = global_vars.cur_time() + 0.05
dlight.color.r = color.r * 255
dlight.color.g = color.g * 255
dlight.color.b = color.b * 255
dlight.color.exponent = cfg_dlights_exponent:get()
end)
Последнее редактирование: