Osiris icon indicating copy to clipboard operation
Osiris copied to clipboard

Draw aimbot FOV

Open NexSqaud opened this issue 7 years ago • 25 comments

#define PI 3.14159265359
#define DEG2RAD(x) ((x) * PI / 180)

constexpr void drawFov() noexcept
	{
		if (config.misc.drawFOV && interfaces.engine->isInGame()) {
			auto local = interfaces.entityList->getEntity(interfaces.engine->getLocalPlayer());
			if (!local || !local->isAlive()) return;
			int weaponId = getWeaponIndex(local->getActiveWeapon()->getProperty<WeaponId>("m_iItemDefinitionIndex"));
			if (!config.aimbot[weaponId].enabled) weaponId = 0;
			if (!config.aimbot[weaponId].enabled) return;
			auto screenSize = interfaces.surface->getScreenSize();
			if (config.aimbot[weaponId].silent) interfaces.surface->setDrawColor(255, 10, 10, 255);
			else interfaces.surface->setDrawColor(10, 255, 10, 255);
			float radius = std::tan(DEG2RAD(config.aimbot[weaponId].fov) / 2.f) / std::tan(DEG2RAD(local->getProperty<bool>("m_bIsScoped") ? local->getProperty<int>("m_iFov") : (90 + config.visuals.fov)) / 2.f) * screenSize.first;
			interfaces.surface->drawOutlinedCircle(screenSize.first / 2, screenSize.second / 2, radius, 100);
		}
	}

NexSqaud avatar Jun 27 '19 16:06 NexSqaud

Looks alot cleaner than what i did rn. Btw does it work for double zoom?

notaila avatar Jun 27 '19 22:06 notaila

This does not work correctly when using a single scope.

NexSqaud avatar Jun 28 '19 03:06 NexSqaud

Where do I need to put it ? :)

PUREHAX avatar Jul 08 '19 13:07 PUREHAX

misc.h and call it from paintTraverse hook like this

//some stuff before this
Misc::spectatorList();
Misc::drawFov();
//and after this

and put

bool drawFOV{false};

in Misc config struct and put

ImGui::Checkbox("Draw Aimbot FOV", &config.misc.drawFOV);

in GUI.cpp near of

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

in config.cpp put

if (miscJson.isMember("Draw FOV")) misc.drawFOV = miscJson["Draw Fov"].asBool();

near of

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

and final put

miscJson["Draw FOV"] = misc.drawFOV;

near of

miscJson["Watermark"] = misc.watermark;

NexSqaud avatar Jul 08 '19 14:07 NexSqaud

It doesnt draw accurately though like the fov is 2x less than what is drawn.

notaila avatar Jul 08 '19 14:07 notaila

update: hooks.cpp

static void __stdcall overrideView(ViewSetup* setup) noexcept
{
    if (interfaces.engine->isInGame()
        && !interfaces.entityList->getEntity(interfaces.engine->getLocalPlayer())->getProperty<bool>("m_bIsScoped"))
        setup->fov += config.visuals.fov;
    setup->farZ += config.visuals.farZ * 10;
	Misc::actualFov = setup->fov;
    hooks.clientMode.callOriginal<void, ViewSetup*>(18, setup);
}

misc.h

static float actualFov = 0.0f;

	constexpr void drawFov() noexcept
	{
		if (config.misc.drawFOV && interfaces.engine->isInGame()) {
			auto local = interfaces.entityList->getEntity(interfaces.engine->getLocalPlayer());
			if (!local || !local->isAlive()) return;
			if (!local->getActiveWeapon()) return;
			int weaponId = getWeaponIndex(local->getActiveWeapon()->getProperty<WeaponId>("m_iItemDefinitionIndex"));
			if (!config.aimbot[weaponId].enabled) weaponId = 0;
			if (!config.aimbot[weaponId].enabled) return;
			auto screenSize = interfaces.surface->getScreenSize();
			if (config.aimbot[weaponId].silent) interfaces.surface->setDrawColor(255, 10, 10, 255);
			else interfaces.surface->setDrawColor(10, 255, 10, 255);
			float radius = std::tan(DEG2RAD(config.aimbot[weaponId].fov) / 2.f) / std::tan(DEG2RAD(actualFov) / 2.f) * screenSize.first;
			interfaces.surface->drawOutlinedCircle(screenSize.first / 2, screenSize.second / 2, radius, 100);
		}
	}

now this should be works normally with scopes Edit:Updated again. Edit2: Tested - now works correctry with 1x scope and 2x scope

NexSqaud avatar Jul 08 '19 14:07 NexSqaud

Thank you for this nice tutorial but I get some errors :( like Error Code C2027

I've basically did everything right I guess

PUREHAX avatar Jul 08 '19 16:07 PUREHAX

And is that on purpose ? " miscJson["Draw FOV"] = misc.watermark; " and not " miscJson["Draw FOV"] = misc.drawFOV; "

PUREHAX avatar Jul 08 '19 16:07 PUREHAX

oops, corrected everything

NexSqaud avatar Jul 08 '19 16:07 NexSqaud

I have 15 Errors with the surface :D

PUREHAX avatar Jul 08 '19 16:07 PUREHAX

🤔 can you show errors?

NexSqaud avatar Jul 08 '19 16:07 NexSqaud

Yeah but they're german :D https://imgur.com/a/3xD7FAi

PUREHAX avatar Jul 08 '19 16:07 PUREHAX

add this in include section

#include "../SDK/Surface.h"

NexSqaud avatar Jul 08 '19 16:07 NexSqaud

Very nice, Thank you <3

PUREHAX avatar Jul 08 '19 16:07 PUREHAX

element class "Config :: Misc" does not have the "drawFOV" component

piterxyz avatar Jul 23 '19 09:07 piterxyz

Ok nvm.

piterxyz avatar Jul 23 '19 09:07 piterxyz

'DEG2RAD': identifier not found

  • (compiling source file Hacks\Misc.cpp)
  • (compiling source file GUI.cpp)
  • (compiling source file Hooks.cpp)

Maybe there's a piece of code missing?

ghost avatar Jul 27 '19 21:07 ghost

@4lb3 look at 1 post.

NexSqaud avatar Jul 28 '19 13:07 NexSqaud

@4lb3 look at 1 post.

I'm sorry, I need glasses.

ghost avatar Jul 29 '19 19:07 ghost

Using a lambda expressions instead of defines

constexpr void drawFov() noexcept
	{
		if (config.misc.drawFOV && interfaces.engine->isInGame()) {
			auto local = interfaces.entityList->getEntity(interfaces.engine->getLocalPlayer());
			if (!local || !local->isAlive()) return;
			if (!local->getActiveWeapon()) return;
			int weaponId = getWeaponIndex(local->getActiveWeapon()->getProperty<WeaponId>("m_iItemDefinitionIndex"));
			if (!config.aimbot[weaponId].enabled) weaponId = 0;
			if (!config.aimbot[weaponId].enabled) return;
			auto screenSize = interfaces.surface->getScreenSize();
			if (config.aimbot[weaponId].silent) interfaces.surface->setDrawColor(255, 10, 10, 255);
			else interfaces.surface->setDrawColor(10, 255, 10, 255);
			float radius = std::tan(degreesToRadians(config.aimbot[weaponId].fov) / 2.f) / std::tan(degreesToRadians(actualFov) / 2.f) * screenSize.first;
			interfaces.surface->drawOutlinedCircle(screenSize.first / 2, screenSize.second / 2, radius, 100);
		}
	}

NexSqaud avatar Feb 17 '20 16:02 NexSqaud