#include "client.h" #include "engine.h" #include "hook.h" #include #include #include "vPanels.h" #include "cMenu.h" #include "ccvar.h" #include "cAimbot.h" #include "public\view_shared.h" #include "cESP.h" #include "cMirc.h" #include "cNoSpread.h" #include "cMapOverview.h" #include "cSpriteESP.h" #include "cDrawing.h" #include "cNickSpammer.h" #include "cConsole.h" #define MACRO_SETUP( x )\ gHookedClient.##x = &new_##x; // resolving classes static cDrawLayer gDrawLayer; cMapLayer gMapLayer; cl_exports_s gHookedClient; cNoSpread gNoSpread; cSpriteESP gSpriteESP; cNickSpammer gNickSpammer; cMirc gMirc( xKeyboardHook ); bool g_bInitialized = false; bool g_bConnected = false; bool g_bUseNetworkVars = false; bool g_bAlreadyDrawing = false; extern int g_iMod; void Initialize ( void ) { g_bInitialized = true; gCvars.Initialize(); vgui::VPANEL vpParent = g_pEnginevgui->GetPanel( PANEL_TOOLS ); const char* szMod = gEngineFuncs.GetGameDirectory(); if (szMod) { if (strstr(szMod,"cstrike")) { add_log("Compatible Mod found: CounterStike Source"); g_iMod = 0; } else { add_log("Compatible Mod found: Half Life 2"); g_iMod = 1; } } ReadSettings("settings.cfg"); gMenu.Initialize("commandmenu.txt"); gDrawLayer.Create( vpParent ); // now who is your daddy? gMapLayer.Create( vpParent ); gMirc.Initialize( xKeyboardHook ); gHLHConsole.Initialize( ConKeyboardHook ); MathLib_Init( 2.2f, 2.2f, 0.0f, 2.0f ); } bool __stdcall new_DispatchUserMessage ( int msg_type, bf_read &msg_data ) { if ( msg_type == 12 && gCvars.antipunish && g_bInitialized && g_iMod == 0) if ( gAimbot.bAbletoAttack() && gCvars.antipunish->GetBool() ) return true; if ( msg_type == 11 && g_iMod == 0 && gAimbot.bAbletoAttack() ) // disallow shaking at any time! return true; return gClientFuncs.DispatchUserMessage( msg_type , msg_data ); } int __stdcall new_HudVidInit( void ) { if (g_bInitialized == false) Initialize(); //this is the best place return gClientFuncs.HudVidInit(); } void hlh_execloops( void ); void __stdcall new_HudUpdate ( bool bActive ) { if ( gEngineFuncs.IsInGame() && g_bInitialized == false) Initialize(); if (g_bInitialized) { gAimbot.CalcAngles(); if (( gCvars.textspam->GetBool() || gCvars.radiospam->GetBool() || gCvars.namechange->GetBool() ) && ( gAimbot.bAbletoAttack() )) gNickSpammer.PerformSpamming(); gESPHelper.ColorizePlayer(); hlh_execloops(); } gClientFuncs.HudUpdate( bActive ); if (g_bInitialized) gAimbot.CalcAngles(); } void __stdcall new_CreateMove ( int sequence_number, float input_sample_frametime, bool active ) { gClientFuncs.CreateMove( sequence_number , input_sample_frametime , active ); if (gEngineFuncs.IsInGame() == false || !g_pInput ) return; g_bConnected = true; CUserCmd* cmd = g_pInput->GetUserCmd(sequence_number); if ( !cmd ) return; if (!gAimbot.bAbletoAttack()) return; QAngle vPunchAngle,vAimAngle; if(!gAimbot.bGetPunchAngles(vPunchAngle)) return; if(!vPunchAngle.IsValid()) return; bool bGotAmmo = gNoSpread.bGotAmmo(); if (gAimbot.bGetAngles(vAimAngle) && gCvars.aimbot->GetBool()) { // cmd->viewangles = vAimAngle; if ( gCvars.autoshoot->GetFloat() > vPunchAngle.Length() && bGotAmmo) cmd->buttons |= IN_ATTACK; } else { if ( gCvars.spinbot->GetBool() && bGotAmmo ) gAimbot.SpinSpin ( cmd ); } if (gCvars.norecoil->GetFloat() != 0.0f) { if ( cmd->viewangles.IsValid() && vPunchAngle.IsValid()) { gAimbot.CompensatePunch(gCvars.norecoil->GetFloat(),cmd->viewangles); //gEngineFuncs.SetViewAngles(cmd->viewangles); } } if(gCvars.bunnyhop->GetInt() && (cmd->buttons & IN_JUMP) && !(gAimbot.iGetFlags() & FL_ONGROUND)) // bunny hop cmd->buttons &= ~IN_JUMP; if ((gCvars.nospread->GetInt() == 1)|| (cmd->buttons & IN_ATTACK && gCvars.nospread->GetInt() == 2)) { float flNew[3],flOld[3]; flOld[0] = cmd->viewangles[0];flOld[1] = cmd->viewangles[1];flOld[2] = cmd->viewangles[2]; if ( g_iMod == 0 ) { gNoSpread.GetSpreadFix( cmd->random_seed, flOld, flNew ); cmd->viewangles[0] += flNew[0];cmd->viewangles[1] += flNew[1];cmd->viewangles[2] += flNew[2]; } else { // gNoSpread.GetSpreadFixHL2( cmd->random_seed, flOld, flNew ); // cmd->viewangles[0] -= flNew[0];cmd->viewangles[1] -= flNew[1];cmd->viewangles[2] -= flNew[2]; } } /* if ( gCvars.antipunish->GetBool() ) { MACRO_EXEC_ONCE( PatchFade(); ); } */ if(gCvars.pistol->GetInt() && (cmd->buttons & IN_ATTACK) && gNoSpread.bCurWeaponPistol()) { static bool bAttack = false; if (bAttack) cmd->buttons |= IN_ATTACK; else cmd->buttons &= ~IN_ATTACK; bAttack = !bAttack; } else { if ( cmd->buttons & IN_ATTACK && gCvars.autoswitch->GetBool()/* && gAimbot.iGetTarget() != -1*/ && gNoSpread.bIsAttackWeapon()) { gEngineFuncs.ClientCmd( "slot2" ); } } if(gCvars.duck->GetInt() && (cmd->buttons & IN_JUMP) && !(gAimbot.iGetFlags() & FL_ONGROUND)) cmd->buttons |= IN_DUCK; cmd->viewangles[2] = 0; } void __stdcall new_HudReset ( void ) { gESPHelper.ResetSounds(); gClientFuncs.HudReset(); gDraw.ClearHudMessages(); gESPHelper.bPlanted = false; } //-------------------------------------------------------------------------------- // The functions below aren't modified yet! //-------------------------------------------------------------------------------- int __stdcall new_Init ( CreateInterfaceFn appSystemFactory, CreateInterfaceFn physicsFactory, CGlobalVarsBase *pGlobals ) { return gClientFuncs.Init( appSystemFactory , physicsFactory , pGlobals ); } void __stdcall new_Shutdown ( void ) { gClientFuncs.Shutdown(); } void __stdcall new_LevelInitPreEntity ( char const* pMapName ) { gClientFuncs.LevelInitPreEntity( pMapName ); } void __stdcall new_LevelInitPostEntity ( void ) { gClientFuncs.LevelInitPostEntity( ); } void __stdcall new_LevelShutdown ( void ) { gClientFuncs.LevelShutdown( ); } ClientClass* __stdcall new_GetAllClasses ( void ) { return gClientFuncs.GetAllClasses(); } void __stdcall new_HudProcessInput ( bool bActive ) { gClientFuncs.HudProcessInput( bActive ); } void __stdcall new_HudText( const char * message ) { gClientFuncs.HudText( message ); } void __stdcall new_IN_ActivateMouse ( void ) { gClientFuncs.IN_ActivateMouse(); } void __stdcall new_IN_DeactivateMouse ( void ) { gClientFuncs.IN_DeactivateMouse(); } void __stdcall new_IN_MouseEvent ( int mstate, bool down ) { gClientFuncs.IN_MouseEvent( mstate , down ); } void __stdcall new_IN_Accumulate ( void ) { gClientFuncs.IN_Accumulate(); } void __stdcall new_IN_ClearStates ( void ) { gClientFuncs.IN_ClearStates(); } bool __stdcall new_IN_IsKeyDown ( const char *name, bool& isdown ) { return gClientFuncs.IN_IsKeyDown( name , isdown ); } int __stdcall new_IN_KeyEvent ( int eventcode, int keynum, const char *pszCurrentBinding ) { return gClientFuncs.IN_KeyEvent( eventcode , keynum , pszCurrentBinding ); } void __stdcall new_ExtraMouseSample ( float frametime, bool active ) { gClientFuncs.ExtraMouseSample( frametime , active ); } bool __stdcall new_WriteUsercmdDeltaToBuffer ( bf_write *buf, int from, int to, bool isnewcommand ) { return gClientFuncs.WriteUsercmdDeltaToBuffer( buf , from , to , isnewcommand ); } void __stdcall new_EncodeUserCmdToBuffer ( bf_write& buf, int slot ) { gClientFuncs.EncodeUserCmdToBuffer( buf , slot ); } void __stdcall new_DecodeUserCmdFromBuffer ( bf_read& buf, int slot ) { gClientFuncs.DecodeUserCmdFromBuffer( buf , slot ); } void __stdcall new_View_Render ( vrect_t *rect ) { gClientFuncs.View_Render( rect ); } void __stdcall new_RenderView (const CViewSetup &view, bool drawViewmodel ) { gClientFuncs.RenderView( view , drawViewmodel ); } void __stdcall new_View_Fade ( ScreenFade_t *pSF ) { gClientFuncs.View_Fade( pSF ); } void __stdcall new_SetCrosshairAngle ( const QAngle& angle ) { gClientFuncs.SetCrosshairAngle( angle ); } void __stdcall new_InitSprite ( CEngineSprite *pSprite, const char * loadname ) { gClientFuncs.InitSprite( pSprite , loadname ); } void __stdcall new_ShutdownSprite ( CEngineSprite *pSprite ) { gClientFuncs.ShutdownSprite( pSprite ); } int __stdcall new_GetSpriteSize ( void ) { return gClientFuncs.GetSpriteSize(); } void __stdcall new_VoiceStatus ( int entindex, qboolean bTalking ) { gClientFuncs.VoiceStatus( entindex , bTalking ); } void __stdcall new_InstallStringTableCallback ( char const *tableName ) { gClientFuncs.InstallStringTableCallback( tableName ); } void __stdcall new_FrameStageNotify( ClientFrameStage_t curStage ) { gClientFuncs.FrameStageNotify( curStage ); } CSaveRestoreData* __stdcall new_SaveInit ( int size ) { return gClientFuncs.SaveInit( size ); } void __stdcall new_SaveWriteFields ( CSaveRestoreData * ptr, const char * szptr, void * pfn, datamap_t * pMap, typedescription_t * pType, int integer ) { gClientFuncs.SaveWriteFields( ptr , szptr , pfn , pMap , pType , integer ); } void __stdcall new_SaveReadFields ( CSaveRestoreData * ptr , const char * szptr, void * pfn, datamap_t * pData, typedescription_t * pType, int integer ) { gClientFuncs.SaveReadFields( ptr , szptr , pfn , pData , pType , integer ); } void __stdcall new_PreSave ( CSaveRestoreData * ptr ) { gClientFuncs.PreSave( ptr ); } void __stdcall new_Save ( CSaveRestoreData * ptr ) { gClientFuncs.Save( ptr ); } void __stdcall new_WriteSaveHeaders ( CSaveRestoreData * ptr) { gClientFuncs.WriteSaveHeaders( ptr ); } void __stdcall new_ReadRestoreHeaders ( CSaveRestoreData * ptr ) { gClientFuncs.ReadRestoreHeaders( ptr ); } void __stdcall new_Restore ( CSaveRestoreData * ptr, bool boolean) { gClientFuncs.Restore( ptr , boolean ); } void __stdcall new_DispatchOnRestore ( void ) { gClientFuncs.DispatchOnRestore(); } CStandardRecvProxies* __stdcall new_GetStandardRecvProxies ( void ) { return gClientFuncs.GetStandardRecvProxies(); } void __stdcall new_WriteSaveGameScreenshot ( const char *pFilename ) { gClientFuncs.WriteSaveGameScreenshot ( pFilename ); } void __stdcall new_EmitSentenceCloseCaption ( char const *tokenstream ) { gClientFuncs.EmitSentenceCloseCaption ( tokenstream ); } void __stdcall new_EmitCloseCaption ( char const *captionname, float duration ) { gClientFuncs.EmitCloseCaption ( captionname , duration ); } void SetupNewClient ( void ) { MACRO_SETUP( Init ); MACRO_SETUP( Shutdown ); MACRO_SETUP( LevelInitPreEntity); MACRO_SETUP( LevelInitPostEntity); MACRO_SETUP( LevelShutdown); MACRO_SETUP( GetAllClasses); MACRO_SETUP( HudVidInit); MACRO_SETUP( HudProcessInput); MACRO_SETUP( HudUpdate); MACRO_SETUP( HudReset); MACRO_SETUP( HudText); MACRO_SETUP( IN_ActivateMouse); MACRO_SETUP( IN_DeactivateMouse); MACRO_SETUP( IN_MouseEvent ); MACRO_SETUP( IN_Accumulate); MACRO_SETUP( IN_ClearStates); MACRO_SETUP( IN_IsKeyDown); MACRO_SETUP( IN_KeyEvent); MACRO_SETUP( CreateMove); MACRO_SETUP( ExtraMouseSample); MACRO_SETUP( WriteUsercmdDeltaToBuffer); MACRO_SETUP( EncodeUserCmdToBuffer); MACRO_SETUP( DecodeUserCmdFromBuffer); MACRO_SETUP( View_Render); MACRO_SETUP( RenderView); MACRO_SETUP( View_Fade); MACRO_SETUP( SetCrosshairAngle); MACRO_SETUP( InitSprite); MACRO_SETUP( ShutdownSprite); MACRO_SETUP( GetSpriteSize); MACRO_SETUP( VoiceStatus); MACRO_SETUP( InstallStringTableCallback); MACRO_SETUP( FrameStageNotify); MACRO_SETUP( DispatchUserMessage); MACRO_SETUP( SaveInit ); MACRO_SETUP( SaveWriteFields); MACRO_SETUP( SaveReadFields); MACRO_SETUP( PreSave); MACRO_SETUP( Save); MACRO_SETUP( WriteSaveHeaders); MACRO_SETUP( ReadRestoreHeaders); MACRO_SETUP( Restore); MACRO_SETUP( DispatchOnRestore ); MACRO_SETUP( GetStandardRecvProxies); MACRO_SETUP( WriteSaveGameScreenshot); MACRO_SETUP( EmitSentenceCloseCaption); MACRO_SETUP( EmitCloseCaption); } Aimbot.cpp #include "cAimBot.h" #include "cESP.h" #include "cNoSpread.h" #include "cDrawing.h" #include "ColourManager.h" extern cNoSpread gNoSpread; CBaseEntityList* g_pEntityList; cAimbot::cAimbot ( void ) { // m_iVisiblity = VISIBILITY_RESET; m_iCurrentTartget = -1; m_hitboxes.push_back( 14 ); } void cAimbot::ClearHitboxes ( void ) { m_hitboxes.clear(); // m_iVisiblity = VISIBILITY_RESET; } void cAimbot::ClearAimvecs ( void ) { m_aimvecs.clear(); // m_iVisiblity = VISIBILITY_RESET; } void cAimbot::AddHitbox ( int iHBIndex ) { m_hitboxes.push_back( iHBIndex ); } void cAimbot::AddAimVec ( float h,float r,float f,int iSequence ) { aimvec_t aimvec; aimvec.flForward = f; aimvec.flRight = r; aimvec.flHeight = h; aimvec.iSequence = iSequence; add_log( "adding %i %f %f %f",iSequence, h,r,f ); m_aimvecs.push_back( aimvec ); } void cAimbot::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 cAimbot::CalcAngle(Vector &src, Vector &dst, QAngle &angles)// Azorbix { 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 cAimbot::flGetFOVDist(QAngle angle, Vector src, Vector dst) { float fov = 0.0f; QAngle ang,aim; CalcAngle(src, dst, ang); MakeVector(angle, aim); MakeVector(ang, ang); float mag_s = sqrt(SQUARE(aim[0]) + SQUARE(aim[1]) + SQUARE(aim[2])); float mag_d = sqrt(SQUARE(ang[0]) + SQUARE(ang[1]) + SQUARE(ang[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; } int cAimbot::iGetFlags ( void ) { int iLocalIndex = gEngineFuncs.GetLocalPlayer(); if (iLocalIndex < 0) return 0; if (g_pEntList->GetClientEntity(iLocalIndex) == NULL) return 0; C_BaseEntity* pLocalBaseEnt = g_pEntList->GetClientEntity( iLocalIndex )->GetBaseEntity(); if (!pLocalBaseEnt) return 0; C_BasePlayer* pBasePlayer = ToBasePlayer( pLocalBaseEnt ); if (!pBasePlayer) return 0; return pBasePlayer->GetFlags(); } bool cAimbot::bGetPunchAngles ( QAngle& qPunchAngle ) { int iLocalIndex = gEngineFuncs.GetLocalPlayer(); if (iLocalIndex < 0) return false; if (g_pEntList->GetClientEntity(iLocalIndex) == NULL) return false; C_BaseEntity* pLocalBaseEnt = g_pEntList->GetClientEntity(iLocalIndex)->GetBaseEntity(); if (!pLocalBaseEnt) return false; C_BasePlayer* pBasePlayer = ToBasePlayer(pLocalBaseEnt); if (!pBasePlayer) return false; qPunchAngle = pBasePlayer->GetPunchAngle(); return true; } void cAimbot::CompensatePunch( float fkFactor,QAngle& eyepos) { QAngle qPunchAngle,eyeAngles; int iLocalIndex = gEngineFuncs.GetLocalPlayer(); if (iLocalIndex < 0) return; if (g_pEntList->GetClientEntity(iLocalIndex) == NULL) return; C_BaseEntity* pLocalBaseEnt = g_pEntList->GetClientEntity(iLocalIndex)->GetBaseEntity(); if (!pLocalBaseEnt) return; C_BasePlayer* pBasePlayer = ToBasePlayer(pLocalBaseEnt); if (!pBasePlayer) return; eyepos -= pBasePlayer->GetPunchAngle() * fkFactor; } void cAimbot::TraceLine( const Vector& vecAbsStart, const Vector& vecAbsEnd, unsigned int mask,ITraceFilter *pFilter, trace_t *ptr ) { Ray_t ray; ray.Init( vecAbsStart, vecAbsEnd ); g_pEnginetrace->TraceRay( ray, mask, pFilter, ptr ); } bool cAimbot::bIsVisible( const Vector& vecAbsStart, const Vector& vecAbsEnd, unsigned int mask, C_BaseEntity* cBaseEnt ) { if (gCvars.aimthru->GetBool()) return true; trace_t tr; TraceLine(vecAbsStart, vecAbsEnd, mask, NULL, &tr); return ((tr.fraction == 1.0f && tr.m_pEnt == cBaseEnt) && tr.DidHitWorld() == false); } void cAimbot::CheckTarget( C_BaseEntity* pEnt,C_BaseEntity* pMe, player_info_t playerInfo_s ) { if (pEnt->GetTeamNumber() == pMe->GetTeamNumber() && gCvars.aimteam->GetInt() == 0) return; if (pEnt->GetTeamNumber() != pMe->GetTeamNumber() && gCvars.aimteam->GetInt() == 1) return; if (flGetFOVDist(pMe->GetAbsAngles(),pMe->GetAbsOrigin(),pEnt->GetAbsOrigin()) > gCvars.aimfov->GetFloat()) return; if ( gCvars.friendsavoiding->GetBool() && bIsFriend( playerInfo_s.guid ) ) return; float flDistance = flGetAimFactor(pMe->GetAbsAngles(),pMe->GetAbsOrigin(),pEnt->GetAbsOrigin()); int iHealth = pEnt->GetHealth(); if ( gCvars.lamertracking->GetBool() && bIsLamer( playerInfo_s.guid ) ) { iHealth -= ( iHealth > 50 )? 50 : iHealth; flDistance -= ( flDistance > 50 )? 50.0f : flDistance; // anyone below has a higher priority } if ((flDistance < m_flLastValue) || ( gCvars.aimsel->GetInt() == 2 && ( m_iHealth > iHealth || (m_iHealth == pEnt->GetHealth() && flDistance < m_flLastValue)))) { Vector vOrigin = pEnt->GetAbsOrigin(); Vector vecOrigin = pMe->GetAbsOrigin(); if(!(pEnt->GetFlags() & FL_DUCKING)) // Tetsuo owns ;) vOrigin[2] += 55; else vOrigin[2] += 35; if(!(pMe->GetFlags() & FL_DUCKING)) // Tetsuo owns ;) vecOrigin[2] += 55; else vecOrigin[2] += 35; if ( bIsVisible( vOrigin, vecOrigin, CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTER|CONTENTS_DEBRIS, pEnt )) { m_iHealth = pEnt->GetHealth(); m_flLastValue = flDistance; m_iCurrentTartget = pEnt->index; m_iVisiblity = VISIBILITY_FULL; } else if ( gCvars.autowall->GetBool() && m_iVisiblity != VISIBILITY_FULL ) { if ( bCanCauseDamage( pEnt, pMe ) ) { m_iHealth = pEnt->GetHealth(); m_flLastValue = flDistance; m_iCurrentTartget = pEnt->index; m_iVisiblity = VISIBILITY_AWALL; } } } } extern int g_iMod; bool cAimbot::bCanShoothrough( C_BaseEntity* pEnt,C_BaseEntity* pMe, trace_t* tr ) { if (g_pPhysicAPI == NULL) return false; if ( gNoSpread.bPenetrationGun() == false && g_iMod == 0) return false; Vector vTarget = pEnt->EyePosition(); surfacedata_t *pSurfaceData = g_pPhysicAPI->GetSurfaceData( tr->surface.surfaceProps ); int iMaterial = pSurfaceData->game.material; if (pSurfaceData->game.material == CHAR_TEX_METAL || pSurfaceData->game.material == CHAR_TEX_FLESH || pSurfaceData->game.material == CHAR_TEX_VENT || pSurfaceData->game.material == CHAR_TEX_GRATE || pSurfaceData->game.material == CHAR_TEX_COMPUTER || pSurfaceData->game.material == CHAR_TEX_BLOODYFLESH || pSurfaceData->game.material == CHAR_TEX_ALIENFLESH ) { return (tr->fraction > 0.82765); } return (tr->fraction > 0.71524); } extern int g_iMod; bool cAimbot::bCanCauseDamage( C_BaseEntity* pEnt,C_BaseEntity* pMe )// this presumes that we did hit an obstacle { trace_t tr; TraceLine(pEnt->EyePosition(),pMe->EyePosition(),MASK_NPCWORLDSTATIC,NULL,&tr); if (tr.allsolid) return false; if (tr.DidHitNonWorldEntity()) { if (pEnt->GetTeamNumber() == pMe->GetTeamNumber() && gCvars.aimteam->GetInt() == 0) return true; if (pEnt->GetTeamNumber() != pMe->GetTeamNumber() && gCvars.aimteam->GetInt() == 1) return true; } if ( g_iMod ) { return tr.fraction > 0.7; } else { return bCanShoothrough(pEnt,pMe,&tr); } } int cAimbot::iGetTarget ( void ) { return m_iCurrentTartget; } void cAimbot::DropTarget ( void ) { m_iCurrentTartget = -1; m_flLastValue = 9999.9f; m_iHealth = 9999; m_iVisiblity = VISIBILITY_RESET; } float cAimbot::flGetAimFactor(QAngle angle, Vector src, Vector dst) { if ( gCvars.aimsel->GetInt() == 0) return gESPHelper.flGetDistance(src,dst); else if ( gCvars.aimsel->GetInt() == 1) return flGetFOVDist(angle,src,dst); return gESPHelper.flGetDistance(src,dst); } bool cAimbot::bAimbox( int iBone ) { for (int i = 0; i < m_hitboxes.size();i++) if (m_hitboxes[i] == iBone) return true; return false; } int cAimbot::iGetSequence( C_BaseEntity* pBaseEntity ) { if (!pBaseEntity) return SEQUENCE_STANDING; int iFlags = pBaseEntity->GetFlags(); // add more here ... on demand if (iFlags & FL_SWIM) return SEQUENCE_SWIMMING; if (iFlags & FL_DUCKING) return SEQUENCE_DUCKING; if ((iFlags & FL_ONGROUND) == false || (iFlags & FL_WATERJUMP) || (iFlags & FL_FLY)) return SEQUENCE_JUMPING; return SEQUENCE_STANDING; } int cAimbot::iGetAimVec( int iSequence ) { for (int i = 0; i < m_aimvecs.size();i++) if (m_aimvecs[i].iSequence == iSequence) return i; return 0; // take the first vector... then } void cAimbot::DrawVecs ( C_BaseEntity* pEnt,C_BaseEntity* pMe ) { if ( pEnt == NULL ) return; Vector vecForward,vecRight,vecUp,vAimPos,vecOrigin = pEnt->GetAbsOrigin(),vecScreen; QAngle ViewAngle = pEnt->GetAbsAngles(); AngleVectors(ViewAngle,&vecForward,&vecRight,&vecUp); if(!(pEnt->GetFlags() & FL_DUCKING)) vecOrigin[2] += 45; else vecOrigin[2] += 25; vAimPos = vecOrigin; for ( int i = 0; i < m_aimvecs.size(); i++ ) { vAimPos = vAimPos + vecForward * m_aimvecs[i].flForward; vAimPos = vAimPos + vecUp * m_aimvecs[i].flHeight; vAimPos = vAimPos + vecRight * m_aimvecs[i].flRight; if ( gDraw.bWorldToScreen( vAimPos, vecScreen )) gDraw.DrawBox ( vecScreen.x, vecScreen.y, gColorManager.dwGetTeamColor( pEnt->GetTeamNumber() ), 2 ); vAimPos = vecOrigin; } } bool cAimbot::bGetTargetPos( Vector& vAimPos, Vector vLocalPosition ) { // Client entity for target IClientEntity* Player = g_pEntList->GetClientEntity(m_iCurrentTartget); if (!Player) return false; // base entity for target C_BaseEntity* pBaseEntity = Player->GetBaseEntity(); if (!pBaseEntity) return false; if ( gCvars.aimmode->GetBool() && m_aimvecs.size()) { int iSequence = iGetSequence( pBaseEntity ); for ( int i = 0; i < m_aimvecs.size(); i++ ) { if ( iSequence != m_aimvecs[i].iSequence ) continue; Vector vecForward,vecRight,vecUp,vecOrigin = pBaseEntity->GetAbsOrigin(); QAngle ViewAngle = pBaseEntity->EyeAngles(); ViewAngle[0] = 0; ViewAngle[2] = 0; AngleVectors(ViewAngle,&vecForward,&vecRight,&vecUp); if(!(pBaseEntity->GetFlags() & FL_DUCKING)) vecOrigin[2] += 45; else vecOrigin[2] += 25; vAimPos = vecOrigin; vAimPos = vAimPos + vecForward * m_aimvecs[i].flForward; vAimPos = vAimPos + vecUp * m_aimvecs[i].flHeight; vAimPos = vAimPos + vecRight * m_aimvecs[i].flRight; if ( bIsVisible( vLocalPosition, vAimPos, CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTER|CONTENTS_DEBRIS , pBaseEntity ) ) return true; } return true; } else { int iLocalIndex = gEngineFuncs.GetLocalPlayer(); if (iLocalIndex < 1) return false; if (g_pEntList->GetClientEntity(iLocalIndex) == NULL) return false; // local base entity C_BaseEntity* pLocalBaseEnt = g_pEntList->GetClientEntity(iLocalIndex)->GetBaseEntity(); if ( m_hitboxes.size() == 0 || pLocalBaseEnt == NULL ) return false; // Combat character C_BaseCombatCharacter* pCombat = ToBaseCombatCharacter( pBaseEntity ); if (!pCombat) return false; // base animating C_BaseAnimating* pBaseAni = pCombat->GetBaseAnimating(); if (!pBaseAni) return false; // Matrix matrix3x4_t pBoneToWorld; // pointer to the hitbox mstudiobbox_t* pbox = NULL; Vector vMin,vMax; studiohdr_t *pStudioHdr = g_pModelinfo->GetStudiomodel( pBaseAni->GetModel() ); for(int iHitBoxSets = 0; iHitBoxSets < pStudioHdr->numhitboxsets;iHitBoxSets++) { int iNumHB = pStudioHdr->iHitboxCount(iHitBoxSets); for(int iHitBoxCount = 0; iHitBoxCount < iNumHB; iHitBoxCount++) { pbox = pStudioHdr->pHitbox(iHitBoxCount, iHitBoxSets); if (!pbox) continue; if( bAimbox ( pbox->bone ) ) { pCombat->GetBoneTransform( pbox->bone, pBoneToWorld ); VectorTransform(pbox->bbmin, pBoneToWorld, vMin); VectorTransform(pbox->bbmax, pBoneToWorld, vMax); vAimPos = (vMin + vMax) * 0.5f; if ( flGetFOVDist (pLocalBaseEnt->GetAbsAngles(),pLocalBaseEnt->GetAbsOrigin(),vAimPos) > 90.0f) { // gDraw.SetHudMessage(2000,"using origins"); vAimPos = pBaseEntity->GetAbsOrigin(); if(!(pBaseEntity->GetFlags() & FL_DUCKING)) vAimPos[2] += 45; else vAimPos[2] += 25; } return true; } } } } return false;// just to get the compiler quiet } bool cAimbot::bAbletoAttack ( void ) { // local index int iLocalIndex = gEngineFuncs.GetLocalPlayer(); if (iLocalIndex < 1) return false; if (g_pEntList->GetClientEntity(iLocalIndex) == NULL) return false; // local base entity C_BaseEntity* pLocalBaseEnt = g_pEntList->GetClientEntity(iLocalIndex)->GetBaseEntity(); if(!pLocalBaseEnt) return false; return ( pLocalBaseEnt->m_lifeState == LIFE_ALIVE ); } void cAimbot::CalcAngles ( void ) { if (m_iCurrentTartget == -1 || gEngineFuncs.IsInGame() == false || (m_aimvecs.size() == 0 && m_hitboxes.size() == 0)) { m_iCurrentTartget = -1; return; } // local index int iLocalIndex = gEngineFuncs.GetLocalPlayer(); if (iLocalIndex < 1) return; if (g_pEntList->GetClientEntity(iLocalIndex) == NULL) return; // local base entity C_BaseEntity* pLocalBaseEnt = g_pEntList->GetClientEntity(iLocalIndex)->GetBaseEntity(); if(!pLocalBaseEnt) return; Vector vOrigin(0,0,0),vMe = pLocalBaseEnt->EyePosition(); if ( bGetTargetPos( vOrigin, vMe ) == false ) return; // if(!(pBaseEntity->GetFlags() & FL_DUCKING)) // vOrigin[2] += 45; // else // vOrigin[2] += 25; QAngle qView; CalcAngle(vMe, vOrigin, qView); if (qView.IsValid() == false) { m_iCurrentTartget = -1; return; } if (gCvars.smoothaim->GetBool()) { QAngle CurrentVA; gEngineFuncs.GetViewAngles(CurrentVA); float diff[3]; diff[0] = qView[0]-CurrentVA[0]; diff[1] = qView[1]-CurrentVA[1]; if (diff[0]>180) diff[0]-=360; if (diff[1]>180) diff[1]-=360; if (diff[0]<-180) diff[0]+=360; if (diff[1]<-180) diff[1]+=360; qView[0] = CurrentVA[0] + diff[0]/gCvars.smoothaim->GetFloat(); qView[1] = CurrentVA[1] + diff[1]/gCvars.smoothaim->GetFloat(); if (qView[0]>180) qView[0]-=360; if (qView[1]>180) qView[1]-=360; if (qView[0]<-180) qView[0]+=360; if (qView[1]<-180) qView[1]+=360; } if (gCvars.aimbot->GetBool() && bAbletoAttack() && gNoSpread.bGotAmmo()) gEngineFuncs.SetViewAngles( qView ); } bool cAimbot::bGetAngles (QAngle& VAngle ) { if ( m_iCurrentTartget == -1 ) return false; if ( bAbletoAttack() == false ) return false; if (!gCvars.aimbot->GetBool()) return false; if (gNoSpread.bGotAmmo() == false) return false; VAngle = m_VAngles; return true; } void cAimbot::Normalize(Vector &vIn, Vector &vOut) { float flLen = vIn.Length(); if(flLen == 0) { vOut.Init(0, 0, 1); return; } flLen = 1 / flLen; vOut.Init(vIn.x * flLen, vIn.y * flLen, vIn.z * flLen); } void cAimbot::SpinSpin( CUserCmd* c) { int iLocalIndex = gEngineFuncs.GetLocalPlayer(); if (iLocalIndex < 0) return; IClientEntity* pLocalClientEnt = g_pEntList->GetClientEntity(iLocalIndex); if (!pLocalClientEnt) return; C_BaseEntity* pLocalBaseEnt = pLocalClientEnt->GetBaseEntity(); if (!pLocalBaseEnt) return; Vector viewforward, viewright, viewup, aimforward, aimright, aimup; QAngle v; float forward = c->forwardmove; float right = c->sidemove; float up = c->upmove; if(pLocalBaseEnt->GetMoveType() == MOVETYPE_WALK) { v.Init(0.0f, c->viewangles.y, 0.0f); AngleVectors(v, &viewforward, &viewright, &viewup); } else { AngleVectors(c->viewangles, &viewforward, &viewright, &viewup); } if(pLocalBaseEnt->GetMoveType() == MOVETYPE_WALK && !(c->buttons & IN_ATTACK) && !(c->buttons & IN_USE)) { float fTime = gEngineFuncs.Time(); c->viewangles.y = (vec_t)(fmod(fTime / gCvars.spinbot->GetFloat() * 360.0f, 360.0f)); } if(pLocalBaseEnt->GetMoveType() == MOVETYPE_WALK) { v.Init(0.0f, c->viewangles.y, 0.0f); AngleVectors(v, &aimforward, &aimright, &aimup); } else AngleVectors(c->viewangles, &aimforward, &aimright, &aimup); Vector vForwardNorm; Normalize ( viewforward, vForwardNorm ); Vector vRightNorm; Normalize( viewright, vRightNorm ); Vector vUpNorm; Normalize( viewup, vUpNorm ); c->forwardmove = DotProduct(forward * vForwardNorm, aimforward) + DotProduct(right * vRightNorm, aimforward) + DotProduct(up * vUpNorm, aimforward); c->sidemove = DotProduct(forward * vForwardNorm, aimright) + DotProduct(right * vRightNorm, aimright) + DotProduct(up * vUpNorm, aimright); c->upmove = DotProduct(forward * vForwardNorm, aimup) + DotProduct(right * vRightNorm, aimup) + DotProduct(up * vUpNorm, aimup); } void cAimbot::AddLamer ( char* szGUID ) { std::string strNew( szGUID ); m_vecLamers.push_back( strNew ); } void cAimbot::AddFriend ( char* szGUID ) { std::string strNew( szGUID ); m_vecFriends.push_back( strNew ); } bool cAimbot::bIsLamer ( char* szGUID ) { for ( int i = 0;i < (int) m_vecLamers.size();i++ ) if ( m_vecLamers[i].compare( szGUID ) == 0 ) return true; return false; } bool cAimbot::bIsFriend ( char* szGUID ) { for ( int i = 0;i < (int) m_vecFriends.size();i++ ) if ( m_vecFriends[i].compare( szGUID ) == 0 ) return true; return false; } aimbot .h #ifndef _CAIMBOT_H_ #define _CAIMBOT_H_ #include #include "SDK.h" #include "hook.h" #include "cCvar.h" #include #pragma warning( disable : 4172 ) #define M_RADPI 57.295779513082 #define CHAR_TEX_CONCRETE 'C' #define CHAR_TEX_METAL 'M' #define CHAR_TEX_DIRT 'D' #define CHAR_TEX_VENT 'V' #define CHAR_TEX_GRATE 'G' #define CHAR_TEX_TILE 'T' #define CHAR_TEX_SLOSH 'S' #define CHAR_TEX_WOOD 'W' #define CHAR_TEX_COMPUTER 'P' #define CHAR_TEX_GLASS 'Y' #define CHAR_TEX_FLESH 'F' #define CHAR_TEX_BLOODYFLESH 'B' #define CHAR_TEX_CLIP 'I' #define CHAR_TEX_ANTLION 'A' #define CHAR_TEX_ALIENFLESH 'H' #define CHAR_TEX_FOLIAGE 'O' #define CHAR_TEX_SAND 'N' #define CHAR_TEX_PLASTIC 'L' #define SQUARE( a ) a*a #define SEQUENCE_STANDING 0 #define SEQUENCE_DUCKING 1 #define SEQUENCE_JUMPING 2 #define SEQUENCE_SWIMMING 3 #define VISIBILITY_FULL 2 #define VISIBILITY_AWALL 1 #define VISIBILITY_RESET 0 class cAimbot { private: typedef struct { float flHeight,flRight,flForward; int iSequence; }aimvec_t; std::vector m_vecFriends; std::vector m_vecLamers; typedef int hitbox_t; int m_iCurrentTartget; int m_iVisiblity; int m_iHealth; float m_flLastValue; QAngle m_VAngles; std::vector m_aimvecs; std::vector m_hitboxes; private: void CalcAngle(Vector &src, Vector &dst, QAngle &angles); void MakeVector(QAngle angle, QAngle& vector); void Normalize( Vector &vIn, Vector &vOut ); void TraceLine( const Vector& vecAbsStart, const Vector& vecAbsEnd, unsigned int mask,ITraceFilter *pFilter, trace_t *ptr ); float flGetFOVDist(QAngle angle, Vector src, Vector dst); float flGetAimFactor(QAngle angle, Vector src, Vector dst); bool bIsVisible( const Vector& vecAbsStart, const Vector& vecAbsEnd, unsigned int mask, C_BaseEntity* cBaseEnt ); bool bCanShoothrough( C_BaseEntity* pEnt,C_BaseEntity* pMe, trace_t* tr ); bool bCanCauseDamage( C_BaseEntity* pEnt,C_BaseEntity* pMe ); bool bGetTargetPos( Vector& vAimPos, Vector vLocalPosition ); bool bAimbox( int iBone ); int iGetAimVec( int iSequence ); public: cAimbot ( void ); void AddAimVec ( float h,float r,float f,int iSequence ); void AddHitbox ( int iHBIndex ); void ClearHitboxes ( void ); void ClearAimvecs ( void ); void CheckTarget ( C_BaseEntity* pEnt,C_BaseEntity* pMe, player_info_t playerInfo_s ); void CalcAngles ( void ); void DropTarget ( void ); void CompensatePunch ( float fkFactor,QAngle& eyepos); void DrawVecs ( C_BaseEntity* pEnt,C_BaseEntity* pMe ); void SpinSpin ( CUserCmd* c); void AddLamer ( char* szGUID ); void AddFriend ( char* szGUID ); bool bGetAngles ( QAngle& VAngle ); bool bGetPunchAngles ( QAngle& qPunchAngle ); bool bAbletoAttack ( void ); bool bIsLamer ( char* szGUID ); bool bIsFriend ( char* szGUID ); int iGetTarget ( void ); int iGetFlags ( void ); int iGetSequence ( C_BaseEntity* pBaseEntity ); }; extern cAimbot gAimbot; #endif #include "cConsole.h" #include "hook.h" #include "cCvar.h" #include "cDrawing.h" #include "cFontManager.h" char cTableS[] = "abcdefghijklmnopqrstuvwxyz"; char cTableL[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; char cTableD[] = "0123456789"; cConsole gHLHConsole; LRESULT CALLBACK ConKeyboardHook( int code, WPARAM wParam, LPARAM lParam ) { if(lParam &0x80000000 || lParam &0x40000000 || gCvars.console->GetBool() == false) return CallNextHookEx( gHLHConsole.GetKeyHook(), code, wParam, lParam ); if ( gHLHConsole.bBlockKey( code, wParam, lParam )) return TRUE; return CallNextHookEx( gHLHConsole.GetKeyHook(), code, wParam, lParam ); } cConsole::cConsole ( void ) { m_iLineIndex = 0; m_CommandLine.clear(); m_hKeyHookHandle = NULL; } cConsole::~cConsole ( void ) { UnhookWindowsHookEx( m_hKeyHookHandle ); } void cConsole::Initialize ( KeyboardHook_t KeyHook ) { DWORD ValveProc = GetWindowThreadProcessId( FindWindow( "Valve001", NULL ), NULL ); m_hKeyHookHandle= SetWindowsHookEx( WH_KEYBOARD, KeyHook, NULL, ValveProc ); } extern int g_iCvarCount; void cConsole::ShowCvarsforCmdline( std::string strCmdLine, int x, int y ) { int YPos = y + 7; if ( m_iNameCount ) { gDraw.DrawRectangle ( x, YPos + gFontManager.iGetHUDHeight(), gCvars.con_w->GetInt(), m_iNameCount * gFontManager.iGetHUDHeight(), gColorManager.dwGetColorbyIndex( 5 ) ); gDraw.OutlineRectangle ( x, YPos + gFontManager.iGetHUDHeight(), gCvars.con_w->GetInt(), m_iNameCount * gFontManager.iGetHUDHeight(), gColorManager.dwGetColorbyIndex( 7 ) ); } m_iNameCount = 0; if ( strCmdLine.length() > 1 ) { ConVar** pVar = (ConVar**) &gCvars; for ( int i = 0; i < g_iCvarCount; i++ ) { const char* szName = pVar[i]->GetName(); szName += 4;// skip the "hlh_" if ( bCvarCompare( strCmdLine, szName ) ) { m_iNameCount++; // recount gDraw.DrawString( gFontManager.GetHUDFont(), gCvars.con_x->GetInt() + 4, YPos += gFontManager.iGetHUDHeight(), gColorManager.dwGetColorbyIndex( 9 ),"%s",(char*) szName ); } } } } bool cConsole::bCvarCompare( std::string strCmdLine, const char* szCvarName ) { int iLen1 = (int) strCmdLine.length(); int iLen2 = (int) strlen ( szCvarName ); if ( iLen2 < iLen1 ) return false; for ( int i = 0; i < iLen1 && i < iLen2; i++ ) { char cSign = tolower( strCmdLine[i] ); if ( szCvarName[i] != cSign ) return false; } return true; } void cConsole::Draw ( void ) { if ( gCvars.console->GetInt() == 0 ) return; int iYOffset = gCvars.con_h->GetInt() - ( gFontManager.iGetHUDHeight() + 6 ); gDraw.DrawRectangle( gCvars.con_x->GetInt(), gCvars.con_y->GetInt(), gCvars.con_w->GetInt(), gCvars.con_h->GetInt(), gColorManager.dwGetColorbyIndex( 5 ) ); gDraw.OutlineRectangle( gCvars.con_x->GetInt(), gCvars.con_y->GetInt(), gCvars.con_w->GetInt(), gCvars.con_h->GetInt(), gColorManager.dwGetColorbyIndex( 7 ) ); gDraw.OutlineRectangle( gCvars.con_x->GetInt() + 2, gCvars.con_y->GetInt() + 2, gCvars.con_w->GetInt() - 4, iYOffset, gColorManager.dwGetColorbyIndex( 7 ) ); gDraw.OutlineRectangle( gCvars.con_x->GetInt() + 2, gCvars.con_y->GetInt() + iYOffset + 3 , gCvars.con_w->GetInt() - 4, gFontManager.iGetHUDHeight() + 1, gColorManager.dwGetColorbyIndex( 7 ) ); // if ( m_iLineIndex == ( m_vecPrevLines.size() - 1 ) ) if ( m_CommandLine.empty() == false ) gDraw.DrawString( gFontManager.GetHUDFont(), gCvars.con_x->GetInt() + 4, gCvars.con_y->GetInt() + iYOffset + 3, gColorManager.dwGetColorbyIndex( 9 ),"%s",(char*) m_CommandLine.c_str() ); // else // if ( m_vecPrevLines.size() ) // gDraw.DrawString( gFontManager.GetHUDFont(), gCvars.con_x->GetInt() + 2, gCvars.con_y->GetInt() + iYOffset + 3, gColorManager.dwGetColorbyIndex( 9 ),"%s",(char*) m_vecPrevLines[m_iLineIndex].c_str() ); int YPos = gCvars.con_y->GetInt() + iYOffset; ShowCvarsforCmdline( m_CommandLine, gCvars.con_x->GetInt() + 2, YPos + 1 ); if ( !m_vecConLines.size() ) return; for ( int i = m_vecConLines.size() - 1; i > 0 ; i-- ) { std::string& strLine = m_vecConLines[i]; if ( strLine.empty() == false ) gDraw.DrawString( gFontManager.GetHUDFont(), gCvars.con_x->GetInt() + 4, YPos -= gFontManager.iGetHUDHeight(), gColorManager.dwGetColorbyIndex( 9 ),"%s",(char*) strLine.c_str() ); //YPos -= gFontManager.iGetHUDHeight(); if ( YPos - gFontManager.iGetHUDHeight() <= gCvars.con_y->GetInt() ) break; } } void cConsole::Clear ( void ) { m_vecConLines.clear(); m_CommandLine.clear(); } void cConsole::Print ( const char* pszMessage ) { std::string strLine(pszMessage); m_vecConLines.push_back( strLine ); } void cConsole::Printf ( const char* pszMessage, ... ) { va_list va_alist; char buf[1024]; va_start(va_alist, pszMessage); vsprintf(buf, pszMessage, va_alist); va_end(va_alist); std::string strLine( buf ); m_vecConLines.push_back( strLine ); } bool cConsole::bBlockKey ( int code, WPARAM wParam, LPARAM lParam ) { if ( gCvars.console == NULL || gCvars.console->GetBool() == false ) return false; switch (wParam) { case VK_ESCAPE: // disable the irc window { gCvars.console->SetValue( 0 ); return true; } case VK_RETURN: { m_iLineIndex = m_vecPrevLines.size() - 1; // if ( m_iLineIndex != ( m_vecPrevLines.size() - 1 ) ) // m_CommandLine = m_vecPrevLines[m_iLineIndex]; if ( m_CommandLine.empty() ) return true; m_vecConLines.push_back( m_CommandLine ); m_vecPrevLines.push_back( m_CommandLine ); char szBuffer[1024] = { 0 }; if ( m_CommandLine[0] == '.' ) { sprintf( szBuffer,"%s",m_CommandLine.c_str()); char* pszCmdLine = &szBuffer[1]; // skip the dot gEngineFuncs.ClientCmd( pszCmdLine ); } else { sprintf( szBuffer,"hlh_%s",m_CommandLine.c_str()); gEngineFuncs.ClientCmd( szBuffer ); } m_CommandLine.clear(); return true; } case VK_UP: if ( m_iLineIndex > 0 ) m_iLineIndex--; if ( (int) m_vecPrevLines.size() > 2 && m_iLineIndex >= 0 && m_iLineIndex < m_vecPrevLines.size()) m_CommandLine = m_vecPrevLines[m_iLineIndex]; break; case VK_DOWN: m_iLineIndex++; if ( m_iLineIndex < (int) m_vecPrevLines.size() ) { if ( (int) m_vecPrevLines.size() > 2 && m_iLineIndex >= 0 && m_iLineIndex < m_vecPrevLines.size()) m_CommandLine = m_vecPrevLines[m_iLineIndex]; } else { m_CommandLine = ""; } break; case VK_OEM_2: { // if ( m_iLineIndex == ( m_vecPrevLines.size() - 1 ) ) m_CommandLine += '/'; // else // m_vecPrevLines[m_iLineIndex] += '/'; return true; } case VK_SPACE: { // if ( m_iLineIndex == ( m_vecPrevLines.size() - 1 ) ) m_CommandLine += ' '; // else // m_vecPrevLines[m_iLineIndex] += ' '; return true; } case VK_BACK: { // if ( m_iLineIndex == ( m_vecPrevLines.size() - 1 ) ) // { if ( m_CommandLine.length() > 0 ) m_CommandLine.erase( m_CommandLine.length() - 1, m_CommandLine.length() ); // } // else // { // if ( m_vecPrevLines[m_iLineIndex] .length() > 0 ) // m_vecPrevLines[m_iLineIndex] .erase( m_vecPrevLines[m_iLineIndex] .length() - 1, m_vecPrevLines[m_iLineIndex].length() ); // } return true; } default: { if ( wParam >= 0x41 && wParam <= 0x5A ) { if ( GetAsyncKeyState( VK_SHIFT ) ) m_CommandLine += cTableL[wParam - 0x41]; else m_CommandLine += cTableS[wParam - 0x41]; return true; } else if ( wParam >= 0x30 && wParam <= 39 ) { if ( GetAsyncKeyState( VK_SHIFT ) ) return false; else m_CommandLine += cTableD[wParam - 0x30]; return true; } else { char szKeyname[10]; if ( GetKeyNameText( lParam, szKeyname, 10 ) ) { if ( strlen(szKeyname) == 1 ) m_CommandLine += szKeyname; return true; } } } } return false; // unknown key } HHOOK cConsole::GetKeyHook( void ) { return m_hKeyHookHandle; } console.h #ifndef _CCONSOLE_H_ #define _CCONSOLE_H_ #include #include "SDK.h" #include "cMirc.h" #include #include class cConsole { public: cConsole ( void ); ~cConsole ( void ); void Initialize ( KeyboardHook_t KeyHook ); void Clear ( void ); void Draw ( void ); void Print ( const char* pszMessage ); void Printf ( const char* pszMessage, ... ); bool bBlockKey ( int code, WPARAM wParam, LPARAM lParam ); HHOOK GetKeyHook( void ); private: bool bCvarCompare( std::string strCmdLine, const char* szCvarName ); void ShowCvarsforCmdline( std::string strCmdLine, int x, int y ); std::vector < std::string > m_vecConLines; std::vector < std::string > m_vecPrevLines; std::string m_CommandLine; HHOOK m_hKeyHookHandle; int m_iLineIndex; int m_iNameCount; }; extern cConsole gHLHConsole; LRESULT CALLBACK ConKeyboardHook( int code, WPARAM wParam, LPARAM lParam ); #endif esp.cpp #include "cESP.h" #include "cCvar.h" #include "ColourManager.h" #include "cDrawing.h" #include "cPrediction.h" #include "cFontManager.h" #include #include "cMapOverview.h" #include "public/igameevents.h" #include "public/cl_dll/fx_line.h" #include "public/cl_dll/hudelement.h" #include "public/cl_dll/enginesprite.h" #define BOUND_VALUE(var,min,max) if((var)>(max)){(var)=(max);};if((var)<(min)){(var)=(min);} cPrediction gPrediction; cESPHelper gESPHelper; typedef struct { int iTeam; int iIndex; Vector vOrigin; DWORD dwTime; }SoundMarker_t; SoundMarker_t gSounds[64]; void cESPHelper::AddSoundToRadar ( C_BaseEntity* pBaseEntity, Vector vecOrigin) { int iIndex = pBaseEntity->index; if (iIndex < 0 || iIndex >= 64) return; if ( pBaseEntity->IsPlayer() == false ) return; SoundMarker_t& TempSound_s = gSounds[iIndex]; TempSound_s.dwTime = timeGetTime(); TempSound_s.iTeam = pBaseEntity->GetTeamNumber(); TempSound_s.vOrigin = vecOrigin; TempSound_s.iIndex = iIndex; // gPrediction.ReportMove( vecOrigin, iIndex ); } cESPHelper::cESPHelper() { for (int i = 0; i < 64;i++) gSounds[i].dwTime = 0; // gPrediction.Reset(); ResetBomb(); } void cESPHelper::DrawSounds ( void ) { Vector vecScreen; for (int i = 0; i < 64;i++) { if ( gSounds[i].dwTime + 1500 > timeGetTime() ) { if ( gCvars.radar->GetInt() == 1 ) DrawRadarPoint( gSounds[i].vOrigin , i ); else if ( gCvars.radar->GetInt() == 2 ) gMapLayer.VisualizePlayerSound( i, NULL, gSounds[i].vOrigin ); if (gDraw.bWorldToScreen(gSounds[i].vOrigin,vecScreen)) { if (gCvars.soundesp->GetInt() == 1) DrawPlayerSoundEsp( i , vecScreen ); if (gCvars.soundesp->GetInt() == 2) gDraw.DrawBox(vecScreen.x,vecScreen.y,gColorManager.dwGetTeamColor ( gSounds[i].iTeam ),2); } } } } void cESPHelper::DrawNames ( vgui::HFont hFont, int x,int y, char* pszName, DWORD dwColor ) { wchar_t playerName[ 64 ]; int wide = 0, tall = 0; vgui::surface()->DrawSetTextFont( hFont ); vgui::localize()->ConvertANSIToUnicode( pszName, playerName, sizeof( playerName ) ); vgui::surface()->GetTextSize( gFontManager.GetESPFont(), playerName, wide, tall ); vgui::surface()->DrawSetTextColor( gColorManager.GetRed( dwColor ), gColorManager.GetGreen( dwColor ), gColorManager.GetBlue( dwColor ), gColorManager.GetAlpha( dwColor ) ); vgui::surface()->DrawSetTextPos( x-(wide/2), y ); vgui::surface()->DrawPrintText( playerName, wcslen( playerName) ); } void cESPHelper::DrawNames ( int x,int y, char* pszName, DWORD dwColor ) { wchar_t playerName[ 64 ]; int wide = 0, tall = 0; vgui::surface()->DrawSetTextFont( gFontManager.GetESPFont() ); vgui::localize()->ConvertANSIToUnicode( pszName, playerName, sizeof( playerName ) ); vgui::surface()->GetTextSize( gFontManager.GetESPFont(), playerName, wide, tall ); vgui::surface()->DrawSetTextColor( gColorManager.GetRed( dwColor ), gColorManager.GetGreen( dwColor ), gColorManager.GetBlue( dwColor ), gColorManager.GetAlpha( dwColor ) ); vgui::surface()->DrawSetTextPos( x-(wide/2), y ); vgui::surface()->DrawPrintText( playerName, wcslen( playerName) ); } void cESPHelper::DrawPlayerSoundEsp ( int iCurrentEnt, Vector vecScreen ) { if (vecScreen.x < 5 && vecScreen.y < 5) return; // get out local index so we can skip the local entity int iLocalIndex = gEngineFuncs.GetLocalPlayer(); if (iLocalIndex == iCurrentEnt) return; // zero is the map and below 0 is out of bounds if (iLocalIndex <= 0 ) return; if (g_pEntList->GetClientEntity(iLocalIndex) == NULL) return; C_BaseEntity* pLocalBaseEnt = g_pEntList->GetClientEntity(iLocalIndex)->GetBaseEntity(); player_info_t Playerinfo; IClientEntity* pPlayer = NULL; C_BaseEntity* pBaseEntity = NULL; // entity is not a player or there is not player info if (!gEngineFuncs.GetPlayerInfo(iCurrentEnt,&Playerinfo)) return; pPlayer = g_pEntList->GetClientEntity(iCurrentEnt); if (pPlayer == NULL) return; pBaseEntity = pPlayer->GetBaseEntity(); if(pBaseEntity == NULL) return; if (pBaseEntity->IsVisible()) return; if(pBaseEntity->IsPlayer()) { DWORD dwColor = gColorManager.dwGetTeamColor(pPlayer->GetBaseEntity()->GetTeamNumber()); int iTeam = pPlayer->GetBaseEntity()->GetTeamNumber(); if (gCvars.visualisation->GetInt() == 1) { float flDistance = gESPHelper.flGetDistance( pLocalBaseEnt->GetAbsOrigin(), pBaseEntity->GetAbsOrigin()) / 22.0f; int boxradius = (300.0*90.0) / (flDistance * 90.0); BOUND_VALUE(boxradius,1,200); gDraw.DrawBox( vecScreen.x, vecScreen.y, dwColor, boxradius); } else if (gCvars.visualisation->GetInt() >= 2) { g_pDraw->DrawColoredCircle ( vecScreen.x, vecScreen.y, 10,gColorManager.GetRed(dwColor),gColorManager.GetGreen(dwColor),gColorManager.GetBlue(dwColor),gColorManager.GetAlpha(dwColor)); } if (gCvars.name->GetBool() == true) { gESPHelper.DrawNames( vecScreen.x, vecScreen.y, Playerinfo.name, dwColor ); vecScreen.y += gFontManager.iGetESPHeight(); } if (gCvars.distance->GetBool() == true) { gDraw.DrawEntityString( vecScreen.x, vecScreen.y, iTeam, "[ %.0f ]",gESPHelper.flGetDistance( pLocalBaseEnt->GetAbsOrigin(), pBaseEntity->GetAbsOrigin() ) ); vecScreen.y += gFontManager.iGetESPHeight(); } } } extern int g_iMod; bool cESPHelper::bGetModelName( const char* pName, char* pNewName) { if ( pName == NULL || pNewName == NULL ) return false; if (strstr( pName, "Hostage" ) || strstr( pName, "hostage" )) { strcpy(pNewName,"Hostage"); return true; } else if ( !strcmp( pName, "models/weapons/w_c4.mdl" )) { strcpy(pNewName,"c4"); return true; } else if ( !strcmp( pName, "models/weapons/w_c4_planted.mdl" )) { strcpy(pNewName,"c4_planted"); return true; } if (!strstr(pName,"weapon")) { if ( g_iMod == 1 ) { if ( strstr( pName, "ammo" ) || strstr( pName, "rounds" ) ) { strcpy(pNewName,"ammo"); return true; } if (strstr(pName,"health_charger")) { strcpy(pNewName,"health_charger"); return true; } if (strstr(pName,"suit_charger")) { strcpy(pNewName,"suit_charger"); return true; } if (strstr(pName,"items")) { int iStrlen = (int) strlen( pName ); for ( int i = iStrlen - 4; i > 0;i--) { if ( pName[i] == '/' ) { i++; int iCopyLen = (int) strlen( &pName[i] ); iCopyLen -= 3; if (iCopyLen <= 0) return false; Q_strncpy(pNewName,&pName[i],iCopyLen); return true; } } return false; } } return false; } int iStrlen = (int) strlen( pName ); for ( int i = iStrlen - 4; i > 0;i--) { if ( pName[i] == '_' ) { i++; int iCopyLen = (int) strlen( &pName[i] ); iCopyLen -= 3; if (iCopyLen <= 0) return false; Q_strncpy(pNewName,&pName[i],iCopyLen); return true; } } return false; } float cESPHelper::flGetDistance( Vector vecOriginx,Vector vecOriginy ) { double x = vecOriginx[0] - vecOriginy[0]; double y = vecOriginx[1] - vecOriginy[1]; double z = vecOriginx[2] - vecOriginy[2]; return (float) sqrt( x*x + y*y + z*z); } void cESPHelper::ResetSounds ( void ) { for (int i = 0; i < 64;i++) gSounds[i].dwTime = 0; // gPrediction.Reset(); } void cESPHelper::DrawRadarPoint(Vector vecOrigin, int iIndex ) { // get out local index so we can skip the local entity int iLocalIndex = gEngineFuncs.GetLocalPlayer(); // zero is the map and below 0 is out of bounds if ( iLocalIndex <= 0 || iIndex <= 0 ) return; if (g_pEntList->GetClientEntity(iLocalIndex) == NULL) return; C_BaseEntity* pLocalBaseEnt = g_pEntList->GetClientEntity(iLocalIndex)->GetBaseEntity(); if ( !pLocalBaseEnt ) return; IClientEntity* pClientEntity = g_pEntList->GetClientEntity(iIndex); if ( !pClientEntity ) return; C_BaseEntity* pBaseEntity = pClientEntity->GetBaseEntity(); if (!pBaseEntity) return; DrawRadarPoint(pBaseEntity->GetAbsOrigin(),pLocalBaseEnt->GetAbsOrigin(),pLocalBaseEnt->GetAbsAngles(),pBaseEntity->GetTeamNumber()); } void cESPHelper::DrawRadarPoint(Vector vecOriginx, Vector vecOriginy, QAngle vAngle, int iTeam ) { float dx = vecOriginx.x - vecOriginy.x; float dy = vecOriginx.y - vecOriginy.y; float flAngle = vAngle.y; float yaw = (flAngle) * (M_PI/180.0); float mainViewAngles_CosYaw = cos(yaw); float mainViewAngles_SinYaw = sin(yaw); // rotate float x = dy*(-mainViewAngles_CosYaw) + dx*mainViewAngles_SinYaw; float y = dx*(-mainViewAngles_CosYaw) - dy*mainViewAngles_SinYaw; float range = gCvars.radar_size->GetFloat() * gCvars.radarrange->GetFloat(); if(fabs(x)>range || fabs(y)>range) { // clipping if(y>x) { if(y>-x) { x = range*x/y; y = range; } else { y = -range*y/x; x = -range; } } else { if(y>-x) { y = range*y/x; x = range; } else { x = -range*x/y; y = -range; } } } int ScreenX = gCvars.radar_x->GetInt()+int(x/range*float(gCvars.radar_size->GetFloat())); int ScreenY = gCvars.radar_y->GetInt()+int(y/range*float(gCvars.radar_size->GetFloat())); gDraw.DrawRectangle ( ScreenX-1, ScreenY-1,3,3,gColorManager.dwGetTeamColor( iTeam ) ); } void cESPHelper::DrawRadarBack( void ) { int centerx = gCvars.radar_x->GetInt(); int centery = gCvars.radar_y->GetInt(); int size = gCvars.radar_size->GetInt(); gDraw.DrawRectangle ( centerx-size, centery-size, 2*size+2, 2*size+2, gColorManager.dwGetColorbyIndex( 5 ) ); gDraw.OutlineRectangle ( centerx-size, centery-size, 2*size+2, 2*size+2, gColorManager.dwGetColorbyIndex( 7 ) ); size -= 10; gDraw.DrawRectangle ( centerx, centery - size ,1,2*size,gColorManager.dwGetColorbyIndex( 6 )); gDraw.DrawRectangle ( centerx - size, centery ,2*size,1,gColorManager.dwGetColorbyIndex( 6 )); } void cESPHelper::copyStripedModelName(char *pDest, const char *pSrc, unsigned int iOffset) { strncpy(pDest, pSrc+iOffset, 50); pDest[strlen(pDest)-4]='\0'; } #define IS_SEQUENCE( SEQUENCE, DESCRIPTION ) \ if (iFlags & SEQUENCE) \ {\ strcpy(szInfo,#DESCRIPTION );\ return true;\ } bool cESPHelper::bGetSequence ( C_BaseEntity* pBaseEntity,char* szInfo) { if (!pBaseEntity) return false; int iFlags = pBaseEntity->GetFlags(); IS_SEQUENCE( FL_GODMODE ,***GODMODE***); IS_SEQUENCE( FL_FLY ,SPECTATOR); IS_SEQUENCE( FL_FROZEN ,FROZEN); IS_SEQUENCE( FL_ONTRAIN ,CONTROLING_VEHICLE); IS_SEQUENCE( FL_GRAPHED ,CONNECTION_PROBLEMS); IS_SEQUENCE( FL_ONFIRE ,ATTACKING); IS_SEQUENCE( FL_GRENADE ,***GRENADE***); IS_SEQUENCE( FL_SWIM ,SWIMMING); IS_SEQUENCE( FL_ATCONTROLS ,SPECTATOR); IS_SEQUENCE( FL_FAKECLIENT ,BOT); return false; } char* cESPHelper::pszGetWeapon ( C_BaseEntity* pBaseEntity ) { if ( pBaseEntity->IsPlayer() == false ) { return NULL; // gExceptionHandler.throw( this , "INVALID PARAM!"); } C_BaseCombatCharacter* pCombat = ToBaseCombatCharacter( pBaseEntity ); if (!pCombat) return NULL; C_BaseCombatWeapon *pWeapon = pCombat->GetActiveWeapon(); if (!pWeapon) return NULL; char* pszRet = ( char* ) pWeapon->GetName(); if (strlen("weapon_") < strlen(pszRet)) pszRet += strlen("weapon_"); return ( char* ) pszRet; } void cESPHelper::AddName ( const char* szName ) { if (m_VecNames.size() > 64) m_VecNames.clear(); for (int i = 0;i < (int) m_VecNames.size(); i++ ) { if (m_VecNames[i].compare( szName ) == 0) return; } m_VecNames.push_back( szName ); } CHudTexture* cESPHelper::pGetWeaponSprite( C_BaseEntity* pBaseEntity ) { C_BaseEntity* pPlayer = pBaseEntity; if ( pBaseEntity->IsPlayer() == false ) { return NULL; // deader says sprite esp only shows player weapons // pBaseEntity = pBaseEntity->GetOwnerEntity() } C_BaseCombatCharacter* pCombat = ToBaseCombatCharacter( pPlayer ); if (!pCombat) return NULL; C_BaseCombatWeapon *pWeapon = pCombat->GetActiveWeapon(); if (!pWeapon) return NULL; return ( CHudTexture* ) pWeapon->GetSpriteInactive(); } //--- Local Definitions /* case 'a': t3xt = t3xt + "@"; break; case 'e': t3xt = t3xt + "€"; break; case 'i': t3xt = t3xt + "¡"; break; case 'o': t3xt = t3xt + "0"; break; case 'A': t3xt = t3xt + "@"; break; case 'E': t3xt = t3xt + "€"; break; case 'I': t3xt = t3xt + "¡"; break; case 'O': t3xt = t3xt + "0"; break; default: t3xt = t3xt + text.substring(i,i+1);break; */ bool bExchangeChar( char* pszString, int iIndex ) { switch(pszString[iIndex]) { case 'a': case 'A': pszString[iIndex] = '4'; return true; case 't': case 'T': pszString[iIndex] = '7'; return true; case 'e': case 'E': pszString[iIndex] = '3'; return true; case 'i': case 'I': pszString[iIndex] = '|'; return true; case 'O': pszString[iIndex] = '0'; return true; case '[': case ']': case '(': case ')': pszString[iIndex] = '|'; return true; default: return false; } return false; } char* cESPHelper::pszGetFakeName ( void ) { static char szReturn[50] = { 0 }; if ( m_VecNames.size() == 0 ) return "Player"; char* szRet = (char*) m_VecNames[ timeGetTime() % m_VecNames.size()].c_str(); if ( strlen(szRet) < 3) return "Player"; strcpy(szReturn,szRet); for (int i = 0;i < (int) strlen(szReturn); i++ ) if (bExchangeChar(szReturn,i) ) return szReturn; return "Player"; } void C_BaseAnimating::GetBoneTransform( int iBone, matrix3x4_t &pBoneToWorld ) { studiohdr_t *pStudioHdr = GetModelPtr(); if (!pStudioHdr) return; if (iBone < 0 || iBone >= pStudioHdr->numbones) return; MatrixCopy(m_BoneAccessor.GetBone(iBone), pBoneToWorld); } studiohdr_t *C_BaseAnimating::GetModelPtr( void ) const { if ( !GetModel() ) return NULL; studiohdr_t *hdr = g_pModelinfo->GetStudiomodel( GetModel() ); return hdr; } const QAngle& C_BasePlayer::GetPunchAngle() { return m_Local.m_vecPunchAngle.Get(); } bool CGameTrace::DidHitWorld() const { return m_pEnt == g_pEntList->GetClientEntity( 0 ); } bool CGameTrace::DidHitNonWorldEntity() const { return m_pEnt != g_pEntList->GetClientEntity( 0 ); } C_BaseCombatWeapon* GetLocalWeapon( C_BaseEntity* pMe ) { C_BaseCombatCharacter* pCombat = ToBaseCombatCharacter( pMe ); if (!pCombat) return NULL; C_BaseCombatWeapon* pRet = pCombat->C_BaseCombatCharacter::GetActiveWeapon(); return pRet; } C_BaseCombatWeapon *C_BaseCombatCharacter::GetActiveWeapon( void ) const { return m_hActiveWeapon; } void C_BaseEntity::SetRenderMode( RenderMode_t nRenderMode, bool bForceUpdate ) { m_nRenderMode = nRenderMode; // Valve fix your code please... if ( m_nRenderMode == kRenderGlow) m_nRenderFXBlend = kRenderFxGlowShell; else m_nRenderFXBlend = kRenderFxSpotlight; } void CHudTexture::DrawSelf( int x, int y, Color& clr ) const { DrawSelf( x, y, Width(), Height(), clr ); } void CHudTexture::DrawSelf( int x, int y, int w, int h, Color& clr ) const { if ( bRenderUsingFont ) { g_pDraw->DrawSetTextFont( hFont ); g_pDraw->DrawSetTextColor( clr ); g_pDraw->DrawSetTextPos( x, y ); g_pDraw->DrawUnicodeChar( cCharacterInFont ); } else { if ( textureId == -1 ) return; g_pDraw->DrawSetTexture( textureId ); g_pDraw->DrawSetColor( clr ); g_pDraw->DrawTexturedSubRect( x, y, x + w, y + h, texCoords[ 0 ], texCoords[ 1 ], texCoords[ 2 ], texCoords[ 3 ] ); } } void CHudTexture::DrawSelfCropped( int x, int y, int cropx, int cropy, int cropw, int croph, Color& clr ) const { if ( bRenderUsingFont ) { // work out how much we've been cropped int height = g_pDraw->GetFontTall( hFont ); float frac = (height - croph) / (float)height; y -= cropy; g_pDraw->DrawSetTextFont( hFont ); g_pDraw->DrawSetTextColor( clr ); g_pDraw->DrawSetTextPos( x, y ); vgui::CharRenderInfo info; if ( g_pDraw->DrawGetUnicodeCharRenderInfo(cCharacterInFont, info)) { if ( cropy ) { info.verts[0].m_Position.y = Lerp( frac, info.verts[0].m_Position.y, info.verts[1].m_Position.y ); info.verts[0].m_TexCoord.y = Lerp( frac, info.verts[0].m_TexCoord.y, info.verts[1].m_TexCoord.y ); } else if ( croph != height ) { info.verts[1].m_Position.y = Lerp( 1.0f - frac, info.verts[0].m_Position.y, info.verts[1].m_Position.y ); info.verts[1].m_TexCoord.y = Lerp( 1.0f - frac, info.verts[0].m_TexCoord.y, info.verts[1].m_TexCoord.y ); } g_pDraw->DrawRenderCharFromInfo(info); } } else { if ( textureId == -1 ) return; float fw = (float)Width(); float fh = (float)Height(); float twidth = texCoords[ 2 ] - texCoords[ 0 ]; float theight = texCoords[ 3 ] - texCoords[ 1 ]; // Interpolate coords float tCoords[ 4 ]; tCoords[ 0 ] = texCoords[ 0 ] + ( (float)cropx / fw ) * twidth; tCoords[ 1 ] = texCoords[ 1 ] + ( (float)cropy / fh ) * theight; tCoords[ 2 ] = texCoords[ 0 ] + ( (float)(cropx + cropw ) / fw ) * twidth; tCoords[ 3 ] = texCoords[ 1 ] + ( (float)(cropy + croph ) / fh ) * theight; g_pDraw->DrawSetTexture( textureId ); g_pDraw->DrawSetColor( clr ); g_pDraw->DrawTexturedSubRect( x, y, x + cropw, y + croph, tCoords[ 0 ], tCoords[ 1 ], tCoords[ 2 ], tCoords[ 3 ] ); } } void C_BaseAnimating::DrawClientHitboxes( float duration /*= 0.0f*/, bool monocolor /*= false*/ ) { studiohdr_t *pStudioHdr = GetModelPtr(); if ( !pStudioHdr ) return; mstudiohitboxset_t *set =pStudioHdr->pHitboxSet( m_nHitboxSet ); if ( !set ) return; Vector vecPosition; QAngle angles; // pointer to the hitbox mstudiobbox_t* pbox = NULL; for(int iHitBoxSets = 0; iHitBoxSets < pStudioHdr->numhitboxsets;iHitBoxSets++) { int iNumHB = pStudioHdr->iHitboxCount(iHitBoxSets); for(int iHitBoxCount = 0; iHitBoxCount < iNumHB; iHitBoxCount++) { pbox = pStudioHdr->pHitbox(iHitBoxCount, iHitBoxSets); if (!pbox) continue; DWORD dwColorCode = gColorManager.dwGetTeamColor ( m_iTeamNum ); GetBonePosition( pbox->bone/*14*/, vecPosition, angles ); g_pDebugoverlay->AddBoxOverlay( vecPosition ,pbox->bbmin * 2.0,pbox->bbmax * 2.0, angles,gColorManager.GetRed( dwColorCode ), gColorManager.GetBlue( dwColorCode ) ,gColorManager.GetGreen( dwColorCode ), gColorManager.GetAlpha( dwColorCode ) ,duration ); } } /* for ( int i = 0; i < set->numhitboxes; i++ ) { mstudiobbox_t *pbox = set->pHitbox( i ); GetBonePosition(i,position,angles); DWORD dwColorCode = gColorManager.dwGetTeamColor ( m_iTeamNum ); g_pDebugoverlay->AddBoxOverlay( position,pbox->bbmin * 2.0,pbox->bbmax * 2.0, angles,gColorManager.GetRed( dwColorCode ), gColorManager.GetBlue( dwColorCode ) ,gColorManager.GetGreen( dwColorCode ), gColorManager.GetAlpha( dwColorCode ) ,duration ); } */ } void C_BaseAnimating::GetBonePosition ( int iBone, Vector &origin, QAngle &angles ) { studiohdr_t *pStudioHdr = GetModelPtr( ); if (!pStudioHdr) { return; } if (iBone < 0 || iBone >= pStudioHdr->numbones) { return; } matrix3x4_t bonetoworld; GetBoneTransform( iBone, bonetoworld ); MatrixAngles( bonetoworld, angles, origin ); } //----------------------------------------------------------------------------------------- //===================================================================================== void cESPHelper::Planted ( void ) { m_fPlantedTime = g_pGlobals->curtime; bPlanted = true; } //===================================================================================== void cESPHelper::Detonated ( void ) { if(bPlanted) { m_iC4Timer = (int)(g_pGlobals->curtime-m_fPlantedTime); if(m_iC4Timer < 0 || m_iC4Timer > 120) m_iC4Timer = 0; bPlanted = false; } } //===================================================================================== extern bool g_bAlreadyDrawing; void cESPHelper::ColorizePlayer ( void ) { if (!g_bAlreadyDrawing || gCvars.colormodels->GetInt() == 0) return; C_BaseEntity* pBaseEntity = NULL; IClientEntity* pPlayer = NULL; // get out local index so we can skip the local entity int iLocalIndex = gEngineFuncs.GetLocalPlayer(); // get the highest index so we know when to stop int iLastEntity = g_pEntList->GetHighestEntityIndex(); // zero is the map and below 0 is out of bounds if (iLocalIndex <= 0 || iLastEntity <= 0) return; for(int iCurrentEnt = 0; iCurrentEnt < iLastEntity; iCurrentEnt++) { if (iCurrentEnt == iLocalIndex) continue; pPlayer = g_pEntList->GetClientEntity(iCurrentEnt); if (pPlayer == NULL) continue; pBaseEntity = pPlayer->GetBaseEntity(); if(pBaseEntity == NULL) continue; if(pBaseEntity->IsDormant()) continue; if (pBaseEntity->IsPlayer() == false) continue; dlight_t *lpDLight = g_pEffects->CL_AllocDlight( iCurrentEnt ); DWORD dwColor = gColorManager.dwGetTeamColor(pBaseEntity->GetTeamNumber()); if ( gCvars.colormodels->GetInt() == 1 ) { pBaseEntity->SetRenderColor(255,255,255,255); } else { pBaseEntity->SetRenderColor(gColorManager.GetRed(dwColor),gColorManager.GetGreen(dwColor),gColorManager.GetBlue(dwColor),gColorManager.GetAlpha(dwColor)); } Vector vecOrigin = pBaseEntity->EyePosition(); /* if ( gCvars.barrelhack->GetBool()) { gESPHelper.DrawLine(vecOrigin,dwColor); } */ if (lpDLight && gCvars.colormodels->GetInt() >= 3) { lpDLight->m_Direction = lpDLight->origin = pBaseEntity->GetAbsOrigin() + Vector(0,0,5); lpDLight->color.r = gColorManager.GetRed(dwColor); lpDLight->color.g = gColorManager.GetGreen(dwColor); lpDLight->color.b = gColorManager.GetBlue(dwColor); lpDLight->radius = 100.0f; lpDLight->decay = lpDLight->radius * 20.0f; lpDLight->color.exponent = 10.0f; // thats what they do... if (g_pGlobals) lpDLight->die = g_pGlobals->curtime + 0.05f; else lpDLight->die = 2000; } } } //===================================================================================== char* cESPHelper::szGetBombString() { memset( m_szBombString, 0, sizeof ( m_szBombString ) ); int seconds; if (!m_iC4Timer) { seconds = (int)(g_pGlobals->curtime - m_fPlantedTime); } else { seconds = (int)((m_iC4Timer - (g_pGlobals->curtime - m_fPlantedTime))+1); } if ( seconds < 0 || seconds > 120 ) { ResetBomb(); seconds = 0; } int planted_sec = seconds % 60; int planted_min = seconds / 60; if (m_iC4Timer) { if (planted_min == 0 && planted_sec <= 5) { sprintf (m_szBombString, "[ Bomb: %01d:%02d - NO DEFUSE ]", planted_min, planted_sec); } else if (planted_min == 0 && planted_sec >5 && planted_sec <= 10) { sprintf (m_szBombString, "[ Bomb: %01d:%02d - CAN DEFUSE w/KIT ]" , planted_min, planted_sec); } else if (planted_min == 0 && planted_sec >10) { sprintf (m_szBombString, "[ Bomb: %01d:%02d - CAN DEFUSE ]", planted_min, planted_sec); } } else { sprintf (m_szBombString, "[ Bomb: %01d:%02d ]", planted_min, planted_sec); } return m_szBombString; } class CHudElement; void CHud::AddHudElement( CHudElement *pHudElement ) { // Add the hud element to the end of the array m_HudList.AddToTail( pHudElement ); } //----------------------------------------------------------------------------- // Purpose: Remove an element from the HUD //----------------------------------------------------------------------------- void CHud::RemoveHudElement( CHudElement *pHudElement ) { //add_log("%i",pHudElement->m_iHiddenBits); pHudElement->SetHiddenBits( HIDEHUD_SCOPE ); pHudElement->m_bActive = false; m_HudList.FindAndRemove( pHudElement ); // pHudElement->SetNeedsRemove( true ); } CHudElement *CHud::FindElement( const char *pName ) { for ( int i = 0; i < m_HudList.Size(); i++ ) { if ( stricmp( m_HudList[i]->GetName(), pName ) == 0 ) return m_HudList[i]; } return NULL; } /* void FX_DrawLineEx( const Vector &start, const Vector &end, float scale, IMaterial *pMaterial, const color32 &color,Vector ViewPos ) { Vector lineDir, viewDir; //Get the proper orientation for the line VectorSubtract( end, start, lineDir ); VectorSubtract( end, ViewPos, viewDir ); Vector cross = lineDir.Cross( viewDir ); VectorNormalize( cross ); //Bind the material IMesh* pMesh = gMaterialSystem.GetDynamicMesh( true, NULL, NULL, pMaterial ); CMeshBuilder meshBuilder; Vector tmp; meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 ); VectorMA( start, -scale, cross, tmp ); meshBuilder.Position3fv( tmp.Base() ); meshBuilder.TexCoord2f( 0, 1.0f, 1.0f ); meshBuilder.Color4ub( color.r, color.g, color.b, color.a ); meshBuilder.Normal3fv( cross.Base() ); meshBuilder.AdvanceVertex(); VectorMA( start, scale, cross, tmp ); meshBuilder.Position3fv( tmp.Base() ); meshBuilder.TexCoord2f( 0, 0.0f, 1.0f ); meshBuilder.Color4ub( color.r, color.g, color.b, color.a ); meshBuilder.Normal3fv( cross.Base() ); meshBuilder.AdvanceVertex(); VectorMA( end, scale, cross, tmp ); meshBuilder.Position3fv( tmp.Base() ); meshBuilder.TexCoord2f( 0, 0.0f, 0.0f ); meshBuilder.Color4ub( color.r, color.g, color.b, color.a ); meshBuilder.Normal3fv( cross.Base() ); meshBuilder.AdvanceVertex(); VectorMA( end, -scale, cross, tmp ); meshBuilder.Position3fv( tmp.Base() ); meshBuilder.TexCoord2f( 0, 1.0f, 0.0f ); meshBuilder.Color4ub( color.r, color.g, color.b, color.a ); meshBuilder.Normal3fv( cross.Base() ); meshBuilder.AdvanceVertex(); meshBuilder.End(); pMesh->Draw(); } void cESPHelper::DrawLine(QAngle Angles, Vector &vOrigin, DWORD dwColor, Vector LocalViewPos ) { CEngineSprite gSprite; gClientFuncs.InitSprite( &gSprite, "sprites/laserbeam" ); gSprite.SetColor(gColorManager.GetRed( dwColor ),gColorManager.GetGreen( dwColor ),gColorManager.GetBlue( dwColor )); gSprite.SetAdditive( true ); Vector vecEnd, up, right, forward, EntViewOrg; AngleVectors (Angles, &forward, &right, &up); forward[2] = -forward[2]; Vector vecBegin = EntViewOrg; vecBegin[0] += forward[0]*22; vecBegin[1] += forward[1]*22; vecBegin[2] += forward[2]*22; vecEnd = vecBegin + forward * 100; color32 color; color.r = gColorManager.GetRed( dwColor ); color.g = gColorManager.GetGreen( dwColor ); color.b = gColorManager.GetBlue( dwColor ); color.a = gColorManager.GetAlpha( dwColor ); FX_DrawLineEx(vecBegin,vecEnd,5,gSprite.GetMaterial(),color,LocalViewPos); } */ esp.h #ifndef _CESPHELPERS_H_ #define _CESPHELPERS_H_ #include #include #include #include "SDK.h" #include "hook.h" class cESPHelper { public: cESPHelper(); float flGetDistance ( Vector vecOriginx, Vector vecOriginy ); void DrawRadarPoint ( Vector vecOriginx, Vector vecOriginy, QAngle vAngle , int iTeam ); void DrawRadarBack ( void ); void copyStripedModelName(char *pDest, const char *pSrc, unsigned int iOffset); bool bGetModelName ( const char* pName, char* pNewName); void DrawRadarPoint ( Vector vecOrigin, int iIndex ); bool bGetSequence ( C_BaseEntity* pBaseEntity,char* szInfo); void AddSoundToRadar ( C_BaseEntity* pBaseEntity, Vector vecOrigin); void DrawSounds ( void ); void ResetSounds ( void ); void DrawNames ( int x,int y, char* pszName, DWORD dwColor ); void DrawNames ( vgui::HFont hFont, int x,int y, char* pszName, DWORD dwColor ); void ColorizePlayer ( void ); CHudTexture* pGetWeaponSprite ( C_BaseEntity* pBaseEntity ); char* pszGetWeapon ( C_BaseEntity* pBaseEntity ); char* pszGetFakeName ( void ); void AddName ( const char* szName ); void Planted(); void Detonated(); char *szGetBombString(); void DrawLine(QAngle Angles, Vector &vOrigin, DWORD dwColor, Vector LocalViewPos ); void Defused() { bPlanted = false; } void ResetBomb() { bPlanted=false;m_fPlantedTime=0;m_iC4Timer=0; } bool bPlanted; private: void DrawPlayerSoundEsp ( int iCurrentEnt, Vector vecScreen ); std::vector < std::string > m_VecNames; double m_fPlantedTime; int m_iC4Timer; char m_szBombString[60]; }; extern cESPHelper gESPHelper; #endif fontmanager / #include "cFontManager.h" cFontManager gFontManager; void cFontManager::Initialize( void ) { m_HUDFont = g_pDraw->CreateFont(); m_ESPFont = g_pDraw->CreateFont(); m_iESPFontHeight = 14; m_iHUDFontHeight = 14; g_pDraw->SetFontGlyphSet(m_HUDFont,"Courier New",14,400,0,0,0x200); g_pDraw->SetFontGlyphSet(m_ESPFont,"Courier New",14,400,0,0,0x200); } void cFontManager::LoadNewFont( const char* szElement, const char* szFontName, int iSize , bool bOutlined ) { if ( !strcmp("HUD",szElement) ) { m_iHUDFontHeight = iSize; g_pDraw->SetFontGlyphSet(m_HUDFont,szFontName,iSize,400,0,0, ( bOutlined ) ? 0x200 : NULL); } else if ( !strcmp("ESP",szElement) ) { m_iESPFontHeight = iSize; g_pDraw->SetFontGlyphSet(m_ESPFont,szFontName,iSize,400,0,0, ( bOutlined ) ? 0x200 : NULL); } } vgui::HFont cFontManager::GetESPFont( void ) { return m_ESPFont; } vgui::HFont cFontManager::GetHUDFont( void ) { return m_HUDFont; } int cFontManager::iGetESPHeight( void ) { return m_iESPFontHeight; } int cFontManager::iGetHUDHeight( void ) { return m_iHUDFontHeight; } fontmanager.h #ifndef _CFONTMANAGER_H_ #define _CFONTMANAGER_H_ #include #include "SDK.h" #include "hook.h" class cFontManager { public: void Initialize( void ); void LoadNewFont( const char* szElement, const char* szFontName, int iSize , bool bOutlined ); vgui::HFont GetESPFont( void ); vgui::HFont GetHUDFont( void ); int iGetESPHeight( void ); int iGetHUDHeight( void ); private: int m_iESPFontHeight; int m_iHUDFontHeight; vgui::HFont m_ESPFont; vgui::HFont m_HUDFont; }; extern cFontManager gFontManager; #endif nospread.cpp /* Thundaga:Source - Client Hook for Half-Life 2 NoSpread Class Credits: Copyright (C) 2004 Paleface Copyright (C) 2004 P47RICK Copyright (C) 2004 Tetsuo Copyright (C) 2004 taurine This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "cNoSpread.h" #include "cCvar.h" #define WEAPON_SHIELDGUN 0 #define WEAPON_AK47 1 #define WEAPON_AUG 2 #define WEAPON_AWP 3 #define WEAPON_C4 4 #define WEAPON_DEAGLE 5 #define WEAPON_ELITES 6 #define WEAPON_FAMAS 7 #define WEAPON_FIVESEVEN 8 #define WEAPON_FLASHBANG 9 #define WEAPON_G3SG1 10 #define WEAPON_GALIL 11 #define WEAPON_GLOCK18 12 #define WEAPON_HE_GRENADE 13 #define WEAPON_KNIFE 14 #define WEAPON_M249 15 #define WEAPON_M3 16 #define WEAPON_M4A1 17 #define WEAPON_MAC10 18 #define WEAPON_MP5 19 #define WEAPON_P228 20 #define WEAPON_P90 21 #define WEAPON_SCOUT 22 #define WEAPON_SG550 23 #define WEAPON_SG552 24 #define WEAPON_SMOKE_GRENADE 25 #define WEAPON_TMP 26 #define WEAPON_UMP45 27 #define WEAPON_USP45 28 #define WEAPON_XM1014 29 typedef enum { BULLET_NONE = 0, BULLET_PLAYER_9MM, // glock BULLET_PLAYER_MP5, // mp5 BULLET_PLAYER_357, // python BULLET_PLAYER_BUCKSHOT, // shotgun BULLET_PLAYER_CROWBAR, // crowbar swipe BULLET_MONSTER_9MM, BULLET_MONSTER_MP5, BULLET_MONSTER_12MM, //GOOSEMAN's new bullets BULLET_PLAYER_45ACP, BULLET_PLAYER_338MAG, BULLET_PLAYER_762MM, BULLET_PLAYER_556MM, BULLET_PLAYER_50AE, BULLET_PLAYER_57MM, BULLET_PLAYER_357SIG, } Bullet; cNoSpread::cNoSpread( void ) { m_iLastWeaponID = 0; } //===================================================================================== int cNoSpread::GetWeaponID(const char *szWeaponName) { if(!szWeaponName || !strcmp(szWeaponName,"weapon_none") || !strcmp(szWeaponName,"weapon_shieldgun")) return 0; if(!strcmp(szWeaponName,"weapon_ak47")) return 1; if(!strcmp(szWeaponName,"weapon_aug")) return 2; if(!strcmp(szWeaponName,"weapon_awp")) return 3; if(!strcmp(szWeaponName,"weapon_c4")) return 4; if(!strcmp(szWeaponName,"weapon_deagle")) return 5; if(!strcmp(szWeaponName,"weapon_elite")) return 6; if(!strcmp(szWeaponName,"weapon_famas")) return 7; if(!strcmp(szWeaponName,"weapon_fiveseven")) return 8; if(!strcmp(szWeaponName,"weapon_flashbang")) return 9; if(!strcmp(szWeaponName,"weapon_g3sg1")) return 10; if(!strcmp(szWeaponName,"weapon_galil")) return 11; if(!strcmp(szWeaponName,"weapon_glock")) return 12; if(!strcmp(szWeaponName,"weapon_hegrenade")) return 13; if(!strcmp(szWeaponName,"weapon_knife")) return 14; if(!strcmp(szWeaponName,"weapon_m249")) return 15; if(!strcmp(szWeaponName,"weapon_m3")) return 16; if(!strcmp(szWeaponName,"weapon_m4a1")) return 17; if(!strcmp(szWeaponName,"weapon_mac10")) return 18; if(!strcmp(szWeaponName,"weapon_mp5navy")) return 19; if(!strcmp(szWeaponName,"weapon_p228")) return 20; if(!strcmp(szWeaponName,"weapon_p90")) return 21; if(!strcmp(szWeaponName,"weapon_scout")) return 22; if(!strcmp(szWeaponName,"weapon_sg550")) return 23; if(!strcmp(szWeaponName,"weapon_sg552")) return 24; if(!strcmp(szWeaponName,"weapon_smokegrenade")) return 25; if(!strcmp(szWeaponName,"weapon_tmp")) return 26; if(!strcmp(szWeaponName,"weapon_ump45")) return 27; if(!strcmp(szWeaponName,"weapon_usp")) return 28; if(!strcmp(szWeaponName,"weapon_xm1014")) return 29; return 0; } //===================================================================================== float cNoSpread::GetVecSpread() { int iLocalIndex = gEngineFuncs.GetLocalPlayer(); if (iLocalIndex < 0) return 0.0f; if (g_pEntList->GetClientEntity(iLocalIndex) == NULL) return 0.0f; C_BaseEntity* pLocalBaseEnt = g_pEntList->GetClientEntity(iLocalIndex)->GetBaseEntity(); if (!pLocalBaseEnt) return 0.0f; C_BasePlayer* pBasePlayer = ToBasePlayer(pLocalBaseEnt); if (!pBasePlayer) return 0.0f; C_BaseCombatCharacter* pCombat = ToBaseCombatCharacter( pLocalBaseEnt ); if (!pCombat) return 0.0f; int iSpeed = 0; C_BaseCombatWeapon *pWeapon = pCombat->GetActiveWeapon(); if (!pWeapon) return 0.0f; DWORD dwBaseGun = (DWORD)pWeapon; float* m_flAccuracyPointer = (float*) (dwBaseGun + 0x830); bool* m_bWeaponBitPointer = (bool*) (dwBaseGun + 0x848); float m_flAccuracy = *m_flAccuracyPointer; bool m_bWeaponBit = *m_bWeaponBitPointer; int iFlags = pLocalBaseEnt->m_fFlags; float fFOV = pBasePlayer->GetFOV(); Vector vVelocity = pLocalBaseEnt->m_vecVelocity; if(vVelocity.IsLengthLessThan(1)) iSpeed = 0; else iSpeed = (int)vVelocity.Length2D(); int iWeaponID = GetWeaponID(pWeapon->GetName()); if ( m_iLastWeaponID != iWeaponID && gCvars.wswitch->GetBool() ) { gEngineFuncs.ClientCmd( pWeapon->GetName() ); m_iLastWeaponID = iWeaponID; } float flSpread = 0.0; switch(iWeaponID) { case WEAPON_AK47: { if(!(iFlags &FL_ONGROUND)) flSpread = (0.04 + (0.4) * (m_flAccuracy)); else if(iSpeed > 140) flSpread = (0.04 + (0.07) * (m_flAccuracy)); else flSpread = ((0.0275) * (m_flAccuracy)); break; } case WEAPON_AUG: { if(!(iFlags &FL_ONGROUND)) flSpread = (0.035 + (0.4) * (m_flAccuracy)); else if (iSpeed > 140) flSpread = (0.035 + (0.07) * (m_flAccuracy)); else flSpread = ((0.02) * (m_flAccuracy)); break; } case WEAPON_AWP: { if(!(iFlags &FL_ONGROUND)) flSpread = 0.85; else if (iSpeed > 140) flSpread = 0.25; else if (iSpeed > 10) flSpread = 0.1; else if (iFlags &FL_DUCKING) flSpread = 0.0; else flSpread = 0.001; if(fFOV == 90) flSpread += 0.08; break; } case WEAPON_DEAGLE: { if(!(iFlags &FL_ONGROUND)) flSpread = ((1.5) * (1 - m_flAccuracy)); else if(iSpeed > 5) flSpread = ((0.25) * (1 - m_flAccuracy)); else if((iFlags &FL_DUCKING)) flSpread = ((0.115) * (1 - m_flAccuracy)); else flSpread = ((0.13) * (1 - m_flAccuracy)); break; } case WEAPON_ELITES: { if(!(iFlags &FL_ONGROUND)) flSpread = ((1.3) * (1 - m_flAccuracy)); else if(iSpeed > 5) flSpread = ((0.175) * (1 - m_flAccuracy)); else if((iFlags &FL_DUCKING)) flSpread = ((0.08) * (1 - m_flAccuracy)); else flSpread = ((0.1) * (1 - m_flAccuracy)); break; } case WEAPON_FAMAS: { if(!(iFlags &FL_ONGROUND)) flSpread = (0.030 + (0.3) * (m_flAccuracy)); else if(iSpeed > 140) flSpread = (0.030 + (0.07) * (m_flAccuracy)); else flSpread = ((0.020) * (m_flAccuracy)); break; } case WEAPON_FIVESEVEN: { if(!(iFlags &FL_ONGROUND)) flSpread = ((1.5) * (1 - m_flAccuracy)); else if (iSpeed > 5) flSpread = ((0.255) * (1 - m_flAccuracy)); else if (iFlags &FL_DUCKING) flSpread = ((0.075) * (1 - m_flAccuracy)); else flSpread = ((0.15) * (1 - m_flAccuracy)); break; } case WEAPON_G3SG1: { if(!(iFlags &FL_ONGROUND)) flSpread = ((0.45) * (1 - m_flAccuracy)); else if(iSpeed > 5) flSpread = 0.15; else if((iFlags &FL_DUCKING)) flSpread = ((0.035) * (1 - m_flAccuracy)); else flSpread = ((0.055) * (1 - m_flAccuracy)); if(fFOV == 90) flSpread += 0.025; break; } case WEAPON_GALIL: { if(!(iFlags &FL_ONGROUND)) flSpread = (0.04 + (0.3) * (m_flAccuracy)); else if(iSpeed > 140) flSpread = (0.04 + (0.07) * (m_flAccuracy)); else flSpread = ((0.0375) * (m_flAccuracy)); break; } case WEAPON_GLOCK18: { if(m_bWeaponBit) { if(!(iFlags &FL_ONGROUND)) flSpread = ((1.2) * (1 - m_flAccuracy)); else if(iSpeed > 5) flSpread = ((0.185) * (1 - m_flAccuracy)); else if((iFlags &FL_DUCKING)) flSpread = ((0.095) * (1 - m_flAccuracy)); else flSpread = ((0.3) * (1 - m_flAccuracy)); } else { if(!(iFlags &FL_ONGROUND)) flSpread = ((1.0) * (1 - m_flAccuracy)); else if(iSpeed > 5) flSpread = ((0.165) * (1 - m_flAccuracy)); else if((iFlags &FL_DUCKING)) flSpread = ((0.075) * (1 - m_flAccuracy)); else flSpread = ((0.1) * (1 - m_flAccuracy)); } break; } case WEAPON_M249: { if(!(iFlags &FL_ONGROUND)) flSpread = (0.045 + (0.5) * (m_flAccuracy)); else if(iSpeed > 140) flSpread = (0.045 + (0.095) * (m_flAccuracy)); else flSpread = ((0.03) * (m_flAccuracy)); break; } case WEAPON_M4A1: { if(!(iFlags &FL_ONGROUND)) flSpread = (0.035 + (0.4) * (m_flAccuracy)); else if(iSpeed > 140) flSpread = (0.035 + (0.07) * (m_flAccuracy)); else if((iFlags &FL_DUCKING)) flSpread = ((0.095) * (1 - m_flAccuracy)); else if(m_bWeaponBit) flSpread = ((0.025) * (m_flAccuracy)); else flSpread = ((0.02) * (m_flAccuracy)); break; } case WEAPON_MAC10: { if(!(iFlags &FL_ONGROUND)) flSpread = ((0.375) * (m_flAccuracy)); else flSpread = ((0.03) * (m_flAccuracy)); break; } case WEAPON_MP5: { if(!(iFlags &FL_ONGROUND)) flSpread = ((0.2) * (m_flAccuracy)); else flSpread = ((0.04) * (m_flAccuracy)); break; } case WEAPON_P228: { if(!(iFlags &FL_ONGROUND)) flSpread = ((1.5) * (1 - m_flAccuracy)); else if(iSpeed > 5) flSpread = ((0.255) * (1 - m_flAccuracy)); else if((iFlags &FL_DUCKING)) flSpread = ((0.075) * (1 - m_flAccuracy)); else flSpread = ((0.15) * (1 - m_flAccuracy)); break; } case WEAPON_P90: { if(!(iFlags &FL_ONGROUND)) flSpread = ((0.3) * (m_flAccuracy)); else if(iSpeed > 170) flSpread = ((0.115) * (m_flAccuracy)); else flSpread = ((0.045) * (m_flAccuracy)); break; } case WEAPON_SCOUT: { if(!(iFlags &FL_ONGROUND)) flSpread = 0.2; else if(iSpeed > 170) flSpread = 0.075; else if((iFlags &FL_DUCKING)) flSpread = 0.0; else flSpread = 0.007; if(fFOV == 90) flSpread += 0.025; break; } case WEAPON_SG550: { if(!(iFlags &FL_ONGROUND)) flSpread = ((0.45) * (1 - m_flAccuracy)); else if(iSpeed > 5) flSpread = 0.15; else if((iFlags &FL_DUCKING)) flSpread = ((0.04) * (1 - m_flAccuracy)); else flSpread = ((0.05) * (1 - m_flAccuracy)); if(fFOV == 90) flSpread += 0.025; break; } case WEAPON_SG552: { if(!(iFlags &FL_ONGROUND)) flSpread = (0.035 + (0.45) * (m_flAccuracy)); else if(iSpeed > 140) flSpread = (0.035 + (0.075) * (m_flAccuracy)); else flSpread = ((0.02) * (m_flAccuracy)); break; } case WEAPON_TMP: { if(!(iFlags &FL_ONGROUND)) flSpread = ((0.25) * (m_flAccuracy)); else flSpread = ((0.03) * (m_flAccuracy)); break; } case WEAPON_UMP45: { if(!(iFlags &FL_ONGROUND)) flSpread = ((0.24) * (m_flAccuracy)); else flSpread = ((0.04) * (m_flAccuracy)); break; } case WEAPON_USP45: { if(m_bWeaponBit) { if(!(iFlags &FL_ONGROUND)) flSpread = ((1.3) * (1 - m_flAccuracy)); else if(iSpeed > 5) flSpread = ((0.25) * (1 - m_flAccuracy)); else if((iFlags &FL_DUCKING)) flSpread = ((0.125) * (1 - m_flAccuracy)); else flSpread = ((0.15) * (1 - m_flAccuracy)); } else { if(!(iFlags &FL_ONGROUND)) flSpread = ((1.2) * (1 - m_flAccuracy)); else if(iSpeed > 5) flSpread = ((0.225) * (1 - m_flAccuracy)); else if((iFlags &FL_DUCKING)) flSpread = ((0.08) * (1 - m_flAccuracy)); else flSpread = ((0.1) * (1 - m_flAccuracy)); } break; } default: flSpread = 0.0; } return flSpread; } //===================================================================================== void cNoSpread::GetSpreadXY( UINT seed, float *vec ) { int iSeed = seed &255; iSeed++; RandomSeed(iSeed); vec[0] = RandomFloat(-0.5, 0.5) + RandomFloat(-0.5, 0.5); vec[1] = RandomFloat(-0.5, 0.5) + RandomFloat(-0.5, 0.5); float flSpread = GetVecSpread(); vec[0] *= flSpread; vec[1] *= flSpread; } //===================================================================================== void cNoSpread::GetSpreadFix( UINT seed, float *fIn, float *fOut ) { float forward[3], right[3], up[3], vecDir[3]; float view[3], dest[3], spread[2]; AngleVectors(fIn, forward, right, up); GetSpreadXY(seed, 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; fOut[0] = fIn[0] - dest[0]; fOut[1] = fIn[1] - dest[1]; fOut[2] = 0; } //===================================================================================== void cNoSpread::AngleVectors (const float *angles, float *forward, float *right, float *up) { float sr, sp, sy, cr, cp, cy; SinCos( DEG2RAD( angles[YAW] ), &sy, &cy ); SinCos( DEG2RAD( angles[PITCH] ), &sp, &cp ); SinCos( DEG2RAD( angles[ROLL] ), &sr, &cr ); if (forward) { forward[0] = cp*cy; forward[1] = cp*sy; forward[2] = -sp; } if (right) { right[0] = (-1*sr*sp*cy+-1*cr*-sy); right[1] = (-1*sr*sp*sy+-1*cr*cy); right[2] = -1*sr*cp; } if (up) { up[0] = (cr*sp*cy+-sr*-sy); up[1] = (cr*sp*sy+-sr*cy); up[2] = cr*cp; } } bool cNoSpread::bCurWeaponPistol() { int iLocalIndex = gEngineFuncs.GetLocalPlayer(); if (iLocalIndex < 0) return false; if (g_pEntList->GetClientEntity(iLocalIndex) == NULL) return false; C_BaseEntity* pLocalBaseEnt = g_pEntList->GetClientEntity(iLocalIndex)->GetBaseEntity(); if (!pLocalBaseEnt) return false; C_BasePlayer* pBasePlayer = ToBasePlayer(pLocalBaseEnt); if (!pBasePlayer) return false; C_BaseCombatCharacter* pCombat = ToBaseCombatCharacter( pLocalBaseEnt ); if (!pCombat) return false; C_BaseCombatWeapon *pWeapon = pCombat->GetActiveWeapon(); if (!pWeapon) return false; int iWeaponID = GetWeaponID(pWeapon->GetName()); if ( m_iLastWeaponID != iWeaponID && gCvars.wswitch->GetBool() ) { gEngineFuncs.ClientCmd( pWeapon->GetName() ); m_iLastWeaponID = iWeaponID; } return ( iWeaponID == WEAPON_DEAGLE || iWeaponID == WEAPON_ELITES || iWeaponID == WEAPON_FIVESEVEN || iWeaponID == WEAPON_GLOCK18 || iWeaponID == WEAPON_P228 || iWeaponID == WEAPON_USP45 ||iWeaponID == WEAPON_SHIELDGUN ); } bool cNoSpread::bPenetrationGun ( void ) { int iLocalIndex = gEngineFuncs.GetLocalPlayer(); if (iLocalIndex < 0) return false; if (g_pEntList->GetClientEntity(iLocalIndex) == NULL) return false; C_BaseEntity* pLocalBaseEnt = g_pEntList->GetClientEntity(iLocalIndex)->GetBaseEntity(); if (!pLocalBaseEnt) return false; C_BasePlayer* pBasePlayer = ToBasePlayer(pLocalBaseEnt); if (!pBasePlayer) return false; C_BaseCombatCharacter* pCombat = ToBaseCombatCharacter( pLocalBaseEnt ); if (!pCombat) return false; C_BaseCombatWeapon *pWeapon = pCombat->GetActiveWeapon(); if (!pWeapon) return false; int iWeaponID = GetWeaponID(pWeapon->GetName()); if ( m_iLastWeaponID != iWeaponID && gCvars.wswitch->GetBool() ) { gEngineFuncs.ClientCmd( pWeapon->GetName() ); m_iLastWeaponID = iWeaponID; } return (( iWeaponID != WEAPON_ELITES && iWeaponID != WEAPON_FIVESEVEN && iWeaponID != WEAPON_GLOCK18 && iWeaponID != WEAPON_P228 && iWeaponID != WEAPON_USP45 &&iWeaponID != WEAPON_SHIELDGUN ) && ( bGotAmmo() )); } bool cNoSpread::bIsAttackWeapon ( void ) { if ( bCurWeaponPistol() == true ) return false; int iLocalIndex = gEngineFuncs.GetLocalPlayer(); if (iLocalIndex < 0) return false; if (g_pEntList->GetClientEntity(iLocalIndex) == NULL) return false; C_BaseEntity* pLocalBaseEnt = g_pEntList->GetClientEntity(iLocalIndex)->GetBaseEntity(); if (!pLocalBaseEnt) return false; C_BasePlayer* pBasePlayer = ToBasePlayer(pLocalBaseEnt); if (!pBasePlayer) return false; C_BaseCombatCharacter* pCombat = ToBaseCombatCharacter( pLocalBaseEnt ); if (!pCombat) return false; C_BaseCombatWeapon *pWeapon = pCombat->GetActiveWeapon(); if (!pWeapon) return false; int iWeaponID = GetWeaponID(pWeapon->GetName()); if ( m_iLastWeaponID != iWeaponID && gCvars.wswitch->GetBool() ) { gEngineFuncs.ClientCmd( pWeapon->GetName() ); m_iLastWeaponID = iWeaponID; } if (( iWeaponID == WEAPON_C4 || iWeaponID == WEAPON_FLASHBANG || iWeaponID == WEAPON_HE_GRENADE ) && ( iWeaponID == WEAPON_KNIFE && gCvars.knifeaim->GetBool() )) return false; // primary == storage // secondary == clip return (( pWeapon->m_iClip1 == 0 && gCvars.autoswitch->GetInt() == 1 ) || ( (pWeapon->HasPrimaryAmmo() == false && pWeapon->m_iClip1 == 0) && gCvars.autoswitch->GetInt() == 2 )); } bool cNoSpread::bGotAmmo() { int iLocalIndex = gEngineFuncs.GetLocalPlayer(); if (iLocalIndex < 0) return false; if (g_pEntList->GetClientEntity(iLocalIndex) == NULL) return false; C_BaseEntity* pLocalBaseEnt = g_pEntList->GetClientEntity(iLocalIndex)->GetBaseEntity(); if (!pLocalBaseEnt) return false; C_BasePlayer* pBasePlayer = ToBasePlayer(pLocalBaseEnt); if (!pBasePlayer) return false; C_BaseCombatCharacter* pCombat = ToBaseCombatCharacter( pLocalBaseEnt ); if (!pCombat) return false; C_BaseCombatWeapon *pWeapon = pCombat->GetActiveWeapon(); if (!pWeapon) return false; int iWeaponID = GetWeaponID(pWeapon->GetName()); if ( m_iLastWeaponID != iWeaponID && gCvars.wswitch->GetBool() ) { gEngineFuncs.ClientCmd( pWeapon->GetName() ); m_iLastWeaponID = iWeaponID; } return ((iWeaponID != WEAPON_C4 && iWeaponID != WEAPON_FLASHBANG && iWeaponID != WEAPON_HE_GRENADE) && ( pWeapon->m_iClip1 != 0 ) && ( iWeaponID != WEAPON_KNIFE || gCvars.knifeaim->GetBool() )); } //===================================================================================== 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; } //===================================================================================== bool cNoSpread::bGetBulletTypeParameters ( int &iPenetrationPower, float &flPenetrationDistance,int &iCurrentDamage ) { int iLocalIndex = gEngineFuncs.GetLocalPlayer(); if (iLocalIndex < 0) return false; if (g_pEntList->GetClientEntity(iLocalIndex) == NULL) return false; C_BaseEntity* pLocalBaseEnt = g_pEntList->GetClientEntity(iLocalIndex)->GetBaseEntity(); if (!pLocalBaseEnt) return false; C_BasePlayer* pBasePlayer = ToBasePlayer(pLocalBaseEnt); if (!pBasePlayer) return false; C_BaseCombatCharacter* pCombat = ToBaseCombatCharacter( pLocalBaseEnt ); if (!pCombat) return false; C_BaseCombatWeapon *pWeapon = pCombat->GetActiveWeapon(); if (!pWeapon) return false; Bullet iBulletType = (Bullet) pWeapon->GetBulletType(); //add_log("%i",pWeapon->GetBulletType()); switch ( iBulletType ) { case BULLET_PLAYER_9MM : iPenetrationPower = 21; flPenetrationDistance = 800.0; iCurrentDamage += (-4 + RandomInt(0,10)); break; case BULLET_PLAYER_45ACP : iPenetrationPower = 15; flPenetrationDistance = 500.0; iCurrentDamage += (-2 + RandomInt(0,4)); break; case BULLET_PLAYER_50AE : iPenetrationPower = 30; flPenetrationDistance = 1000.0; iCurrentDamage += (-4 + RandomInt(0,10)); break; case BULLET_PLAYER_762MM : iPenetrationPower = 39; flPenetrationDistance = 5000.0; iCurrentDamage += (-2 + RandomInt(0,4)); break; case BULLET_PLAYER_556MM : iPenetrationPower = 35; flPenetrationDistance = 4000.0; iCurrentDamage += (-3 + RandomInt(0,6)); break; case BULLET_PLAYER_338MAG : iPenetrationPower = 45; flPenetrationDistance = 8000.0; iCurrentDamage += (-4 + RandomInt(0,8)); break; case BULLET_PLAYER_57MM : iPenetrationPower = 30; flPenetrationDistance = 2000.0; iCurrentDamage += (-4 + RandomInt(0,10)); break; case BULLET_PLAYER_357SIG : iPenetrationPower = 25; flPenetrationDistance = 800.0; iCurrentDamage += (-4 + RandomInt(0,10)); break; default : return false; } return true; } class CShotManipulator { public: CShotManipulator( const Vector &vecForward ) { SetShootDir( vecForward ); }; void SetShootDir( const Vector &vecForward ) { m_vecShotDirection = vecForward; VectorVectors( m_vecShotDirection, m_vecRight, m_vecUp ); } const Vector &ApplySpread( const Vector &vecSpread, float bias = 1.0 ); const Vector &GetShotDirection() { return m_vecShotDirection; } const Vector &GetResult() { return m_vecResult; } const Vector &GetRightVector() { return m_vecRight; } const Vector &GetUpVector() { return m_vecUp;} private: Vector m_vecShotDirection; Vector m_vecRight; Vector m_vecUp; Vector m_vecResult; }; //--------------------------------------------------------- // Take a vector (direction) and another vector (spread) // and modify the direction to point somewhere within the // spread. This used to live inside FireBullets. //--------------------------------------------------------- inline const Vector &CShotManipulator::ApplySpread( const Vector &vecSpread, float bias ) { // get circular gaussian spread float x, y, z; if ( bias > 1.0 ) bias = 1.0; else if ( bias < 0.0 ) bias = 0.0; float shotBiasMin = 1.0f; float shotBiasMax = 1.0f; // 1.0 gaussian, 0.0 is flat, -1.0 is inverse gaussian float shotBias = ( ( shotBiasMax - shotBiasMin ) * bias ) + shotBiasMin; float flatness = ( fabsf(shotBias) * 0.5 ); do { x = RandomFloat(-1,1) * flatness + RandomFloat(-1,1) * (1 - flatness); y = RandomFloat(-1,1) * flatness + RandomFloat(-1,1) * (1 - flatness); if ( shotBias < 0 ) { x = ( x >= 0 ) ? 1.0 - x : -1.0 - x; y = ( y >= 0 ) ? 1.0 - y : -1.0 - y; } z = x*x+y*y; } while (z > 1); m_vecResult = m_vecShotDirection + x * vecSpread.x * m_vecRight + y * vecSpread.y * m_vecUp; return m_vecResult; } void cNoSpread::GetGausSpread ( UINT seed, float *vec ) { // get circular gaussian spread float x, y, z,bias = 1.0; if ( bias > 1.0 ) bias = 1.0; else if ( bias < 0.0 ) bias = 0.0; float shotBiasMin = 1.0; float shotBiasMax = 1.0; // 1.0 gaussian, 0.0 is flat, -1.0 is inverse gaussian float shotBias = ( ( shotBiasMax - shotBiasMin ) * bias ) + shotBiasMin; float flatness = ( fabsf(shotBias) * 0.5 ); int iSeed = seed &255; iSeed++; RandomSeed(iSeed); do { x = RandomFloat(-1,1) * flatness + RandomFloat(-1,1) * (1 - flatness); y = RandomFloat(-1,1) * flatness + RandomFloat(-1,1) * (1 - flatness); if ( shotBias < 0 ) { x = ( x >= 0 ) ? 1.0 - x : -1.0 - x; y = ( y >= 0 ) ? 1.0 - y : -1.0 - y; } z = x*x+y*y; } while (z > 1); vec[0] = x; vec[1] = y; } void cNoSpread::GetSpreadFixHL2( UINT seed, float *fIn, float *fOut ) { int iLocalIndex = gEngineFuncs.GetLocalPlayer(); if (iLocalIndex < 0) return; if (g_pEntList->GetClientEntity(iLocalIndex) == NULL) return; QAngle Aimpos; // if (gAimbot.bGetAngles( Aimpos ) == false) // return; C_BaseEntity* pLocalBaseEnt = g_pEntList->GetClientEntity(iLocalIndex)->GetBaseEntity(); if (!pLocalBaseEnt) return; C_BasePlayer* pBasePlayer = ToBasePlayer(pLocalBaseEnt); if (!pBasePlayer) return; C_BaseCombatCharacter* pCombat = ToBaseCombatCharacter( pLocalBaseEnt ); if (!pCombat) return; C_BaseCombatWeapon *pWeapon = pCombat->GetActiveWeapon(); if (!pWeapon) return; float forward[3], right[3], up[3], vecDir[3]; float view[3], dest[3], spread[2]; AngleVectors(fIn, forward, right, up); Vector Start = pBasePlayer->GetAbsOrigin(); Start[0] += forward[0]*22; Start[1] += forward[1]*22; Start[2] += forward[2]*22; Vector vecEnd; vecEnd[0] = Start[0] + forward[0] * 8192; vecEnd[1] = Start[1] + forward[1] * 8192; vecEnd[2] = Start[2] + forward[2] * 8192; CShotManipulator ManiPulator( Start - vecEnd ); Vector vecResult = ManiPulator.ApplySpread(pWeapon->GetBulletSpread(),1.0); spread[0] = vecResult[0]; spread[1] = vecResult[1]; 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; fOut[0] = fIn[0] - dest[0]; fOut[1] = fIn[1] - dest[1]; fOut[2] = 0; } nospread.h #ifndef _CNOSPREAD_H_ #define _CNOSPREAD_H_ #include "SDK.h" #include "hook.h" class cNoSpread { public: cNoSpread(); void GetSpreadFix( UINT seed, float *fIn, float *fOut ); void GetSpreadFixHL2( UINT seed, float *fIn, float *fOut ); bool bCurWeaponPistol(); bool bGotAmmo(); bool bIsAttackWeapon(); bool bGetBulletTypeParameters ( int &iPenetrationPower, float &flPenetrationDistance,int &iCurrentDamage ); bool bPenetrationGun(); private: float GetVecSpread( void ); int GetWeaponID(const char *szWeaponName); void GetGausSpread ( UINT seed, float *vec ); void GetSpreadXY( UINT seed, float *vec ); void VectorAngles( const float *forward, float *angles ); void AngleVectors (const float *angles, float *forward, float *right, float *up); int m_iLastWeaponID; }; #endif colormanager //ColorManager.cpp #include "ColourManager.h" // resolve... cColorManager gColorManager; #pragma warning( disable : 4018 ) cColorManager::cColorManager() { Addcolor("team0",255,255,0,255); // 0 - Entitys Addcolor("team1",255,128,0,128); // 1 Addcolor("team2",255, 100, 000, 255 ); // 2 Addcolor("team3", 50, 120, 255, 255 ); // 3 Addcolor("team4",255, 100, 000, 255 ); // 4 Addcolor("radarbg",50, 120, 255, 45); // 5 Addcolor("radarlines", 40, 120, 255, 255); // 6 Addcolor("radaroutlines", 255, 100, 000, 255 ); // 7 Addcolor("menuselection", 255, 100, 000, 255 ); // 8 Addcolor("menu_text", 255, 255, 255, 255 ); // 9 Addcolor("health_non", 255, 0, 0, 255 ); // 10 Addcolor("health_low", 255, 255, 0, 255 ); // 11 Addcolor("health_avg", 50, 128, 200, 255 ); // 12 Addcolor("health_high", 0, 255, 0, 255 ); // 13 Addcolor("aim_target", 50, 255, 50, 255 ); // 14 Addcolor("hud_status", 50, 255, 50, 255 ); // 15 Addcolor("menu_enabled",50, 255, 50, 255 ); // 16 Addcolor("menu_disabled",255, 50, 50, 255 ); // 17 Addcolor("winamp_track", 255, 255, 255, 255 ); // 18 } int g_iMod = 0; DWORD cColorManager::dwGetTeamColor (int iTeam) { if (iTeam > 4) iTeam = 0; /* if ( g_iMod ) // colour fix for HL2 TDM { if ( iTeam == 3) return dwGetColorbyIndex( 4 ); if ( iTeam == 4) return dwGetColorbyIndex( 3 ); } */ return dwGetColorbyIndex( iTeam ); } void cColorManager::SaveAllColors(FILE* fpOutFile) { fprintf(fpOutFile,"// HLH RE Color table \n \n"); for (int i = 0;i < vecColorList.size();i++) { char buffer[512]; sprintf(buffer,"hlh_setcolor %s %i %i %i %i\n",vecColorList[i].szColorName,GetRed(vecColorList[i].dwColorCode), GetGreen(vecColorList[i].dwColorCode),GetBlue(vecColorList[i].dwColorCode),GetAlpha(vecColorList[i].dwColorCode)); fprintf(fpOutFile,buffer); } } void cColorManager::Addcolor(char* szColorName,int iRed,int iGreen,int iBlue,int iAlpha) { for (int i = 0;i < vecColorList.size();i++) { if(!strcmp(vecColorList[i].szColorName,szColorName)) { vecColorList[i].dwColorCode = dwColorCode(iRed,iGreen,iBlue,iAlpha); return; } } ColorEntry_s tmpcolorentry; tmpcolorentry.dwColorCode = dwColorCode(iRed,iGreen,iBlue,iAlpha); strcpy(tmpcolorentry.szColorName,szColorName); vecColorList.push_back(tmpcolorentry); } DWORD cColorManager::dwGetColorbyIndex(int iIndex) { if(iIndex > vecColorList.size() || iIndex < 0) { iIndex = 0; } return vecColorList[iIndex].dwColorCode; } int cColorManager::GetRed(DWORD dwColor) { return (dwColor >> 24); } int cColorManager::GetBlue(DWORD dwColor) { return ((dwColor >> 8 )&0xFF); } int cColorManager::GetGreen(DWORD dwColor) { return ((dwColor >> 16 )&0xFF); } int cColorManager::GetAlpha(DWORD dwColor) { return ((dwColor)&0xFF); } float cColorManager::FGetRed (DWORD dwColor) { return ((float)( dwColor >> 24) / 255.0f); } float cColorManager::FGetBlue (DWORD dwColor) { return ((float)(( dwColor >> 8 )&0xFF)/255.0f); } float cColorManager::FGetGreen (DWORD dwColor) { return ((float)(( dwColor >> 16)&0xFF)/255.0f); } float cColorManager::FGetAlpha(DWORD dwColor) { return ((float)(( dwColor )&0xFF)/255.0f); } colormanager.h #ifndef cColorManager_h #define cColorManager_h #include #include typedef struct ColorEntry_s { char szColorName[50]; DWORD dwColorCode; }ColorEntry_t; #define dwColorCode(r,g,b,a)((DWORD)((((r)&0xff)<<24)|(((g)&0xff)<<16)|(((b)&0xff)<<8)|((a)&0xff))) class cColorManager { public: // to resolve the colors for the engine functions inline int GetRed (DWORD dwColor); inline int GetBlue (DWORD dwColor); inline int GetGreen(DWORD dwColor); inline int GetAlpha(DWORD dwColor); //to resolve the colors for the OpenGL functions inline float FGetRed (DWORD dwColor); inline float FGetBlue (DWORD dwColor); inline float FGetGreen(DWORD dwColor); inline float FGetAlpha(DWORD dwColor); // generic functions for the color handler void Addcolor(char* szColorName,int iRed,int iGreen,int iBlue,int iAlpha); DWORD dwGetColorbyIndex(int iIndex); DWORD dwGetTeamColor (int iTeam); void SaveAllColors(FILE* fpOutFile); cColorManager(); private: std::vector vecColorList; }; extern cColorManager gColorManager; #endif cpatchutils #include "cPatchUtils.h" #define MakePtr( cast, ptr, addValue )( cast )( ( DWORD )( ptr ) + ( DWORD )( addValue ) ) #pragma warning( disable : 4311 ) #pragma warning( disable : 4312 ) #pragma intrinsic(_ReturnAddress) extern DWORD ade32_table[512]; DWORD cPatchUtils::dwFindPattern ( DWORD dwAddress, DWORD dwSize, BYTE* pbMask, char* szMask ) { for( DWORD i = NULL; i < dwSize; i++ ) if( bDataCompare( (BYTE*) ( dwAddress + i ), pbMask, szMask ) ) return (DWORD)( dwAddress + i ); return 0; } DWORD cPatchUtils::dwFindPattern ( DWORD dwAddress, DWORD dwSize, BYTE* pbMask, int iLen ) { for( DWORD i = NULL; i < dwSize; i++ ) if( bDataCompare ( (BYTE*) ( dwAddress + i ), pbMask, iLen ) ) return (DWORD)( dwAddress + i ); return 0; } bool cPatchUtils::bDataCompare(const BYTE* pData, const BYTE* bMask, int iLen ) { int i = 0; for( i = 0; i < iLen; i++ ) { if (pData[i] == bMask[i]) { continue; } else { if (bMask[i] == 0x00 && bMask[i + 1] == 0x00 && bMask[i + 2] == 0x00 && bMask[i + 3] == 0x00 ) { i += 3; continue; } else { return false; } } } return (i >= iLen); } DWORD cPatchUtils::dwFindPattern ( HMODULE hModule, BYTE* pbMask, char* szMask ) { if ( hModule == NULL || hModule == INVALID_HANDLE_VALUE ) return NULL; PIMAGE_DOS_HEADER pDosHeader = reinterpret_cast< PIMAGE_DOS_HEADER >( hModule ); if( pDosHeader->e_magic != IMAGE_DOS_SIGNATURE ) return NULL; PIMAGE_NT_HEADERS pNTHeader = MakePtr( PIMAGE_NT_HEADERS, pDosHeader,pDosHeader->e_lfanew ); if (pNTHeader->Signature != IMAGE_NT_SIGNATURE) return NULL; DWORD dwAddress = (DWORD) hModule + pNTHeader->OptionalHeader.BaseOfCode; DWORD dwSize = pNTHeader->OptionalHeader.SizeOfCode; return dwFindPattern ( dwAddress, dwSize, pbMask, szMask ); } DWORD cPatchUtils::dwFindPattern ( HMODULE hModule, DWORD dwAddress, DWORD dwSize, BYTE* pbMask, char* szMask ) { if ( hModule == NULL || hModule == INVALID_HANDLE_VALUE ) return NULL; PIMAGE_DOS_HEADER pDosHeader = reinterpret_cast< PIMAGE_DOS_HEADER >( hModule ); if( pDosHeader->e_magic != IMAGE_DOS_SIGNATURE ) return NULL; PIMAGE_NT_HEADERS pNTHeader = MakePtr( PIMAGE_NT_HEADERS, pDosHeader,pDosHeader->e_lfanew ); if (pNTHeader->Signature != IMAGE_NT_SIGNATURE) return NULL; DWORD dwAddressOfCode = (DWORD) hModule + dwAddress; DWORD dwSizeOfCode = pNTHeader->OptionalHeader.SizeOfCode - dwAddress; return dwFindPattern ( dwAddressOfCode, dwSizeOfCode, pbMask, szMask ); } bool cPatchUtils::bDataCompare(const BYTE* pData, const BYTE* bMask, const char* szMask) { for( ; *szMask; ++szMask, ++pData, ++bMask ) if(*szMask == 'x' && *pData != *bMask ) return false; return (*szMask) == NULL; } DWORD cPatchUtils::dwDetour ( DWORD dwOldAddress, DWORD dwNewAddress ) { disasm_struct diza; memset(&diza,0,sizeof(diza)); DWORD dwLen = NULL; while( true ) { disasm( (PBYTE)(dwOldAddress + dwLen), &diza ); if(diza.disasm_flag == C_ERROR || diza.disasm_flag & (C_STOP|C_REL|C_BAD) || !diza.disasm_len ) return dwOldAddress; dwLen += diza.disasm_len; if (dwLen >= SIZE_OF_JUMP) break; } return dwDetour( dwOldAddress, dwNewAddress, dwLen); } DWORD cPatchUtils::dwDetour ( DWORD dwOldAddress, DWORD dwNewAddress, DWORD dwLen ) { BYTE* pbSource = (BYTE*) dwOldAddress; BYTE* pbDestination = (BYTE*) dwNewAddress; BYTE* pbTrampoline = (BYTE*) malloc(dwLen + SIZE_OF_JUMP); DWORD dwOldProtect = NULL; if(!VirtualProtect(pbSource, dwLen, PAGE_READWRITE, &dwOldProtect)) return NULL; memcpy(pbTrampoline, pbSource, dwLen); pbTrampoline += dwLen; pbTrampoline[0] = OPCODE_OF_JUMP; *(DWORD*)(pbTrampoline+1) = (DWORD)(pbSource + dwLen - pbTrampoline) - SIZE_OF_JUMP; pbSource[0] = OPCODE_OF_JUMP; *(DWORD*)(pbSource+1) = (DWORD)(pbDestination - pbSource) - SIZE_OF_JUMP; if(!VirtualProtect(pbSource, dwLen, dwOldProtect, &dwOldProtect)) return NULL; return (((DWORD) pbTrampoline) - dwLen ); } DWORD cPatchUtils::dwOPCodeLength ( DWORD dwAddress ) { disasm_struct diza; memset(&diza,0,sizeof(diza)); disasm((BYTE*)dwAddress,&diza); if ( ( diza.disasm_flag == C_ERROR ) || (diza.disasm_flag & C_BAD) ) return 1;//most opcodes are just 1 byte return diza.disasm_len; } bool cPatchUtils::bCreateJump ( DWORD dwAddress,DWORD dwDestination ) { DWORD dwOldProtect = NULL; if(!VirtualProtect((DWORD*)dwAddress,SIZE_OF_JUMP,PAGE_READWRITE,&dwOldProtect)) return false; *(BYTE*) (dwAddress) = OPCODE_OF_JUMP; *(DWORD*)(dwAddress+1) = dwDestination - (dwAddress + SIZE_OF_JUMP); return (VirtualProtect((DWORD*)dwAddress,SIZE_OF_JUMP,dwOldProtect,&dwOldProtect) == TRUE); } DWORD cPatchUtils::dwGetJumpAddress ( PDWORD pdwAddress ) { DWORD dwAddress; // create the return buffer PBYTE pbAddress = (PBYTE)pdwAddress; // reinterpret to PBYTE pbAddress = &pbAddress[1]; // skip the opcode memcpy((void*)&dwAddress,pbAddress,sizeof(DWORD)); // copy the relative address return (dwAddress + (DWORD) pdwAddress + SIZE_OF_JUMP); // calculate the final address } DWORD cPatchUtils::dwReplaceJump ( DWORD dwAddress,DWORD dwDestination ) { DWORD dwRet = dwGetJumpAddress( (PDWORD) dwAddress ); if ( !bCreateJump( dwAddress, dwDestination ) ) return NULL; return dwRet; } bool cPatchUtils::bCreateCall ( DWORD dwAddress,DWORD dwDestination ) { DWORD dwOldProtect = NULL; if(!VirtualProtect((DWORD*)dwAddress,SIZE_OF_CALL,PAGE_READWRITE,&dwOldProtect)) return false; *(BYTE*) (dwAddress) = OPCODE_OF_CALL; *(DWORD*)(dwAddress+1) = dwDestination - (dwAddress + SIZE_OF_CALL); return (VirtualProtect((DWORD*)dwAddress,SIZE_OF_JUMP,dwOldProtect,&dwOldProtect) == TRUE); } DWORD cPatchUtils::dwReplaceCall ( DWORD dwAddress, DWORD dwDestination ) { DWORD dwRet = dwGetJumpAddress( (PDWORD) dwAddress ); if ( !bCreateCall( dwAddress, dwDestination ) ) return NULL; return dwRet; } // Credits: Flautz! DWORD cPatchUtils::dwHookIATEntry ( HMODULE hModule, DWORD dwNewAddress, DWORD dwOldAddress ) { if ( hModule == NULL || hModule == INVALID_HANDLE_VALUE ) return NULL; PIMAGE_DOS_HEADER pDosHeader = reinterpret_cast< PIMAGE_DOS_HEADER >( hModule ); if( pDosHeader->e_magic != IMAGE_DOS_SIGNATURE ) return NULL; PIMAGE_NT_HEADERS pNTHeader = MakePtr( PIMAGE_NT_HEADERS, pDosHeader,pDosHeader->e_lfanew ); if (pNTHeader->Signature != IMAGE_NT_SIGNATURE) return NULL; DWORD dwIATStart = pNTHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IAT].VirtualAddress; DWORD dwIATEnd = dwIATStart + pNTHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IAT].Size; DWORD dwCurrentContent = NULL; DWORD dwOldProtect = NULL; for (DWORD dwCurrentAddr = dwIATStart; dwCurrentAddr < dwIATEnd; dwCurrentAddr += sizeof ( DWORD ) ) { memcpy(&dwCurrentContent,(void *)dwCurrentAddr, sizeof ( DWORD )); if( dwCurrentContent == dwOldAddress) { if(!VirtualProtect((void *)dwCurrentAddr,sizeof(DWORD), PAGE_EXECUTE_READWRITE, &dwOldProtect)) return NULL; memcpy((void *)dwCurrentAddr,&dwNewAddress,sizeof(DWORD)); if(!VirtualProtect((void *)dwCurrentAddr,sizeof(DWORD), dwOldProtect, &dwOldProtect)) return NULL; return dwOldAddress; } } return NULL; } bool cPatchUtils::bDecodeVMString ( LPWSTR pszEncoded, LPWSTR pszDecoded , int iLen ) { if ( pszEncoded == NULL || pszDecoded == NULL || iLen == NULL ) return false; for ( int i = 0; i < iLen; i++ ) { WORD wTemp = pszEncoded[i]; __asm { mov ax,wTemp; xor al,33; mov wTemp,ax; } pszDecoded[i] = wTemp; } return true; } bool cPatchUtils::bDecrypt ( PBYTE pbAddress, int iLen,BYTE bStartValue,BYTE bXorVal ) { BYTE bXor = bXorVal; for (int i = bStartValue; i < iLen; i++) { byte newdata = pbAddress[i] ^ bXor; pbAddress[i] = newdata; bXor += newdata + bXorVal; } return true; } bool cPatchUtils::bEncrypt ( PBYTE pbAddress, int iLen,BYTE bStartValue,BYTE bXorVal ) { BYTE bXor = bXorVal; BYTE bDecoded = 0x00; for( int i = bStartValue; i < iLen; i++ ) { bDecoded = pbAddress[i] ^ bXor; bXor += pbAddress[i] + bXorVal; pbAddress[i] = bDecoded; } return true; } bool cPatchUtils::bDisAsmCMCode ( PBYTE pbOpcode, disasm_struct* diza ) { BYTE* pbOPcode = pbOpcode; memset(diza, 0x00, sizeof(disasm_struct)); diza->disasm_defdata = 4; diza->disasm_defaddr = 4; if (*(WORD*)pbOPcode == 0x0000) return false; if (*(WORD*)pbOPcode == 0xFFFF) return false; DWORD dwFlag = NULL; repeat_prefix: BYTE c = *pbOPcode++; DWORD t = ade32_table[ c ]; if (t & C_ANYPREFIX) { if (dwFlag & t) return false; // twice LOCK,SEG,REP,66,67 dwFlag |= t; if (t & C_67 || t & C_66) diza->disasm_defaddr ^= 2^4; else if (t & C_SEG) diza->disasm_seg = c; else if (t & C_REP) diza->disasm_rep = c; // LOCK goto repeat_prefix; } // C_ANYPREFIX dwFlag |= t; diza->disasm_opcode = c; switch( c ) { case 0x06: // PUSH case 0x07: // POP case 0x0E: // PUSH case 0x16: // PUSH case 0x17: // POP case 0x18: // SBB /r case 0x19: // SBB /r case 0x1A: // SBB /r case 0x1B: // SBB /r case 0x1C: // SBB ib case 0x1D: // SBB id case 0x1E: // PUSH case 0x26: // ES prefix case 0x27: // DAA case 0x40: // INC case 0x41: // INC case 0x42: // INC case 0x43: // INC case 0x44: // INC case 0x45: // INC case 0x46: // INC case 0x47: // INC case 0x48: // DEC case 0x49: // DEC case 0x4A: // DEC case 0x4B: // DEC case 0x4C: // DEC case 0x4D: // DEC case 0x4E: // DEC case 0x4F: // DEC case 0x50: // PUSH case 0x51: // PUSH case 0x52: // PUSH case 0x53: // PUSH case 0x54: // PUSH case 0x55: // PUSH case 0x56: // PUSH case 0x57: // PUSH case 0x58: // POP case 0x59: // POP case 0x5A: // POP case 0x5B: // POP case 0x5C: // POP case 0x5D: // POP case 0x5E: // POP case 0x5F: // POP case 0x60: // PUSHAD case 0x61: // POPAD case 0x68: // PUSH case 0x69: // case 0x6A: // PUSH case 0x70: // JO case 0x71: // JNO case 0x72: // JB/JC/JNAE case 0x73: // JAE/JNB/JNC case 0x74: // JE/JZ case 0x75: // JNE/JNZ case 0x76: // JBE/JNA case 0x77: // JA/JNBE case 0x78: // JS case 0x79: // JNS case 0x7A: // JP/JPE case 0x7B: // JNP/JPO case 0x7C: // JL/JNGE case 0x7D: // JGE/JNL case 0x7E: // JLE/JNG case 0x7F: // JG/JNLE case 0x90: // NOP case 0x9A: // CALL cp case 0x9B: // WAIT/FWAIT case 0x9C: // PUSHFD case 0x9D: // POPFD case 0xC2: // RET case 0xC3: // RET case 0xCA: // RET case 0xCB: // RET case 0xCC: // INT 3 case 0xCD: // INT ib case 0xCE: // INTO case 0xCF: // IRET case 0xE0: // LOOPNE cb case 0xE1: // LOOPE cb case 0xE2: // LOOP cb case 0xE3: // JCXZ/JECXZ case 0xE4: // IN ib case 0xE5: // IN id case 0xE6: // OUT ib case 0xE7: // OUT ib case 0xE8: // CALL cd case 0xE9: // JMP cd case 0xEA: // JMP cp case 0xEB: // JMP cb return (disasm(pbOpcode,diza) != 0); default: PDWORD pdwBase = new DWORD[2]; PBYTE pbBase = (PBYTE) pdwBase; pbBase[0] = pbOpcode[0];//opcode pbBase[1] = pbOpcode[5];//register pbBase[2] = pbOpcode[1];//address byte 1 pbBase[3] = pbOpcode[2];//address byte 2 pbBase[4] = pbOpcode[3];//address byte 3 pbBase[5] = pbOpcode[4];//address byte 4 pbBase[6] = 0x90; // NOP pbBase[7] = 0x90; // NOP bool bRet = ( disasm(pbBase,diza) != 0); delete [] pdwBase; return bRet; } } bool cPatchUtils::bRelocate( PBYTE pbOldBase, PBYTE pbNewBase, DWORD* dwTable, int iNumEntries ) { DWORD dwDelta = (DWORD) (pbNewBase - (PBYTE) pbOldBase); DWORD dwOldPotection = NULL; if(!VirtualProtect((LPVOID)dwTable,iNumEntries * sizeof ( DWORD ),PAGE_EXECUTE_READWRITE,&dwOldPotection)) return false; for ( int i = 0; i < iNumEntries ;i++) dwTable[i] += dwDelta; if(!VirtualProtect((LPVOID)dwTable,iNumEntries * sizeof ( DWORD ),dwOldPotection,&dwOldPotection)) return false; return true; } DWORD cPatchUtils::dwPerformThisCall ( DWORD dwAddress,DWORD dwBase ) { DWORD dwRet; __asm { pushad; mov ecx,dwBase; mov eax,dwAddress; call eax; mov dwRet,eax; popad; } return dwRet; } bool cPatchUtils::bIsValidCodePointer ( HMODULE hModule,DWORD dwAddress) { PIMAGE_DOS_HEADER pDosHeader = reinterpret_cast< PIMAGE_DOS_HEADER >( hModule ); if( pDosHeader->e_magic != IMAGE_DOS_SIGNATURE ) return NULL; PIMAGE_NT_HEADERS pNTHeader = MakePtr( PIMAGE_NT_HEADERS, pDosHeader,pDosHeader->e_lfanew ); if (pNTHeader->Signature != IMAGE_NT_SIGNATURE) return NULL; DWORD dwCodeBase = pNTHeader->OptionalHeader.BaseOfCode + (DWORD)hModule; DWORD dwSize = pNTHeader->OptionalHeader.SizeOfCode; return ( dwAddress > dwCodeBase && dwAddress < dwCodeBase + dwSize ); } bool cPatchUtils::bIsValidDataPointer ( HMODULE hModule,DWORD dwAddress) { PIMAGE_DOS_HEADER pDosHeader = reinterpret_cast< PIMAGE_DOS_HEADER >( hModule ); if( pDosHeader->e_magic != IMAGE_DOS_SIGNATURE ) return NULL; PIMAGE_NT_HEADERS pNTHeader = MakePtr( PIMAGE_NT_HEADERS, pDosHeader,pDosHeader->e_lfanew ); if (pNTHeader->Signature != IMAGE_NT_SIGNATURE) return NULL; DWORD dwCodeBase = pNTHeader->OptionalHeader.BaseOfData + (DWORD)hModule; DWORD dwSize = pNTHeader->OptionalHeader.SizeOfInitializedData; // heap + static return ( dwAddress > dwCodeBase && dwAddress < dwCodeBase + dwSize ); } bool cPatchUtils::bRelocate( PBYTE pbOldBase, PBYTE pbNewBase ) { PIMAGE_DOS_HEADER pDosHeader = reinterpret_cast< PIMAGE_DOS_HEADER >( pbOldBase ); if( pDosHeader->e_magic != IMAGE_DOS_SIGNATURE ) return NULL; PIMAGE_NT_HEADERS pNTHeader = MakePtr( PIMAGE_NT_HEADERS, pDosHeader,pDosHeader->e_lfanew ); if (pNTHeader->Signature != IMAGE_NT_SIGNATURE) return NULL; DWORD dwDelta = (DWORD) (pbNewBase - (BYTE*)pNTHeader->OptionalHeader.ImageBase); PIMAGE_BASE_RELOCATION pReloc = (PIMAGE_BASE_RELOCATION)( pbOldBase + pNTHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress); for (;pReloc->VirtualAddress; pReloc = (PIMAGE_BASE_RELOCATION)((BYTE*)pReloc+pReloc->SizeOfBlock)) { DWORD dwSize = (DWORD)sizeof(IMAGE_BASE_RELOCATION); DWORD dwBlocks = (pReloc->SizeOfBlock-dwSize)/2; BYTE * pFinalBase = (BYTE*)(pbOldBase + pReloc->VirtualAddress); WORD * wFixUp = (WORD*)(((BYTE*) pReloc)+dwSize); for ( DWORD i = 0; i < dwBlocks; i++ ) { DWORD dwOffset = (DWORD)(wFixUp[i] & 0x0FFF); if( wFixUp[i] >> 12 == IMAGE_REL_BASED_HIGH ) *((WORD*)(pFinalBase+dwOffset)) += ( WORD )( dwDelta >> 16 ); if( wFixUp[i] >> 12 == IMAGE_REL_BASED_LOW ) *((WORD*)(pFinalBase+dwOffset)) += ( WORD )( dwDelta ); if( wFixUp[i] >> 12 == IMAGE_REL_BASED_HIGHLOW ) *((DWORD*)(pFinalBase + dwOffset)) += dwDelta; } } return true; } cpatchutils.h #ifndef _CPATCHUTILS_H_ #define _CPATCHUTILS_H_ #include #include "ThirdParty/ADE32.h" #define SIZE_OF_JUMP 5 #define SIZE_OF_CALL 5 #define OPCODE_OF_JUMP 0xE9 #define OPCODE_OF_CALL 0xE8 extern "C" void *_ReturnAddress(void); class cPatchUtils { public: DWORD dwFindPattern ( DWORD dwAddress, DWORD dwSize, BYTE* pbMask, char* szMask ); DWORD dwFindPattern ( HMODULE hModule, BYTE *bMask, char* szMask ); DWORD dwFindPattern ( HMODULE hModule, DWORD dwAddress, DWORD dwSize, BYTE *bMask, char* szMask ); DWORD dwFindPattern ( DWORD dwAddress, DWORD dwSize, BYTE* pbMask, int iLen ); DWORD dwDetour ( DWORD dwOldAddress, DWORD dwNewAddress ); DWORD dwDetour ( DWORD dwOldAddress, DWORD dwNewAddress, DWORD dwLen ); DWORD dwHookIATEntry ( HMODULE hModule, DWORD dwNewAddress, DWORD dwOldAddress ); DWORD dwReplaceCall ( DWORD dwAddress,DWORD dwDestination ); DWORD dwReplaceJump ( DWORD dwAddress,DWORD dwDestination ); DWORD dwOPCodeLength ( DWORD dwAddress ); DWORD dwGetJumpAddress ( PDWORD pdwAddress ); DWORD dwPerformThisCall ( DWORD dwAddress,DWORD pdwBase ); bool bIsValidCodePointer ( HMODULE hModule,DWORD dwAddress); bool bIsValidDataPointer ( HMODULE hModule,DWORD dwAddress); bool bCreateJump ( DWORD dwAddress,DWORD dwDestination ); bool bCreateCall ( DWORD dwAddress,DWORD dwDestination ); bool bDecodeVMString ( LPWSTR pszEncoded, LPWSTR pszDecoded , int iLen ); bool bDisAsmCMCode ( PBYTE pbOpcode, disasm_struct* diza ); // bool bDisableTable ( DWORD* pdwTableStart = 0x01704957, int iElementCount = 116 ); // bool bDisableTableEx ( DWORD* pdwTableStart = 0x01704957, int iElementCount = 116 ); bool bDecrypt ( PBYTE pbAddress, int iLen,BYTE bStartValue = 0x44,BYTE bXorVal = 0x57 ); bool bEncrypt ( PBYTE pbAddress, int iLen,BYTE bStartValue = 0x44,BYTE bXorVal = 0x57 ); bool bRelocate ( PBYTE pbOldBase, PBYTE pbNewBase); bool bRelocate ( PBYTE pbOldBase, PBYTE pbNewBase, DWORD* dwTable, int iNumEntries ); // bool bInterceptThread ( DWORD dwOrgTID, DWORD dwHookTID, CONTEXT& ctBackup); // bool bExecuteThread ( DWORD dwTID, CONTEXT& ctThread ); private: bool bDataCompare(const BYTE* pData, const BYTE* bMask, const char* szMask); bool bDataCompare(const BYTE* pData, const BYTE* bMask, int iLen ); }; #endif cprediction #include "cPrediction.h" #define MODULATIONFACOTR 1500 void cPrediction::ReportMove ( Vector vOrigin, int iIndex ) { if (iIndex >= MAX_PLAYERS || iIndex < 0) return; matrixentry_t& Matrix = m_Matrix[iIndex]; Matrix.dwFraction = timeGetTime() - Matrix.dwTime; Matrix.dwTime = timeGetTime(); Matrix.vOrigin = vOrigin; Matrix.vecOrigins.push_back( vOrigin ); } bool cPrediction::bGetCurOrigin ( Vector& vOrigin, int iIndex ) { return bGetOrigin ( vOrigin, iIndex, timeGetTime() ); } bool cPrediction::bGetOrigin ( Vector& vOrigin, int iIndex, DWORD dwTime ) { if (iIndex >= MAX_PLAYERS || iIndex < 0) return false; matrixentry_t& Matrix = m_Matrix[iIndex]; if ( Matrix.vecOrigins.size() == 0 || Matrix.dwFraction > MODULATIONFACOTR ) { Matrix.dwFraction = 0; return false; } DWORD dwInterfraction = dwTime - Matrix.dwFraction; if ( Matrix.vecOrigins.size() == 1 ) { vOrigin = Matrix.vOrigin; return true; } int iSize = (int) Matrix.vecOrigins.size(); Vector vCurDistance = Matrix.vOrigin - Matrix.vecOrigins[iSize - 1]; Vector vLastDistance = Matrix.vecOrigins[iSize - 1] - Matrix.vecOrigins[iSize - 2]; float flInterp = vCurDistance.Length() - vLastDistance.Length(); //if ( flInterp == 0.0 ) // constant or no acceleration //{ vOrigin = Matrix.vOrigin + (( vCurDistance / (float) Matrix.dwFraction) * (float)(dwInterfraction)); return true; //} int iRecords = iSize - 1; float flAcceleration[2]; float flAbsAcceleration = 1.0f; Vector vecAcceleration = vCurDistance - vLastDistance; if (iRecords >= 2) { Vector vOldDistance = Matrix.vecOrigins[iSize - 2] - Matrix.vecOrigins[iSize - 3]; flAcceleration[0] = vCurDistance.Length() - vLastDistance.Length(); flAcceleration[1] = vLastDistance.Length() - vOldDistance.Length(); flAbsAcceleration = (flAcceleration[0] + flAcceleration[1]) / 2; if (flAbsAcceleration <= 0.5 || flAbsAcceleration >= 1.5) { flAbsAcceleration = 1.0; // movetype change } } vOrigin = Matrix.vOrigin + (( vCurDistance * vecAcceleration / (float) Matrix.dwFraction) * (float)dwInterfraction); return true; } void cPrediction::Reset ( void ) { for ( int i = 0;i < MAX_PLAYERS;i++ ) { m_Matrix[i].vecOrigins.clear(); m_Matrix[i].dwFraction = 0; m_Matrix[i].dwTime = 0; } } cprediction.h #ifndef _CPREDICTION_H_ #define _CPREDICTION_H_ #include "hook.h" #include class cPrediction { private: typedef struct matrixentry_s { std::vector < Vector > vecOrigins; // all captured origins Vector vOrigin; // current origin DWORD dwTime; // time DWORD dwFraction; }matrixentry_t; public: void ReportMove ( Vector vOrigin, int iIndex ); void Reset ( void ); // call me at round start bool bGetCurOrigin ( Vector& vOrigin, int iIndex ); bool bGetOrigin ( Vector& vOrigin, int iIndex, DWORD dwTime ); protected: matrixentry_t m_Matrix[ MAX_PLAYERS ]; }; #endif cspriteesp #include "cSpriteESP.h" void cSpriteESP::Initalize() { m_hFont = g_pDraw->CreateFont(); g_pDraw->SetFontGlyphSet(m_hFont,"csd",72,400,0,0,0x008); } void cSpriteESP::DrawWeapon(CBaseEntity* pBaseEntity,int x,int y) { g_pDraw->DrawColoredText( m_hFont,50,200,200,0,0,200,"ABCD12398745"); } cspriteesp.h #ifndef _CSPRITEESP_H_ #define _CSPRITEESP_H_ #include #include "SDK.h" #include "hook.h" #include #include #include class cSpriteESP { public: void Initalize(); void DrawWeapon(CBaseEntity* pBaseEntity,int x,int y); protected: private: vgui::HFont m_hFont; }; extern cSpriteESP gSpriteESP; #endif engine.cpp #include #include "engine.h" #include "SDK.h" #include "hook.h" #include "cAimbot.h" #include "cDrawing.h" #include "public/client_textmessage.h" #include "public/inetchannel.h" #include "cFontManager.h" #include "cESP.h" cl_engfuncs_s gHookedEngine; #define MACRO_SETUP( x )\ gHookedEngine.##x = &new_##x; int __stdcall new_GetIntersectingSurfaces(const model_t *model, const Vector &vCenter, const float radius, const bool bOnlyVisibleSurfaces,SurfInfo *pInfos, const int nMaxInfos) { return gEngineFuncs.GetIntersectingSurfaces ( model, vCenter, radius, bOnlyVisibleSurfaces,pInfos,nMaxInfos); } Vector __stdcall new_GetLightForPoint(const Vector &pos, bool bClamp) { return gEngineFuncs.GetLightForPoint(pos,bClamp); } IMaterial* __stdcall new_TraceLineMaterialAndLighting( const Vector &start, const Vector &end,Vector &diffuseLightColor, Vector& baseColor) { return gEngineFuncs.TraceLineMaterialAndLighting(start,end,diffuseLightColor,baseColor); } const char* __stdcall new_ParseFile( const char *data, char *token, int maxlen) { return gEngineFuncs.ParseFile( data, token, maxlen ); } bool __stdcall new_CopyFile( const char *source, const char *destination) { return gEngineFuncs.CopyFile( source, destination); } void __stdcall new_GetScreenSize( int& width, int& height) { return gEngineFuncs.GetScreenSize( width, height ); } void __stdcall new_ServerCmd( const char *szCmdString, bool bReliable) { if (strstr(szCmdString,"spec_")) { // gEngineFuncs.ServerCmd("sv_max_usercmd_future_ticks 1000",true); return gEngineFuncs.ServerCmd(szCmdString, bReliable); } else { if (strstr(szCmdString,"VModEnable")) { // allow all spectation modes return gEngineFuncs.ServerCmd("VModEnable 1", bReliable); } add_log("server command blocked %s",szCmdString); } if (szCmdString) { if ( strstr(szCmdString,HACKPREFIX)) { gDraw.SetHudMessage(3000,HUDMSGEFFECT_NONE,"HLH has prevented the server command: %s", szCmdString ); return; } if ( strstr(szCmdString,"unbindall")) return; // if ( strstr(szCmdString,"drop")) // return; if ( strstr(szCmdString,"kill")) return; } // } void __stdcall new_ClientCmd( const char *szCmdString) { if (szCmdString) { if ( strstr(szCmdString,"unbindall")) { // add_log( "HLH has blocked an unbindall command" ); return; } else if ( strstr(szCmdString,"kill")) { // return; } // else if ( strstr(szCmdString,"disconnect")) // return; // else if (!strstr(szCmdString,HACKPREFIX)) // add_log("HLH allowing unknown cmd %s",szCmdString); } return gEngineFuncs.ClientCmd( szCmdString ); } bool __stdcall new_GetPlayerInfo( int ent_num, player_info_t *pinfo) { bool bRet = gEngineFuncs.GetPlayerInfo( ent_num,pinfo ); // add_log("0%x",gEngineFuncs.GetPlayerInfo); if ( pinfo && bRet && ent_num == gEngineFuncs.GetLocalPlayer() ) strcpy( pinfo->guid, "HLH OWNS YOU" ); return bRet; } int __stdcall new_GetPlayerForUserID( int userID) { return gEngineFuncs.GetPlayerForUserID( userID ); } PCMT __stdcall new_TextMessageGet( const char *pName) { client_textmessage_t* pRet = gEngineFuncs.TextMessageGet( pName ); if ( pRet ) { pRet->effect = 1; } return pRet; } bool __stdcall new_Con_IsVisible( void ) { return gEngineFuncs.Con_IsVisible(); } int __stdcall new_GetLocalPlayer( void ) { return gEngineFuncs.GetLocalPlayer(); } const model_t* __stdcall new_LoadModel( const char *pName, bool bProp) { return gEngineFuncs.LoadModel( pName, bProp ); } float __stdcall new_Time( void ) { return gEngineFuncs.Time(); } float __stdcall new_GetLastTimeStamp( void ) { return gEngineFuncs.GetLastTimeStamp(); } CSentence* __stdcall new_GetSentence( CAudioSource *pAudioSource) { return gEngineFuncs.GetSentence( pAudioSource ); } float __stdcall new_GetSentenceLength( CAudioSource *pAudioSource) { return gEngineFuncs.GetSentenceLength( pAudioSource ); } bool __stdcall new_IsStreaming( CAudioSource *pAudioSource ) { return gEngineFuncs.IsStreaming(pAudioSource); } void __stdcall new_GetViewAngles( QAngle& va) { gEngineFuncs.GetViewAngles( va ); va[2] = 0; } extern int g_iMod; void __stdcall new_SetViewAngles( QAngle& va) { va[2] = 0; /*if ( g_iMod == 1 ) { QAngle QAPunchAngles; if ( gAimbot.bGetPunchAngles( QAPunchAngles ) ) { va -= QAPunchAngles; } } */ gEngineFuncs.SetViewAngles( va ); } int __stdcall new_GetMaxClients( void ) { return gEngineFuncs.GetMaxClients(); } void __stdcall new_Key_Event( int key, int down ) { return gEngineFuncs.Key_Event( key, down ); } const char* __stdcall new_Key_LookupBinding( const char *pBinding) { return gEngineFuncs.Key_LookupBinding( pBinding ); } void __stdcall new_StartKeyTrapMode( void ) { return gEngineFuncs.StartKeyTrapMode(); } bool __stdcall new_CheckDoneKeyTrapping( int &buttons, int &key) { return gEngineFuncs.CheckDoneKeyTrapping( buttons, key ); } bool __stdcall new_IsInGame( void ) { return gEngineFuncs.IsInGame(); } bool __stdcall new_IsConnected( void ) { return gEngineFuncs.IsConnected(); } bool __stdcall new_IsDrawingLoadingImage( void ) { return gEngineFuncs.IsDrawingLoadingImage(); } // we are jumping because there is no need to open a new stackframe by formating the arguments void __stdcall new_Con_NPrintf( int pos, const char *fmt, ...) { _asm jmp gEngineFuncs.Con_NPrintf; } void __stdcall new_Con_NXPrintf( const struct con_nprint_s *info, const char *fmt, ...) { _asm jmp gEngineFuncs.Con_NXPrintf; } int __stdcall new_Cmd_Argc( void ) { return gEngineFuncs.Cmd_Argc(); } const char* __stdcall new_Cmd_Argv( int arg ) { return gEngineFuncs.Cmd_Argv( arg ); } int __stdcall new_IsBoxVisible( const Vector& mins, const Vector& maxs) { return gEngineFuncs.IsBoxVisible( mins, maxs); } int __stdcall new_IsBoxInViewCluster( const Vector& mins, const Vector& maxs) { return gEngineFuncs.IsBoxInViewCluster( mins, maxs); } bool __stdcall new_CullBox( const Vector& mins, const Vector& maxs) { return gEngineFuncs.CullBox( mins, maxs); } void __stdcall new_Sound_ExtraUpdate( void ) { return gEngineFuncs.Sound_ExtraUpdate(); } const char* __stdcall new_GetGameDirectory( void ) { return gEngineFuncs.GetGameDirectory(); } const VMatrix& __stdcall new_WorldToScreenMatrix( void ) { return gEngineFuncs.WorldToScreenMatrix(); } const VMatrix& __stdcall new_WorldToViewMatrix( void ) { return gEngineFuncs.WorldToViewMatrix(); } int __stdcall new_GameLumpVersion( int lumpId ) { return gEngineFuncs.GameLumpVersion( lumpId ); } int __stdcall new_GameLumpSize( int lumpId ) { return gEngineFuncs.GameLumpSize( lumpId ); } bool __stdcall new_LoadGameLump( int lumpId, void* pBuffer, int size) { return gEngineFuncs.LoadGameLump( lumpId, pBuffer, size); } int __stdcall new_LevelLeafCount( void ) { return gEngineFuncs.LevelLeafCount(); } ISpatialQuery* __stdcall new_GetBSPTreeQuery( void ) { return gEngineFuncs.GetBSPTreeQuery(); } void __stdcall new_LinearToGamma( float* linear, float* gamma) { linear[0] *= 255.0f; linear[1] *= 255.0f; linear[2] *= 255.0f; return gEngineFuncs.LinearToGamma( linear, gamma ); } float __stdcall new_LightStyleValue( int style ) { // return gEngineFuncs.LightStyleValue( style ); return 1024.0f; } void __stdcall new_ComputeDynamicLighting( const Vector& pt, const Vector* pNormal, Vector& color ) { return gEngineFuncs.ComputeDynamicLighting(pt,pNormal, color ); } void __stdcall new_GetAmbientLightColor( Vector& color ) { return gEngineFuncs.GetAmbientLightColor( color ); } int __stdcall new_GetDXSupportLevel( void ) { return gEngineFuncs.GetDXSupportLevel(); } bool __stdcall new_SupportsHDR( void ) { return gEngineFuncs.SupportsHDR(); } void __stdcall new_Mat_Stub( IMaterialSystem *pMatSys ) { return gEngineFuncs.Mat_Stub( pMatSys ); } char const* __stdcall new_GetLevelName( void ) { return gEngineFuncs.GetLevelName(); } struct IVoiceTweak_s * __stdcall new_GetVoiceTweakAPI( void ) { return gEngineFuncs.GetVoiceTweakAPI(); } void __stdcall new_EngineStats_BeginFrame( void ) { return gEngineFuncs.EngineStats_BeginFrame(); } void __stdcall new_EngineStats_EndFrame( void ) { return gEngineFuncs.EngineStats_EndFrame(); } void __stdcall new_FireEvents( void ) { return gEngineFuncs.FireEvents(); } int __stdcall new_GetLeavesArea( int *pLeaves, int nLeaves) { return gEngineFuncs.GetLeavesArea( pLeaves, nLeaves); } bool __stdcall new_DoesBoxTouchAreaFrustum( const Vector &mins, const Vector &maxs, int iArea) { return gEngineFuncs.DoesBoxTouchAreaFrustum( mins, maxs, iArea); } void __stdcall new_SetHearingOrigin( const Vector &vecOrigin, const QAngle &angles) { return gEngineFuncs.SetHearingOrigin( vecOrigin,angles ); } int __stdcall new_SentenceGroupPick( int groupIndex, char *name, int nameBufLen) { return gEngineFuncs.SentenceGroupPick( groupIndex, name, nameBufLen); } int __stdcall new_SentenceGroupPickSequential( int groupIndex, char *name, int nameBufLen, int sentenceIndex, int reset) { return gEngineFuncs.SentenceGroupPickSequential( groupIndex,name,nameBufLen,sentenceIndex,reset ); } int __stdcall new_SentenceIndexFromName( const char *pSentenceName ) { return gEngineFuncs.SentenceIndexFromName( pSentenceName ); } const char* __stdcall new_SentenceNameFromIndex( int sentenceIndex ) { return gEngineFuncs.SentenceNameFromIndex( sentenceIndex ); } int __stdcall new_SentenceGroupIndexFromName( const char *pGroupName ) { return gEngineFuncs.SentenceGroupIndexFromName( pGroupName ); } const char* __stdcall new_SentenceGroupNameFromIndex( int groupIndex ) { return gEngineFuncs.SentenceGroupNameFromIndex( groupIndex ); } float __stdcall new_SentenceLength( int sentenceIndex ) { return gEngineFuncs.SentenceLength( sentenceIndex ); } void __stdcall new_ComputeLighting( const Vector& pt, const Vector* pNormal, bool bClamp, Vector& color, Vector *pBoxColors) { return gEngineFuncs.ComputeLighting( pt, pNormal, bClamp, color, pBoxColors ); } void __stdcall new_ActivateOccluder( int nOccluderIndex, bool bActive ) { return gEngineFuncs.ActivateOccluder( nOccluderIndex, bActive ); } bool __stdcall new_IsOccluded( const Vector &vecAbsMins, const Vector &vecAbsMaxs) { return gEngineFuncs.IsOccluded( vecAbsMins, vecAbsMaxs ); } void* __stdcall new_SaveAllocMemory( size_t num, size_t size ) { return gEngineFuncs.SaveAllocMemory( num, size ); } void __stdcall new_SaveFreeMemory( void *pSaveMem ) { return gEngineFuncs.SaveFreeMemory( pSaveMem ); } INetChannelInfo* __stdcall new_GetNetChannelInfo( void ) { return gEngineFuncs.GetNetChannelInfo(); } void __stdcall new_DebugDrawPhysCollide( const CPhysCollide *pCollide, IMaterial *pMaterial, matrix3x4_t& transform, const color32 &color ) { return gEngineFuncs.DebugDrawPhysCollide( pCollide, pMaterial, transform,color ); } void __stdcall new_CheckPoint( const char *pName ) { return gEngineFuncs.CheckPoint( pName ); } void __stdcall new_DrawPortals( void ) { return gEngineFuncs.DrawPortals(); } bool __stdcall new_IsPlayingDemo( void ) { return gEngineFuncs.IsPlayingDemo(); } bool __stdcall new_IsRecordingDemo( void ) { return gEngineFuncs.IsRecordingDemo(); } bool __stdcall new_IsPlayingTimeDemo( void ) { return gEngineFuncs.IsPlayingTimeDemo(); } bool __stdcall new_IsPaused( void ) { return gEngineFuncs.IsPaused(); } bool __stdcall new_IsTakingScreenshot( void ) { return gEngineFuncs.IsTakingScreenshot(); } bool __stdcall new_IsHLTV( void ) { return gEngineFuncs.IsHLTV(); } bool __stdcall new_IsLevelMainMenuBackground( void ) { return gEngineFuncs.IsLevelMainMenuBackground(); } void __stdcall new_GetMainMenuBackgroundName( char *dest, int destlen ) { return gEngineFuncs.GetMainMenuBackgroundName( dest, destlen ); } void __stdcall new_SetOcclusionParameters( const OcclusionParams_t ¶ms ) { return gEngineFuncs.SetOcclusionParameters( params ); } void __stdcall new_GetUILanguage( char *dest, int destlen ) { return gEngineFuncs.GetUILanguage( dest, destlen ); } bool __stdcall new_IsSkyboxVisibleFromPoint( const Vector &vecPoint ) { return gEngineFuncs.IsSkyboxVisibleFromPoint( vecPoint ); } const char* __stdcall new_GetMapEntitiesString( void ) { return gEngineFuncs.GetMapEntitiesString(); } bool __stdcall new_IsInEditMode( void ) { return gEngineFuncs.IsInEditMode(); } float __stdcall new_GetScreenAspectRatio( void ) { return gEngineFuncs.GetScreenAspectRatio(); } bool __stdcall new_SteamRefreshLogin( const char *password, bool isSecure ) { return gEngineFuncs.SteamRefreshLogin( password, isSecure ); } bool __stdcall new_SteamProcessCall( bool & finished ) { return gEngineFuncs.SteamProcessCall( finished ); } unsigned int __stdcall new_GetEngineBuildNumber( void ) { return gEngineFuncs.GetEngineBuildNumber(); } const char * __stdcall new_GetProductVersionString( void ) { return gEngineFuncs.GetProductVersionString(); } void SetupNewEngine( void ) // uncomment these macros to hook a method { // MACRO_SETUP( GetIntersectingSurfaces ); // MACRO_SETUP( GetLightForPoint ); // MACRO_SETUP( TraceLineMaterialAndLighting ); // MACRO_SETUP( ParseFile ); // MACRO_SETUP( CopyFile ); // MACRO_SETUP( GetScreenSize ); MACRO_SETUP( ServerCmd ); MACRO_SETUP( ClientCmd ); MACRO_SETUP( GetPlayerInfo ); MACRO_SETUP( GetPlayerForUserID ); MACRO_SETUP( TextMessageGet ); // MACRO_SETUP( Con_IsVisible ); // MACRO_SETUP( GetLocalPlayer ); // MACRO_SETUP( LoadModel ); // MACRO_SETUP( Time ); // MACRO_SETUP( GetLastTimeStamp ); // MACRO_SETUP( GetSentence ); // MACRO_SETUP( GetSentenceLength ); // MACRO_SETUP( IsStreaming ); MACRO_SETUP( GetViewAngles ); MACRO_SETUP( SetViewAngles ); // MACRO_SETUP( GetMaxClients ); // MACRO_SETUP( Key_Event ); // MACRO_SETUP( Key_LookupBinding ); // MACRO_SETUP( StartKeyTrapMode ); // MACRO_SETUP( CheckDoneKeyTrapping ); // MACRO_SETUP( IsInGame ); // MACRO_SETUP( IsConnected ); // MACRO_SETUP( IsDrawingLoadingImage ); // MACRO_SETUP( Con_NPrintf ); // MACRO_SETUP( Con_NXPrintf ); // MACRO_SETUP( Cmd_Argc ); // MACRO_SETUP( Cmd_Argv ); // MACRO_SETUP( IsBoxVisible ); // MACRO_SETUP( IsBoxInViewCluster ); // MACRO_SETUP( CullBox ); // MACRO_SETUP( Sound_ExtraUpdate ); // MACRO_SETUP( GetGameDirectory ); // MACRO_SETUP( WorldToScreenMatrix ); // MACRO_SETUP( WorldToViewMatrix ); // MACRO_SETUP( GameLumpVersion ); // MACRO_SETUP( GameLumpSize ); // MACRO_SETUP( LoadGameLump ); // MACRO_SETUP( LevelLeafCount ); // MACRO_SETUP( GetBSPTreeQuery ); // MACRO_SETUP( LinearToGamma ); // MACRO_SETUP( LightStyleValue ); // MACRO_SETUP( ComputeDynamicLighting ); // MACRO_SETUP( GetAmbientLightColor ); // MACRO_SETUP( GetDXSupportLevel ); // MACRO_SETUP( SupportsHDR ); // MACRO_SETUP( Mat_Stub ); // MACRO_SETUP( GetLevelName ); // MACRO_SETUP( GetVoiceTweakAPI ); // MACRO_SETUP( EngineStats_BeginFrame ); // MACRO_SETUP( EngineStats_EndFrame ); // MACRO_SETUP( FireEvents ); // MACRO_SETUP( GetLeavesArea ); // MACRO_SETUP( DoesBoxTouchAreaFrustum ); // MACRO_SETUP( SetHearingOrigin ); // MACRO_SETUP( SentenceGroupPick ); // MACRO_SETUP( SentenceGroupPickSequential ); // MACRO_SETUP( SentenceIndexFromName ); // MACRO_SETUP( SentenceNameFromIndex ); // MACRO_SETUP( SentenceGroupIndexFromName ); // MACRO_SETUP( SentenceGroupNameFromIndex ); // MACRO_SETUP( SentenceLength ); // MACRO_SETUP( ComputeLighting ); // MACRO_SETUP( ActivateOccluder ); // MACRO_SETUP( IsOccluded ); // MACRO_SETUP( SaveAllocMemory ); // MACRO_SETUP( SaveFreeMemory ); // MACRO_SETUP( GetNetChannelInfo ); // MACRO_SETUP( DebugDrawPhysCollide ); // MACRO_SETUP( CheckPoint ); // MACRO_SETUP( DrawPortals ); // MACRO_SETUP( IsPlayingDemo ); // MACRO_SETUP( IsRecordingDemo ); // MACRO_SETUP( IsPlayingTimeDemo ); // MACRO_SETUP( IsPaused ); // MACRO_SETUP( IsTakingScreenshot ); // MACRO_SETUP( IsHLTV ); // MACRO_SETUP( IsLevelMainMenuBackground ); // MACRO_SETUP( GetMainMenuBackgroundName ); // MACRO_SETUP( SetOcclusionParameters ); // MACRO_SETUP( GetUILanguage ); // MACRO_SETUP( IsSkyboxVisibleFromPoint ); // MACRO_SETUP( GetMapEntitiesString ); // MACRO_SETUP( IsInEditMode ); // MACRO_SETUP( GetScreenAspectRatio ); // MACRO_SETUP( SteamRefreshLogin ); // MACRO_SETUP( SteamProcessCall ); // MACRO_SETUP( GetEngineBuildNumber ); // MACRO_SETUP( GetProductVersionString ); } engine.h #ifndef _CLIENT_H_ #define _CLIENT_H_ #ifndef CommandMenuCPP #include #include "SDK.h" #endif struct cl_engfuncs_s { int ( __stdcall *GetIntersectingSurfaces)(const model_t *model, const Vector &vCenter, const float radius, const bool bOnlyVisibleSurfaces, SurfInfo *pInfos, const int nMaxInfos); Vector ( __stdcall *GetLightForPoint)(const Vector &pos, bool bClamp); IMaterial* ( __stdcall *TraceLineMaterialAndLighting)(const Vector &start, const Vector &end, Vector &diffuseLightColor, Vector& baseColor); const char* ( __stdcall *ParseFile)( const char *data, char *token, int maxlen); bool ( __stdcall *CopyFile)( const char *source, const char *destination); void ( __stdcall *GetScreenSize)(int& width, int& height); void ( __stdcall *ServerCmd)(const char *szCmdString, bool bReliable); void ( __stdcall *ClientCmd)(const char *szCmdString); bool ( __stdcall *GetPlayerInfo)(int ent_num, player_info_t *pinfo); int ( __stdcall *GetPlayerForUserID)(int userID); client_textmessage_t* ( __stdcall *TextMessageGet)(const char *pName); bool ( __stdcall *Con_IsVisible)(void); int ( __stdcall *GetLocalPlayer)(void); const model_t* ( __stdcall *LoadModel)(const char *pName, bool bProp); float ( __stdcall *Time)(void); float ( __stdcall *GetLastTimeStamp)(void); CSentence* ( __stdcall *GetSentence)(CAudioSource *pAudioSource); float ( __stdcall *GetSentenceLength)(CAudioSource *pAudioSource); bool ( __stdcall *IsStreaming)(CAudioSource *pAudioSource); void ( __stdcall *GetViewAngles)(QAngle& va); void ( __stdcall *SetViewAngles)(QAngle& va); int ( __stdcall *GetMaxClients)(void); void ( __stdcall *Key_Event)(int key, int down); const char* ( __stdcall *Key_LookupBinding)(const char *pBinding); void ( __stdcall *StartKeyTrapMode)(void); bool ( __stdcall *CheckDoneKeyTrapping)(int &buttons, int &key); bool ( __stdcall *IsInGame)(void); bool ( __stdcall *IsConnected)(void); bool ( __stdcall *IsDrawingLoadingImage)(void); void ( __cdecl *Con_NPrintf)(int pos, const char *fmt, ...); void ( __cdecl *Con_NXPrintf)(const struct con_nprint_s *info, const char *fmt, ...); int ( __stdcall *Cmd_Argc)(void); const char* ( __stdcall *Cmd_Argv)(int arg); int ( __stdcall *IsBoxVisible)(const Vector& mins, const Vector& maxs); int ( __stdcall *IsBoxInViewCluster)(const Vector& mins, const Vector& maxs); bool ( __stdcall *CullBox)(const Vector& mins, const Vector& maxs); void ( __stdcall *Sound_ExtraUpdate)(void); const char* ( __stdcall *GetGameDirectory)(void); const VMatrix& ( __stdcall *WorldToScreenMatrix)(); const VMatrix& ( __stdcall *WorldToViewMatrix)(); int ( __stdcall *GameLumpVersion)(int lumpId); int ( __stdcall *GameLumpSize)(int lumpId); bool ( __stdcall *LoadGameLump)(int lumpId, void* pBuffer, int size); int ( __stdcall *LevelLeafCount)(); ISpatialQuery* ( __stdcall *GetBSPTreeQuery)(); void ( __stdcall *LinearToGamma)(float* linear, float* gamma); float ( __stdcall *LightStyleValue)(int style); void ( __stdcall *ComputeDynamicLighting)(const Vector& pt, const Vector* pNormal, Vector& color); void ( __stdcall *GetAmbientLightColor)(Vector& color); int ( __stdcall *GetDXSupportLevel)(); bool ( __stdcall *SupportsHDR)(); void ( __stdcall *Mat_Stub)(IMaterialSystem *pMatSys); const char* ( __stdcall *GetLevelName)(void); struct IVoiceTweak_s* ( __stdcall *GetVoiceTweakAPI)( void ); void ( __stdcall *EngineStats_BeginFrame)( void ); void ( __stdcall *EngineStats_EndFrame)( void ); void ( __stdcall *FireEvents)(); int ( __stdcall *GetLeavesArea)(int *pLeaves, int nLeaves); bool ( __stdcall *DoesBoxTouchAreaFrustum)(const Vector &mins, const Vector &maxs, int iArea); void ( __stdcall *SetHearingOrigin)(const Vector &vecOrigin, const QAngle &angles); int ( __stdcall *SentenceGroupPick)( int groupIndex, char *name, int nameBufLen ); int ( __stdcall *SentenceGroupPickSequential)( int groupIndex, char *name, int nameBufLen, int sentenceIndex, int reset ); int ( __stdcall *SentenceIndexFromName)( const char *pSentenceName ); const char* ( __stdcall *SentenceNameFromIndex)( int sentenceIndex ); int ( __stdcall *SentenceGroupIndexFromName)( const char *pGroupName ); const char* ( __stdcall *SentenceGroupNameFromIndex)( int groupIndex ); float ( __stdcall *SentenceLength)( int sentenceIndex ); void ( __stdcall *ComputeLighting)( const Vector& pt, const Vector* pNormal, bool bClamp, Vector& color, Vector *pBoxColors); void ( __stdcall *ActivateOccluder)( int nOccluderIndex, bool bActive ); bool ( __stdcall *IsOccluded)( const Vector &vecAbsMins, const Vector &vecAbsMaxs ); void* ( __stdcall *SaveAllocMemory)( size_t num, size_t size ); void ( __stdcall *SaveFreeMemory)( void *pSaveMem ); INetChannelInfo* ( __stdcall *GetNetChannelInfo)( void ); void ( __stdcall *DebugDrawPhysCollide)( const CPhysCollide *pCollide, IMaterial *pMaterial, matrix3x4_t& transform, const color32 &color ); void ( __stdcall *CheckPoint)( const char *pName ); void ( __stdcall *DrawPortals)(); bool ( __stdcall *IsPlayingDemo)( void ); bool ( __stdcall *IsRecordingDemo)( void ); bool ( __stdcall *IsPlayingTimeDemo)( void ); bool ( __stdcall *IsPaused)( void ); bool ( __stdcall *IsTakingScreenshot)( void ); bool ( __stdcall *IsHLTV)( void ); bool ( __stdcall *IsLevelMainMenuBackground)( void ); void ( __stdcall *GetMainMenuBackgroundName)( char *dest, int destlen ); void ( __stdcall *SetOcclusionParameters)( const OcclusionParams_t ¶ms ); void ( __stdcall *GetUILanguage)( char *dest, int destlen ); bool ( __stdcall *IsSkyboxVisibleFromPoint)( const Vector &vecPoint ); const char* ( __stdcall *GetMapEntitiesString)(); bool ( __stdcall *IsInEditMode)( void ); float ( __stdcall *GetScreenAspectRatio)(); bool ( __stdcall *SteamRefreshLogin)( const char *password, bool isSecure ); bool ( __stdcall *SteamProcessCall)( bool & finished ); unsigned int ( __stdcall *GetEngineBuildNumber)(); const char* ( __stdcall *GetProductVersionString)(); int ( __stdcall *GetLastPressedEngineKey)( void ); }; #define PCMT client_textmessage_t* extern cl_engfuncs_s gHookedEngine; #endif #include "MaterialSystem.h" #include "cCvar.h" #include #include "hook.h" #include "cMapOverview.h" DWORD dwOld; #define MACRO_SETUP( x ) if(VirtualProtect((LPVOID)&g_pMaterialSystem->##x,4,PAGE_EXECUTE_READWRITE,&dwOld))g_pMaterialSystem->##x = &new_##x; cl_materialsystem_s gMaterialSystem; cl_materialsystem_s gHookedMaterialSystem; cl_materialsystem_s* g_pMaterialSystem; extern cMapLayer gMapLayer; extern bool g_bInitialized; void add_log (const char * fmt, ...); IMaterial* pFlashEffect = NULL; IMaterial* pSmokeEffect = NULL; IMaterial* pSmokeStack = NULL; IMaterial* pSmokeEffect1 = NULL; IMaterial* pFlashOverlay = NULL; IMaterial* pTeamKillOverlay = NULL; IMaterial* pTeamTerror = NULL; IMaterial* pTeamCounter = NULL; IMaterial* pTeamCounterOld = NULL; IMaterial* pLaserBeam = NULL; IMaterial* pScreenSmoke = NULL; IMaterial* pScopeArc = NULL; IMaterial* pScopeLens = NULL; /* IMaterial* pLaserBeam = NULL; */ void SetTexturesTransparent( void ); std::vector g_vecMapTextures; std::vector g_vecIntTextures; void ClearMapTextures() { g_vecMapTextures.clear(); g_vecIntTextures.clear(); pFlashEffect = NULL; pSmokeEffect = NULL; pSmokeStack = NULL; pSmokeEffect1 = NULL; pFlashOverlay = NULL; pTeamTerror = NULL; pTeamCounter = NULL; pTeamCounterOld = NULL; pLaserBeam = NULL; pScreenSmoke = NULL; // pTeamKillOverlay= NULL; pScopeArc = NULL; pScopeLens = NULL; } void SetTexturesSolid() { for (int i = 0;i < g_vecMapTextures.size();i++) g_vecMapTextures[i]->AlphaModulate( 1.0 ); } void SetSolidTexVisible( bool bVisible ) { if ( pTeamKillOverlay ) pTeamKillOverlay->SetMaterialVarFlag( MATERIAL_VAR_NO_DRAW , !bVisible ); } void RemoveObstacles( void ) { if ( g_bInitialized && gEngineFuncs.IsInGame() && gEngineFuncs.IsLevelMainMenuBackground() == false ) { if (pSmokeEffect && gCvars.smoke->GetBool()) { pSmokeEffect->AlphaModulate(0.0f); pSmokeEffect->ColorModulate(0.0,0.0,0.0); pSmokeEffect->SetMaterialVarFlag(MATERIAL_VAR_NO_DRAW,true); } if (pFlashOverlay && gCvars.antiflash->GetBool()) { pFlashOverlay->AlphaModulate(0.0f); pFlashOverlay->ColorModulate(0.0,0.0,0.0); pFlashOverlay->SetMaterialVarFlag(MATERIAL_VAR_NO_DRAW,true); } if (pFlashEffect && gCvars.antiflash->GetBool()) { pFlashEffect->AlphaModulate(0.0f); pFlashEffect->ColorModulate(0.0,0.0,0.0); pFlashEffect->SetMaterialVarFlag(MATERIAL_VAR_NO_DRAW,true); } if (pSmokeEffect1 && gCvars.smoke->GetBool()) { pSmokeEffect1->AlphaModulate(0.0f); pSmokeEffect1->ColorModulate(0.0,0.0,0.0); pSmokeEffect1->SetMaterialVarFlag(MATERIAL_VAR_NO_DRAW,true); } if (pSmokeStack && gCvars.smoke->GetBool()) { pSmokeStack->AlphaModulate(0.0f); pSmokeStack->ColorModulate(0.0,0.0,0.0); pSmokeStack->SetMaterialVarFlag(MATERIAL_VAR_NO_DRAW,true); } if (pScreenSmoke && gCvars.smoke->GetBool()) { pScreenSmoke->AlphaModulate(0.0f); pScreenSmoke->ColorModulate(0.0,0.0,0.0); pScreenSmoke->SetMaterialVarFlag(MATERIAL_VAR_NO_DRAW,true); } if ( pTeamTerror ) { if (gCvars.colormodels->GetBool()) { DWORD dwColor = gColorManager.dwGetTeamColor( 3 ); pTeamTerror->SetMaterialVarFlag( MATERIAL_VAR_HALFLAMBERT, true ); pTeamTerror->ColorModulate(gColorManager.GetRed(dwColor),gColorManager.GetGreen(dwColor),gColorManager.GetBlue(dwColor)); /* if ( gCvars.colormodels->GetInt() == 1 ) { bool bSuccess = false; IMaterialVar* pMatVar = pTeamTerror->FindVar("$baseTexture",bSuccess,false); if ( bSuccess ) pMatVar->SetTextureValue("red_additive"); } */ } // MATERIAL_VAR_HALFLAMBERT if (gCvars.modelhack->GetBool()) { pTeamTerror->SetMaterialVarFlag( MATERIAL_VAR_IGNOREZ, true ); pTeamTerror->SetMaterialVarFlag( MATERIAL_VAR_ZNEARER, true ); // pTeamTerror->SetMaterialVarFlag( MATERIAL_VAR_NOCULL, true ); } else { pTeamTerror->SetMaterialVarFlag( MATERIAL_VAR_IGNOREZ, false ); pTeamTerror->SetMaterialVarFlag( MATERIAL_VAR_ZNEARER, false ); // pTeamTerror->SetMaterialVarFlag( MATERIAL_VAR_NOCULL, false ); } } if ( pTeamCounterOld ) { if (gCvars.colormodels->GetBool()) { DWORD dwColor = gColorManager.dwGetTeamColor( 4 ); pTeamCounterOld->SetMaterialVarFlag( MATERIAL_VAR_HALFLAMBERT, true ); pTeamCounterOld->ColorModulate(gColorManager.GetRed(dwColor),gColorManager.GetGreen(dwColor),gColorManager.GetBlue(dwColor)); } // MATERIAL_VAR_HALFLAMBERT if (gCvars.modelhack->GetBool()) { pTeamCounterOld->SetMaterialVarFlag( MATERIAL_VAR_IGNOREZ, true ); pTeamCounterOld->SetMaterialVarFlag( MATERIAL_VAR_ZNEARER, true ); // pTeamCounterOld->SetMaterialVarFlag( MATERIAL_VAR_NOCULL, true ); } else { pTeamCounterOld->SetMaterialVarFlag( MATERIAL_VAR_IGNOREZ, false ); pTeamCounterOld->SetMaterialVarFlag( MATERIAL_VAR_ZNEARER, false ); // pTeamCounterOld->SetMaterialVarFlag( MATERIAL_VAR_NOCULL, false ); } } if ( pTeamCounter ) { if (gCvars.colormodels->GetBool()) { DWORD dwColor = gColorManager.dwGetTeamColor( 4 ); pTeamCounter->SetMaterialVarFlag( MATERIAL_VAR_HALFLAMBERT, true ); pTeamCounter->ColorModulate(gColorManager.GetRed(dwColor),gColorManager.GetGreen(dwColor),gColorManager.GetBlue(dwColor)); } // MATERIAL_VAR_HALFLAMBERT if (gCvars.modelhack->GetBool()) { pTeamCounter->SetMaterialVarFlag( MATERIAL_VAR_IGNOREZ, true ); pTeamCounter->SetMaterialVarFlag( MATERIAL_VAR_ZNEARER, true ); // pTeamCounter->SetMaterialVarFlag( MATERIAL_VAR_NOCULL, true ); } else { pTeamCounter->SetMaterialVarFlag( MATERIAL_VAR_IGNOREZ, false ); pTeamCounter->SetMaterialVarFlag( MATERIAL_VAR_ZNEARER, false ); // pTeamCounter->SetMaterialVarFlag( MATERIAL_VAR_NOCULL, false ); } } if ( gCvars.ovzoom ) gMapLayer.SetZoom ( gCvars.ovzoom->GetFloat() ); SetTexturesTransparent(); } } void SetTexturesTransparent() { if (gCvars.whmode->GetInt() == 2) { for (int i = 0;i < g_vecMapTextures.size();i++) { g_vecMapTextures[i]->AlphaModulate( gCvars.wallhack->GetFloat() ); // g_vecMapTextures[i]->SetMaterialVarFlag( MATERIAL_VAR_IGNOREZ, true ); // g_vecMapTextures[i]->SetMaterialVarFlag( MATERIAL_VAR_ZNEARER, true ); // g_vecMapTextures[i]->SetMaterialVarFlag( MATERIAL_VAR_NOCULL, true ); } } else { SetTexturesSolid(); if ( gCvars.whmode->GetInt() == 1 ) { for (int i = 0;i < g_vecIntTextures.size();i++) g_vecIntTextures[i]->AlphaModulate( gCvars.wallhack->GetFloat() ); } } } bool bIngame = false; IMaterial* __stdcall new_FindMaterial ( char const* pMaterialName, const char *pTextureGroupName, bool complain, const char *pComplainPrefix ) { IMaterial* pTemp = NULL; try { pTemp = gMaterialSystem.FindMaterial( pMaterialName, pTextureGroupName, complain, pComplainPrefix ); } catch (...) { return NULL; } _asm pushad; if (pMaterialName && pTextureGroupName && pTemp ) { if (gEngineFuncs.IsInGame()) { bIngame = true; if (!strcmp(pMaterialName,"vgui/white_additive")) pFlashOverlay = pTemp; else if (!strcmp(pMaterialName,"effects/flashbang")) pFlashEffect = pTemp; else if (!strcmp(pMaterialName,"particle/particle_smokegrenade1")) pSmokeEffect1 = pTemp; else if (!strcmp(pMaterialName,"particle/SmokeStack")) pSmokeStack = pTemp; else if ((!strcmp(pMaterialName,"particle/particle_smokegrenade")||!strcmp(pMaterialName,"particle/particle_smokegrenade1"))) pSmokeEffect = pTemp; else if ( strstr(pMaterialName,"vgui/white") ) pTeamKillOverlay = pTemp; } else { if(!strcmp(pTextureGroupName, "World textures"))//tetsushi forced me { if (bIngame) { ClearMapTextures(); bIngame = false; } g_vecMapTextures.push_back( pTemp ); if ( strstr(pMaterialName,"wood") || strstr(pMaterialName,"WOOD") || strstr(pMaterialName,"door") || strstr(pMaterialName,"DOOR") || strstr(pMaterialName,"gate") || strstr(pMaterialName,"GATE") || strstr(pMaterialName,"box") || strstr(pMaterialName,"BOX") ) g_vecIntTextures.push_back( pTemp ); } else if (!strcmp(pMaterialName,"models\\player\\terror\\TerrorTemp")) pTeamTerror = pTemp; else if (!strcmp(pMaterialName,"models\\player\\ct_urban\\ct_urban")) pTeamCounter = pTemp; else if (strstr(pMaterialName,"UrbanTemp")) pTeamCounterOld = pTemp; else if ( strstr(pMaterialName,"screenspace_fog") ) pScreenSmoke = pTemp; else if ( strstr(pMaterialName,"scope_arc") ) pScopeArc = pTemp; else if ( strstr(pMaterialName,"scope_lens") ) pScopeLens = pTemp; else if ( strstr(pMaterialName,"vgui/white") ) pTeamKillOverlay = pTemp; } } _asm popad; return pTemp; } void SetupNewMaterialSystem ( void ) { MACRO_SETUP( FindMaterial ); } materialsystem.h #ifndef _MATERIALSYSTEM_H_ #define _MATERIALSYSTEM_H_ #include #include "SDK.h" #include "materialsystem/itexture.h" struct cl_materialsystem_s { bool ( __stdcall *Connect)( CreateInterfaceFn factory ); void ( __stdcall *Disconnect)(); void* ( __stdcall *QueryInterface)( const char *pInterfaceName ); InitReturnVal_t ( __stdcall *Init)(); void ( __stdcall *Shutdown)(); void ( __stdcall *SetShaderAPI)( char const *pShaderAPIDLL ); void ( __stdcall *SetAdapter)( int nAdapter, int nFlags ); CreateInterfaceFn( __stdcall *Initx)( char const* pShaderAPIDLL,IMaterialProxyFactory *pMaterialProxyFactory,CreateInterfaceFn fileSystemFactory,CreateInterfaceFn cvarFactory ); IMaterialSystemHardwareConfig* ( __stdcall *GetHardwareConfig)( const char *pVersion, int *returnCode ); int ( __stdcall *GetDisplayAdapterCount)(); void ( __stdcall *GetDisplayAdapterInfo)( int adapter, MaterialAdapterInfo_t& info ); int ( __stdcall *GetModeCount)( int adapter ); void ( __stdcall *GetModeInfo)( int adapter, int mode, MaterialVideoMode_t& info ); void ( __stdcall *GetDisplayMode)( MaterialVideoMode_t& mode ); bool ( __stdcall *SetMode)( void* hwnd, const MaterialSystem_Config_t &config ); const MaterialSystemHardwareIdentifier_t& ( __stdcall *GetVideoCardIdentifier)( void ); bool ( __stdcall *AddView)( void* hwnd ); void ( __stdcall *RemoveView)( void* hwnd ); void ( __stdcall *SetView)( void* hwnd ); void ( __stdcall *Get3DDriverInfo)( Material3DDriverInfo_t& info ); bool ( __stdcall *UpdateConfig)( bool bForceUpdate ); const MaterialSystem_Config_t& ( __stdcall *GetCurrentConfigForVideoCard)(); bool ( __stdcall *OverrideConfig)( const MaterialSystem_Config_t &config, bool bForceUpdate ); MaterialHandle_t ( __stdcall *FirstMaterial)(); MaterialHandle_t ( __stdcall *NextMaterial)( MaterialHandle_t h ); MaterialHandle_t ( __stdcall *InvalidMaterial)(); IMaterial* ( __stdcall *GetMaterial)( MaterialHandle_t h ); IMaterial* ( __stdcall *FindMaterial)( char const* pMaterialName, const char *pTextureGroupName, bool complain, const char *pComplainPrefix ); ITexture* ( __stdcall *FindTexture)( char const* pTextureName, const char *pTextureGroupName, bool complain ); void ( __stdcall *BindLocalCubemap)( ITexture *pTexture ); void ( __stdcall *SetRenderTarget)( ITexture *pTexture ); ITexture* ( __stdcall *GetRenderTarget)( void ); void ( __stdcall *GetRenderTargetDimensions)( int &width, int &height); void ( __stdcall *GetBackBufferDimensions)( int &width, int &height); int ( __stdcall *GetNumMaterials)( ); void ( __stdcall *UncacheUnusedMaterials)( bool bRecomputeStateSnapshots ); void ( __stdcall *UncacheAllMaterials)( ); void ( __stdcall *CacheUsedMaterials)( ); void ( __stdcall *ReloadTextures)( ); void ( __stdcall *BeginLightmapAllocation)( ); int ( __stdcall *AllocateLightmap)( int width, int height, int offsetIntoLightmapPage[2],IMaterial *pMaterial ); int ( __stdcall *AllocateWhiteLightmap)( IMaterial *pMaterial ); void ( __stdcall *EndLightmapAllocation)( ); void ( __stdcall *UpdateLightmap)( int lightmapPageID, int lightmapSize[2],int offsetIntoLightmapPage[2], float *pFloatImage, float *pFloatImageBump1,float *pFloatImageBump2, float *pFloatImageBump3 ); void ( __stdcall *FlushLightmaps)( ); int ( __stdcall *GetNumSortIDs)( ); void ( __stdcall *GetSortInfo)( MaterialSystem_SortInfo_t *sortInfoArray ); void ( __stdcall *BeginFrame)( ); void ( __stdcall *EndFrame)( ); void ( __stdcall *Bind)( IMaterial *material, void *proxyData); void ( __stdcall *BindLightmapPage)( int lightmapPageID ); void ( __stdcall *DepthRange)( float zNear, float zFar ); void ( __stdcall *ClearBuffers)( bool bClearColor, bool bClearDepth, bool bClearStencil); void ( __stdcall *ReadPixels)( int x, int y, int width, int height, unsigned char *data, ImageFormat dstFormat ); void ( __stdcall *SetAmbientLight)( float r, float g, float b ); void ( __stdcall *SetLight)( int lightNum, LightDesc_t& desc ); void ( __stdcall *SetAmbientLightCube)( Vector4D cube[6] ); void ( __stdcall *CopyRenderTargetToTexture)( ITexture *pTexture ); void ( __stdcall *SetFrameBufferCopyTexture)( ITexture *pTexture, int textureIndex); ITexture* ( __stdcall *GetFrameBufferCopyTexture)( int textureIndex ); ImageFormat ( __stdcall *GetBackBufferFormat)(); void ( __stdcall *Flush)( bool flushHardware ); void ( __stdcall *DebugPrintUsedMaterials)( const char *pSearchSubString, bool bVerbose ); void ( __stdcall *DebugPrintUsedTextures)( void ); void ( __stdcall *ToggleSuppressMaterial)( char const* pMaterialName ); void ( __stdcall *ToggleDebugMaterial)( char const* pMaterialName ); void ( __stdcall *MatrixMode)( MaterialMatrixMode_t matrixMode ); void ( __stdcall *PushMatrix)( void ); void ( __stdcall *PopMatrix)( void ); void ( __stdcall *LoadMatrix)( VMatrix const& matrix ); void ( __stdcall *LoadMatrixx)( matrix3x4_t const& matrix ); void ( __stdcall *MultMatrix)( VMatrix const& matrix ); void ( __stdcall *MultMatrixx)( matrix3x4_t const& matrix ); void ( __stdcall *MultMatrixLocal)( VMatrix const& matrix ); void ( __stdcall *MultMatrixLocalx)( matrix3x4_t const& matrix ); void ( __stdcall *GetMatrix)( MaterialMatrixMode_t matrixMode, VMatrix *matrix ); void ( __stdcall *GetMatrixx)( MaterialMatrixMode_t matrixMode, matrix3x4_t *matrix ); void ( __stdcall *LoadIdentity)( void ); void ( __stdcall *Ortho)( double left, double top, double right, double bottom, double zNear, double zFar ); void ( __stdcall *PerspectiveX)( double fovx, double aspect, double zNear, double zFar ); void ( __stdcall *PickMatrix)( int x, int y, int width, int height ); void ( __stdcall *Rotate)( float angle, float x, float y, float z ); void ( __stdcall *Translate)( float x, float y, float z ); void ( __stdcall *Scale)( float x, float y, float z ); void ( __stdcall *Viewport)( int x, int y, int width, int height ); void ( __stdcall *GetViewport)( int& x, int& y, int& width, int& height ); void ( __stdcall *CullMode)( MaterialCullMode_t cullMode ); void ( __stdcall *SetHeightClipMode)( MaterialHeightClipMode_t nHeightClipMode ); void ( __stdcall *SetHeightClipZ)( float z ); void ( __stdcall *FogMode)( MaterialFogMode_t fogMode ); void ( __stdcall *FogStart)( float fStart ); void ( __stdcall *FogEnd)( float fEnd ); void ( __stdcall *SetFogZ)( float fogZ ); MaterialFogMode_t ( __stdcall *GetFogMode)( void ); void ( __stdcall *FogColor3f)( float r, float g, float b ); void ( __stdcall *FogColor3fv)( float const* rgb ); void ( __stdcall *FogColor3ub)( unsigned char r, unsigned char g, unsigned char b ); void ( __stdcall *FogColor3ubv)( unsigned char const* rgb ); void ( __stdcall *GetFogColor)( unsigned char *rgb ); void ( __stdcall *SetNumBoneWeights)( int numBones ); IMaterialProxyFactory* ( __stdcall *GetMaterialProxyFactory)(); void ( __stdcall *GetLightmapPageSize)( int lightmap, int *width, int *height ); void ( __stdcall *SwapBuffers)( ); void ( __stdcall *SpewDriverInfo)(); IMesh* ( __stdcall *CreateStaticMesh)( IMaterial* pMaterial, const char *pTextureBudgetGroup, bool bForceTempMesh ); IMesh* ( __stdcall *CreateStaticMeshx)( MaterialVertexFormat_t fmt, const char *pTextureBudgetGroup, bool bSoftwareVertexShader ); void ( __stdcall *DestroyStaticMesh)( IMesh* mesh ); IMesh* ( __stdcall *GetDynamicMesh)( bool buffered, IMesh* pVertexOverride,IMesh* pIndexOverride, IMaterial *pAutoBind); int ( __stdcall *SelectionMode)( bool selectionMode ); void ( __stdcall *SelectionBuffer)( unsigned int* pBuffer, int size ); void ( __stdcall *ClearSelectionNames)( ); void ( __stdcall *LoadSelectionName)( int name ); void ( __stdcall *PushSelectionName)( int name ); void ( __stdcall *PopSelectionName)(); void ( __stdcall *AddReleaseFunc)( MaterialBufferReleaseFunc_t func ); void ( __stdcall *RemoveReleaseFunc)( MaterialBufferReleaseFunc_t func ); void ( __stdcall *AddRestoreFunc)( MaterialBufferRestoreFunc_t func ); void ( __stdcall *RemoveRestoreFunc)( MaterialBufferRestoreFunc_t func ); void ( __stdcall *ReloadMaterials)( const char *pSubString ); void ( __stdcall *ResetMaterialLightmapPageInfo)(); void ( __stdcall *ClearColor3ub)( unsigned char r, unsigned char g, unsigned char b ); void ( __stdcall *ClearColor4ub)( unsigned char r, unsigned char g, unsigned char b, unsigned char a ); void ( __stdcall *SetInStubMode)( bool bInStubMode ); IMaterial* ( __stdcall *CreateMaterial)( const char *pMaterialName, KeyValues *pVMTKeyValues ); ITexture* ( __stdcall *CreateRenderTargetTexture)( int w, int h, RenderTargetSizeMode_t sizeMode,ImageFormat format, MaterialRenderTargetDepth_t depth); ITexture* ( __stdcall *CreateProceduralTexture)( const char *pTextureName, const char *pTextureGroupName,int w, int h, ImageFormat fmt, int nFlags ); void ( __stdcall *OverrideDepthEnable)( bool bEnable, bool bDepthEnable ); void ( __stdcall *DrawScreenSpaceQuad)( IMaterial* pMaterial ); void ( __stdcall *ReleaseTempTextureMemory)(); ITexture* ( __stdcall *CreateNamedRenderTargetTexture)( const char *pRTName, int w, int h, RenderTargetSizeMode_t sizeMode,ImageFormat format, MaterialRenderTargetDepth_t depth, bool bClampTexCoords, bool bAutoMipMap); void ( __stdcall *SyncToken)( const char *pToken ); float ( __stdcall *ComputePixelWidthOfSphere)( const Vector& origin, float flRadius ); OcclusionQueryObjectHandle_t ( __stdcall *CreateOcclusionQueryObject)( void ); void ( __stdcall *DestroyOcclusionQueryObject)( OcclusionQueryObjectHandle_t ); void ( __stdcall *BeginOcclusionQueryDrawing)( OcclusionQueryObjectHandle_t ); void ( __stdcall *EndOcclusionQueryDrawing)( OcclusionQueryObjectHandle_t ); int ( __stdcall *OcclusionQuery_GetNumPixelsRendered)( OcclusionQueryObjectHandle_t ); void ( __stdcall *SetFlashlightMode)( bool bEnable ); void ( __stdcall *SetFlashlightState)( const FlashlightState_t &state, const VMatrix &worldToTexture ); void ( __stdcall *SetModeChangeCallBack)( ModeChangeCallbackFunc_t func ); bool ( __stdcall *GetRecommendedConfigurationInfo)( int nDXLevel, KeyValues * pKeyValues ); MaterialHeightClipMode_t ( __stdcall *GetHeightClipMode)( ); float( __stdcall *ComputePixelDiameterOfSphere)( const Vector& vecAbsOrigin, float flRadius ); void ( __stdcall *EnableUserClipTransformOverride)( bool bEnable ); void ( __stdcall *UserClipTransform)( const VMatrix &worldToView ); void ( __stdcall *EvictManagedResources)(); void ( __stdcall *UNKOWN_1)(); void ( __stdcall *UNKOWN_2)(); void ( __stdcall *UNKOWN_3)(); void ( __stdcall *UNKOWN_4)(); void ( __stdcall *UNKOWN_5)(); void ( __stdcall *UNKOWN_6)(); void ( __stdcall *UNKOWN_7)(); }; extern cl_materialsystem_s gMaterialSystem; extern cl_materialsystem_s gHookedMaterialSystem; extern cl_materialsystem_s* g_pMaterialSystem; void SetupNewMaterialSystem( void ); #endif modinfoclient #include "modelInfoClient.h" #define MACRO_SETUP( x )\ gHookedModelInfoClient.##x = &new_##x; cl_ModelInfoClient_s gHookedModelInfoClient; cl_ModelInfoClient_s gModelInfoClient; int __stdcall new_GetModelSpriteWidth( const model_t *model ) { return gModelInfoClient.GetModelSpriteWidth( model ); } int __stdcall new_GetModelSpriteHeight( const model_t *model ) { return gModelInfoClient.GetModelSpriteHeight( model ); } unsigned char __stdcall new_ComputeLevelScreenFade( const Vector &vecAbsOrigin, float flRadius, float flFadeScale ) { return gModelInfoClient.ComputeLevelScreenFade( vecAbsOrigin, flRadius, flFadeScale ); } unsigned char __stdcall new_ComputeViewScreenFade( const Vector &vecAbsOrigin, float flRadius, float flFadeScale ) { return gModelInfoClient.ComputeViewScreenFade( vecAbsOrigin, flRadius, flFadeScale ); } void SetupNewModelInfoClient ( void ) { MACRO_SETUP(ComputeViewScreenFade); MACRO_SETUP(GetModelSpriteWidth); MACRO_SETUP(GetModelSpriteHeight); MACRO_SETUP(ComputeLevelScreenFade); } modinfoclient.h #ifndef _MODELINFOCLIENTS_H_ #define _MODELINFOCLIENTS_H_ #include #include "SDK.h" struct vcollide_t; struct studiohdr_t; struct virtualmodel_t; struct cl_ModelInfoClient_s { void (__stdcall *IVModelInfo)( void ); const model_t* (__stdcall *GetModel)( int modelindex ); int (__stdcall *GetModelIndex)( const char *name ); const char* (__stdcall *GetModelName)( const model_t *model ); vcollide_t* (__stdcall *GetVCollide)( const model_t *model ); vcollide_t* (__stdcall *GetVCollidex)( int modelindex );//because struct don't support member overloading void (__stdcall *GetModelBounds)( const model_t *model, Vector& mins, Vector& maxs ); void (__stdcall *GetModelRenderBounds)( const model_t *model, Vector& mins, Vector& maxs ); int (__stdcall *GetModelFrameCount)( const model_t *model ); int (__stdcall *GetModelType)( const model_t *model ); void* (__stdcall *GetModelExtraData)( const model_t *model ); bool (__stdcall *ModelHasMaterialProxy)( const model_t *model ); bool (__stdcall *IsTranslucent)( model_t const* model ); bool (__stdcall *IsTranslucentTwoPass)( const model_t *model ); void (__stdcall *RecomputeTranslucency)( const model_t *model ); int (__stdcall *GetModelMaterialCount)( const model_t* model ); void (__stdcall *GetModelMaterials)( const model_t *model, int count, IMaterial** ppMaterial ); bool (__stdcall *IsModelVertexLit)( const model_t *model ); const char* (__stdcall *GetModelKeyValueText)( const model_t *model ); float (__stdcall *GetModelRadius)( const model_t *model ); const studiohdr_t* (__stdcall *FindModel)( const studiohdr_t *pStudioHdr, void **cache, const char *modelname ); const studiohdr_t* (__stdcall *FindModelx)( void *cache ); virtualmodel_t* (__stdcall *GetVirtualModel)( const studiohdr_t *pStudioHdr ); byte* (__stdcall *GetAnimBlock)( const studiohdr_t *pStudioHdr, int iBlock ); void (__stdcall *GetModelMaterialColorAndLighting)( const model_t *model, Vector const& origin,QAngle const& angles, trace_t* pTrace, Vector& lighting, Vector& matColor ); void (__stdcall *GetIlluminationPoint)( const model_t *model, Vector const& origin, QAngle const& angles, Vector* pLightingCenter ); int (__stdcall *GetModelContents)( int modelIndex ); studiohdr_t* (__stdcall *GetStudiomodel)( const model_t *mod ); int (__stdcall *GetModelSpriteWidth)( const model_t *model ); int (__stdcall *GetModelSpriteHeight)( const model_t *model ); void (__stdcall *SetLevelScreenFadeRange)( float flMinSize, float flMaxSize ); void (__stdcall *GetLevelScreenFadeRange)( float *pMinArea, float *pMaxArea ); void (__stdcall *SetViewScreenFadeRange)( float flMinSize, float flMaxSize ); unsigned char (__stdcall *ComputeLevelScreenFade)( const Vector &vecAbsOrigin, float flRadius, float flFadeScale ); unsigned char (__stdcall *ComputeViewScreenFade)( const Vector &vecAbsOrigin, float flRadius, float flFadeScale ); }; extern cl_ModelInfoClient_s gHookedModelInfoClient; extern cl_ModelInfoClient_s gModelInfoClient; void SetupNewModelInfoClient ( void ); #endif modelrender.cpp #include "Engine.h" #include "ModelRender.h" #include "RenderView.h" #include "hook.h" #include "cCvar.h" //====================================================================================== cl_modelrendfuncs_s gModelRenderFuncs; cl_modelrendfuncs_s gHookedModelRender; extern renderview_s gOrgRenderView; //====================================================================================== #define MACRO_SETUP( x )\ gHookedModelRender.##x = &Hooked_##x; extern bool g_bDrawn; extern bool g_bInitialized; //====================================================================================== int __stdcall Hooked_DrawModel( int flags, IClientRenderable *cliententity, ModelInstanceHandle_t instance, int entity_index, const model_t *model, Vector const& origin, QAngle const& angles, int skin, int body, int hitboxset, const matrix3x4_t *modelToWorld, const matrix3x4_t *pLightingOffset ) { _asm pushad; const char* pszModelName = g_pModelinfo->GetModelName( model ); if (pszModelName && gCvars.whmode->GetInt() == 1 ) { if (!strstr(pszModelName,"models/weapons/") && !strstr(pszModelName,"models/player/")) { gOrgRenderView.SetBlend( gCvars.wallhack->GetFloat() ); } else { gOrgRenderView.SetBlend( 1.0f ); } } else { gOrgRenderView.SetBlend( 1.0f ); } _asm popad; return gModelRenderFuncs.DrawModel( flags, cliententity, instance, entity_index, model, origin, angles, skin, body, hitboxset, modelToWorld, pLightingOffset ); } //====================================================================================== void __stdcall Hooked_ForcedMaterialOverride( IMaterial *newMaterial ) { return gModelRenderFuncs.ForcedMaterialOverride( newMaterial ); } //====================================================================================== void __stdcall Hooked_SetViewTarget( const Vector& target ) { return gModelRenderFuncs.SetViewTarget( target ); } //====================================================================================== void __stdcall Hooked_SetFlexWeights( int numweights, const float *weights ) { return gModelRenderFuncs.SetFlexWeights( numweights, weights ); } //====================================================================================== void __stdcall Hooked_SetFlexWeightsX( int numweights, const float *weights, const float *delayedweights ) { return gModelRenderFuncs.SetFlexWeightsX( numweights, weights, delayedweights ); } //====================================================================================== matrix3x4_t* __stdcall Hooked_pBoneToWorld( int i ) { return gModelRenderFuncs.pBoneToWorld( i ); } //====================================================================================== matrix3x4_t* __stdcall Hooked_pBoneToWorldArray() { return gModelRenderFuncs.pBoneToWorldArray(); } //====================================================================================== ModelInstanceHandle_t __stdcall Hooked_CreateInstance( IClientRenderable *pRenderable, LightCacheHandle_t *pCache ) { return gModelRenderFuncs.CreateInstance( pRenderable, pCache ); } //====================================================================================== void __stdcall Hooked_DestroyInstance( ModelInstanceHandle_t handle ) { return gModelRenderFuncs.DestroyInstance( handle ); } //====================================================================================== void __stdcall Hooked_SetStaticLighting( ModelInstanceHandle_t handle, LightCacheHandle_t* pHandle ) { return gModelRenderFuncs.SetStaticLighting( handle, pHandle ); } //====================================================================================== LightCacheHandle_t __stdcall Hooked_GetStaticLighting( ModelInstanceHandle_t handle ) { return gModelRenderFuncs.GetStaticLighting( handle ); } //====================================================================================== bool __stdcall Hooked_ChangeInstance( ModelInstanceHandle_t handle, IClientRenderable *pRenderable ) { return gModelRenderFuncs.ChangeInstance( handle, pRenderable ); } //====================================================================================== void __stdcall Hooked_AddDecal( ModelInstanceHandle_t handle, Ray_t const& ray, Vector const& decalUp, int decalIndex, int body, bool noPokeThru, int maxLODToDecal ) { return gModelRenderFuncs.AddDecal( handle, ray, decalUp, decalIndex, body, noPokeThru, maxLODToDecal ); } //====================================================================================== void __stdcall Hooked_RemoveAllDecals( ModelInstanceHandle_t handle ) { return gModelRenderFuncs.RemoveAllDecals( handle ); } //====================================================================================== void __stdcall Hooked_RemoveAllDecalsFromAllModels() { return gModelRenderFuncs.RemoveAllDecalsFromAllModels(); } //====================================================================================== void __stdcall Hooked_DrawModelShadow( IClientRenderable *pRenderable, int body ) { return gModelRenderFuncs.DrawModelShadow( pRenderable, body ); } //====================================================================================== void __stdcall Hooked_RecomputeStaticLighting( ModelInstanceHandle_t handle ) { return gModelRenderFuncs.RecomputeStaticLighting( handle ); } //====================================================================================== void __stdcall Hooked_ReleaseAllStaticPropColorData( void ) { return gModelRenderFuncs.ReleaseAllStaticPropColorData(); } //====================================================================================== void __stdcall Hooked_RestoreAllStaticPropColorData( void ) { return gModelRenderFuncs.RestoreAllStaticPropColorData(); } //====================================================================================== void SetupModelRenderHooks() { MACRO_SETUP( DrawModel ); MACRO_SETUP( ForcedMaterialOverride ); MACRO_SETUP( SetViewTarget ); MACRO_SETUP( SetFlexWeights ); MACRO_SETUP( SetFlexWeightsX ); MACRO_SETUP( pBoneToWorld ); MACRO_SETUP( pBoneToWorldArray ); MACRO_SETUP( CreateInstance ); MACRO_SETUP( DestroyInstance ); MACRO_SETUP( SetStaticLighting ); MACRO_SETUP( GetStaticLighting ); MACRO_SETUP( ChangeInstance ); MACRO_SETUP( AddDecal ); MACRO_SETUP( RemoveAllDecals ); MACRO_SETUP( RemoveAllDecalsFromAllModels ); MACRO_SETUP( DrawModelShadow ); MACRO_SETUP( RecomputeStaticLighting ); MACRO_SETUP( ReleaseAllStaticPropColorData ); MACRO_SETUP( RestoreAllStaticPropColorData ); } //====================================================================================== modelrender.h #ifndef __MODELRENDER_H_ #define __MODELRENDER_H_ #include "SDK.h" //====================================================================================== struct cl_modelrendfuncs_s { int ( __stdcall *DrawModel ) ( int flags, IClientRenderable *cliententity, ModelInstanceHandle_t instance, int entity_index, const model_t *model, Vector const& origin, QAngle const& angles, int skin, int body, int hitboxset, const matrix3x4_t *modelToWorld, const matrix3x4_t *pLightingOffset ); void ( __stdcall *ForcedMaterialOverride) ( IMaterial *newMaterial ); void ( __stdcall *SetViewTarget) ( const Vector& target ); void ( __stdcall *SetFlexWeights) ( int numweights, const float *weights ); void ( __stdcall *SetFlexWeightsX) ( int numweights, const float *weights, const float *delayedweights ); matrix3x4_t* ( __stdcall *pBoneToWorld) (int i); matrix3x4_t* ( __stdcall *pBoneToWorldArray) (); ModelInstanceHandle_t ( __stdcall *CreateInstance) ( IClientRenderable *pRenderable, LightCacheHandle_t *pCache ); void ( __stdcall *DestroyInstance) ( ModelInstanceHandle_t handle ); void ( __stdcall *SetStaticLighting) ( ModelInstanceHandle_t handle, LightCacheHandle_t* pHandle ); LightCacheHandle_t ( __stdcall *GetStaticLighting) ( ModelInstanceHandle_t handle ); bool ( __stdcall *ChangeInstance) ( ModelInstanceHandle_t handle, IClientRenderable *pRenderable ); void ( __stdcall *AddDecal) ( ModelInstanceHandle_t handle, Ray_t const& ray, Vector const& decalUp, int decalIndex, int body, bool noPokeThru, int maxLODToDecal ); void ( __stdcall *RemoveAllDecals) ( ModelInstanceHandle_t handle ); void ( __stdcall *RemoveAllDecalsFromAllModels) (); void ( __stdcall *DrawModelShadow) ( IClientRenderable *pRenderable, int body ); void ( __stdcall *RecomputeStaticLighting) ( ModelInstanceHandle_t handle ); void ( __stdcall *ReleaseAllStaticPropColorData) ( void ); void ( __stdcall *RestoreAllStaticPropColorData) ( void ); }; //====================================================================================== extern cl_modelrendfuncs_s gModelRenderFuncs; extern cl_modelrendfuncs_s gHookedModelRender; #endif //====================================================================================== dllmain /* GAME-DECEPTION.COM Of course does this version still include a few bugs, and of course i doesn't contain everything you wanted, and i am sorry for that. But i've never aimed at making the best Counter-Strike Source Hack. All I ever wanted was to get the community started on CSS, and i think this version is enough to do so. I want to thank everyone who supported/ helped me making this hack. LTFX Guy, [XT]Tetsuo & Paleface/Pizzapan who always gave me the ideas, code and advice i needed. Diddle for his great support of the endusers and beta testing and Origin who supposedly found the most bugs ;). Sincerly Yours Patrick */ #include #include #include #include #include #include "hook.h" #include "cMenu.h" #define HACKPREFIX "hlh_" //#error Don't forget to credit Game-Deception! char g_szHome[256] = { 0 }; // removed the filename.filetype from the path void StripFileName( char* pszPath ) { int iLen = (int) strlen ( pszPath ); char * pos = pszPath + iLen; while( pos >= pszPath && *pos != '\\' ) --pos; *(char*)(pos+1) = 0; } // returns the directory where the hack is located at std::string szDirFile ( char* pszName ) { std::string szRet = g_szHome; return ( szRet + pszName ); } // executes script files void ReadSettings( char* lpszFile ) { const char* pszPath = gEngineFuncs.GetGameDirectory(); if ( !pszPath ) return; char szPath[1024] = { 0 }; std::string strPath = szDirFile( lpszFile ); sprintf ( szPath,"%s\\cfg\\%s",pszPath,lpszFile); CopyFile ( strPath.c_str(), szPath, FALSE ); gEngineFuncs.ClientCmd( "exec settings.cfg" ); // DeleteFile( szPath ); /* add_log(gEngineFuncs.GetGameDirectory()); std::string strPath = szDirFile( lpszFile ); std::ifstream ifs(strPath.c_str()); if(!ifs || !ifs.is_open()) return; char buf[1024] = { 0 }; while(ifs) { memset( (void*)buf, 0, sizeof ( char [1024] ) ); ifs.getline( buf, 1020 ); if(!ifs) break; if ( ( buf[0] == '/' && buf[1] == '/' ) || ( strlen(buf) < 2) ) continue; gEngineFuncs.ClientCmd( buf ); }*/ } BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) { switch(fdwReason) { case DLL_PROCESS_ATTACH: { GetModuleFileName( (HMODULE) hinstDLL , g_szHome , 256 ); StripFileName ( g_szHome ); LaunchThread(); if ( GetVersion() < 0x501 ) { add_log("HLH HAS DETECTED AN OLD WINDOWS VERSION"); add_log("HLH WILL ATTEMPT TO RUN AT THIS WINDOWS VERSION"); add_log("BUT FULL FUNCTIONALITY CAN'T BE GRANTED"); add_log("PLEASE INSTALL WINDOWS XP!"); } break; } case DLL_PROCESS_DETACH: { void UnHook ( void ); UnHook(); } default: break; } return TRUE; } void add_log (const char * fmt, ...) { va_list va_alist; char buf[256],logbuf[1024]; FILE* file; struct tm* current_tm; time_t current_time; time (¤t_time); current_tm = localtime (¤t_time); sprintf (logbuf, "%02d:%02d:%02d-> ", current_tm->tm_hour, current_tm->tm_min, current_tm->tm_sec); va_start(va_alist, fmt); vsprintf(buf, fmt, va_alist); va_end(va_alist); strcat(logbuf, buf); strcat(logbuf, "\n"); if((file = fopen( szDirFile("newhook.log").data(), "a+")) != NULL ) { fputs(logbuf,file); fclose(file); } } vpanels #include "vPanels.h" #include "cMenu.h" #include "cDrawing.h" #include "cFontManager.h" #include "cCvar.h" #include "cESP.h" #include "cAimbot.h" #include "string_t.h" #include #include #include #include #include #include "cDrawing.h" #include "cMirc.h" #include "cWinAmp.h" #include "public/cl_dll/hudelement.h" #include "cConsole.h" #define DLMODULATIONFACTOR 200 #define BOUND_VALUE(var,min,max) if((var)>(max)){(var)=(max);};if((var)<(min)){(var)=(min);} cAimbot gAimbot; extern bool g_bAlreadyDrawing; bool g_bDrawn = false; void SetSolidTexVisible( bool bVisible ); extern IMaterial* pScopeArc; extern IMaterial* pScopeLens; 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 ) { 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 ScreenSize_t sScreenSize;// struct to pass the screen-size gEngineFuncs.GetScreenSize( sScreenSize.m_iWidth, sScreenSize.m_iHeight ); SetSize( sScreenSize.m_iWidth, sScreenSize.m_iHeight ); gDraw.Initialize(); gFontManager.Initialize(); } //======================================================================================== // drawing goes here :o void drawclock() { char logbuf[30]= { 0 }; struct tm* current_tm; time_t current_time; time (¤t_time); current_tm = localtime (¤t_time); int iHour = current_tm->tm_hour; if (gCvars.clockstyle->GetBool()) { if (iHour > 12) { iHour -= 12; sprintf ( logbuf, "%02d:%02d:%02d PM", iHour, current_tm->tm_min, current_tm->tm_sec); } else { sprintf ( logbuf, "%02d:%02d:%02d AM", iHour, current_tm->tm_min, current_tm->tm_sec); } } else { sprintf ( logbuf, "%02d:%02d:%02d", iHour, current_tm->tm_min, current_tm->tm_sec); } gDraw.DrawString(gFontManager.GetHUDFont(),gCvars.clock_x->GetInt(),gCvars.clock_y->GetInt(),gColorManager.dwGetColorbyIndex( 9 ),logbuf); } void DrawAimSpots( C_BaseEntity* pMe, C_BaseEntity* pEnt ) { if ( gCvars.drawspots->GetBool() == false ) return; if ( gCvars.drawspots->GetInt() == 1 ) { // Combat character C_BaseCombatCharacter* pCombat = ToBaseCombatCharacter( pEnt ); if (!pCombat) return; // base animating C_BaseAnimating* pBaseAni = pCombat->GetBaseAnimating(); if (!pBaseAni) return; pBaseAni->DrawClientHitboxes( 255, true ); } } bool bHideSolid = false; void RemoveObstacles(); void cDrawPanel::Paint( void ) { RemoveObstacles(); SetSolidTexVisible( true ); // don't hide our hacks...!!111 if (!gEngineFuncs.IsInGame() || !g_bIsHooked) return; if (gCvars.clock->GetInt() == 1) { drawclock(); } if (gCvars.irc->GetBool()) { gMirc.Draw(); } else { gHLHConsole.Draw(); } gDraw.DrawHudMessage(); if ( gESPHelper.bPlanted && gCvars.bombtimer->GetBool() ) gDraw.DrawString(gFontManager.GetHUDFont(),50,gDraw.ScreenHeight() - (30 + gFontManager.iGetHUDHeight()),gColorManager.dwGetColorbyIndex( 15 ), gESPHelper.szGetBombString() ); gMenu.DrawMenu(); if ( gCvars.radar->GetInt() == 1) gESPHelper.DrawRadarBack(); if ( gCvars.soundesp->GetBool() ) gESPHelper.DrawSounds(); if ( gCvars.trackinfo->GetInt() == 1 || gCvars.trackinfo->GetInt() == 3 ) gWinAmp.DrawTrack(); switch(gCvars.cross->GetInt()) { case 1: gDraw.DrawRectangle((gDraw.ScreenWidth() / 2) - 25, gDraw.ScreenHeight() / 2, 50, 1, 255, 255, 255, 178); gDraw.DrawRectangle(gDraw.ScreenWidth() / 2, (gDraw.ScreenHeight() / 2) - 25, 1, 50, 255, 255, 255, 178); gDraw.DrawRectangle((gDraw.ScreenWidth() / 2) - 7, gDraw.ScreenHeight() / 2, 14, 1, 255, 0, 0, 178); gDraw.DrawRectangle(gDraw.ScreenWidth() / 2, (gDraw.ScreenHeight() / 2) - 7, 1, 14, 255, 0, 0, 178); break; case 2: gDraw.DrawRectangle(gDraw.ScreenWidth() / 2 - 14, (gDraw.ScreenHeight() / 2), 9, 1, 255, 0, 0, 178); gDraw.DrawRectangle(gDraw.ScreenWidth() / 2 +5, (gDraw.ScreenHeight() / 2), 9, 1, 255, 0, 0, 178); gDraw.DrawRectangle(gDraw.ScreenWidth() / 2, (gDraw.ScreenHeight() / 2) - 14, 1, 9, 255, 0, 0, 178); gDraw.DrawRectangle(gDraw.ScreenWidth() / 2, (gDraw.ScreenHeight() / 2) + 5, 1, 9, 255, 0, 0, 178); gDraw.DrawRectangle(gDraw.ScreenWidth() / 2, (gDraw.ScreenHeight() / 2) , 1, 1, 255, 0, 0, 178); break; case 3: gDraw.DrawRectangle(gDraw.ScreenWidth() / 2 - 14, (gDraw.ScreenHeight() / 2), 9,2, 255, 0, 0, 178); gDraw.DrawRectangle(gDraw.ScreenWidth() / 2 +6, (gDraw.ScreenHeight() / 2), 9,2, 255, 0, 0, 178); gDraw.DrawRectangle(gDraw.ScreenWidth() / 2, (gDraw.ScreenHeight() / 2) - 14, 2,9, 255, 0, 0, 178); gDraw.DrawRectangle(gDraw.ScreenWidth() / 2, (gDraw.ScreenHeight() / 2) + 7, 2,9, 255, 0, 0, 178); gDraw.DrawRectangle(gDraw.ScreenWidth() / 2, (gDraw.ScreenHeight() / 2) , 2,2, 255, 0, 0, 178); break; } // get out local index so we can skip the local entity int iLocalIndex = gEngineFuncs.GetLocalPlayer(); // get the highest index so we know when to stop int iLastEntity = g_pEntList->GetHighestEntityIndex(); // storage for the screen coordinates Vector vecScreen,vecScreenOrg; // zero is the map and below 0 is out of bounds if (iLocalIndex <= 0 || iLastEntity <= 0) return; if (g_pEntList->GetClientEntity(iLocalIndex) == NULL) return; C_BaseEntity* pLocalBaseEnt = g_pEntList->GetClientEntity(iLocalIndex)->GetBaseEntity(); IClientEntity* pPlayer = NULL; C_BasePlayer* pLocalBasePlayer= NULL; C_BaseEntity* pBaseEntity = NULL; C_BasePlayer* pBasePlayer = NULL; pLocalBasePlayer = ToBasePlayer( pLocalBaseEnt ); if (pLocalBasePlayer == NULL) return; // storage for entity names char szNewName[50] = { 0 }; if (pLocalBaseEnt == NULL) return; pBasePlayer = ToBasePlayer( pLocalBaseEnt ); if ( pBasePlayer ) { if ( gCvars.textspam->GetInt() == 2 ) { pBasePlayer->m_Local.m_iHideHUD |= HIDEHUD_CHAT; } else { pBasePlayer->m_Local.m_iHideHUD &= ~HIDEHUD_CHAT; } } if ( pBasePlayer && gCvars.blackout->GetBool() ) { if ( pBasePlayer->m_Local.m_iFOV && pBasePlayer->m_Local.m_iFOV != 90 && gAimbot.bAbletoAttack()) { if ( gCvars.cross->GetBool() == false ) { gDraw.DrawRectangle((gDraw.ScreenWidth() / 2) - 25, gDraw.ScreenHeight() / 2, 50, 1, 255, 255, 255, 178); gDraw.DrawRectangle(gDraw.ScreenWidth() / 2, (gDraw.ScreenHeight() / 2) - 25, 1, 50, 255, 255, 255, 178); gDraw.DrawRectangle((gDraw.ScreenWidth() / 2) - 7, gDraw.ScreenHeight() / 2, 14, 1, 255, 0, 0, 178); gDraw.DrawRectangle(gDraw.ScreenWidth() / 2, (gDraw.ScreenHeight() / 2) - 7, 1, 14, 255, 0, 0, 178); } bHideSolid = true; if( pScopeArc ) pScopeArc->SetMaterialVarFlag( MATERIAL_VAR_NO_DRAW, true ); if( pScopeLens ) pScopeLens->SetMaterialVarFlag( MATERIAL_VAR_NO_DRAW, true ); } else { bHideSolid = false; if( pScopeArc ) pScopeArc->SetMaterialVarFlag( MATERIAL_VAR_NO_DRAW, false ); if( pScopeLens ) pScopeLens->SetMaterialVarFlag( MATERIAL_VAR_NO_DRAW, false ); } } g_bDrawn = true; player_info_t Playerinfo; int iTargetIndex = gAimbot.iGetTarget(); gAimbot.DropTarget(); g_bAlreadyDrawing = true; for(int iCurrentEnt = 0; iCurrentEnt < iLastEntity; iCurrentEnt++) { if (iCurrentEnt == iLocalIndex) continue; // entity is not a player or there is not player info if (!gEngineFuncs.GetPlayerInfo(iCurrentEnt,&Playerinfo)) continue; gESPHelper.AddName( Playerinfo.name ); pPlayer = g_pEntList->GetClientEntity(iCurrentEnt); if (pPlayer == NULL) continue; pBaseEntity = pPlayer->GetBaseEntity(); if(pBaseEntity == NULL) continue; if(pBaseEntity->IsDormant()) continue; if ( gCvars.drawspots->GetBool() ) gAimbot.DrawVecs( pBaseEntity, pLocalBaseEnt ); if(pBaseEntity->IsSolid() && pBaseEntity->IsPlayer()) { gAimbot.CheckTarget( pBaseEntity, pLocalBaseEnt, Playerinfo ); Vector vecOrigin = pBaseEntity->GetAbsOrigin(); if(!(pBaseEntity->GetFlags() & FL_DUCKING)) // Tetsuo owns ;) vecOrigin[2] += 45; else vecOrigin[2] += 25; if ( gCvars.radar->GetInt() == 1 ) gESPHelper.DrawRadarPoint( pBaseEntity->GetAbsOrigin(), pLocalBaseEnt->GetAbsOrigin() , pLocalBaseEnt->GetAbsAngles(),pPlayer->GetBaseEntity()->GetTeamNumber() ); if ( gDraw.bWorldToScreen(vecOrigin,vecScreenOrg) ) { vecOrigin[2] += gCvars.espheight->GetFloat() * 5.0f; if (!gDraw.bWorldToScreen(vecOrigin,vecScreen)) { continue; } // DrawAimSpots( pLocalBaseEnt, pBaseEntity ); DWORD dwColor = gColorManager.dwGetTeamColor(pPlayer->GetBaseEntity()->GetTeamNumber()); int iTeam = pPlayer->GetBaseEntity()->GetTeamNumber(); if (gCvars.colortarget->GetBool() && iTargetIndex == iCurrentEnt) { dwColor = gColorManager.dwGetColorbyIndex(14); iTeam = 14; } if (gCvars.visualisation->GetInt() == 1) { float flDistance = gESPHelper.flGetDistance( pLocalBaseEnt->GetAbsOrigin(), pBaseEntity->GetAbsOrigin()) / 22.0f; int boxradius = (300.0*90.0) / (flDistance * 90.0); BOUND_VALUE(boxradius,1,200); gDraw.DrawBox( vecScreenOrg.x, vecScreenOrg.y, dwColor, boxradius); } else if (gCvars.visualisation->GetInt() >= 2) { g_pDraw->DrawColoredCircle ( vecScreenOrg.x, vecScreenOrg.y, 10,gColorManager.GetRed(dwColor),gColorManager.GetGreen(dwColor),gColorManager.GetBlue(dwColor),gColorManager.GetAlpha(dwColor)); } if (gCvars.name->GetBool() == true) { wchar_t playerName[ 64 ]; surface()->DrawSetTextFont( gFontManager.GetESPFont() ); vgui::localize()->ConvertANSIToUnicode( Playerinfo.name, playerName, sizeof( playerName ) ); int wide, tall; vgui::surface()->GetTextSize( gFontManager.GetESPFont(), playerName, wide, tall ); vgui::surface()->DrawSetTextColor( gColorManager.GetRed( dwColor ), gColorManager.GetGreen( dwColor ), gColorManager.GetBlue( dwColor ), gColorManager.GetAlpha( dwColor ) ); vgui::surface()->DrawSetTextPos( vecScreen.x-(wide/2), vecScreen.y ); vgui::surface()->DrawPrintText( playerName, wcslen( playerName) ); // gESPHelper.DrawNames( vecScreen.x, vecScreen.y, Playerinfo.name, dwColor ); vecScreen.y += gFontManager.iGetESPHeight(); } if (gCvars.health->GetInt() == 1) { gDraw.DrawEntityString( vecScreen.x, vecScreen.y, iTeam, "[ %i ]",pBaseEntity->GetHealth() ); vecScreen.y += gFontManager.iGetESPHeight(); } else if (gCvars.health->GetInt() == 2) { gDraw.DrawHealth( vecScreen.x, vecScreen.y, pBaseEntity->GetHealth() ); vecScreen.y += gFontManager.iGetESPHeight()/2; } else if (gCvars.health->GetInt() == 3) { gDraw.DrawHealthBar( vecScreen.x, vecScreen.y, pBaseEntity->GetHealth() ); vecScreen.y += gFontManager.iGetESPHeight()/2; } if ( gCvars.weapon->GetBool() == true ) { if ( gCvars.weapon->GetInt() == 2) { CHudTexture* pTexture = gESPHelper.pGetWeaponSprite( pBaseEntity ); if ( pTexture ) { Color color; color.SetColor( gColorManager.GetRed(dwColor), gColorManager.GetGreen(dwColor), gColorManager.GetBlue(dwColor), gColorManager.GetAlpha(dwColor) ); // pTexture->DrawSelfCropped ( vecScreen.x - gFontManager.iGetESPHeight()/2, vecScreen.y, 0, 0, gFontManager.iGetESPHeight() ,gFontManager.iGetESPHeight() ,color ); pTexture->DrawSelf ( vecScreen.x - gFontManager.iGetESPHeight()*2, vecScreen.y - gFontManager.iGetESPHeight()/2,gFontManager.iGetESPHeight() ,gFontManager.iGetESPHeight() ,color ); vecScreen.y += gFontManager.iGetESPHeight(); } } else { char* szWeaponName = gESPHelper.pszGetWeapon( pBaseEntity ); if ( szWeaponName ) { gDraw.DrawEntityString( vecScreen.x, vecScreen.y, iTeam, "%s", szWeaponName ); vecScreen.y += gFontManager.iGetESPHeight()/2; } } } if (gCvars.distance->GetBool() == true) { gDraw.DrawEntityString( vecScreen.x, vecScreen.y, iTeam, "[ %.0f ]",gESPHelper.flGetDistance( pLocalBaseEnt->GetAbsOrigin(), pBaseEntity->GetAbsOrigin() ) ); vecScreen.y += gFontManager.iGetESPHeight(); } if (gCvars.infoesp->GetBool() == true) { char szInfo[20] = { 0 }; if (gESPHelper.bGetSequence(pBaseEntity,szInfo)) { gDraw.DrawEntityString( vecScreen.x, vecScreen.y, iTeam, "%s",szInfo ); vecScreen.y += gFontManager.iGetESPHeight(); } } } } else { Vector vecOrigin = pBaseEntity->GetAbsOrigin(); if( gDraw.bWorldToScreen(vecOrigin,vecScreen) ) { gDraw.DrawEntityString( vecScreen.x, vecScreen.y, pPlayer->GetBaseEntity()->GetTeamNumber(), "[ Dead - %s ]",Playerinfo.name ); } } } gAimbot.CalcAngles(); iLastEntity = g_pEntList->GetMaxEntities(); for(int iCurrentEnt = 0; iCurrentEnt < iLastEntity && gCvars.entity->GetBool(); iCurrentEnt++) { pPlayer = g_pEntList->GetClientEntity(iCurrentEnt); if (!pPlayer) continue; pBaseEntity = pPlayer->GetBaseEntity(); if ( !pBaseEntity ) continue; if( pBaseEntity->IsDormant() || pBaseEntity->IsPlayer()) continue; const char* lpName = g_pModelinfo->GetModelName( pBaseEntity->GetModel() ); if (!lpName) continue; if(!gESPHelper.bGetModelName(lpName,szNewName)) { continue; } if (gCvars.radar->GetInt() == 1 && pLocalBaseEnt) { if ( strstr(szNewName,"c4") ) gESPHelper.DrawRadarPoint( pPlayer->GetAbsOrigin(), pLocalBaseEnt->GetAbsOrigin() , pLocalBaseEnt->GetAbsAngles(), 0); } if ( !strstr(szNewName,"c4") && !strstr(szNewName,"hostage") ) { if ( pBaseEntity->IsSolid() == false ) continue; } if( gDraw.bWorldToScreen(pPlayer->GetAbsOrigin(),vecScreen) ) gDraw.DrawEntityString( vecScreen.x, vecScreen.y, 0 ,szNewName ); } SetSolidTexVisible(!bHideSolid); } string_t C_BaseEntity::GetModelName( void ) const { return m_ModelName; } int CBaseCombatCharacter::WeaponCount() const { return MAX_WEAPONS; } vpanels.h /* This is an example Implementation of public Tetsuo's vPanel Example * * So i don't really deserve any credit here and all the credit belongs to Xen and Tetsuo. */ #ifndef _VPANELS_H_ #define _VPANELS_H_ #include #include "SDK.h" #include "hook.h" // this defines our local panel where are all the drawing happens class cDrawPanel : public vgui::Panel { typedef vgui::Panel BaseClass; public: cDrawPanel( vgui::VPANEL parent ); // constructor virtual void Paint(); // callback method (called by the engine) }; // gate class to our draw-panel class cDrawLayer { private: cDrawPanel* pDrawPanel; // pointer to the draw-panel public: cDrawLayer ( void ); // constructor ~cDrawLayer ( void ); // destructor void Create ( vgui::VPANEL parent ); // method which creates our draw-panel void Destroy( void ); // method which removes our draw-panel on demand }; #endif worldrender #include "Engine.h" #include "WorldRender.h" #include "hook.h" //====================================================================================== cl_worldrendfuncs_s gWorldRenderFuncs; cl_worldrendfuncs_s gHookedWorldRender; //====================================================================================== #define MACRO_SETUP( x )\ gHookedWorldRender.##x = &Hooked_##x; //====================================================================================== void __stdcall Hooked_DrawBrushModel( IClientEntity *baseentity, model_t *model, const Vector& origin, const QAngle& angles, bool sort ) { return gWorldRenderFuncs.DrawBrushModel( baseentity, model, origin, angles, sort ); } //====================================================================================== void __stdcall Hooked_DrawIdentityBrushModel( model_t *model ) { return gWorldRenderFuncs.DrawIdentityBrushModel( model ); } //====================================================================================== void __stdcall Hooked_TouchLight( struct dlight_t *light ) { return gWorldRenderFuncs.TouchLight( light ); } //====================================================================================== void __stdcall Hooked_Draw3DDebugOverlays( void ) { // return gWorldRenderFuncs.Draw3DDebugOverlays(); } //====================================================================================== void __stdcall Hooked_SetBlend( float blend ) { return gWorldRenderFuncs.SetBlend( blend ); } //====================================================================================== float __stdcall Hooked_GetBlend( void ) { return gWorldRenderFuncs.GetBlend(); } //====================================================================================== void __stdcall Hooked_SetColorModulation( float const* blend ) { return gWorldRenderFuncs.SetColorModulation( blend ); } //====================================================================================== void __stdcall Hooked_GetColorModulation( float* blend ) { gWorldRenderFuncs.GetColorModulation( blend ); } //====================================================================================== void __stdcall Hooked_SceneBegin( void ) { return gWorldRenderFuncs.SceneBegin(); } //====================================================================================== void __stdcall Hooked_SceneEnd( void ) { return gWorldRenderFuncs.SceneEnd(); } //====================================================================================== void __stdcall Hooked_GetVisibleFogVolume( const Vector& eyePoint, VisibleFogVolumeInfo_t *pInfo ) { return gWorldRenderFuncs.GetVisibleFogVolume( eyePoint, pInfo ); } //====================================================================================== void __stdcall Hooked_BuildWorldLists( WorldListInfo_t* pInfo, bool updateLightmaps, int iForceViewLeaf ) { return gWorldRenderFuncs.BuildWorldLists( pInfo, updateLightmaps, iForceViewLeaf ); } //====================================================================================== void __stdcall Hooked_DrawWorldLists( unsigned long flags, float waterZAdjust ) { return gWorldRenderFuncs.DrawWorldLists( flags, waterZAdjust ); } //====================================================================================== void __stdcall Hooked_DrawTopView( bool enable ) { return gWorldRenderFuncs.DrawTopView( enable ); } //====================================================================================== void __stdcall Hooked_TopViewBounds( Vector2D const& mins, Vector2D const& maxs ) { return gWorldRenderFuncs.TopViewBounds( mins, maxs ); } //====================================================================================== void __stdcall Hooked_DrawLights( void ) { return gWorldRenderFuncs.DrawLights(); } //====================================================================================== void __stdcall Hooked_DrawMaskEntities( void ) { return gWorldRenderFuncs.DrawMaskEntities(); } //====================================================================================== void __stdcall Hooked_DrawTranslucentSurfaces( int sortIndex, unsigned long flags ) { return gWorldRenderFuncs.DrawTranslucentSurfaces( sortIndex, flags ); } //====================================================================================== void __stdcall Hooked_DrawLineFile( void ) { return gWorldRenderFuncs.DrawLineFile(); } //====================================================================================== void __stdcall Hooked_DrawLightmaps( void ) { return gWorldRenderFuncs.DrawLightmaps(); } //====================================================================================== void __stdcall Hooked_ViewSetupVis( bool novis, int numorigins, const Vector origin[] ) { return gWorldRenderFuncs.ViewSetupVis( novis, numorigins, origin ); } //====================================================================================== bool __stdcall Hooked_AreAnyLeavesVisible( int *leafList, int nLeaves ) { return gWorldRenderFuncs.AreAnyLeavesVisible( leafList, nLeaves ); } //====================================================================================== void __stdcall Hooked_ViewSetup3D( const CViewSetup *view, Frustum frustumPlanes ) { return gWorldRenderFuncs.ViewSetup3D( view, frustumPlanes ); } //====================================================================================== void __stdcall Hooked_ViewSetup2D( const CViewSetup *view ) { return gWorldRenderFuncs.ViewSetup2D( view ); } //====================================================================================== void __stdcall Hooked_VguiPaint( void ) { return gWorldRenderFuncs.VguiPaint(); } //====================================================================================== void __stdcall Hooked_ViewDrawFade( byte *color, IMaterial *pMaterial ) { return gWorldRenderFuncs.ViewDrawFade( color, pMaterial ); } //====================================================================================== void __stdcall Hooked_SetProjectionMatrix( float fov, float zNear, float zFar ) { return gWorldRenderFuncs.SetProjectionMatrix( fov, zNear, zFar ); } //====================================================================================== colorVec __stdcall Hooked_GetLightAtPoint( Vector& pos ) { colorVec cvReturn; cvReturn.a = 0x00; cvReturn.r = 0x00; cvReturn.g = 0x00; cvReturn.b = 0x00; return cvReturn; return gWorldRenderFuncs.GetLightAtPoint( pos ); } //====================================================================================== int __stdcall Hooked_GetViewEntity( void ) { return gWorldRenderFuncs.GetViewEntity(); } //====================================================================================== float __stdcall Hooked_GetFieldOfView( void ) { return gWorldRenderFuncs.GetFieldOfView(); } //====================================================================================== unsigned char** __stdcall Hooked_GetAreaBits( void ) { return gWorldRenderFuncs.GetAreaBits(); } //====================================================================================== void __stdcall Hooked_SetFogVolumeState( int nVisibleFogVolume, bool bUseHeightFog ) { return gWorldRenderFuncs.SetFogVolumeState( nVisibleFogVolume, bUseHeightFog ); } //====================================================================================== void __stdcall Hooked_InstallBrushSurfaceRenderer( IBrushRenderer* pBrushRenderer ) { return gWorldRenderFuncs.InstallBrushSurfaceRenderer( pBrushRenderer ) ; } //====================================================================================== void __stdcall Hooked_DrawBrushModelShadow( IClientRenderable *pRenderable ) { return gWorldRenderFuncs.DrawBrushModelShadow( pRenderable ); } //====================================================================================== bool __stdcall Hooked_LeafContainsTranslucentSurfaces( int sortIndex, unsigned long flags ) { return gWorldRenderFuncs.LeafContainsTranslucentSurfaces( sortIndex, flags ); } //====================================================================================== bool __stdcall Hooked_DoesBoxIntersectWaterVolume( const Vector &mins, const Vector &maxs, int leafWaterDataID ) { return gWorldRenderFuncs.DoesBoxIntersectWaterVolume( mins, maxs, leafWaterDataID ); } //====================================================================================== void SetupWorldRenderHooks() { MACRO_SETUP( DrawBrushModel ); MACRO_SETUP( DrawIdentityBrushModel ); MACRO_SETUP( TouchLight ); MACRO_SETUP( Draw3DDebugOverlays ); MACRO_SETUP( SetBlend ); MACRO_SETUP( GetBlend ); MACRO_SETUP( SetColorModulation ); MACRO_SETUP( GetColorModulation ); MACRO_SETUP( SceneBegin ); MACRO_SETUP( SceneEnd ); MACRO_SETUP( GetVisibleFogVolume ); MACRO_SETUP( BuildWorldLists ); MACRO_SETUP( DrawWorldLists ); MACRO_SETUP( DrawTopView ); MACRO_SETUP( TopViewBounds ); MACRO_SETUP( DrawLights ); MACRO_SETUP( DrawMaskEntities ); MACRO_SETUP( DrawTranslucentSurfaces ); MACRO_SETUP( DrawLineFile ); MACRO_SETUP( DrawLightmaps ); MACRO_SETUP( ViewSetupVis ); MACRO_SETUP( AreAnyLeavesVisible ); MACRO_SETUP( ViewSetup3D ); MACRO_SETUP( ViewSetup2D ); MACRO_SETUP( VguiPaint ); MACRO_SETUP( ViewDrawFade ); MACRO_SETUP( SetProjectionMatrix ); MACRO_SETUP( GetLightAtPoint ); MACRO_SETUP( GetViewEntity ); MACRO_SETUP( GetFieldOfView ); MACRO_SETUP( GetAreaBits ); MACRO_SETUP( SetFogVolumeState ); MACRO_SETUP( InstallBrushSurfaceRenderer ); MACRO_SETUP( DrawBrushModelShadow ); MACRO_SETUP( LeafContainsTranslucentSurfaces ); MACRO_SETUP( DoesBoxIntersectWaterVolume ); } //====================================================================================== worldrender.h #ifndef __WORLDRENDER_H_ #define __WORLDRENDER_H_ #include #include "SDK.h" //====================================================================================== struct cl_worldrendfuncs_s { void ( __stdcall *DrawBrushModel) ( IClientEntity *baseentity, model_t *model, const Vector& origin, const QAngle& angles, bool sort ); void ( __stdcall *DrawIdentityBrushModel) ( model_t *model ); void ( __stdcall *TouchLight) ( struct dlight_t *light ); void ( __stdcall *Draw3DDebugOverlays) ( void ); void ( __stdcall *SetBlend) ( float blend ); float ( __stdcall *GetBlend) ( void ); void ( __stdcall *SetColorModulation) ( float const* blend ); void ( __stdcall *GetColorModulation) ( float* blend ); void ( __stdcall *SceneBegin) ( void ); void ( __stdcall *SceneEnd) ( void ); void ( __stdcall *GetVisibleFogVolume) ( const Vector& eyePoint, VisibleFogVolumeInfo_t *pInfo ); void ( __stdcall *BuildWorldLists) ( WorldListInfo_t* pInfo, bool updateLightmaps, int iForceViewLeaf ); void ( __stdcall *DrawWorldLists) ( unsigned long flags, float waterZAdjust ); void ( __stdcall *DrawTopView) ( bool enable ); void ( __stdcall *TopViewBounds) ( Vector2D const& mins, Vector2D const& maxs ); void ( __stdcall *DrawLights) ( void ); void ( __stdcall *DrawMaskEntities) ( void ); void ( __stdcall *DrawTranslucentSurfaces) ( int sortIndex, unsigned long flags ); void ( __stdcall *DrawLineFile) ( void ); void ( __stdcall *DrawLightmaps) ( void ); void ( __stdcall *ViewSetupVis) ( bool novis, int numorigins, const Vector origin[] ); bool ( __stdcall *AreAnyLeavesVisible) ( int *leafList, int nLeaves ); void ( __stdcall *ViewSetup3D) ( const CViewSetup *view, Frustum frustumPlanes ); void ( __stdcall *ViewSetup2D) ( const CViewSetup *view ); void ( __stdcall *VguiPaint) ( void ); void ( __stdcall *ViewDrawFade) ( byte *color, IMaterial *pMaterial ); void ( __stdcall *SetProjectionMatrix) ( float fov, float zNear, float zFar ); colorVec ( __stdcall *GetLightAtPoint) ( Vector& pos ); int ( __stdcall *GetViewEntity) ( void ); float ( __stdcall *GetFieldOfView) ( void ); unsigned char** ( __stdcall *GetAreaBits) ( void ); void ( __stdcall *SetFogVolumeState) ( int nVisibleFogVolume, bool bUseHeightFog ); void ( __stdcall *InstallBrushSurfaceRenderer) ( IBrushRenderer* pBrushRenderer ); void ( __stdcall *DrawBrushModelShadow) ( IClientRenderable *pRenderable ); bool ( __stdcall *LeafContainsTranslucentSurfaces) ( int sortIndex, unsigned long flags ); bool ( __stdcall *DoesBoxIntersectWaterVolume) ( const Vector &mins, const Vector &maxs, int leafWaterDataID ); }; //====================================================================================== extern cl_worldrendfuncs_s gWorldRenderFuncs; extern cl_worldrendfuncs_s gHookedWorldRender; void SetupWorldRenderHooks( void ); #endif //====================================================================================== #ifndef _SDK_H_ #define _SDK_H_ #define CLIENT_DLL #pragma warning( disable : 4311 ) #pragma warning( disable : 4312 ) #pragma warning( disable : 4541 ) #pragma warning( disable : 4267 ) #pragma warning( disable : 4183 ) #include "public/cdll_int.h" #include "public/cl_dll/imessagechars.h" #include "public/cl_dll/iclientmode.h" #include "public/cl_dll/cliententitylist.h" #include "public/cl_dll/cdll_client_int.h" #include "public/cl_dll/cbase.h" #include "public/cl_dll/sdk/c_sdk_player.h" #include "public/cl_dll/c_baseanimating.h" #include "public/cl_dll/ivieweffects.h" #include "public/cl_dll/c_basecombatweapon.h" #include "public/cl_dll/c_baseplayer.h" #include "public/icliententitylist.h" #include "public/engine/ivmodelrender.h" #include "public/iefx.h" #include "public/icvar.h" #include "public/ivrenderview.h" #include "public/engine/ivdebugoverlay.h" #include "public/materialsystem/imaterialsystemstub.h" #include "public/engine/IVEngineCache.h" #include "public/engine/ivmodelinfo.h" #include "public/ienginevgui.h" #include "public/networkstringtabledefs.h" #include "public/ispatialpartition.h" #include "public/engine/ishadowmgr.h" #include "public/engine/IStaticPropMgr.h" #include "public/engine/IEngineSound.h" #include "public/vstdlib/random.h" #include "public/VGuiMatSurface/IMatSystemSurface.h" #include "public/vgui/Cursor.h" #include "public/vgui/Dar.h" #include "public/vgui/IBorder.h" #include "public/vgui/IClientPanel.h" #include "public/vgui/IPanel.h" #include "vgui_controls/controls.h" #include "vgui/ISurface.h" #include "vgui_controls/Panel.h" #include "public/engine/IEngineTrace.h" #include "public/IGameUIFuncs.h" #include "public/igameevents.h" #include "public/VGuiMatSurface/IMatSystemSurface.h" #include "public/input.h" #include "public/game_shared/usermessages.h" #include "public/vgui/IInputInternal.h" #include "public/vgui_controls/Frame.h" #include "public/vgui_controls/CheckButton.h" #include "public/vgui_controls/ComboBox.h" #include "public/vgui_controls/Button.h" #include "public/vgui_controls/Controls.h" #include "public/vgui_controls/DialogManager.h" #include "public/vgui_controls/RadioButton.h" #include "public/vgui_controls/Menu.h" #include "public/cl_dll/game_controls/commandmenu.h" #include "public/tier1/convar.h" #include "public/game_shared/basecombatweapon_shared.h" #include "public/game_shared/takedamageinfo.h" #include "public/vphysics_interface.h" #include "public/shake.h" #include "public/dlight.h" #include "public/iefx.h" #include "public/igameevents.h" #include "public/materialsystem/IMaterialVar.h" #include "public/vgui/ILocalize.h" #define IN_ATTACK (1 << 0) #define IN_JUMP (1 << 1) #define IN_DUCK (1 << 2) #define IN_FORWARD (1 << 3) #define IN_BACK (1 << 4) #define IN_USE (1 << 5) #define IN_CANCEL (1 << 6) #define IN_LEFT (1 << 7) #define IN_RIGHT (1 << 8) #define IN_MOVELEFT (1 << 9) #define IN_MOVERIGHT (1 << 10) #define IN_ATTACK2 (1 << 11) #define IN_RUN (1 << 12) #define IN_RELOAD (1 << 13) #define IN_ALT1 (1 << 14) #define IN_ALT2 (1 << 15) #define IN_SCORE (1 << 16) // Used by client.dll for when scoreboard is held down #define IN_SPEED (1 << 17) // Player is holding the speed key #define IN_WALK (1 << 18) // Player holding walk key #define IN_ZOOM (1 << 19) // Zoom key for HUD zoom #define IN_WEAPON1 (1 << 20) // weapon defines these bits #define IN_WEAPON2 (1 << 21) // weapon defines these bits #define IN_BULLRUSH (1 << 22) #define HIDEHUD_WEAPONSELECTION ( 1<<0 ) // Hide ammo count & weapon selection #define HIDEHUD_FLASHLIGHT ( 1<<1 ) #define HIDEHUD_ALL ( 1<<2 ) #define HIDEHUD_HEALTH ( 1<<3 ) // Hide health & armor / suit battery #define HIDEHUD_PLAYERDEAD ( 1<<4 ) // Hide when local player's dead #define HIDEHUD_NEEDSUIT ( 1<<5 ) // Hide when the local player doesn't have the HEV suit #define HIDEHUD_MISCSTATUS ( 1<<6 ) // Hide miscellaneous status elements (trains, pickup history, death notices, etc) #define HIDEHUD_CHAT ( 1<<7 ) // Hide all communication elements (saytext, voice icon, etc) #define HIDEHUD_CROSSHAIR ( 1<<8 ) // Hide crosshairs #define HIDEHUD_VEHICLE_CROSSHAIR ( 1<<9 ) // Hide vehicle crosshair #define HIDEHUD_INVEHICLE ( 1<<10 ) #define HIDEHUD_SCOPE ( 1<<11 ) #pragma comment ( lib, "tier0.lib" ) #pragma comment ( lib, "vstdlib.lib" ) #pragma comment ( lib, "vgui_surfacelib.lib" ) #pragma comment ( lib, "unitlib.lib" ) #pragma comment ( lib, "vgui_controls.lib" ) #pragma comment ( lib, "nvtc.lib" ) #pragma comment ( lib, "vtf.lib" ) #pragma comment ( lib, "unitlib.lib" ) #pragma comment ( lib, "nvtristrip.lib" ) #pragma comment ( lib, "appframework.lib" ) #pragma comment ( lib, "vmpi.lib" ) // #pragma pointers_to_members( full_generality, virtual_inheritance ) // #pragma check_stack( off ) #define MakePtr(Type, Base, Offset) ((Type)(DWORD(Base) + (DWORD)(Offset))) // Y0da #endif