Гайд Paintball Bullet Impact

Новичок
Статус
Оффлайн
Регистрация
9 Окт 2021
Сообщения
23
Реакции[?]
40
Поинты[?]
3K
Demo:

C++:
class IVEfx
{
public:

    int Draw_DecalIndexFromName(char* name)
    {
        using Type = int(__thiscall*)(void*, char*);

        return GetVirtualMethod<Type>(this, 0)(this, name);
    }
};

bool UTIL_Precache(const char* szModelName, const char* szTable) noexcept
{
    static auto ClientStringTableContainer = Interfaces::GetInterface("engine", "VEngineClientStringTable001");

    auto FindTable = GetVirtualMethod<void* (__thiscall*)(void*, const char*) >(ClientStringTableContainer, 3);

    if (void* m_pPrecacheTable = FindTable(ClientStringTableContainer, szTable); m_pPrecacheTable)
    {
        auto AddString = GetVirtualMethod<int(__thiscall*)(void*, bool, const char*, int, const void*) >(m_pPrecacheTable, 8);

        AddString(m_pPrecacheTable, false, szModelName, -1, 0);

        return true;
    }

    return false;
}

namespace Paintball
{
    constexpr int iMaxDecals = 2048;

    std::vector<int> TexturesIndexes;

    void OnStartUp()
    {
        // r_decals var is hidden!
        // Engine->ClientCmd_Unrestricted("r_decals 2048");
        //

        if (auto r_decals = g_Cvar->FindVar("r_decals"); r_decals)
        {
            r_decals->SetValue(iMaxDecals);
        }
    }

    void OnLevelInit()
    {
        TexturesIndexes.clear();

        char DirectoryPath[MAX_PATH];

        GetCurrentDirectory(MAX_PATH, DirectoryPath);

        strcat(DirectoryPath, "\\csgo\\materials\\paintball");

        if (std::filesystem::is_directory(DirectoryPath) == false) // prevent crash.
            return;

        for (const auto& entry : std::filesystem::directory_iterator(DirectoryPath))
        {
            auto FilePath = entry.path().string();

            auto Pos = FilePath.find("paintball");

            if (Pos != std::string::npos)
            {
                strcpy(DirectoryPath, FilePath.c_str() + Pos);

                Pos = std::string(DirectoryPath).find(".vmt");

                if (Pos != std::string::npos)
                {
                    DirectoryPath[Pos] = 0;

                    UTIL_Precache(DirectoryPath, "decalprecache");

                    int TextureIndex = g_pEffects->Draw_DecalIndexFromName(DirectoryPath);

                    if (TextureIndex) {

                        TexturesIndexes.push_back(TextureIndex);
                    }
                }
            }
        }
    }
}

DetourHookInfo* DecalShoot;

void __fastcall Hooked_DecalShoot
(
    IVEfx* pSelf,void*, int textureIndex, int entity,
    const void* model, const Vector& model_origin, const Vector& model_angles,
    const Vector& position, const Vector* saxis, int flags, const Vector* pNormal, int nAdditionalDecalFlags
)
{
    if (Paintball::TexturesIndexes.empty() == false)
    {
        textureIndex = Paintball::TexturesIndexes.at(RandomInt(0, Paintball::TexturesIndexes.size() - 1));
    }

    using Type = void(__thiscall*)(IVEfx*, int, int, const void*, const Vector&, const Vector&, const Vector&, const Vector*, int, const Vector*, int);

   reinterpret_cast<Type>(DecalShoot->Original)(pSelf, textureIndex, entity, model, model_origin, model_angles, position, saxis, flags, pNormal, nAdditionalDecalFlags);
}

g_pEffects = (IVEfx*)(Interfaces::GetInterface("engine", "VEngineEffects001"));

DecalShoot = new DetourHookInfo(EngineModule + "55 8B EC 51 FF 75 2C", Hooked_DecalShoot, 1);


credits to altex from alliedmodders for the materials.
 

Вложения

