-
Автор темы
- #1
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
winning
*i did not test this*
*i did not test this*
C++:
bool Autowall::ClipTraceToPlayers( Vector* start, Vector* end, CGameTrace* tr, C_BaseEntity* entity, float fr )
{
if ( fr < 0.f )
fr = tr->fraction;
Vector delta = *end - *start;
AngleNormalize( delta );
Vector mins_plus_maxs = entity->GetCollideable( )->OBBMins( ) + entity->GetCollideable( )->OBBMaxs( );
Vector divided_by_2 = mins_plus_maxs * 0.5f;
Vector origin_hitbox = entity->m_vecOrigin( ) + divided_by_2;
Vector _start = *start;
float distance = ( ( ( origin_hitbox.z - start->y ) * delta.y ) + ( ( origin_hitbox.x - start->x ) * delta.x ) ) + ( ( origin_hitbox.y - start->z ) * delta.z );
float length = 0.f;
if ( distance >= 0.f )
{
if ( distance <= 0.f )
{
length = sqrt( ( ( ( origin_hitbox.x - ( ( delta.x * distance ) + _start.x ) ) * ( origin_hitbox.x - ( ( delta.x * distance ) + _start.x ) ) ) + ( ( origin_hitbox.z - ( ( delta.y * distance ) + _start.y ) ) * ( origin_hitbox.z - ( ( delta.y * distance ) + _start.y ) ) ) ) + ( ( origin_hitbox.y - ( ( delta.z * distance ) + _start.z ) ) * ( origin_hitbox.y - ( ( delta.z * distance ) + _start.z ) ) ) );
}
else
{
length = -sqrt( ( ( ( origin_hitbox.z - end->y ) * ( origin_hitbox.z - end->y ) ) + ( ( origin_hitbox.x - end->x ) * ( origin_hitbox.x - end->x ) ) ) + ( ( origin_hitbox.y - end->z ) * ( origin_hitbox.y - end->z ) ) );
}
}
else
{
length = -sqrt( ( ( origin_hitbox.z - _start.y * origin_hitbox.z - _start.y ) + ( ( origin_hitbox.x - _start.x ) * ( origin_hitbox.x - _start.x ) ) ) + ( ( origin_hitbox.y - _start.z ) * ( origin_hitbox.y - _start.z ) ) );
}
if ( length <= 60.0f )
{
trace_t out_tr;
Ray_t r{ };
r.Init( *start, *end );
g_EngineTrace->ClipRayToEntity( r, 0x4600400B, entity, &out_tr );
if ( fr > out_tr.fraction )
memcpy( tr, &out_tr, sizeof( CGameTrace ) );
}
}