V--Aimbot.cpp #include "CAimbot.h" #include "sdk.h" cCAimbot::cCAimbot( void ) { flBestDist = 99999.9f; m_nTarget = -1; } void cCAimbot::DropTarget( void ) { flBestDist = 99999.9f; m_nTarget = -1; } int cCAimbot::iGetTarget( void ) { return m_nTarget; } void cCAimbot::MakeVector( QAngle angle, QAngle& vector ) { float pitch; float yaw; float tmp; pitch = (float)(angle[0] * M_PI/180); yaw = (float)(angle[1] * M_PI/180); tmp = (float) cos(pitch); vector[0] = (float) (-tmp * -cos(yaw)); vector[1] = (float) (sin(yaw)*tmp); vector[2] = (float) -sin(pitch); } void cCAimbot::CalcAngle( Vector &src, Vector &dst, QAngle &angles ) { double delta[3] = { (src[0]-dst[0]), (src[1]-dst[1]), (src[2]-dst[2]) }; double hyp = sqrt(delta[0]*delta[0] + delta[1]*delta[1]); angles[0] = (float) (atan(delta[2]/hyp) * M_RADPI); angles[1] = (float) (atan(delta[1]/delta[0]) * M_RADPI); angles[2] = 0.0f; if(delta[0] >= 0.0) { angles[1] += 180.0f; } } float cCAimbot::GetFov( QAngle angle, Vector src, Vector dst ) { QAngle ang,aim; float fov; CalcAngle(src, dst, ang); MakeVector(angle, aim); MakeVector(ang, ang); float mag_s = sqrt((aim[0]*aim[0]) + (aim[1]*aim[1]) + (aim[2]*aim[2])); float mag_d = sqrt((aim[0]*aim[0]) + (aim[1]*aim[1]) + (aim[2]*aim[2])); float u_dot_v = aim[0]*ang[0] + aim[1]*ang[1] + aim[2]*ang[2]; fov = acos(u_dot_v / (mag_s*mag_d)) * (180.0 / M_PI); return fov; } bool cCAimbot::GetVisible( Vector& vecAbsStart, Vector& vecAbsEnd, C_BaseEntity* pBaseEnt ) { player_info_t pinfo; trace_t tr; Ray_t ray; ray.Init( vecAbsStart, vecAbsEnd ); HalFLife2.m_pEnginetrace->TraceRay( ray, MASK_NPCWORLDSTATIC|CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEBRIS|CONTENTS_HITBOX, NULL, &tr ); if ( tr.fraction > 0.97f ) return true; if ( tr.m_pEnt && pBaseEnt ) { if ( tr.m_pEnt->index == 0 || tr.allsolid ) return false; if (( HalFLife2.m_pEngine->GetPlayerInfo( tr.m_pEnt->index, &pinfo ) || pBaseEnt->index == tr.m_pEnt->index) && tr.fraction > 0.92) return true; } return false; } bool GetBonePosition ( int iBone, Vector& vecOrigin, QAngle qAngles, int index ) { if( iBone < 0 || iBone >= 20 ) return false; matrix3x4_t pmatrix[MAXSTUDIOBONES]; IClientEntity* ClientEntity = HalFLife2.m_pEntList->GetClientEntity( index ); if ( ClientEntity == NULL ) return false; if ( ClientEntity->IsDormant() ) return false; IClientRenderable* RenderEntity = ClientEntity->GetClientRenderable(); if( RenderEntity == NULL/* nothing */ ) return false; if( RenderEntity->SetupBones( pmatrix, 128, BONE_USED_BY_HITBOX, HalFLife2.m_pGlobals->curtime ) == false ) return false; MatrixAngles( pmatrix[ iBone ], qAngles, vecOrigin ); return true; } void cCAimbot::AimAtTarget( CUserCmd* c ) { if( HalFLife2.m_pEngine->IsInGame() == false || HalFLife2.m_pEngine->IsHLTV() == true || HalFLife2.m_pMyPlayer->BaseEnt() == NULL ) return; DropTarget(); //----------------------------------// player_info_t pinfo; QAngle* pPunchAngle = ( QAngle* )( (DWORD)HalFLife2.m_pMyPlayer->BaseEnt() + 0xBB0 ); //----------------------------------// //----------------------------------// for( int index = 1; index <= HalFLife2.m_pEntList->NumberOfEntities( false ); ++index ) { if ( index == HalFLife2.m_pEngine->GetLocalPlayer() ) continue; IClientEntity* ClientEntity = HalFLife2.m_pEntList->GetClientEntity( index ); if ( ClientEntity == NULL || ClientEntity->IsDormant() ) continue; CBaseEntity* pBaseEntity = ClientEntity->GetBaseEntity(); //Get Life State int *lifestate = (int*) ( ( DWORD )pBaseEntity + ( DWORD )0x87 ); if( pBaseEntity == NULL/* nothing */ || pBaseEntity->IsDormant()/* not active */ || !(*lifestate == LIFE_ALIVE)/* not alive */ || HalFLife2.m_pEngine->GetPlayerInfo( index, &pinfo ) == false/* not a player!*/ || pBaseEntity->GetTeamNumber() == HalFLife2.m_pMyPlayer->BaseEnt()->GetTeamNumber()/*enemy*/ || !GetBonePosition( 14/*Head*/, vPlayer, c->viewangles, index ) || GetFov( HalFLife2.m_pMyPlayer->BaseEnt()->GetAbsAngles(), HalFLife2.m_pMyPlayer->BaseEnt()->EyePosition(), vPlayer ) > 5.0f || !GetVisible( HalFLife2.m_pMyPlayer->BaseEnt()->EyePosition(), vPlayer, pBaseEntity )/* not visible */ || flBestDist < GetFov( HalFLife2.m_pMyPlayer->BaseEnt()->GetAbsAngles(), HalFLife2.m_pMyPlayer->BaseEnt()->EyePosition(), vPlayer )) continue; flBestDist = GetFov( HalFLife2.m_pMyPlayer->BaseEnt()->GetAbsAngles(), HalFLife2.m_pMyPlayer->BaseEnt()->EyePosition(), vPlayer ); m_nTarget = index; // Calculate the delta origin Vector vDeltaOrigin = vPlayer - vPlayer; // Calculate the Latency float fLatency = HalFLife2.m_pEngine->GetNetChannelInfo()->GetLatency( FLOW_OUTGOING ); // Compensate the latency vDeltaOrigin[0] *= fLatency; vDeltaOrigin[1] *= fLatency; vDeltaOrigin[2] *= fLatency; //Apply the prediction PredictedTargetPosition = vPlayer + vDeltaOrigin; } if( m_nTarget == -1 ) return; CalcAngle( HalFLife2.m_pMyPlayer->BaseEnt()->EyePosition(), PredictedTargetPosition, c->viewangles ); //recoil c->viewangles.x -= ( pPunchAngle->x *2.0f ); c->viewangles.y -= ( pPunchAngle->y *2.0f ); //aimbot HalFLife2.m_pEngine->SetViewAngles( c->viewangles );//aim //nospread float flNew[3],flOld[3]; flOld[0] = c->viewangles[0];flOld[1] = c->viewangles[1];flOld[2] = c->viewangles[2]; HalFLife2.m_pNoSpread->GetSpreadFix( c->random_seed, flOld, flNew ); c->viewangles[0] += flNew[0];c->viewangles[1] += flNew[1];c->viewangles[2] += flNew[2]; DropTarget(); if(base.m_psCvar->misc_autopistol){ static bool bInAttack = false; if ( bInAttack ) c->buttons |= IN_ATTACK; else c->buttons &= ~IN_ATTACK; bInAttack = !bInAttack; } //autoshoot if(base.m_psCvar->misc_autopistol){ static bool bInAttack = false; if ( bInAttack ) c->buttons |= IN_ATTACK; else c->buttons &= ~IN_ATTACK; bInAttack = !bInAttack; } xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx client.cpp #ifndef __CLIENT__H #define __CLIENT__H #include #include "SDK.h" struct CClient { int (__stdcall *Init)( CreateInterfaceFn appSystemFactory, CreateInterfaceFn physicsFactory, CGlobalVarsBase *pGlobals ); void (__stdcall *Shutdown)( void ); void (__stdcall *LevelInitPreEntity)( char const* pMapName ); void (__stdcall *LevelInitPostEntity)( void ); void (__stdcall *LevelShutdown)( void ); ClientClass *(__stdcall *GetAllClasses)( void ); int (__stdcall *HudVidInit)( void ); void (__stdcall *HudProcessInput)( bool bActive ); void (__stdcall *HudUpdate)( bool bActive ); void (__stdcall *HudReset)( void ); void (__stdcall *HudText)( const char * message ); void (__stdcall *IN_ActivateMouse)( void ); void (__stdcall *IN_DeactivateMouse)( void ); void (__stdcall *IN_MouseEvent)(int mstate, bool down); void (__stdcall *IN_Accumulate)(void); void (__stdcall *IN_ClearStates)(void); bool (__stdcall *IN_IsKeyDown)( const char *name, bool& isdown ); int (__stdcall *IN_KeyEvent)( int eventcode, int keynum, const char *pszCurrentBinding ); void (__stdcall *CreateMove)( int sequence_number, float input_sample_frametime,bool active ); void (__stdcall *ExtraMouseSample)( float frametime, bool active ); bool (__stdcall *WriteUsercmdDeltaToBuffer)( bf_write *buf, int from, int to, bool isnewcommand ); void (__stdcall *EncodeUserCmdToBuffer)( bf_write& buf, int slot ); void (__stdcall *DecodeUserCmdFromBuffer)( bf_read& buf, int slot ); void (__stdcall *View_Render)( vrect_t *rect ); void (__stdcall *RenderView)( const CViewSetup &view, bool drawViewmodel ); void (__stdcall *View_Fade)( ScreenFade_t *pSF ); void (__stdcall *SetCrosshairAngle)( const QAngle& angle ); void (__stdcall *InitSprite)( CEngineSprite *pSprite, const char *loadname ); void (__stdcall *ShutdownSprite)( CEngineSprite *pSprite ); int (__stdcall *GetSpriteSize)( void ); void (__stdcall *VoiceStatus)( int entindex, qboolean bTalking ); void (__stdcall *InstallStringTableCallback)( char const *tableName ); void (__stdcall *FrameStageNotify)( ClientFrameStage_t curStage ); bool (__stdcall *DispatchUserMessage)( int msg_type, bf_read &msg_data ); CSaveRestoreData *(__stdcall *SaveInit)( int size ); void (__stdcall *SaveWriteFields)( CSaveRestoreData *, const char *, void *, datamap_t *, typedescription_t *, int ); void (__stdcall *SaveReadFields)( CSaveRestoreData *, const char *, void *, datamap_t *, typedescription_t *, int ); void (__stdcall *PreSave)( CSaveRestoreData * ); void (__stdcall *Save)( CSaveRestoreData * ); void (__stdcall *WriteSaveHeaders)( CSaveRestoreData * ); void (__stdcall *ReadRestoreHeaders)( CSaveRestoreData * ); void (__stdcall *Restore)( CSaveRestoreData *, bool ); void (__stdcall *DispatchOnRestore)(); CStandardRecvProxies* (__stdcall *GetStandardRecvProxies)(); void (__stdcall *WriteSaveGameScreenshot)( const char *pFilename ); void (__stdcall *EmitSentenceCloseCaption)( char const *tokenstream ); void (__stdcall *EmitCloseCaption)( char const *captionname, float duration ); }; extern CClient gClient; extern CClient* g_pHookedClient; void __stdcall new_HudUpdate ( bool bActive ); void __stdcall new_CreateMove ( int sequence_number, float input_sample_frametime, bool active ); #endif if(base.m_psCvar->misc_autopistol) { if (!base.m_pWeapon->IsCurWepGrenade() && !base.m_pWeapon->IsDefusing( cmd ) ) { if(base.m_pWeapon->IsAttacking(cmd)&& base.m_psCvar->misc_autopistol) { static bool bAttack = false; if (bAttack) cmd->buttons |= IN_ATTACK; else cmd->buttons &= ~IN_ATTACK; bAttack = !bAttack; } xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Simple royal menu creidts: h1web(most of the code is his), fum1n add these files then put Code: gMenu.InitializeMenu(); gMenu.MenuDrawing(); in cDrawPanel::Paint the easyest way to add somthing to the menu is: Code: //Example: float esp; if(esp){ DrawPlayerESP(); } //or whatever you're using //then in the cMenu.cpp put: i = AddMenuEntry(i, " Player ESP",&esp, 0, 1, 1); Here's the file that had cDrawPanel::Paint and where I added #include "Panels.h" #include "sdk.h" //------------------------------ ScreenSize_t sScreenSize; // struct to store the screen-size //------------------------------ //---------------------------------------------------------------------------------------------------------- CDrawLayer::CDrawLayer ( void ) { pDrawPanel = NULL; } CDrawLayer::~CDrawLayer ( void ) { Destroy(); } void CDrawLayer::Create( vgui::VPANEL parent ) { pDrawPanel = new CDrawPanel ( parent ); } void CDrawLayer::Destroy( void ) { if ( pDrawPanel ) { ExitProcess( 0 ); pDrawPanel->SetParent( (vgui::Panel *)NULL ); delete pDrawPanel; pDrawPanel = NULL; } } //------------------------------------------------------------------------------------------------------------------ CDrawPanel::CDrawPanel( vgui::VPANEL parent ) : BaseClass( NULL,"DrawPanel" ) { SetParent( parent ); // set the parent SetPos( 0, 0 ); // start at the left top corner SetVisible( true ); // yup ... :) SetCursor( null ); // not needed HalFLife2.m_pEngine->GetScreenSize( sScreenSize.m_iWidth, sScreenSize.m_iHeight ); SetSize( sScreenSize.m_iWidth, sScreenSize.m_iHeight ); } void CDrawPanel::Paint( void ) gMenu.InitializeMenu(); gMenu.MenuDrawing(); { if ( !HalFLife2.m_pEngine->IsConnected() || !HalFLife2.m_pEngine->IsInGame() || !HalFLife2.m_pMyPlayer->BaseEnt() || HalFLife2.m_pEngine->Con_IsVisible() || HalFLife2.m_pEngine->IsLevelMainMenuBackground()) return; //Now Draw The Stuff HalFLife2.m_pEsp->CrossHairByLix(); HalFLife2.m_pEsp->DrawEsp(); }