Osiris: [CODE] Bomb timer

Created on 22 Jul 2019  路  40Comments  路  Source: danielkrupinski/Osiris

misc.h

static float plantedTime = 0.0f;
    static float defusingTime = 0.0f;
    static bool plantingBomb = false;
    static bool defusingBomb = false;
    static bool haveDefusers = false;

    constexpr void bombEvents(GameEvent* event) noexcept
    {
        if (!config.misc.drawBombTimer) return;
        switch (fnv::hashRuntime(event->getName())) {
        case fnv::hash("bomb_beginplant"):
            plantingBomb = true;
            break;
        case fnv::hash("bomb_abortplant"):
            plantingBomb = false;
            break;
        case fnv::hash("bomb_planted"):
            plantedTime = memory.globalVars->currenttime;
            plantingBomb = false;
            break;
        case fnv::hash("bomb_begindefuse"):
            defusingBomb = true;
            defusingTime = memory.globalVars->currenttime;
            haveDefusers = event->getBool("haskit");
            break;
        case fnv::hash("bomb_abortdefuse"):
            defusingTime = 0.0f;
            defusingBomb = false;
            break;
        case fnv::hash("round_start"):
        case fnv::hash("bomb_exploded"):
        case fnv::hash("bomb_defused"):
            plantingBomb = false;
            defusingBomb = false;
            haveDefusers = false;
            plantedTime = 0.0f;
            defusingTime = 0.0f;
            break;
        }
    }

    static void drawTimer() noexcept
    {

        if (!interfaces.engine->isInGame()) return;
        auto local = interfaces.entityList->getEntity(interfaces.engine->getLocalPlayer());
        if (!local) return;
        static auto screen = interfaces.surface->getScreenSize();
        if (plantingBomb) {
            static auto text = interfaces.surface->getTextSize(Surface::font, L"Bomb is planting!");
            interfaces.surface->setTextFont(Surface::font);
            interfaces.surface->setTextPosition(5, (screen.second / 2) - (text.second / 2));
            if (local->getProperty<int>("m_iTeamNum") == 3) {
                interfaces.surface->setTextColor(255, 0, 0, 255);
            }
            else {
                interfaces.surface->setTextColor(0, 255, 0, 255);
            }
            interfaces.surface->printText(L"Bomb is planting!");
        }
        if (plantedTime > 0.0f) {
            float blowTime = plantedTime + interfaces.cvar->findVar("mp_c4timer")->getInt();
            float timer = blowTime - memory.globalVars->currenttime;

            if (timer > 0.0000f) {
                std::wstring timerText(L"Bomb timer: ");
                timerText += std::to_wstring(timer);
                static auto textSize = interfaces.surface->getTextSize(Surface::font, timerText.c_str());
                interfaces.surface->setTextFont(Surface::font);
                interfaces.surface->setTextPosition(5, (screen.second / 2) - textSize.second);
                if (local->getProperty<int>("m_iTeamNum") == 3) {
                    interfaces.surface->setTextColor(255, 0, 0, 255);
                }
                else {
                    interfaces.surface->setTextColor(0, 255, 0, 255);
                }
                interfaces.surface->printText(timerText.c_str());
                if(defusingBomb){
                    float defusedTime = (defusingTime + (haveDefusers ? 5 : 10));
                    float defuse = defusedTime - memory.globalVars->currenttime;
                    std::wstring defuseTimer(L"Defuse timer: ");
                    defuseTimer += std::to_wstring(defuse);
                    interfaces.surface->setTextFont(Surface::font);
                    interfaces.surface->setTextPosition(5, screen.second / 2);
                    if (local->getProperty<int>("m_iTeamNum") == 3) {
                        interfaces.surface->setTextColor(0, 255, 0, 255);
                    }
                    else {
                        interfaces.surface->setTextColor(255, 0, 0, 255);
                    }
                    interfaces.surface->printText(defuseTimer.c_str());
                }
            }
        }
    }

In hooks.cpp put bombEvents outside switch-case construstion in fireEventClientSide.

All 40 comments

Thanks, doesn't work.

@deprale
put this in hooks.cpp in paintTraverse

Misc::drawTimer();

near of

Esp::render();

put bombEvent like on screenshot
put this

bool drawBombTimer{ false };

in config.h near of

bool watermark{ false };

put this

if(miscJson.isMember("Draw bomb timer"))misc.drawBombTimer = miscJson["Draw bomb timer"].asBool();

in config.cpp in config::load near of

if (miscJson.isMember("Watermark")) misc.watermark = miscJson["Watermark"].asBool();

put this

miscJson["Draw bomb timer"] = misc.drawBombTimer;

in config.cpp in config::save near of

miscJson["Watermark"] = misc.watermark;

and finally put this

ImGui::Checkbox("Draw bomb timer", &config.misc.drawBombTimer);

in gui.cpp near of

ImGui::Checkbox("Watermark", &config.misc.watermark);

Thanks

Oh, i forgot about that.
gameevent.h in GameEvent class

