Code Monkey home page Code Monkey logo

Comments (3)

OzymoGit avatar OzymoGit commented on May 23, 2024

Is it possible to do this without hooking any game function ? @danielkrupinski

from goesp.

avangersGameDestruction avatar avangersGameDestruction commented on May 23, 2024

it is possible code you need
Config.h
ColorToggle bombTimer{ 1.0f, 0.55f, 0.0f };

on the GUI.cpp :
ImGuiCustom::colorPicker("Bomb timer", config->misc.bombTimer);

inside Misc.cpp
`void Misc::drawBombTimer() noexcept
{
if (config->misc.bombTimer.enabled) {
for (int i = interfaces->engine->getMaxClients(); i <= interfaces->entityList->getHighestEntityIndex(); i++) {
Entity* entity = interfaces->entityList->getEntity(i);
if (!entity || entity->isDormant() || entity->getClientClass()->classId != ClassId::PlantedC4 || !entity->c4Ticking())
continue;

        constexpr unsigned font{ 0xc1 };
        interfaces->surface->setTextFont(font);
        interfaces->surface->setTextColor(255, 255, 255);
        auto drawPositionY{ interfaces->surface->getScreenSize().second / 8 };
        auto bombText{ (std::wstringstream{ } << L"Bomb on " << (!entity->c4BombSite() ? 'A' : 'B') << L" : " << std::fixed << std::showpoint << std::setprecision(3) << (std::max)(entity->c4BlowTime() - memory->globalVars->currenttime, 0.0f) << L" s").str() };
        const auto bombTextX{ interfaces->surface->getScreenSize().first / 2 - static_cast<int>((interfaces->surface->getTextSize(font, bombText.c_str())).first / 2) };
        interfaces->surface->setTextPosition(bombTextX, drawPositionY);
        drawPositionY += interfaces->surface->getTextSize(font, bombText.c_str()).second;
        interfaces->surface->printText(bombText.c_str());

        const auto progressBarX{ interfaces->surface->getScreenSize().first / 3 };
        const auto progressBarLength{ interfaces->surface->getScreenSize().first / 3 };
        constexpr auto progressBarHeight{ 5 };

        interfaces->surface->setDrawColor(50, 50, 50);
        interfaces->surface->drawFilledRect(progressBarX - 3, drawPositionY + 2, progressBarX + progressBarLength + 3, drawPositionY + progressBarHeight + 8);
        if (config->misc.bombTimer.rainbow)
            interfaces->surface->setDrawColor(rainbowColor(memory->globalVars->realtime, config->misc.bombTimer.rainbowSpeed));
        else
            interfaces->surface->setDrawColor(config->misc.bombTimer.color);

        static auto c4Timer = interfaces->cvar->findVar("mp_c4timer");

        interfaces->surface->drawFilledRect(progressBarX, drawPositionY + 5, static_cast<int>(progressBarX + progressBarLength * std::clamp(entity->c4BlowTime() - memory->globalVars->currenttime, 0.0f, c4Timer->getFloat()) / c4Timer->getFloat()), drawPositionY + progressBarHeight + 5);

        if (entity->c4Defuser() != -1) {
            if (PlayerInfo playerInfo; interfaces->engine->getPlayerInfo(interfaces->entityList->getEntityFromHandle(entity->c4Defuser())->index(), playerInfo)) {
                if (wchar_t name[128];  MultiByteToWideChar(CP_UTF8, 0, playerInfo.name, -1, name, 128)) {
                    drawPositionY += interfaces->surface->getTextSize(font, L" ").second;
                    const auto defusingText{ (std::wstringstream{ } << name << L" is defusing: " << std::fixed << std::showpoint << std::setprecision(3) << (std::max)(entity->c4DefuseCountDown() - memory->globalVars->currenttime, 0.0f) << L" s").str() };

                    interfaces->surface->setTextPosition((interfaces->surface->getScreenSize().first - interfaces->surface->getTextSize(font, defusingText.c_str()).first) / 2, drawPositionY);
                    interfaces->surface->printText(defusingText.c_str());
                    drawPositionY += interfaces->surface->getTextSize(font, L" ").second;

                    interfaces->surface->setDrawColor(50, 50, 50);
                    interfaces->surface->drawFilledRect(progressBarX - 3, drawPositionY + 2, progressBarX + progressBarLength + 3, drawPositionY + progressBarHeight + 8);
                    interfaces->surface->setDrawColor(0, 255, 0);
                    interfaces->surface->drawFilledRect(progressBarX, drawPositionY + 5, progressBarX + static_cast<int>(progressBarLength * (std::max)(entity->c4DefuseCountDown() - memory->globalVars->currenttime, 0.0f) / (interfaces->entityList->getEntityFromHandle(entity->c4Defuser())->hasDefuser() ? 5.0f : 10.0f)), drawPositionY + progressBarHeight + 5);

                    drawPositionY += interfaces->surface->getTextSize(font, L" ").second;
                    const wchar_t* canDefuseText;

                    if (entity->c4BlowTime() >= entity->c4DefuseCountDown()) {
                        canDefuseText = L"Can Defuse";
                        interfaces->surface->setTextColor(0, 255, 0);
                    } else {
                        canDefuseText = L"Cannot Defuse";
                        interfaces->surface->setTextColor(255, 0, 0);
                    }

                    interfaces->surface->setTextPosition((interfaces->surface->getScreenSize().first - interfaces->surface->getTextSize(font, canDefuseText).first) / 2, drawPositionY);
                    interfaces->surface->printText(canDefuseText);
                }
            }
        }
        break;
    }
}

}`

hope this helps you a lot

from goesp.

danielkrupinski avatar danielkrupinski commented on May 23, 2024

Added (f233abf)

from goesp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.