Вопрос [gs] get_max_desync

Дизайнер
Статус
Оффлайн
Регистрация
18 Авг 2017
Сообщения
1,931
Реакции[?]
2,258
Поинты[?]
146K
Товары в продаже
1
Код:
local get_max_desync = function (animstate)
    local speedfactor = math.clamp(animstate.feet_speed_forwards_or_sideways, 0, 1)
    local avg_speedfactor = (animstate.stop_to_full_running_fraction * -0.3 - 0.2) * speedfactor + 1

    local duck_amount = animstate.duck_amount

    if duck_amount > 0 then
        local max_velocity = math.clamp(animstate.feet_speed_forwards_or_sideways, 0, 1)
        local duck_speed = duck_amount * max_velocity

        avg_speedfactor = avg_speedfactor + (duck_speed * (0.5 - avg_speedfactor))
    end

    return 58 * math.clamp(avg_speedfactor, .5, 1)
end
 
Пользователь
Статус
Оффлайн
Регистрация
3 Июл 2021
Сообщения
825
Реакции[?]
93
Поинты[?]
10K
Код:
local get_max_desync = function (animstate)
    local speedfactor = math.clamp(animstate.feet_speed_forwards_or_sideways, 0, 1)
    local avg_speedfactor = (animstate.stop_to_full_running_fraction * -0.3 - 0.2) * speedfactor + 1

    local duck_amount = animstate.duck_amount

    if duck_amount > 0 then
        local max_velocity = math.clamp(animstate.feet_speed_forwards_or_sideways, 0, 1)
        local duck_speed = duck_amount * max_velocity

        avg_speedfactor = avg_speedfactor + (duck_speed * (0.5 - avg_speedfactor))
    end

    return 58 * math.clamp(avg_speedfactor, .5, 1)
end
от душы, ты мой спаситель
 
ryo
Пользователь
Статус
Оффлайн
Регистрация
4 Июн 2021
Сообщения
323
Реакции[?]
113
Поинты[?]
2K
где в ските ебаный анимстеит брать
Код:
local ffi = require "ffi";

ffi.cdef [[
    typedef struct {
        char pad[ 3 ];
        char m_bForceWeaponUpdate; //0x4
        char pad1[ 91 ];
        void* m_pBaseEntity; //0x60
        void* m_pActiveWeapon; //0x64
        void* m_pLastActiveWeapon; //0x68
        float m_flLastClientSideAnimationUpdateTime; //0x6C
        int m_iLastClientSideAnimationUpdateFramecount; //0x70
        float m_flAnimUpdateDelta; //0x74
        float m_flEyeYaw; //0x78
        float m_flPitch; //0x7C
        float m_flGoalFeetYaw; //0x80
        float m_flCurrentFeetYaw; //0x84
        float m_flCurrentTorsoYaw; //0x88
        float m_flUnknownVelocityLean; //0x8C
        float m_flLeanAmount; //0x90
        char pad2[ 4 ];
        float m_flFeetCycle; //0x98
        float m_flFeetYawRate; //0x9C
        char pad3[ 4 ];
        float m_fDuckAmount; //0xA4
        float m_fLandingDuckAdditiveSomething; //0xA8
        char pad4[ 4 ];
        float m_vOriginX; //0xB0
        float m_vOriginY; //0xB4
        float m_vOriginZ; //0xB8
        float m_vLastOriginX; //0xBC
        float m_vLastOriginY; //0xC0
        float m_vLastOriginZ; //0xC4
        float m_vVelocityX; //0xC8
        float m_vVelocityY; //0xCC
        char pad5[ 4 ];
        float m_flUnknownFloat1; //0xD4
        char pad6[ 8 ];
        float m_flUnknownFloat2; //0xE0
        float m_flUnknownFloat3; //0xE4
        float m_flUnknown; //0xE8
        float m_flSpeed2D; //0xEC
        float m_flUpVelocity; //0xF0
        float m_flSpeedNormalized; //0xF4
        float m_flFeetSpeedForwardsOrSideWays; //0xF8
        float m_flFeetSpeedUnknownForwardOrSideways; //0xFC
        float m_flTimeSinceStartedMoving; //0x100
        float m_flTimeSinceStoppedMoving; //0x104
        bool m_bOnGround; //0x108
        bool m_bInHitGroundAnimation; //0x109
        float m_flTimeSinceInAir; //0x10A
        float m_flLastOriginZ; //0x10E
        float m_flHeadHeightOrOffsetFromHittingGroundAnimation; //0x112
        float m_flStopToFullRunningFraction; //0x116
        char pad7[ 4 ]; //0x11A
        float m_flMagicFraction; //0x11E
        char pad8[ 60 ]; //0x122
        float m_flWorldForce; //0x15E
        char pad9[ 462 ]; //0x162
        float m_flMaxYaw; //0x334
        float m_flMinYaw; //0x330
    } c_animstate;
]];

local native_GetClientEntity = vtable_bind("client.dll", "VClientEntityList003", 3, "uintptr_t(__thiscall*)(void*, int)");

local function get_animstate(entity)
    local player_ptr = native_GetClientEntity(entity);
    local animstate_ptr = ffi.cast("char*", player_ptr) + 0x9960;
    local state = ffi.cast("c_animstate**", animstate_ptr)[0];

    return state;
end

local function get_max_feetdelta(animstate)
    local duck_amount = animstate.m_fDuckAmount;

    local feet_speed_forwards_or_sideways = math.max(0, math.min(1, animstate.m_flFeetSpeedForwardsOrSideWays));
    local feet_speed_unknown_forward_or_sideways = math.max(1, animstate.m_flFeetSpeedUnknownForwardOrSideways);
    local value = (animstate.m_flStopToFullRunningFraction * -0.3 - 0.2) * feet_speed_forwards_or_sideways + 1;

    if duck_amount > 0 then
        value = value + duck_amount * feet_speed_unknown_forward_or_sideways * (0.5 - value);
    end

    local m_flMinBodyYaw = value * math.abs(animstate.m_flMinYaw);
    local m_flMaxBodyYaw = value * math.abs(animstate.m_flMaxYaw);

    if (math.abs(animstate.m_flEyeYaw - animstate.m_flGoalFeetYaw) <= m_flMaxBodyYaw) then
        if (m_flMinBodyYaw > math.abs(animstate.m_flEyeYaw - animstate.m_flGoalFeetYaw)) then
            return math.abs(m_flMinBodyYaw);
        else
            return math.abs(m_flMaxBodyYaw);
        end
    else
        return math.abs(m_flMaxBodyYaw);
    end
end


-- example
local me = entity.get_local_player();

if me == nil then
    return;
end

local animstate = get_animstate(me);
local max_delta = get_max_feetdelta(animstate);
 
Сверху Снизу