ffi.cdef[[
struct m_flposeparameter_t {
int sznameindex;
int flags;
float value;
float state;
float loop;
};
]]
math.round = function(a) return math.floor(a + 0.5) end
se.time_to_ticks = function (time)
return math.round(time / globalvars.get_interval_per_tick())
end
ffi_ptrs = {
ent_list = ffi.cast("void***", se.create_interface("client.dll", "VClientEntityList003"))
}
ffi_ptrs.m_flposeparameter = ffi.cast('struct m_flposeparameter_t*(__thiscall*)(void*, int)',
client.find_pattern('client.dll', '55 8B EC 8B 45 08 57 8B F9 8B 4F 04 85 C9 75 15'))
ffi_ptrs.get_ent_address = ffi.cast("uintptr_t(__thiscall*)(void*, int)", ffi_ptrs.ent_list[0][3])
entity_t.address = function(s)
return ffi_ptrs.get_ent_address(ffi_ptrs.ent_list, s:get_index())
end
entity_t.studio_hdr = function(s)
return ffi.cast('void**', s:address() + 0x2950)[0]
end
entity_t.get_poseparam = function(s, index)
if not s or not s:address() then return end
local studio_hdr = s:studio_hdr()
if not studio_hdr then return end
return ffi_ptrs.m_flposeparameter(studio_hdr, index)
end
entity_t.flags = function(s, flag)
local flags = s:get_prop_int(se.get_netvar("DT_BasePlayer", "m_fFlags"))
if not flag then return flags end
return bit.band(flags, flag) == flag
end
entity_t.in_air = function(s)
return not s:flags(1)
end
local pitch_ticks = 0
client.register_callback("paint", function()
local lp = entitylist.get_local_player()
if not lp or not lp:is_alive() then pitch_ticks = 0 return end
local tickcount = globalvars.get_tick_count()
if lp:in_air() then
pitch_ticks = -1
elseif pitch_ticks < 0 and pitch_ticks > -4 then
pitch_ticks = pitch_ticks - 1
elseif pitch_ticks <= -4 then
pitch_ticks = tickcount + se.time_to_ticks(1)
end
local body_pitch = lp:get_poseparam(12)
if body_pitch then
if tickcount < pitch_ticks and pitch_ticks > 0 and not lp:in_air() then
body_pitch.value, body_pitch.state = 0.5, 0.5
else
body_pitch.value, body_pitch.state = -90, 90
end
end
end)
client.register_callback("unload", function()
local lp = entitylist.get_local_player()
if not lp or not lp:is_alive() then return end
local body_pitch = lp:get_poseparam(12)
if body_pitch then body_pitch.value, body_pitch.state = -90, 90 end
end)