STR
18-01-08, 08:15
#include "sdk.h"
cAimHelper::cAimHelper()
{
vPlayer.Init(0,0,0);
vFinal.Init(0,0,0);
iTarget = -1;
}
bool cAimHelper::CheckPlayerVisibility( C_BaseEntity* pBaseEntity )
{
//improve me
ray.Init( Me.BaseEnt()->EyePosition(), vPlayer );
m_pEnginetrace->TraceRay( ray ,MASK_ALL, 0, &tr );
if ( tr.fraction > 0.97 )
return true;
else
return false;
}
bool cAimHelper::GetHitBox( C_BaseEntity* pBaseEntity )
{
//improve me.
matrix3x4_t pmatrix[MAXSTUDIOBONES];
studiohdr_t *studeo_hedah = m_pModelinfo->GetStudiomodel((model_t*)pBaseEntity->GetModel());
if(!pBaseEntity->SetupBones( pmatrix, MAXSTUDIOBONES, BONE_USED_BY_HITBOX, m_pGlobals->curtime ))
return false;
for(int iNumHitBoxSets = 0; iNumHitBoxSets < studeo_hedah->numhitboxsets;iNumHitBoxSets++)
{
for(int iHitboxCount = 0; iHitboxCount < studeo_hedah->iHitboxCount(iNumHitBoxSets); iHitboxCount++)
{
mstudiobbox_t* Area = studeo_hedah->pHitbox(iHitboxCount, iNumHitBoxSets);
if(Area->bone == RawrICopyPaste)
{
VectorTransform(Area->bbmin, pmatrix[ Area->bone ], vMin);
VectorTransform(Area->bbmax, pmatrix[ Area->bone ], vMax);
vPlayer = (vMin + vMax) * 0.5f;
}
}
}
return true;
}
void cAimHelper::AdjustVectors()
{
Vector vDeltaOrigin = Vector(
cvars.proofens_adjust_x.flGetValue(),
cvars.proofens_adjust_y.flGetValue(),
cvars.proofens_adjust_z.flGetValue()
);
VectorCopy( vPlayer + vDeltaOrigin, vFinal );
//add some kind of ping corrections etc here
}
bool cAimHelper::CheckAll( C_BaseEntity* pBaseEntity )
{
if( !m_pEngine->GetPlayerInfo( pBaseEntity->index , &m_pPlayerInfo ))
return false;
if( !gESP.IsAlive( pBaseEntity ) )
return false;
if( pBaseEntity->GetTeamNumber() == Me.BaseEnt()->GetTeamNumber() )
return false;
if( !GetHitBox( pBaseEntity ))
return false;
if( !CheckPlayerVisibility( pBaseEntity ))
return false;
if( hMaths.FOV( Me.BaseEnt()->GetAbsAngles(), Me.BaseEnt()->EyePosition(), vPlayer ) > cvars.proofens_fov.iGetValue() )
return false;
iTarget = pBaseEntity->index;
AdjustVectors();
return true;
}
void cAimHelper::SetAngle( CUserCmd* pUserCmd )
{
iTarget = -1;
for( int index = 1; index < m_pEntList->GetHighestEntityIndex(); ++index )
{
if ( index == m_pEngine->GetLocalPlayer() ) continue;
IClientEntity* ClientEntity = m_pEntList->GetClientEntity( index );
if ( ClientEntity == NULL||ClientEntity->IsDormant() ) continue;
CBaseEntity* pBaseEntity = ClientEntity->GetBaseEntity();
if ( CheckAll( pBaseEntity ) )
continue;
}
if( iTarget < 1)
return;
hMaths.CalcAngle( Me.BaseEnt()->EyePosition(), vFinal, pUserCmd->viewangles );
m_pEngine->SetViewAngles( pUserCmd->viewangles );
if( cvars.proofens_autoshoot.iGetValue() == 1 )
m_pInput->MouseEvent( 1, true );
}
class cAimHelper
{
public:
cAimHelper();
bool CheckPlayerVisibility( C_BaseEntity* pBaseEntity );
void AdjustVectors();
bool GetHitBox( C_BaseEntity* pBaseEntity );
bool CheckAll( C_BaseEntity* pBaseEntity );
void SetAngle( CUserCmd* cmd );
int iTarget;
Vector vPlayer,vFinal,vMin,vMax;
trace_t tr;
Ray_t ray;
player_info_t m_pPlayerInfo;
};
cAimHelper::cAimHelper()
{
vPlayer.Init(0,0,0);
vFinal.Init(0,0,0);
iTarget = -1;
}
bool cAimHelper::CheckPlayerVisibility( C_BaseEntity* pBaseEntity )
{
//improve me
ray.Init( Me.BaseEnt()->EyePosition(), vPlayer );
m_pEnginetrace->TraceRay( ray ,MASK_ALL, 0, &tr );
if ( tr.fraction > 0.97 )
return true;
else
return false;
}
bool cAimHelper::GetHitBox( C_BaseEntity* pBaseEntity )
{
//improve me.
matrix3x4_t pmatrix[MAXSTUDIOBONES];
studiohdr_t *studeo_hedah = m_pModelinfo->GetStudiomodel((model_t*)pBaseEntity->GetModel());
if(!pBaseEntity->SetupBones( pmatrix, MAXSTUDIOBONES, BONE_USED_BY_HITBOX, m_pGlobals->curtime ))
return false;
for(int iNumHitBoxSets = 0; iNumHitBoxSets < studeo_hedah->numhitboxsets;iNumHitBoxSets++)
{
for(int iHitboxCount = 0; iHitboxCount < studeo_hedah->iHitboxCount(iNumHitBoxSets); iHitboxCount++)
{
mstudiobbox_t* Area = studeo_hedah->pHitbox(iHitboxCount, iNumHitBoxSets);
if(Area->bone == RawrICopyPaste)
{
VectorTransform(Area->bbmin, pmatrix[ Area->bone ], vMin);
VectorTransform(Area->bbmax, pmatrix[ Area->bone ], vMax);
vPlayer = (vMin + vMax) * 0.5f;
}
}
}
return true;
}
void cAimHelper::AdjustVectors()
{
Vector vDeltaOrigin = Vector(
cvars.proofens_adjust_x.flGetValue(),
cvars.proofens_adjust_y.flGetValue(),
cvars.proofens_adjust_z.flGetValue()
);
VectorCopy( vPlayer + vDeltaOrigin, vFinal );
//add some kind of ping corrections etc here
}
bool cAimHelper::CheckAll( C_BaseEntity* pBaseEntity )
{
if( !m_pEngine->GetPlayerInfo( pBaseEntity->index , &m_pPlayerInfo ))
return false;
if( !gESP.IsAlive( pBaseEntity ) )
return false;
if( pBaseEntity->GetTeamNumber() == Me.BaseEnt()->GetTeamNumber() )
return false;
if( !GetHitBox( pBaseEntity ))
return false;
if( !CheckPlayerVisibility( pBaseEntity ))
return false;
if( hMaths.FOV( Me.BaseEnt()->GetAbsAngles(), Me.BaseEnt()->EyePosition(), vPlayer ) > cvars.proofens_fov.iGetValue() )
return false;
iTarget = pBaseEntity->index;
AdjustVectors();
return true;
}
void cAimHelper::SetAngle( CUserCmd* pUserCmd )
{
iTarget = -1;
for( int index = 1; index < m_pEntList->GetHighestEntityIndex(); ++index )
{
if ( index == m_pEngine->GetLocalPlayer() ) continue;
IClientEntity* ClientEntity = m_pEntList->GetClientEntity( index );
if ( ClientEntity == NULL||ClientEntity->IsDormant() ) continue;
CBaseEntity* pBaseEntity = ClientEntity->GetBaseEntity();
if ( CheckAll( pBaseEntity ) )
continue;
}
if( iTarget < 1)
return;
hMaths.CalcAngle( Me.BaseEnt()->EyePosition(), vFinal, pUserCmd->viewangles );
m_pEngine->SetViewAngles( pUserCmd->viewangles );
if( cvars.proofens_autoshoot.iGetValue() == 1 )
m_pInput->MouseEvent( 1, true );
}
class cAimHelper
{
public:
cAimHelper();
bool CheckPlayerVisibility( C_BaseEntity* pBaseEntity );
void AdjustVectors();
bool GetHitBox( C_BaseEntity* pBaseEntity );
bool CheckAll( C_BaseEntity* pBaseEntity );
void SetAngle( CUserCmd* cmd );
int iTarget;
Vector vPlayer,vFinal,vMin,vMax;
trace_t tr;
Ray_t ray;
player_info_t m_pPlayerInfo;
};