Code:
VISUAL BASIC C++ MICROSOFT 2013
**************************************By eXx0 PRODUCTION
type
FFireBullet = procedure (idx: Integer; _forward, right, up: PArray3OfSingle; cShots: Integer; vecSrc, vecDirShooting: PArray3OfSingle; flDistance: Single; iBulletType, iTracerFreq: Integer; tracerCount: PInteger; flSpreadX, flSpreadY: Single);cdecl;
var
oldFireBullet : FFireBullet = pointer ($019024C0);
newFireBullet : FFireBullet;
procedure myFireBullet(idx: Integer; _forward, right, up: PArray3OfSingle; cShots: Integer; vecSrc, vecDirShooting: PArray3OfSingle; flDistance: Single; iBulletType, iTracerFreq: Integer; tracerCount: PInteger; flSpreadX, flSpreadY: Single);cdecl;
var
vDir, view, target: Array[0..2] of Single;
begin
vDir[0] := _forward[0] + flSpreadX * right[0] + flSpreadY * up[0];
view[0] := 8192 * vDir[0];
vDir[1] := _forward[1] + flSpreadX * right[1] + flSpreadY * up[1];
view[1] := 8192 * vDir[1];
vDir[2] := _forward[2] + flSpreadX * right[2] + flSpreadY * up[2];
view[2] := 8192 * vDir[2];
VectorUtils.VectorAngles(view,target);
target[0] := target[0] * -1;
me.spreadAngles.x := me.viewAngles.x - target[0];
me.spreadAngles.y := me.viewAngles.y - target[1];
me.spreadAngles.z := 0;
newFireBullet(idx,_forward,right,up,cShots,vecSrc,vecDirShooting,flDistance,iBulletType,iTracerFreq,tracerCount,flSpreadX,flSpreadY);
end;
procedure CL_CreateMove(_para1:single; ucmd:usercmd_s; _para3:longint);cdecl;
begin
gExportTable.CL_CreateMove(_para1,ucmd,_para3);
If _nospread Then
begin
ucmd.viewangles.x := ucmd.viewangles.x + me.spreadAngles.x;
ucmd.viewangles.y := ucmd.viewangles.y + me.spreadAngles.y;
ucmd.viewangles.z := ucmd.viewangles.z + me.spreadAngles.z;
end;
If _norecoil then
begin
ucmd.viewangles.x := ucmd.viewangles.x - me.punchangle.x;
ucmd.viewangles.y := ucmd.viewangles.y - me.punchangle.y;
end;
end;
procedure HookClient;
begin
While not Assigned(pExportTable.Initialize) Do
Sleep(50);
CopyMemory(@gExportTable,pExportTable,sizeOf(ExportTable_t));
//...
//....
MyHook.Detour(@oldFireBullet,@MyFireBullet,@NewFireBullet);
end;
void ApplyNoRecoil(float Frametime, float *Punchangle, float *Viewangle)
{
float Punch[3], Length;
VectorCopy(Punchangle, Punch);
Length = VectorNormalize(Punch);
Length -= (10.0 + Length * 0.5) * Frametime;
Length = max(Length, 0.0);
VectorScale(Punch, Length, Punch);
Viewangle[0] += Punch[0] + Punch[0];
Viewangle[1] += Punch[1] + Punch[1];
}
//**********************************************************************************************************************************
inline void AntiPitchRecoil(float frametime, float* punchangle, float* Angles)
{
float Punch[3], Length;
VectorCopy(punchangle, Punch);
Length = VectorLength(Punch);
Length -= (10.0 + Length * 0.5) * frametime;
Length = max(Length, 0.0);
VectorScale(Punch, Length, Punch);
Angles[0] -= (Punch[0] + Punch[0]);
}
//**********************************************************************************************************************************
inline void antiRecoil(float* pa, struct usercmd_s * usercmd, float frametime)
{
if(cvar.recoil<0) cvar.recoil =0.0;
switch(cvar.norecoil){
case 1:
{
usercmd->viewangles[0] -= (pa[0] * cvar.recoil);
usercmd->viewangles[1] -= (pa[1] * cvar.recoil);
}
break;
case 2:
{
int* intcoil = (int *)0x01A17C1C;
usercmd->viewangles[0] -= ((pa[0]) * (float)(255/(float)(*intcoil)));
usercmd->viewangles[1] -= ((pa[1]) * (float)(255/(float)(*intcoil)));
}
break;
case 3:
{
AntiPitchRecoil(frametime,pa,usercmd->viewangles);
usercmd->viewangles[1] -= (pa[1] * cvar.recoil);
}
break;
case 4:
{
float recoiladdon = 0.0f;
if(me.spread.recoil < 1) recoiladdon = 0.0f;
else recoiladdon = (me.spread.recoil / 100.0f);
usercmd->viewangles[0] -= (pa[0] * (cvar.recoil +recoiladdon));
usercmd->viewangles[1] -= (pa[1] * (cvar.recoil +recoiladdon));
}
break;
case 5:
{
float post_recoilmultiply = 0.0f;
if (me.spread.recoil == 0) post_recoilmultiply = 0.0f;
else post_recoilmultiply = ((me.spread.recoil +1)/100.0f);
usercmd->viewangles[0] -= (pa[0] * (cvar.recoil + post_recoilmultiply));
usercmd->viewangles[1] -= (pa[1] * (cvar.recoil + post_recoilmultiply));
}
break;
default:
break;
}
VectorClear(pa);//si ya se restaron, se ponen a cero
}
static int boxpnt[6][4] =
{
{ 0, 4, 6, 2 }, // +X
{ 0, 1, 5, 4 }, // +Y
{ 0, 2, 3, 1 }, // +Z
{ 7, 5, 1, 3 }, // -X
{ 7, 3, 2, 6 }, // -Y
{ 7, 6, 4, 5 }, // -Z
};
void CalcTriggerbot( vec3_t mins, vec3_t maxs, IPlayers * pe )
{
int j;
vec3_t tmp;
vec3_t p[8],q[8];
float gap = cfg.box_gap;
for (j = 0; j < 8; j++)
{
tmp[0] = (j & 1) ? mins[0] - gap : maxs[0] + gap;
tmp[1] = (j & 2) ? mins[1] - gap : maxs[1] + gap ;
tmp[2] = (j & 4) ? mins[2] - gap : maxs[2] + gap ;
Utils::VectorCopy(tmp, p[j]);
}
if ( pe->GetEnt()->angles )
{
vec3_t forward, right, up, vPlayerAngles, vAngles;
vAngles[0] = 0;
vAngles[1]= pe->GetEnt()->angles[1];
vAngles[2]=0;
gEngine.pfnAngleVectors( vAngles, forward, right, up );
for (j = 0; j < 8; j++)
{
Utils::VectorCopy(p[j], tmp);
p[j][0] = DotProduct ( tmp, forward );
p[j][1] = DotProduct ( tmp, right );
p[j][2] = DotProduct ( tmp, up );
}
}
for (j = 0; j < 8; j++)
Utils::VectorAdd(p[j], pe->GetEnt()->origin, p[j]);
float left = 99999;
float right = -99999;
float top = -99999;
float bottom = 99999;
vec3_t vTl,vTr,vBl,vBr;
bool bOffScreen = false;
for (j = 0; j < 6; j++)
{
// make sure all 6 sides of the box are visible, otherwise boxes get messy
if( !Utils::CalcScreen( p[boxpnt[j][1]], vTl ) ||
!Utils::CalcScreen( p[boxpnt[j][3]], vBr ) ||
!Utils::CalcScreen( p[boxpnt[j][2]], vTr ) ||
!Utils::CalcScreen( p[boxpnt[j][0]], vBl ) )
bOffScreen = true;
// calculate furthest points from player
if( vTl[0] < left )
left = vTl[0];
if( vTr[0] > right )
right = vTr[0];
if( vTl[1] > top )
top = vTl[1];
if( vBl[1] < bottom )
bottom = vBl[1];
}
if( !bOffScreen ) {
// mouse is within target area?
if( gEnv.centerx >= left &&
gEnv.centerx <= right &&
gEnv.centery >= bottom &&
gEnv.centery <= top )
{
// profit!!!
}
}
}
#include <windows.h>
#include "SDKInclude.h"
#include "TransInclude.h"
#include "NoRecoil.h"
CNoRecoil::CNoRecoil(void)
{
}
CNoRecoil::~CNoRecoil(void)
{
}
void CNoRecoil::PredictAndFixRecoil(struct ref_params_s *pparams)
{
memcpy(lastPunch,curPunch,sizeof(lastPunch));
memcpy(lastAverage,curAverage,sizeof(lastAverage));
memcpy(curPunch,pparams->punchangle,sizeof(pparams->punchangle));
curAverage[0]=(curPunch[0]+lastPunch[0]/2);
curAverage[2]=(curPunch[2]+lastPunch[2]/2);
pparams->cl_viewangles[0] -= curAverage[0]-lastAverage[0];
pparams->cl_viewangles[2] -= curAverage[2]-lastAverage[2];
}
void CNoRecoil::ResetEstimationOnAttackBail()
{
RtlZeroMemory(curAverage,sizeof(curAverage));
RtlZeroMemory(lastAverage,sizeof(lastAverage));
RtlZeroMemory(curPunch,sizeof(curPunch));
RtlZeroMemory(lastPunch,sizeof(lastPunch));
}
#pragma once
class CNoRecoil
{
public:
CNoRecoil(void);
~CNoRecoil(void);
void CNoRecoil::PredictAndFixRecoil(struct ref_params_s *pparams);
void CNoRecoil::ResetEstimationOnAttackBail();
private:
float curPunch[3];
float lastPunch[3];
float curAverage[3];
float lastAverage[3];
};
//
#include "nospread.h"
#include "weaponslist.h"
// add them...
#define WEAPONLIST_GALIL 14
#define WEAPONLIST_FAMAS 15
static unsigned int glSeed = 0;
#define M_PI 3.14159265358979323846
unsigned int seed_table[ 256 ] =
{
28985, 27138, 26457, 9451, 17764, 10909, 28790, 8716, 6361, 4853, 17798, 21977, 19643, 20662, 10834, 20103,
27067, 28634, 18623, 25849, 8576, 26234, 23887, 18228, 32587, 4836, 3306, 1811, 3035, 24559, 18399, 315,
26766, 907, 24102, 12370, 9674, 2972, 10472, 16492, 22683, 11529, 27968, 30406, 13213, 2319, 23620, 16823,
10013, 23772, 21567, 1251, 19579, 20313, 18241, 30130, 8402, 20807, 27354, 7169, 21211, 17293, 5410, 19223,
10255, 22480, 27388, 9946, 15628, 24389, 17308, 2370, 9530, 31683, 25927, 23567, 11694, 26397, 32602, 15031,
18255, 17582, 1422, 28835, 23607, 12597, 20602, 10138, 5212, 1252, 10074, 23166, 19823, 31667, 5902, 24630,
18948, 14330, 14950, 8939, 23540, 21311, 22428, 22391, 3583, 29004, 30498, 18714, 4278, 2437, 22430, 3439,
28313, 23161, 25396, 13471, 19324, 15287, 2563, 18901, 13103, 16867, 9714, 14322, 15197, 26889, 19372, 26241,
31925, 14640, 11497, 8941, 10056, 6451, 28656, 10737, 13874, 17356, 8281, 25937, 1661, 4850, 7448, 12744,
21826, 5477, 10167, 16705, 26897, 8839, 30947, 27978, 27283, 24685, 32298, 3525, 12398, 28726, 9475, 10208,
617, 13467, 22287, 2376, 6097, 26312, 2974, 9114, 21787, 28010, 4725, 15387, 3274, 10762, 31695, 17320,
18324, 12441, 16801, 27376, 22464, 7500, 5666, 18144, 15314, 31914, 31627, 6495, 5226, 31203, 2331, 4668,
12650, 18275, 351, 7268, 31319, 30119, 7600, 2905, 13826, 11343, 13053, 15583, 30055, 31093, 5067, 761,
9685, 11070, 21369, 27155, 3663, 26542, 20169, 12161, 15411, 30401, 7580, 31784, 8985, 29367, 20989, 14203,
29694, 21167, 10337, 1706, 28578, 887, 3373, 19477, 14382, 675, 7033, 15111, 26138, 12252, 30996, 21409,
25678, 18555, 13256, 23316, 22407, 16727, 991, 9236, 5373, 29402, 6117, 15241, 27715, 19291, 19888, 19847
};
unsigned int cNoSpread::U_Random( void )
{
glSeed *= 69069;
glSeed += seed_table[ glSeed & 0xff ];
return ( ++glSeed & 0x0fffffff );
}
void cNoSpread::U_Srand( unsigned int seed )
{
glSeed = seed_table[ seed & 0xff ];
}
int cNoSpread::UTIL_SharedRandomLong( unsigned int seed, int low, int high )
{
unsigned int range;
U_Srand( (int)seed + low + high );
range = high - low + 1;
if ( !(range - 1) )
{
return low;
}
else
{
int offset;
int rnum;
rnum = U_Random();
offset = rnum % range;
return (low + offset);
}
}
float cNoSpread::UTIL_SharedRandomFloat( unsigned int seed, float low, float high )
{
unsigned int range;
U_Srand( (int)seed + *(int *)&low + *(int *)&high );
U_Random();
U_Random();
range = (unsigned int)(high - low);
if ( !range )
{
return low;
}
else
{
int tensixrand;
float offset;
tensixrand = U_Random() & 65535;
offset = (float)tensixrand / 65536.0f;
return (low + offset * range );
}
}
float cNoSpread::GetVecSpread()
{
if (vecflSpreadVar.size() == 0)
return 0.0f;
if (m_iRecoil < vecflSpreadVar.size())
{
return vecflSpreadVar[m_iRecoil];
}
return 0.0f;
}
void cNoSpread::AddSpreadVar(struct event_args_s *args)
{
m_iRecoil++;
float vecspread[2],vec[2];
int future = 1;
vec[0] = UTIL_SharedRandomFloat(m_uiRandom_Seed + 0 + future, -0.5, 0.5) + UTIL_SharedRandomFloat(m_uiRandom_Seed + 1 + future, -0.5, 0.5);
vec[1] = UTIL_SharedRandomFloat(m_uiRandom_Seed + 2 + future, -0.5, 0.5) + UTIL_SharedRandomFloat(m_uiRandom_Seed + 3 + future, -0.5, 0.5);
vecspread[0] = args->fparam1[0] / vec[0];
vecspread[1] = args->fparam2[1] / vec[1];
if (vecspread[0] < 0.0f)
vecspread[0] *= -1.0f;
if (vecspread[1] < 0.0f)
vecspread[1] *= -1.0f;
vecflSpreadVar.push_back(((vecspread[0] + vecspread[1])/2));
}
void cNoSpread::GetSpreadXY(float *vec)
{
float vecspread, speed;
vec[0] = UTIL_SharedRandomFloat(m_uiRandom_Seed + 1 + 0, -0.5, 0.5) + UTIL_SharedRandomFloat(m_uiRandom_Seed + 1 + 1, -0.5, 0.5);
vec[1] = UTIL_SharedRandomFloat(m_uiRandom_Seed + 2 + 1, -0.5, 0.5) + UTIL_SharedRandomFloat(m_uiRandom_Seed + 3 + 1, -0.5, 0.5);
vecspread = GetVecSpread();
vec[0] *= vecspread;
vec[1] *= vecspread;
return;
}
void cNoSpread::GetSpreadOffset(float *inangles, float *outangles)
{
float forward[3], right[3], up[3], vecDir[3];
float view[3], dest[3], spread[2];
gEngfuncs.pfnAngleVectors(inangles, forward, right, up);
GetSpreadXY(spread);
vecDir[0] = forward[0] + spread[0] * right[0] + spread[1] * up[0];
view[0] = 8192 * vecDir[0];
vecDir[1] = forward[1] + spread[0] * right[1] + spread[1] * up[1];
view[1] = 8192 * vecDir[1];
vecDir[2] = forward[2] + spread[0] * right[2] + spread[1] * up[2];
view[2] = 8192 * vecDir[2];
VectorAngles(view, dest);
dest[0] *= -1;
outangles[0] = inangles[0] - dest[0];
outangles[1] = inangles[1] - dest[1];
outangles[2] = 0;
}
void cNoSpread::VectorAngles(const float *forward, float *angles)
{
float tmp, yaw, pitch;
if (forward[1] == 0 && forward[0] == 0)
{
yaw = 0;
pitch = 0;
}
else
{
yaw = atan2(forward[1], forward[0]) * 180 / M_PI;
if (yaw < 0)
yaw += 360;
tmp = sqrt(forward[0] * forward[0] + forward[1] * forward[1]);
pitch = atan2(forward[2], tmp) * 180 / M_PI;
}
angles[0] = pitch;
angles[1] = yaw;
angles[2] = 0;
}
void cNoSpread::DefaultSpreadVar(int weaponid)
{
vecflSpreadVar.clear();
if (weaponid == WEAPONLIST_DEAGLE)
vecflSpreadVar.push_back(0.9f);
else if (weaponid == WEAPONLIST_MP5)
vecflSpreadVar.push_back(0.0f);
else if (weaponid == WEAPONLIST_AK47)
vecflSpreadVar.push_back(0.2f);
else if (weaponid == WEAPONLIST_SG552)
vecflSpreadVar.push_back(0.2f);
else if (weaponid == WEAPONLIST_AUG)
vecflSpreadVar.push_back(0.3f);
else if (weaponid == WEAPONLIST_M4A1)
vecflSpreadVar.push_back(0.2f);
else if (weaponid == WEAPONLIST_M249)
vecflSpreadVar.push_back(0.2f);
else if (weaponid == WEAPONLIST_MAC10)
vecflSpreadVar.push_back(0.15f);
else if (weaponid == WEAPONLIST_UMP45)
vecflSpreadVar.push_back(0.0f);
else if (weaponid == WEAPONLIST_TMP)
vecflSpreadVar.push_back(0.2f);
else if (weaponid == WEAPONLIST_P90)
vecflSpreadVar.push_back(0.15f);
else if (weaponid == WEAPONLIST_P228)
vecflSpreadVar.push_back(0.9f);
else if (weaponid == WEAPONLIST_FIVESEVEN)
vecflSpreadVar.push_back(0.92f);
else if (weaponid == WEAPONLIST_ELITE)
vecflSpreadVar.push_back(0.88f);
else if (weaponid == WEAPONLIST_GLOCK18)
vecflSpreadVar.push_back(0.9f);
else if (weaponid == WEAPONLIST_USP)
vecflSpreadVar.push_back(0.92f);
else if (weaponid == WEAPONLIST_G3SG1)
vecflSpreadVar.push_back(0.2f);
else if (weaponid == WEAPONLIST_SG550)
vecflSpreadVar.push_back(0.2f);
else
vecflSpreadVar.push_back (0.2f);
}
void cNoSpread::HUD_PostRunCmd(struct local_state_s *from, struct local_state_s *to, struct usercmd_s *cmd, int runfuncs, double time, unsigned int random_seed)
{
static int prevammo = 0, curammo;
int i, index, Id;
if (runfuncs)
{
m_uiRandom_Seed = random_seed;
if (cmd->buttons & IN_ATTACK && CanCurWeaponAttack()) // catch case when pistol and IN_ATTACK is always on and not firing
{
// there are some disco fans inhere to night
}
else if (!(cmd->buttons & (IN_ATTACK | IN_ATTACK2)))
{
if (me.spread.recoil > 15)
me.spread.recoil = 15;
if (IsCurWeaponSec())
{
m_iRecoil = 0;
}
else if (m_iRecoil > 0)
{
if (m_flRecoilTime <= time)
{
m_flRecoilTime = m_flRecoilTime + 0.0225;
m_iRecoil--;
}
}
}
for (i=0;i<WeaponList.size();i++)
{
if (WeaponList[i].Id == to->client.m_iId)
{
if (!WeaponList[i].CurWeapon) // FIX: This doesn't catch when you have a weapon and you buy the same weapon
{
m_iRecoil = 0;
DefaultSpreadVar(WeaponList[i].Id);
}
WeaponList[i].CurWeapon = true;
}
else
WeaponList[i].CurWeapon = false;
}
for (i=0;i<MAX_WEAPONS;i++)
{
// this assumes (i == wd[i].m_iId)
index = GetWeaponIndexByID(i);
if (index == -1)
continue;
if (to->weapondata[i].m_iId)
memcpy(&WeaponList[index].weapondata, &to->weapondata[i], sizeof(weapon_data_t));
else
memset(&WeaponList[index].weapondata, 0, sizeof(weapon_data_t));
}
if (IsReloading())
{
Id = GetCurWeaponId();
m_iRecoil = 0;
DefaultSpreadVar(Id);
}
}
}
#ifndef NOSPREAD_H
#define NOSPREAD_H
#include <Windows.h>
#include <vector>
#include "engine/allclientheaders.h"
class cNoSpread
{
public:
void GetSpreadOffset(float *inangles, float *outangles); // to be called in cl_createmove
void HUD_PostRunCmd(struct local_state_s *from, struct local_state_s *to, struct usercmd_s *cmd, int runfuncs, double time, unsigned int random_seed);// to be called POST HUD_POSTRUNCMD
void DefaultSpreadVar(int weaponid); // to be called on reload and weaponchange
void AddSpreadVar(struct event_args_s *args); // to be called in the weapon events
private:
int m_iRecoil;
float m_flRecoilTime;
UINT m_uiRandom_Seed;
std::vector<float>vecflSpreadVar;
float GetVecSpread( void );
void GetSpreadXY(float *vec);
void VectorAngles(const float *forward, float *angles);
void U_Srand( unsigned int seed );
unsigned int U_Random( void );
int UTIL_SharedRandomLong( unsigned int seed, int low, int high );
float UTIL_SharedRandomFloat( unsigned int seed, float low, float high );
};
#endif
#include <windows.h>
#include "engine/wrect.h"
#include "engine/cl_dll.h"
#include "engine/cl_entity.h"
#include "recoil.h"
#include "random.h"
#include "client.h"
#include "cvar.h"
#include "aimbot.h"
#include "attack.h"
#include "playeritems.h"
#pragma optimize("gtp",on)
void cNoSpread::GetSpreadXY(unsigned int seed, int future, float *velocity, float *vec)
{
float vecspread, speed;
vec[0] = UTIL_SharedRandomFloat(seed + future, -0.5, 0.5) + UTIL_SharedRandomFloat(seed + 1 + future, -0.5, 0.5);
vec[1] = UTIL_SharedRandomFloat(seed + 2 + future, -0.5, 0.5) + UTIL_SharedRandomFloat(seed + 3 + future, -0.5, 0.5);
speed = sqrt(velocity[0] * velocity[0] + velocity[1] * velocity[1]);
vecspread = this->m_fSpread;
vec[0] *= vecspread;
vec[1] *= vecspread;
return;
}
void VectorAngles( const float *forward, float *angles );
void cNoSpread::GetRecoilOffset(int future, float *inangles, float *velocity, float *outangles)
{
float forward[3], right[3], up[3], vecDir[3];
float view[3], dest[3], spread[2];
gEngfuncs.pfnAngleVectors(inangles, forward, right, up);
GetSpreadXY(m_uiSeed, future, velocity, spread);
vecDir[0] = forward[0] + spread[0] * right[0] + spread[1] * up[0];
view[0] = 8192 * vecDir[0];
vecDir[1] = forward[1] + spread[0] * right[1] + spread[1] * up[1];
view[1] = 8192 * vecDir[1];
vecDir[2] = forward[2] + spread[0] * right[2] + spread[1] * up[2];
view[2] = 8192 * vecDir[2];
VectorAngles(view, dest);
dest[0] *= -1;
outangles[0] = inangles[0] - dest[0];
outangles[1] = inangles[1] - dest[1];
outangles[2] = 0;
}
#ifndef RECOIL_H
#define RECOIL_H
#include "windows.h"
class cNoSpread
{
public:
void GetSpread(float fSpread)
{
if (fSpread == 0.0f)
{
m_fLastSpread = m_fcurrentSpread = m_fSpread = fSpread;
}
else
{
if (m_fLastSpread)
{
m_fSpread = m_fcurrentSpread - m_fLastSpread + fSpread;
m_fLastSpread = m_fcurrentSpread;
m_fcurrentSpread = fSpread;
}
else
{
m_fLastSpread = m_fcurrentSpread = m_fSpread = fSpread;
}
}
};
void SetSpreadtoZero()
{
m_fLastSpread = m_fcurrentSpread = m_fSpread = 0.0f;
}
void GetSeed(unsigned int uiSeed)
{
m_uiSeed = uiSeed;
};
void GetRecoilOffset(int future, float *inangles, float *velocity, float *outangles);
private:
void GetSpreadXY(unsigned int seed, int future, float *velocity, float *vec);
float m_fSpread;
float m_fcurrentSpread;
float m_fLastSpread;
unsigned int m_uiSeed;
};
extern cNoSpread gNoSpread;
#endif
#pragma optimize("gtp",on)
#include "random.h"
//===================================================================================By eXx0 PRODUCTION
static unsigned int glSeed = 0;
unsigned int seed_table[ 256 ] =
{
28985, 27138, 26457, 9451, 17764, 10909, 28790, 8716, 6361, 4853, 17798, 21977, 19643, 20662, 10834, 20103,
27067, 28634, 18623, 25849, 8576, 26234, 23887, 18228, 32587, 4836, 3306, 1811, 3035, 24559, 18399, 315,
26766, 907, 24102, 12370, 9674, 2972, 10472, 16492, 22683, 11529, 27968, 30406, 13213, 2319, 23620, 16823,
10013, 23772, 21567, 1251, 19579, 20313, 18241, 30130, 8402, 20807, 27354, 7169, 21211, 17293, 5410, 19223,
10255, 22480, 27388, 9946, 15628, 24389, 17308, 2370, 9530, 31683, 25927, 23567, 11694, 26397, 32602, 15031,
18255, 17582, 1422, 28835, 23607, 12597, 20602, 10138, 5212, 1252, 10074, 23166, 19823, 31667, 5902, 24630,
18948, 14330, 14950, 8939, 23540, 21311, 22428, 22391, 3583, 29004, 30498, 18714, 4278, 2437, 22430, 3439,
28313, 23161, 25396, 13471, 19324, 15287, 2563, 18901, 13103, 16867, 9714, 14322, 15197, 26889, 19372, 26241,
31925, 14640, 11497, 8941, 10056, 6451, 28656, 10737, 13874, 17356, 8281, 25937, 1661, 4850, 7448, 12744,
21826, 5477, 10167, 16705, 26897, 8839, 30947, 27978, 27283, 24685, 32298, 3525, 12398, 28726, 9475, 10208,
617, 13467, 22287, 2376, 6097, 26312, 2974, 9114, 21787, 28010, 4725, 15387, 3274, 10762, 31695, 17320,
18324, 12441, 16801, 27376, 22464, 7500, 5666, 18144, 15314, 31914, 31627, 6495, 5226, 31203, 2331, 4668,
12650, 18275, 351, 7268, 31319, 30119, 7600, 2905, 13826, 11343, 13053, 15583, 30055, 31093, 5067, 761,
9685, 11070, 21369, 27155, 3663, 26542, 20169, 12161, 15411, 30401, 7580, 31784, 8985, 29367, 20989, 14203,
29694, 21167, 10337, 1706, 28578, 887, 3373, 19477, 14382, 675, 7033, 15111, 26138, 12252, 30996, 21409,
25678, 18555, 13256, 23316, 22407, 16727, 991, 9236, 5373, 29402, 6117, 15241, 27715, 19291, 19888, 19847
};
//===================================================================================By eXx0 PRODUCTION
unsigned int U_Random( void )
{
glSeed *= 69069;
glSeed += seed_table[ glSeed & 0xff ];
return ( ++glSeed & 0x0fffffff );
}
//===================================================================================By eXx0 PRODUCTION
void U_Srand( unsigned int seed )
{
glSeed = seed_table[ seed & 0xff ];
}
//===================================================================================By eXx0 PRODUCTION
int UTIL_SharedRandomLong( unsigned int seed, int low, int high )
{
unsigned int range;
U_Srand( (int)seed + low + high );
range = high - low + 1;
if ( !(range - 1) )
{
return low;
}
else
{
int offset;
int rnum;
rnum = U_Random();
offset = rnum % range;
return (low + offset);
}
}
//===================================================================================By eXx0 PRODUCTION
float UTIL_SharedRandomFloat( unsigned int seed, float low, float high )
{
unsigned int range;
U_Srand( (int)seed + *(int *)&low + *(int *)&high );
U_Random();
U_Random();
range = (unsigned int)(high - low);
if ( !range )
{
return low;
}
else
{
int tensixrand;
float offset;
tensixrand = U_Random() & 65535;
offset = (float)tensixrand / 65536.0f;
return (low + offset * range );
}
}
class CNoSpread
{
private:
DWORD BaseGun;
float Distance;
int Flags;
float FOV;
UINT Seed;
float Speed;
float SpreadVar;
int WeaponBit;
int WeaponID;
private:
float GetDistance(void);
float GetVecSpread(void);
public:
void Apply(float *OldAngles, float *CmdAngles);
void Update(local_state_s *to, unsigned int random_seed);
};
extern CNoSpread gNoSpread;
CNoSpread gNoSpread;
float CNoSpread::GetDistance(void)
{
// M3: 3000
// Xm1014: 3048
// ...
}
float CNoSpread::GetVecSpread(void)
{
float VecSpread;
switch (WeaponID)
{
case WEAPON_AK47:
{
if (!(Flags & FL_ONGROUND))
VecSpread = SpreadVar * x + x;
else if (Speed > 140.0f)
VecSpread = SpreadVar * x + x;
else
VecSpread = SpreadVar * x;
break;
}
...
default:
{
VecSpread = 0.0f;
break;
}
}
return VecSpread;
}
void CNoSpread::Apply(float *OldAngles, float *CmdAngles)
{
float Forward[3], Right[3], Up[3], vecDir[3], vecEnd[3], NewAngles[3], Spread[2], VecSpread;
Spread[0] = UTIL_SharedRandomFloat(Seed + 1, -0.5, 0.5) + UTIL_SharedRandomFloat(Seed + 2, -0.5, 0.5);
Spread[1] = UTIL_SharedRandomFloat(Seed + 3, -0.5, 0.5) + UTIL_SharedRandomFloat(Seed + 4, -0.5, 0.5);
VecSpread = GetVecSpread();
Spread[0] *= VecSpread;
Spread[1] *= VecSpread;
gEngine.pfnAngleVectors(OldAngles, Forward, Right, Up);
for (int i = 0; i < 3; i++)
{
vecDir[i] = Forward[i] + Spread[0] * Right[i] + Spread[1] * Up[i];
vecEnd[i] = Distance * vecDir[i];
}
VectorAngles(vecEnd, NewAngles);
NewAngles[0] = -NewAngles[0];
CmdAngles[0] += OldAngles[0] - NewAngles[0];
CmdAngles[1] += OldAngles[1] - NewAngles[1];
}
void CNoSpread::Update(local_state_s *to, unsigned int random_seed)
{
Flags = to->client.flags;
FOV = to->client.fov;
Seed = random_seed;
float Speed = to->client.velocity.Length();
int WeaponID = to->client.m_iId;
Distance = GetDistance();
if (to->weapondata[WeaponID].m_flNextPrimaryAttack <= 0.0f)
{
BaseGun = *(DWORD*)(dwTableInit + 0x0);
SpreadVar = *(float*)(BaseGun + 0xF8);
WeaponBit = *(int*)(BaseGun + 0x128);
}
}
if (runfuncs) gNoSpread.Update(to, random_seed);
usercmd_t UserCmd;
void CL_CreateMove(float frametime, usercmd_s *cmd, int active)
{
gClient.CL_CreateMove(frametime, cmd, active);
RtlCopyMemory(&UserCmd, cmd, sizeof(UserCmd);
... // aimbot before nospread
gNoSpread.Apply(UserCmd.viewangles, cmd->viewangles);
...
}
//HSPRITE ( *pfnSPR_Load ) ( const char *szPicName );
HSPRITE SPR_Load(const char *szPicName)
{
if(strstr(szPicName, "gas_puff_01"))
{
return 0;
}
//Log("PicName: %s", szPicName);
return gEngfuncs.pfnSPR_Load(szPicName);
}
if (pNearestEnt != NULL && fNearestAimTarget[0] > 0 && fNearestAimTarget[1] > 0)
{
// Define the aimsmooth factor
#define AIM_SMOOTH 3
// Is the right mousebutton actually pressed?
if (GetAsyncKeyState(VK_RBUTTON))
{
//Calculate the interpolation
float x = fNearestAimTarget[0] - iScreenCenterX;
float y = fNearestAimTarget[1] - iScreenCenterY;
x /= AIM_SMOOTH;
y /= AIM_SMOOTH;
fNearestAimTarget[0] = iScreenCenterX + x;
fNearestAimTarget[1] = iScreenCenterY + y;
//Aim on the target
SetCursorPos((int)fNearestAimTarget[0], (int)fNearestAimTarget[1]);
}
}
void GetHeadPosition(cl_entity_t *pEnt)
{
typedef float BoneMatrix_t[MAXSTUDIOBONES][3][4];
model_t *pModel;
studiohdr_t *pStudioHeader;
BoneMatrix_t *pBoneMatrix;
Vector vBBMin = Vector(0, 0, 0);
Vector vBBMax = Vector(0, 0, 0);
mstudiobbox_t *pHitbox;
Vector vAimOffs = Vector(0, 0, 0);
vAimOffs[0] = cvar.hbx;
vAimOffs[1] = cvar.hby;
vAimOffs[2] = cvar.hbz;
int i;
if(!vPlayers[pEnt->index].bGotHead)
{
pModel = pstudio->SetupPlayerModel(pEnt->index);
pStudioHeader = (studiohdr_t*)pstudio->Mod_Extradata(pModel);
pBoneMatrix = (BoneMatrix_t*)pstudio->StudioGetBoneTransform();
aimvec av; // This is an aimvec structure the aimbot traditionally uses.
vPlayers[pEnt->index].Hitbox.clear(); // This is the array of hitboxes, we're clearing it so we have fresh aiming spots.
pHitbox = (mstudiobbox_t*)((byte*)pStudioHeader + pStudioHeader->hitboxindex);
i = cvar.hitbox;
if(cvar.hitbox>20){cvar.hitbox=11;}
if(i>=0)
{
VectorTransform(pHitbox[i].bbmin, (*pBoneMatrix)[pHitbox[i].bone], vBBMin);
VectorTransform(pHitbox[i].bbmax, (*pBoneMatrix)[pHitbox[i].bone], vBBMax);
vPlayers[pEnt->index].vPlayerHead = (vBBMax + vBBMin)*0.5f - vAimOffs;
vPlayers[pEnt->index].bGotHead = true;
VectorSubtract(vPlayers[pEnt->index].vPlayerHead, vPlayers[pEnt->index].getEnt()->origin, vPlayers[pEnt->index].vPlayerHead);
av.h = vPlayers[pEnt->index].vPlayerHead[2]; // using the head hitbox as the first point in our aimvec array, so it takes precedence over others.
av.f = vPlayers[pEnt->index].vPlayerHead[1];
av.r = vPlayers[pEnt->index].vPlayerHead[0];
vPlayers[pEnt->index].Hitbox.push_back(av); // this is where the actual adding occurs.
if(cvar.autodetect && gAimbot.target==-1) // is ad enabled and why calculate further if I have a target already?
{
for(int q=1;q<20;q++)
{
float curspot[3];
VectorTransform(pHitbox[q].bbmin, (*pBoneMatrix)[pHitbox[q].bone], vBBMin);
VectorTransform(pHitbox[q].bbmax, (*pBoneMatrix)[pHitbox[q].bone], vBBMax);
VectorCopy((vBBMax + vBBMin) * 0.5f, curspot );
vPlayers[pEnt->index].bAimSpot[q] = true;
VectorSubtract(curspot,vPlayers[pEnt->index].getEnt()->origin,curspot);
// The above is just the same thing the function does, finding the middle of the bounding box and subtracting.
av.h = curspot[2]; // these are other hitboxes
av.f = curspot[1]; // we want to add for autodetect
av.r = curspot[0];
vPlayers[pEnt->index].Hitbox.push_back(av); // this actually adds the hitbox's position to the aimvec structure Hitbox in the VecPlayers class, or vPlayers.
}
}
Vector vCubePoints[8];
Vector vCubePointsTrans[8];
vCubePoints[0] = pHitbox[i].bbmin;
vCubePoints[1] = Vector(pHitbox[i].bbmin.x, pHitbox[i].bbmax.y, pHitbox[i].bbmin.z);
vCubePoints[2] = Vector(pHitbox[i].bbmax.x, pHitbox[i].bbmax.y, pHitbox[i].bbmin.z);
vCubePoints[3] = Vector(pHitbox[i].bbmax.x, pHitbox[i].bbmin.y, pHitbox[i].bbmin.z);
vCubePoints[4] = pHitbox[i].bbmax;
vCubePoints[5] = Vector(pHitbox[i].bbmin.x, pHitbox[i].bbmax.y, pHitbox[i].bbmax.z);
vCubePoints[6] = Vector(pHitbox[i].bbmin.x, pHitbox[i].bbmin.y, pHitbox[i].bbmax.z);
vCubePoints[7] = Vector(pHitbox[i].bbmax.x, pHitbox[i].bbmin.y, pHitbox[i].bbmax.z);
for(int j = 0; j < 8; j++)
VectorTransform(vCubePoints[j], (*pBoneMatrix)[pHitbox[i].bone], vCubePointsTrans[j]);
if(cvar.drawhitbox)
{
glDisable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
ColorEntry *clr;
clr = PlayerColor(pEnt->index);
glColor4f(clr->onebased_r,clr->onebased_g,clr->onebased_b,clr->onebased_a);
glLineWidth(0.15f);
glBegin(GL_LINE_LOOP);
glVertex3fv(vCubePointsTrans[0]);
glVertex3fv(vCubePointsTrans[1]);
glVertex3fv(vCubePointsTrans[2]);
glVertex3fv(vCubePointsTrans[3]);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex3fv(vCubePointsTrans[4]);
glVertex3fv(vCubePointsTrans[5]);
glVertex3fv(vCubePointsTrans[6]);
glVertex3fv(vCubePointsTrans[7]);
glEnd();
glBegin(GL_LINES);
glVertex3fv(vCubePointsTrans[0]);
glVertex3fv(vCubePointsTrans[6]);
glVertex3fv(vCubePointsTrans[1]);
glVertex3fv(vCubePointsTrans[5]);
glVertex3fv(vCubePointsTrans[2]);
glVertex3fv(vCubePointsTrans[4]);
glVertex3fv(vCubePointsTrans[3]);
glVertex3fv(vCubePointsTrans[7]);
glEnd();
glDisable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
}
}
} |