Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void FreeStanding() // should have rewritten
- {
- static float FinalAngle;
- bool bside1 = false;
- bool bside2 = false;
- bool autowalld = false;
- float tempdis = 999999999.f;
- Vector2D LocalOrg = Vector2D(Globals::LocalPlayer->GetOrigin().x, Globals::LocalPlayer->GetOrigin().y);
- float closeYaw = 999.f;
- for (int i = 1; i <= g_pEngine->GetMaxClients(); ++i)
- {
- C_BaseEntity* pPlayerEntity = g_pEntityList->GetClientEntity(i);
- if (!pPlayerEntity
- || !pPlayerEntity->IsAlive()
- || pPlayerEntity->IsDormant()
- || pPlayerEntity == Globals::LocalPlayer
- || pPlayerEntity->GetTeam() == Globals::LocalPlayer->GetTeam())
- continue;
- Vector2D EnemyOrg = Vector2D(pPlayerEntity->GetOrigin().x, pPlayerEntity->GetOrigin().y);
- if (tempdis > fabs(g_Math.Distance(EnemyOrg, LocalOrg)))
- {
- closeYaw = g_Math.NormalizeYaw(g_Math.CalcAngle(Globals::LocalPlayer->GetOrigin(), pPlayerEntity->GetOrigin()).y);
- tempdis = fabs(g_Math.Distance(EnemyOrg, LocalOrg));
- }
- if (c_config::get().Freestanding)
- {
- float angToLocal = g_Math.CalcAngle(Globals::LocalPlayer->GetOrigin(), pPlayerEntity->GetOrigin()).y;
- Vector ViewPoint = pPlayerEntity->GetOrigin() + Vector(0, 0, 90);
- Vector2D Side1 = { (45 * sin(g_Math.GRD_TO_BOG(angToLocal))),(45 * cos(g_Math.GRD_TO_BOG(angToLocal))) };
- Vector2D Side2 = { (45 * sin(g_Math.GRD_TO_BOG(angToLocal + 180))) ,(45 * cos(g_Math.GRD_TO_BOG(angToLocal + 180))) };
- Vector2D Side3 = { (50 * sin(g_Math.GRD_TO_BOG(angToLocal))),(50 * cos(g_Math.GRD_TO_BOG(angToLocal))) };
- Vector2D Side4 = { (50 * sin(g_Math.GRD_TO_BOG(angToLocal + 180))) ,(50 * cos(g_Math.GRD_TO_BOG(angToLocal + 180))) };
- Vector Origin = Globals::LocalPlayer->GetOrigin();
- Vector2D OriginLeftRight[] = { Vector2D(Side1.x, Side1.y), Vector2D(Side2.x, Side2.y) };
- Vector2D OriginLeftRightLocal[] = { Vector2D(Side3.x, Side3.y), Vector2D(Side4.x, Side4.y) };
- for (int side = 0; side < 2; side++)
- {
- Vector OriginAutowall = { Origin.x + OriginLeftRight[side].x, Origin.y - OriginLeftRight[side].y , Origin.z + 80 };
- Vector OriginAutowall2 = { ViewPoint.x + OriginLeftRightLocal[side].x, ViewPoint.y - OriginLeftRightLocal[side].y , ViewPoint.z };
- if (g_Autowall.CanHitFloatingPoint(OriginAutowall, ViewPoint))
- {
- if (side == 0)
- {
- FreestandingSide = true;
- bside1 = true;
- FinalAngle = angToLocal + 90;
- }
- else if (side == 1)
- {
- FreestandingSide = false;
- bside2 = true;
- FinalAngle = angToLocal - 90;
- }
- autowalld = true;
- }
- else
- {
- for (int side222 = 0; side222 < 2; side222++)
- {
- Vector OriginAutowall222 = { Origin.x + OriginLeftRight[side222].x, Origin.y - OriginLeftRight[side222].y , Origin.z + 80 };
- if (g_Autowall.CanHitFloatingPoint(OriginAutowall222, OriginAutowall2))
- {
- if (side222 == 0)
- {
- FreestandingSide = true;
- bside1 = true;
- FinalAngle = angToLocal + 90;
- }
- else if (side222 == 1)
- {
- FreestandingSide = false;
- bside2 = true;
- FinalAngle = angToLocal - 90;
- }
- autowalld = true;
- }
- }
- }
- }
- }
- }
- if (!autowalld || (bside1 && bside2))
- {
- if (closeYaw != 999.f && c_config::get().AtTarget)
- Globals::pCmd->viewangles.y = g_Math.NormalizeYaw(closeYaw + SentYaw);
- else
- Globals::pCmd->viewangles.y += SentYaw;
- }
- else
- Globals::pCmd->viewangles.y = FinalAngle;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement