-
Автор темы
- #1
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Здhавствуйтеб все вот фикс trace to exit lw
Код:
void TraceLine(Vector& absStart, const Vector& absEnd, unsigned int mask, player_t* ignore, CGameTrace* ptr)
{
Ray_t ray;
ray.Init(absStart, absEnd);
CTraceFilter filter;
filter.pSkip = ignore;
m_trace()->TraceRay(ray, mask, &filter, ptr);
}
bool autowall::trace_to_exit(CGameTrace& enterTrace, CGameTrace& exitTrace, Vector startPosition, const Vector& direction)
{
static ConVar* sv_clip_penetration_traces_to_players = m_cvar()->FindVar(crypt_str("sv_clip_penetration_traces_to_players"));
Vector new_end, out;
float dist = 0.0f;
int iterations = 23;
int first_contents = 0;
int contents;
Ray_t r{};
while (1)
{
iterations--;
if (iterations <= 0 || dist > 90.f)
break;
dist += 4.0f;
out = startPosition + (direction * dist);
contents = m_trace()->GetPointContents(out, 0x4600400B, nullptr);
if (first_contents == -1)
first_contents = contents;
if (contents & 0x600400B && (!(contents & CONTENTS_HITBOX) || first_contents == contents))
continue;
new_end = out - (direction * 4.f);
TraceLine(out, new_end, 0x4600400B, nullptr, &exitTrace);
if (exitTrace.startsolid && (exitTrace.surface.flags & SURF_HITBOX) != 0)
{
TraceLine(out, startPosition, MASK_SHOT_HULL, (player_t*)exitTrace.hit_entity, &exitTrace);
if (exitTrace.DidHit() && !exitTrace.startsolid)
{
out = exitTrace.endpos;
return true;
}
continue;
}
if (!exitTrace.DidHit() || exitTrace.startsolid)
{
if (enterTrace.hit_entity != m_entitylist()->GetClientEntity(0))
{
if (exitTrace.hit_entity && is_breakable_entity(exitTrace.hit_entity))
{
exitTrace.surface.surfaceProps = enterTrace.surface.surfaceProps;
exitTrace.endpos = startPosition + direction;
return true;
}
}
continue;
}
if ((exitTrace.surface.flags & 0x80u) != 0)
{
if (enterTrace.hit_entity && is_breakable_entity(enterTrace.hit_entity) && exitTrace.hit_entity && is_breakable_entity(exitTrace.hit_entity))
{
out = exitTrace.endpos;
return true;
}
if (!(enterTrace.surface.flags & 0x80u))
continue;
}
if (exitTrace.plane.normal.Dot(direction) <= 1.f)
{
out -= direction * (exitTrace.fraction * 4.0f);
return true;
}
}
return false;
}