Osiris icon indicating copy to clipboard operation
Osiris copied to clipboard

Viewmodel weapon XYZ location changer

Open RyDeem opened this issue 4 years ago • 21 comments

Decided to revive my old viewmodel mover project (based on #584), thanks #2019 for the inspiration.

menu1 menu2

Changes the location of the viewmodel onscreen in a kind of neat menu.

Code may be long or something, but this gets the job done quite good.

Warning: You will lose your current viewmodel settings, so save them or write them down if you want to not forget what they were.

Notes:

  1. Dual berretas/Elites are locked to 0,0,0, currently as they look wierd if moved, might change this later
  2. C4/Bomb is locked to zeroes as well.
  3. when unloading cheat in misc tab "unhook" button viewmodel gets reset to 0, and so does cl_righthand to 1. (here we would need a system to get the viewmodel values before inject (or enabling viewmodel mover) and set them back to defaults when needed. As currently this only sets the XYZ location to 0.0.0 when disabling this feature in the GUI and unhooking the cheat, not what it was before/user settings.)
  4. Added grenades and misc/dangerzone equipables to WeaponId.h to make my life more easy.
  5. This is mainly aimed at people who use cl_righthand 1 all the time, i say this because it resets to 1 when disabling the function/unhooking, this needs to change to the users set values.

Can someone help me optimize this? it works in local server if inject after connected but crashes sometimes otherwise in casual any maybe comp too

RyDeem avatar Aug 04 '20 02:08 RyDeem

Nice! maybe see if you can add roll?

KernCS avatar Aug 04 '20 04:08 KernCS

Nice! maybe see if you can add roll?

I got this far but i cant figure out how to full port it. (this code snippet [ 1 ] is not functional)

Can someone take a look?

[ 1 ]

if (interfaces->engine->isInGame() && localPlayer && localPlayer->isWeapon())
{
    auto ViewModel = reinterpret_cast<Entity*>(interfaces->entityList->getEntityFromHandle(localPlayer->viewModel()));
    if (ViewModel)
    {
        auto vsView = Utils::GetVFunc<13, CViewSetup*>(ecx);
        auto eyeAng = vsView->angles;
        eyeAng.z -= 90.f;

        ViewModel->SetAbsAngles(eyeAng);
    }
}

[source]
uintptr_t __fastcall Hooks::Func::OnRenderStart(PVOID ecx, PVOID)
{
	static auto oOnRenderStart = Hooks::ViewRender->GetOriginalFunction<onrenderstart_t>(4);
 
	auto retval = oOnRenderStart(ecx);
 
	if (Interfaces::EngineClient->IsInGame() && CG::Local && CG::LocalWeapon)
	{
		auto ViewModel = reinterpret_cast<C_BaseEntity*>(Interfaces::ClientEntList->GetClientEntityFromHandle(*CG::Local->GetViewModel()));
		if (ViewModel)
		{
			auto vsView = Utils::GetVFunc<13, CViewSetup*>(ecx);
			auto eyeAng = vsView->angles;
			eyeAng.z -= 90.f;
 
			ViewModel->SetAbsAngles(eyeAng);
		}
	}
	return retval;
}

RyDeem avatar Aug 04 '20 05:08 RyDeem

pretty sure you can reduce the amount of code by using the config system similar to how it saves the chams... This should remove all those unique variables. idk ive not looked at the config system recently and i know its changed slightly

NekoRem avatar Aug 04 '20 08:08 NekoRem

also i'd move this to somewhere else so it doesn't get looped constantly that might be causing the crashes from first glance

static ConVar* viewmodel_x = interfaces->cvar->findVar("viewmodel_offset_x");
    static ConVar* viewmodel_y = interfaces->cvar->findVar("viewmodel_offset_y");
    static ConVar* viewmodel_z = interfaces->cvar->findVar("viewmodel_offset_z");
    static ConVar* cl_righthand = interfaces->cvar->findVar("cl_righthand");
    static ConVar* sv_minspec = interfaces->cvar->findVar("sv_competitive_minspec");

NekoRem avatar Aug 04 '20 08:08 NekoRem

Thank you for looking in to this Rem.

config rework would be needed yes, even more if i want to add more types of guns, or each gun independent like aimbot does.

where would i move the static cons then? makes sense in retrospect to not loop const

RyDeem avatar Aug 04 '20 08:08 RyDeem

Hello, i use other osiris version which has other cfg saving method i like this version because it has jb and better esp than new osiris i tried to redo the config from your post but still have errors, any help pls?

if (visualsJson.isMember("Playermodel CT")); visuals.playerModelCT = visualsJson["Playermodel CT"].asInt(); if (visualsJson.isMember("ViewmodelXYZ")); v.viewmodelxyz = visualsJson["ViewmodelXYZ"].asBool(); if (visualsJson.isMember("ViewmodelXYZ cl_right")); v.viewmodel_clright = visualsJson["ViewmodelXYZ cl_right"].asBool(); if (visualsJson.isMember("ViewmodelXYZ X")); v.viewmodel_x = visualsJson["ViewmodelXYZ X"].asBool(); if (visualsJson.isMember("ViewmodelXYZ Y")); v.viewmodel_y = visualsJson["ViewmodelXYZ Y"].asBool(); if (visualsJson.isMember("ViewmodelXYZ Z")); v.viewmodel_z = visualsJson["ViewmodelXYZ Z"].asBool(); if (visualsJson.isMember("Color correction")) { const auto& cc = visualsJson["Color correction"];

visualsJson["Playermodel T"] = visuals.playerModelT; visualsJson["Playermodel CT"] = visuals.playerModelCT; visualsJson["ViewmodelXYZ"] = v.viewmodelxyz; visualsJson["ViewmodelXYZ cl_right"] = v.viewmodel_clright; visualsJson["ViewmodelXYZ X"] = v.viewmodel_x; visualsJson["ViewmodelXYZ Y"] = v.viewmodel_y; visualsJson["ViewmodelXYZ Z"] = v.viewmodel_z;

braken1 avatar Aug 04 '20 09:08 braken1

Hello, i use other osiris version which has other cfg saving method i like this version because it has jb and better esp than new osiris i tried to redo the config from your post but still have errors, any help pls?

if (visualsJson.isMember("Playermodel CT")); visuals.playerModelCT = visualsJson["Playermodel CT"].asInt(); if (visualsJson.isMember("ViewmodelXYZ")); v.viewmodelxyz = visualsJson["ViewmodelXYZ"].asBool(); if (visualsJson.isMember("ViewmodelXYZ cl_right")); v.viewmodel_clright = visualsJson["ViewmodelXYZ cl_right"].asBool(); if (visualsJson.isMember("ViewmodelXYZ X")); v.viewmodel_x = visualsJson["ViewmodelXYZ X"].asBool(); if (visualsJson.isMember("ViewmodelXYZ Y")); v.viewmodel_y = visualsJson["ViewmodelXYZ Y"].asBool(); if (visualsJson.isMember("ViewmodelXYZ Z")); v.viewmodel_z = visualsJson["ViewmodelXYZ Z"].asBool(); if (visualsJson.isMember("Color correction")) { const auto& cc = visualsJson["Color correction"];

visualsJson["Playermodel T"] = visuals.playerModelT; visualsJson["Playermodel CT"] = visuals.playerModelCT; visualsJson["ViewmodelXYZ"] = v.viewmodelxyz; visualsJson["ViewmodelXYZ cl_right"] = v.viewmodel_clright; visualsJson["ViewmodelXYZ X"] = v.viewmodel_x; visualsJson["ViewmodelXYZ Y"] = v.viewmodel_y; visualsJson["ViewmodelXYZ Z"] = v.viewmodel_z;

oh nvm i fixed it by replading v.viewmodel_z by visuals.viewmodel_z

braken1 avatar Aug 04 '20 09:08 braken1

haha i pasted the first version which dont have the opposite cl_righthand feature on knife ggggg

braken1 avatar Aug 04 '20 09:08 braken1

would you mind creating a simple opposite hand knife feature -_- im dumb and cant make this code work, the first one worked but didnt saved to cfg

braken1 avatar Aug 04 '20 10:08 braken1

would you mind creating a simple opposite hand knife feature -_- im dumb and cant make this code work, the first one worked but didnt saved to cfg

///////// in Visuals.cpp for example
void Visuals::KnifeSwapper() noexcept{

static ConVar* cl_righthand = interfaces->cvar->findVar("cl_righthand");
const bool config_righthand = config->visuals.viewmodelXYZ.viewmodel_clright;

auto activeWeapon = localPlayer->getActiveWeapon();

if (!localPlayer->isAlive())
{
    if (!localPlayer->getObserverTarget())
        return;
    if (localPlayer->getObserverMode() != ObsMode::InEye)
        return;
    const auto activeWeapon = localPlayer->getObserverTarget()->getActiveWeapon();
}

const auto classid = activeWeapon->getClientClass()->classId;
if (classid == ClassId::Knife) { 
    if(cl_righthand->getInt() != static_cast<int>(config_righthand)  ){
        cl_righthand = config_righthand ;
    }
}
}

/////// in Gui.cpp

ImGui::Checkbox("Knife Swap", &config->visuals.viewmodelXYZ.viewmodel_clright);

i hope that helps, figure out the hooks and .h file yourself if you can

RyDeem avatar Aug 04 '20 10:08 RyDeem

would you mind creating a simple opposite hand knife feature -_- im dumb and cant make this code work, the first one worked but didnt saved to cfg

///////// in Visuals.cpp for example
void Visuals::KnifeSwapper() noexcept{

static ConVar* cl_righthand = interfaces->cvar->findVar("cl_righthand");
const bool config_righthand = config->visuals.viewmodelXYZ.viewmodel_clright;

auto activeWeapon = localPlayer->getActiveWeapon();

if (!localPlayer->isAlive())
{
    if (!localPlayer->getObserverTarget())
        return;
    if (localPlayer->getObserverMode() != ObsMode::InEye)
        return;
    const auto activeWeapon = localPlayer->getObserverTarget()->getActiveWeapon();
}

const auto classid = activeWeapon->getClientClass()->classId;
if (classid == ClassId::Knife) { 
    if(cl_righthand->getInt() != config_righthand ){
        cl_righthand = config_righthand ;
    }
}
}

/////// in Gui.cpp

ImGui::Checkbox("Knife Swap", &config->visuals.viewmodelXYZ.viewmodel_clright);

i hope that helps, figure out the hooks and .h file yourself if you can

ill try it thanks

braken1 avatar Aug 04 '20 10:08 braken1

I hope it works for you i did not test it wrote it just now, so you might have to fix some stuff

RyDeem avatar Aug 04 '20 10:08 RyDeem

I hope it works for you i did not test it wrote it just now, so you might have to fix some stuff

i guess this only works with xyz changer const bool config_righthand = config->visuals.viewmodelXYZ.viewmodel_clright; not as code itself?

braken1 avatar Aug 04 '20 11:08 braken1

I hope it works for you i did not test it wrote it just now, so you might have to fix some stuff

i guess this only works with xyz changer const bool config_righthand = config->visuals.viewmodelXYZ.viewmodel_clright; not as code itself?

Yes but make that config path yourself, i just made it to be close to the end product. Like

const bool config_righthand = config->visuals.Knife_cl_clright;

the config is not hard currently, in config.h in

    struct Visuals {
bool config_righthand { false };
}

and in config.cpp

static void from_json(const json& j, Config::Visuals& v) //This is to LOAD config.
{

    read<value_t::boolean>(j, "Config Righthand", v.config_righthand ); (THIS IS FOR bool )

    read_number(j, "Config Righthand", v.config_righthand ); (THIS IS FOR int , float , etc )
}
static void to_json(json& j, const Config::Misc& o) //This is to save config.
{
WRITE("Config Righthand", config_righthand);
}

//////////////////// so figur out wich one you need (bool)

and this code is not completekly copy pastable, so just try to figure it out, coding is like a puzzle game when you dont know the basics imho, so beat the puzzle my friend. :)

RyDeem avatar Aug 04 '20 18:08 RyDeem

https://cdn.discordapp.com/attachments/724638912248807465/740312005520523364/Screenshot_2020-08-04-22-55-27-834_com.android.chrome.jpg

im done

ghost avatar Aug 04 '20 20:08 ghost

getWeaponIndex() and getWeaponClass() are used in aimbot and triggerbot, it crashes because of modifications you've made to those functions.

danielkrupinski avatar Aug 04 '20 21:08 danielkrupinski

Sadly it still crashes even without the changes to getWeaponIndex() and getWeaponClass(). (although a lot less.)

i did not change the existing funtion definitions, just added new ones, how would that crash? (trying to understand )

RyDeem avatar Aug 04 '20 22:08 RyDeem

hey, maybe im missing something but i still get 2 errors i tried to fix 1 and had another 200 so i am asking for help image

braken1 avatar Aug 05 '20 08:08 braken1

1st error looks like you need a pointer to the function viewmodelxyz in visuals.h 2nd looks like yuo are missing a { before a }

RyDeem avatar Aug 05 '20 21:08 RyDeem

image

SapphireCodenz avatar Aug 17 '20 17:08 SapphireCodenz

crashes when afk/tabbed out

SapphireCodenz avatar Sep 16 '20 16:09 SapphireCodenz