constexpr auto getBool(const char* keyName) noexcept
    {
        return callVirtualMethod<bool, const char*, bool>(this, 5, keyName, false);
    }

and check includes in top of misc.h

#include "../Memory.h"
#include "../Interfaces.h"
#include "../SDK/FrameStage.h"
#include "../SDK/UserCmd.h"
#include "../SDK/WeaponId.h"
#include "../SDK/NetworkChannel.h"
#include "../SDK/Entity.h"
#include "../SDK/Client.h"
#include "../SDK/GameEvent.h"
#include "../SDK/GlobalVars.h"
#include "../SDK/Surface.h"
#include "../SDK/ConVar.h"
#include "../SDK/Cvar.h"

I'm an idiot, can someone provide screenshots for this? .-.

TIA, if not its fine I just don't know exactly what to do

I'm an idiot, can someone provide screenshots for this? .-.

TIA, if not its fine I just don't know exactly what to do

Everything is very well explained.

Thank you! @NexSqaud :D

I'll have to wait until someone compiles this for me :p hope Daniel incorporates it himself because I get 100+ errors.
Thank you for your work though!

I think you can also get bombsite the bomb is being planted at.

Bombsite index is different on all maps.

I checked indexes on some maps:

Mirage:
A - 425
B - 426

Inferno:
A - 333
B - 422

Overpass:
A - 79
B - 507

Dust II:
A - 278
B - 279

Cobblestone:
A - 216
B - 107

Cache:
A - 317
B - 318

Train:
A - 93
B - 538

Nuke:
A - 153
B - 404

Vertigo:
A - 223
B - 278

The bombsite B index is usually greater than the bombsite A index, but not on cobblestone. Although cobblestone is still not in the MM map pool

What about C4 damage prediction , I think it base on the distant from player to the bomb ( Vertigo has small bomb range )

https://i.imgur.com/kvtridR.png

@NexSqaud Did everything you said :s

https://i.imgur.com/kvtridR.png

@NexSqaud Did everything you said :s

In misc.h Put the code in namespace misc, dont paste it outside

thanks @NexSqaud this post and your comments worked perfectly!

https://i.imgur.com/kvtridR.png
@NexSqaud Did everything you said :s

In misc.h Put the code in namespace misc, dont paste it outside

Thanks bro, figured it out now.

I'm dumb! XD

EDIT:
https://i.imgur.com/Y7RoZzO.png

2nd EDIT: Nvm I'm an idiot, I should have pasted everything into the namespace misc thingy.
I just realised I can't even paste. lol.

I think you can also get bombsite the bomb is being planted at.

With radar hack on, the player can see where the bomb is planted.

@NexSqaud i put everything you said. I don`t get any errors but is not showing me anything in game... any ideeas why?

Edit1: Now is showing the time but is not showing "Bomb is planting" or "Defuse time"

It works, but when the players aborts the bomb planting, the message still there. When this happened to me, the player aborted the bomb planting in the round restart delay time.

For me is not showing Bomb is planting, is not show Defuse time.

Make sure you correctly copied all variables and functions and you calling it right.

I triple check them...
If i replace this
plantingBomb = false; defusingBomb = false; haveDefusers = false;
with True, its showing just Bomb is planting and the time is bugged and is not dessapear after is defused or planted etc. So clearly is a problem somewhere and i dont understand where...

The code is put in misc.h after before last '}' .

plantingBomb, defusingBomb and haveDefusers must be false. Check in hooks.cpp in fireEventClientSide you calling Misc::bombEvents() outside switch-case construction

i have it like this
```
case fnv::hash("player_hurt"):
Misc::playHitSound(event);
Visuals::hitMarker(event);
break;
}
Misc::bombEvents(event);
return hooks.gameEventManager.callOriginal(9, event);

Idk, all works perfectly for me.

for me dont... i dont understand why... i recheck it 3/4 times...
can you upload your files to see the difference between them? thank you very much.

I swear i have everything like you... but is not showing me just the c4 timer after is planted
is not showing me Bomb is planting, bomb is defusing etc....

Where you testing? On community servers or official servers?

Insecure, bots practice 馃槵 wingman/casual (offline with bots.)

I tested with bots too.

I dont know man... i dont get any errors in vs... and in game is just showing me the time after you plant the bomb... but i dont get the messages when somebody is trying to defuse or to plant

@NexSqaud I get the same problem as @cojo1989

@NexSqaud i got these errors

https://imgur.com/a/BGpb4w6

It works perfectly for me why are you guys getting errors?

@kschou95 you just copied my hooks.cpp? I have some unneeded stuff in this.

@kschou95 you just copied my hooks.cpp? I have some unneeded stuff in this.

wow I models changer is sick, can u share it on your repositories ?

@tirziz now it crash game.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hvhdark picture hvhdark  路  3Comments

bruhmoment21 picture bruhmoment21  路  3Comments

nikita-tarasov3 picture nikita-tarasov3  路  3Comments

NameNotTakenYAY picture NameNotTakenYAY  路  3Comments

GeorgieeeDev picture GeorgieeeDev  路  3Comments