-
Автор темы
- #1
крутой autowall для крутого чита для крутой игры
CanHit() - пример использования
point - target hitbox vector
damage_given: кол-во урона которое должен нанести выстрел
CanHit() - пример использования
point - target hitbox vector
damage_given: кол-во урона которое должен нанести выстрел
C++:
struct FireBulletData
{
FireBulletData( const Vector &eye_pos )
: src( eye_pos )
{
}
Vector src;
trace_t enter_trace;
Vector direction;
tracefilter_t filter;
float trace_length;
float trace_length_remaining;
float current_damage;
int penetrate_count;
};
void ScaleDamage( int hitgroup, C_CSPlayer *enemy, float weapon_armor_ratio, float ¤t_damage )
{
current_damage *= GetHitgroupDamageMult( hitgroup );
if( enemy->m_ArmorValue() > 0 )
{
if( hitgroup == HITGROUP_HEAD )
{
if( enemy->m_bHasHelmet() )
current_damage *= ( weapon_armor_ratio * .5f );
}
else
{
current_damage *= ( weapon_armor_ratio * .5f );
}
}
}
bool SimulateFireBullet( C_CSPlayer *local, C_WeaponCSBase *weapon, FireBulletData &data )
{
data.penetrate_count = 4;
data.trace_length = 0.0f;
auto *wpn_data = weapon->GetCSWpnData();
data.current_damage = (float)wpn_data->damage();
while( ( data.penetrate_count > 0 ) && ( data.current_damage >= 1.0f ) )
{
data.trace_length_remaining = wpn_data->range() - data.trace_length;
Vector end = data.src + data.direction * data.trace_length_remaining;
TraceLine( data.src, end, 0x4600400B, local, &data.enter_trace );
UTIL_ClipTraceToPlayers( data.src, end + data.direction * 40.f, 0x4600400B, &data.filter, &data.enter_trace );
if( data.enter_trace.fraction == 1.0f )
break;
if( ( data.enter_trace.hitgroup <= 7 )
&& ( data.enter_trace.hitgroup > 0 )
&& ( config.rage.target_friendly_fire || AreEnemies( local, data.enter_trace.m_pEnt ) )
&& ( DoesRayTouchHitbox( end, &data ) ) )
{
data.trace_length += data.enter_trace.fraction * data.trace_length_remaining;
data.current_damage *= pow( wpn_data->range_modifier(), data.trace_length * 0.002 );
ScaleDamage( data.enter_trace.hitgroup, data.enter_trace.m_pEnt, wpn_data->armor_ratio(), data.current_damage );
return true;
}
if( !config.rage.aim_auto_wall )
break;
if( !HandleBulletPenetration( wpn_data, data ) )
break;
}
return false;
}
bool TraceToExit( Vector &end, trace_t *enter_trace, Vector start, Vector dir, trace_t *exit_trace )
{
float distance = 0.0f;
while( distance <= 90.0f )
{
distance += 4.0f;
end = start + dir * distance;
auto point_contents = csgo()->enginetrace->GetPointContents( end, MASK_SHOT_HULL | CONTENTS_HITBOX, NULL );
if( point_contents & MASK_SHOT_HULL && ( !( point_contents & CONTENTS_HITBOX ) ) )
continue;
auto new_end = end - ( dir * 4.0f );
TraceLine( end, new_end, 0x4600400B, 0, exit_trace );
if( exit_trace->startsolid && exit_trace->surface.flags & SURF_HITBOX )
{
TraceLine( end, start, 0x600400B, exit_trace->m_pEnt, exit_trace );
if( ( exit_trace->fraction < 1.0f || exit_trace->allsolid ) && !exit_trace->startsolid )
{
end = exit_trace->endpos;
return true;
}
continue;
}
if( !( exit_trace->fraction < 1.0 || exit_trace->allsolid || exit_trace->startsolid ) || exit_trace->startsolid )
{
if( exit_trace->m_pEnt )
{
if( enter_trace->DidHitNonWorldEntity() && csgo()->IsBreakableEntity( enter_trace->m_pEnt ) )
return true;
}
continue;
}
if( ( ( exit_trace->surface.flags >> 7 ) & 1 ) && !( ( enter_trace->surface.flags >> 7 ) & 1 ) )
continue;
if( exit_trace->plane.normal.Dot( dir ) <= 1.0f )
{
auto fraction = exit_trace->fraction * 4.0f;
end = end - ( dir * fraction );
return true;
}
}
return false;
}
bool HandleBulletPenetration( CCSWeaponInfo *wpn_data, FireBulletData &data )
{
surfacedata_t *enter_surface_data = csgo()->physprops->GetSurfaceData( data.enter_trace.surface.surfaceProps );
int enter_material = enter_surface_data->game.material;
float enter_surf_penetration_mod = enter_surface_data->game.penetration_modifier;
data.trace_length += data.enter_trace.fraction * data.trace_length_remaining;
data.current_damage *= pow( wpn_data->range_modifier(), ( data.trace_length * 0.002 ) );
if( ( data.trace_length > 3000.f ) || ( enter_surf_penetration_mod < 0.1f ) )
data.penetrate_count = 0;
if( data.penetrate_count <= 0 )
return false;
Vector dummy;
trace_t trace_exit;
if( !TraceToExit( dummy, &data.enter_trace, data.enter_trace.endpos, data.direction, &trace_exit ) )
return false;
surfacedata_t *exit_surface_data = csgo()->physprops->GetSurfaceData( trace_exit.surface.surfaceProps );
int exit_material = exit_surface_data->game.material;
float exit_surf_penetration_mod = exit_surface_data->game.penetration_modifier;
float final_damage_modifier = 0.16f;
float combined_penetration_modifier = 0.0f;
if( ( ( data.enter_trace.contents & CONTENTS_GRATE ) != 0 ) || ( enter_material == 89 ) || ( enter_material == 71 ) )
{
combined_penetration_modifier = 3.0f;
final_damage_modifier = 0.05f;
}
else
{
combined_penetration_modifier = ( enter_surf_penetration_mod + exit_surf_penetration_mod ) * 0.5f;
}
if( enter_material == exit_material )
{
if( exit_material == 87 || exit_material == 85 )
combined_penetration_modifier = 3.0f;
else if( exit_material == 76 )
combined_penetration_modifier = 2.0f;
}
float v34 = fmaxf( 0.f, 1.0f / combined_penetration_modifier );
float v35 = ( data.current_damage * final_damage_modifier ) + v34 * 3.0f * fmaxf( 0.0f, ( 3.0f / wpn_data->penetration() ) * 1.25f );
float thickness = VectorLength( trace_exit.endpos - data.enter_trace.endpos );
thickness *= thickness;
thickness *= v34;
thickness /= 24.0f;
float lost_damage = fmaxf( 0.0f, v35 + thickness );
if( lost_damage > data.current_damage )
return false;
if( lost_damage >= 0.0f )
data.current_damage -= lost_damage;
if( data.current_damage < 1.0f )
return false;
data.src = trace_exit.endpos;
data.penetrate_count--;
return true;
}
bool aimbot::CanHit( const Vector &point, float *damage_given )
{
auto *local = LocalPlayer();
auto data = FireBulletData( local->EyePosition() );
data.filter = tracefilter_t( local );
QAngle angles;
CalcAngle( data.src, point, angles );
AngleVectors( angles, &data.direction );
VectorNormalize( data.direction );
if( SimulateFireBullet( local, local->GetActiveWeapon(), data ) )
{
*damage_given = data.current_damage;
return true;
}
return false;
}