Последнее редактирование:
Модератор форума
Участник
Статус
Оффлайн
Регистрация
26 Янв 2020
Сообщения
378
Реакции[?]
157
Поинты[?]
9K
Demo:

C++:
class IVEfx
{
public:

    int Draw_DecalIndexFromName(char* name)
    {
        using Type = int(__thiscall*)(void*, char*);

        return GetVirtualMethod<Type>(this, 0)(this, name);
    }
};

bool UTIL_Precache(const char* szModelName, const char* szTable) noexcept
{
    static auto ClientStringTableContainer = Interfaces::GetInterface("engine", "VEngineClientStringTable001");

    auto FindTable = GetVirtualMethod<void* (__thiscall*)(void*, const char*) >(ClientStringTableContainer, 3);

    if (void* m_pPrecacheTable = FindTable(ClientStringTableContainer, szTable); m_pPrecacheTable)
    {
        auto AddString = GetVirtualMethod<int(__thiscall*)(void*, bool, const char*, int, const void*) >(m_pPrecacheTable, 8);

        AddString(m_pPrecacheTable, false, szModelName, -1, 0);

        return true;
    }

    return false;
}

namespace Paintball
{
    constexpr int iMaxDecals = 2048;

    std::vector<int> TexturesIndexes;

    void OnStartUp()
    {
        // r_decals var is hidden!
        // Engine->ClientCmd_Unrestricted("r_decals 2048");
        //

        if (auto r_decals = g_Cvar->FindVar("r_decals"); r_decals)
        {
            r_decals->SetValue(iMaxDecals);
        }
    }

    void OnLevelInit()
    {
        TexturesIndexes.clear();

        char DirectoryPath[MAX_PATH];

        GetCurrentDirectory(MAX_PATH, DirectoryPath);

        strcat(DirectoryPath, "\\csgo\\materials\\paintball");

        if (std::filesystem::is_directory(DirectoryPath) == false) // prevent crash.
            return;

        for (const auto& entry : std::filesystem::directory_iterator(DirectoryPath))
        {
            auto FilePath = entry.path().string();

            auto Pos = FilePath.find("paintball");

            if (Pos != std::string::npos)
            {
                strcpy(DirectoryPath, FilePath.c_str() + Pos);

                Pos = std::string(DirectoryPath).find(".vmt");

                if (Pos != std::string::npos)
                {
                    DirectoryPath[Pos] = 0;

                    UTIL_Precache(DirectoryPath, "decalprecache");

                    int TextureIndex = g_pEffects->Draw_DecalIndexFromName(DirectoryPath);

                    if (TextureIndex) {

                        TexturesIndexes.push_back(TextureIndex);
                    }
                }
            }
        }
    }
}

DetourHookInfo* DecalShoot;

void __fastcall Hooked_DecalShoot
(
    IVEfx* pSelf,void*, int textureIndex, int entity,
    const void* model, const Vector& model_origin, const Vector& model_angles,
    const Vector& position, const Vector* saxis, int flags, const Vector* pNormal, int nAdditionalDecalFlags
)
{
    if (Paintball::TexturesIndexes.empty() == false)
    {
        textureIndex = Paintball::TexturesIndexes.at(RandomInt(0, Paintball::TexturesIndexes.size() - 1));
    }

    using Type = void(__thiscall*)(IVEfx*, int, int, const void*, const Vector&, const Vector&, const Vector&, const Vector*, int, const Vector*, int);

   reinterpret_cast<Type>(DecalShoot->Original)(pSelf, textureIndex, entity, model, model_origin, model_angles, position, saxis, flags, pNormal, nAdditionalDecalFlags);
}

g_pEffects = (IVEfx*)(Interfaces::GetInterface("engine", "VEngineEffects001"));

DecalShoot = new DetourHookInfo(EngineModule + "55 8B EC 51 FF 75 2C", Hooked_DecalShoot, 1);


credits to altex from alliedmodders for the materials.
so interesting...
 
coder of the year
Участник
Статус
Оффлайн
Регистрация
13 Мар 2019
Сообщения
886
Реакции[?]
266
Поинты[?]
4K
Сверху Снизу