-
Автор темы
- #1
C++:
int side_trace = 0;
void DetectSide(player_t* player)
{
Vector src3D, dst3D, forward, right, up, src, dst;
float back_two, right_two, left_two;
trace_t tr;
Ray_t ray, ray2, ray3, ray4, ray5;
CTraceFilter filter;
math::angle_vectors(Vector(0, GetBackwardYaw(player), 0), &forward, &right, &up);
src3D = player->GetEyePosition();
dst3D = src3D + (forward * 384);
ray.Init(src3D, dst3D);
m_trace()->TraceRay(ray, MASK_SHOT, &filter, &tr);
back_two = (tr.endpos - tr.startpos).Length();
ray2.Init(src3D + right * 35, dst3D + right * 35);
m_trace()->TraceRay(ray2, MASK_SHOT, &filter, &tr);
right_two = (tr.endpos - tr.startpos).Length();
ray3.Init(src3D - right * 35, dst3D - right * 35);
m_trace()->TraceRay(ray3, MASK_SHOT, &filter, &tr);
left_two = (tr.endpos - tr.startpos).Length();
if (left_two > right_two) {
side_trace = -1;
//Body should be right
//right
}
else if (right_two > left_two) {
side_trace = 1;
//left
}
else
side_trace = 0;
}
Код:
float GetBackwardYaw(player_t* player) {
return math::calculate_angle(player->m_vecOrigin(), player->m_vecOrigin()).y;
}
Последнее редактирование: