Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef void(__thiscall* tOverrideMouseInput)(PVOID, float *x, float *y);
- tOverrideMouseInput oOverrideMouseInput;
- void __stdcall hkOverrideMouseInput(float *_x, float *_y)
- {
- oOverrideMouseInput(pClientMode, _x, _y);
- //If there is no mouse movement then we don't want to do anything (you can change that if you want)
- if (*(float*)_x == 0.0f || *(float*)_y == 0.0f)
- return;
- IClientEntity *pLocalEntity = pEntityList->GetClientEntity(pEngine->GetLocalPlayer());
- if (!pLocalEntity)
- return;
- if (!pLocalEntity->IsAlive())
- return;
- CBaseCombatWeapon* pWeapon = (CBaseCombatWeapon*)pEntityList->GetClientEntityFromHandle(pLocalEntity->GetActiveWeaponHandle());
- if (!pWeapon)
- return;
- //Knife/Golden Knife - I don't want aim assistance with knifes
- int iWeaponClass = pWeapon->GetClientClass()->m_ClassID;
- if (iWeaponClass == 90 || iWeaponClass == 91)
- return;
- //Grab our data...
- QAngle ViewAngles;
- pEngine->GetViewAngles(ViewAngles);
- ViewAngles += pLocalEntity->GetPunchAngles() * 2.0f;
- NormalizeAngles(ViewAngles);
- Vector vecPlayer = pLocalEntity->GetOrigin();
- Vector vecPlayerEyes = vecPlayer + pLocalEntity->GetEyePosition();
- int iBestTarget = -1;
- //Get best target
- for (int i = 1; i < pEngine->GetMaxClients() + 1; i++)
- {
- //Pick best target here... it's your job, ez pz.
- iBestTarget = pEngine->GetLocalPlayer();
- break;
- }
- if (iBestTarget != -1)
- {
- IClientEntity* pEntity = pEntityList->GetClientEntity(iBestTarget);
- if (!pEntity)
- return;
- Vector vecHitbox = GetHitboxPosition(pEntity, 0); //Or use bones, w/e
- Vector vecDelta = vecHitbox - vecPlayerEye;
- QAngle qEntityAngles = CalcAngle(vecPlayerEye, vecHitbox);
- NormalizeAngles(qEntityAngles);
- QAngle qDelta = ViewAngles - qEntityAngles;
- NormalizeAngles(qDelta);
- //Angles to pixels, 0.022 == m_yaw == m_pitch
- //https://github.com/alliedmodders/hl2sdk/blob/csgo/game/client/in_mouse.cpp#L439
- qDelta.x /= 0.022f;
- qDelta.y /= 0.022f;
- //Convert them to vectors, since I am lazy and vectors have stuff like Lenght :v Notice that we use yaw as X and -pitch as Y.
- Vector vMouse = Vector(*(float*)_x, *(float*)_y, 0.0f);
- Vector vDelta = Vector(qDelta.y, -qDelta.x, 0.0f);
- //Scale down
- //I also added some "distance scaling", since it looked very strange and snappy without it.
- float fDistanceScaling = fNearsetFOV / 17.5f;
- fDistanceScaling += 0.385f;
- vDelta = vDelta.Normalized() * vMouse.Length() * fDistanceScaling;
- //Average of two vectors
- float fRandom = RandomFloat(6.15f, 7.65f) * (1.0 - fDistanceScaling);
- vDelta *= fRandom;
- vMouse *= 10.0f - fRandom;
- vDelta += vMouse;
- vDelta /= 10.0f;
- //Override original input with our values :v
- *(float*)_x = vDelta.x;
- *(float*)_y = vDelta.y;
- return;
- }
- }
- //Hooking:
- //ClientMode pointer is your job, if you don't know how to do it check this out:
- //http://www.unknowncheats.me/forum/source-engine/159253-finding-pointer-clientmode-game.html
- pClientModeHook = new CVMTHookManager((PDWORD*)pClientMode);
- oOverrideMouseInput = (tOverrideMouseInput)pInputHook->dwHookMethod((DWORD)hkOverrideMouseInput, 23);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement