-
Автор темы
- #1
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
C++:
Vector GetViewAngles(){
Vector ang;
EngineClient->GetViewAngles(ang);
return ang;
}
Vector NormaliseAngleToniWare(Vector one)
{
float ar[2] = { one.x, one.y };
for (int i = 0; i < 2; i++){
while (ar[i] > 180)
ar[i] -= 360;
while (ar[i] < -180)
ar[i] += 360;
}
return Vector(ar[0], ar[1], 0);
}
Vector VectorClamp(Vector val, float minVal, float maxVal)
{
float ar[3] = { val.x, val.y, val.z };
for (int i = 0; i < 3; i++)
{
if (ar[i] < minVal)
ar[i] = minVal;
else if (ar[i] > maxVal)
ar[i] = maxVal;
}
return Vector(ar[0], ar[1], ar[2]);
}
struct CAngleLog
{
CAngleLog::CAngleLog(Vector _deltaAngle, float _curtime){
deltaAngle = _deltaAngle;
curtime = _curtime;
}
Vector deltaAngle;
float curtime;
};
static std::deque<CAngleLog>AngleLog;
void ActualDrawAngleChange(){
static float X = 800, Y = 800, maxtime = 1; int count = 0;
Vector lastdelta = Vector(0, 0, 0), avgDelta = Vector(0, 0, 0), oldAvgDelta = Vector(0, 0, 0);
for (auto Log = AngleLog.begin(); Log != AngleLog.end(); Log++){
if (AngleLog.empty())
break;
count++;
if (count > AngleLog.size())
count = AngleLog.size();
auto delta = Log->deltaAngle;
delta *= 300;
delta.y *= -1;//fix left/right
if (!lastdelta.GoodVector()){ lastdelta = delta; continue; }
if (!oldAvgDelta.GoodVector()){ lastdelta = delta; oldAvgDelta = (delta + lastdelta) / 2; continue; }
avgDelta = (delta + lastdelta) / 2;
Render->DrawLine(X + oldAvgDelta.y, Y + oldAvgDelta.x, X + avgDelta.y, Y + avgDelta.x, RGBA(255, 255, 255, (float)((float)count / (float)AngleLog.size()) *255));
oldAvgDelta = avgDelta;
lastdelta = delta;
}
Render->Drawxhair(X, Y, RGBA(255, 0, 0, 255));//Reference
}
void FunctionDrawAngleChange(){
static Vector oldangle = Vector(0, 0, 0);
Vector curAngle = GetViewAngles(),
deltaAngle = NormaliseAngleToniWare(curAngle - oldangle);
static float nextupdate = 0;
if (Globals->cur_time > nextupdate || fabsf(Globals->cur_time - nextupdate) > 5.f){
AngleLog.push_back(CAngleLog(deltaAngle, Globals->cur_time));
if (!AngleLog.empty() && AngleLog.size() > 150)
AngleLog.pop_front();
oldangle = curAngle;
nextupdate = Globals->cur_time + (1 / 50);
}
ActualDrawAngleChange();
}