private static C_CSPlayer GetClosestPlayer(C_CSPlayer local) { var maxFov = fov.GetValue(); C_CSPlayer target = new C_CSPlayer(IntPtr.Zero); var viewAngles = CEngineClient.Instance.GetViewAngles(); var eyePos = local.GetEyePos(); for (int i = 1; i < CEngineClient.Instance.GetMaxClients(); i++) { var potentialTarget = new C_CSPlayer(i); if (!potentialTarget.IsValid() || potentialTarget.m_BaseAddress == local.m_BaseAddress) { continue; } if (!potentialTarget.IsPlayer() || !potentialTarget.IsAlive() || potentialTarget.IsDormant() || !potentialTarget.IsEnemy()) { continue; } var targetBone = utils.GetEntityBone(potentialTarget, Bones.HEAD_0); var targetFov = GetFov(viewAngles, utils.CalcAngle(eyePos, targetBone)); if (targetFov > maxFov) { continue; } maxFov = targetFov; target = potentialTarget; } return(target); }
private static void CreateMove_BeforeCreateMove(ref CUserCmd pCmd) { if (!(menu.Children[0] as GUIManager.ToggleMenu).IsToggled()) { return; } if (!hotkey.IsToggled()) { return; } var pLocal = C_CSPlayer.GetLocalPlayer(); if (pLocal.IsValid() && pLocal.IsAlive()) { var weapon = pLocal.GetActiveWeapon(); if (!weapon.IsValid() || weapon.IsC4() || weapon.IsKnife() || weapon.IsGrenade()) { return; } var vTraceForward = new Vector3(); var vTraceAngles = pCmd.viewangles; global::HepajSharp.Utils.Utils.AngleVectors(vTraceAngles, ref vTraceForward); var vTraceStart = C_CSPlayer.GetLocalPlayer().GetEyePos(); var vTraceEnd = vTraceStart + vTraceForward * 8192.0f; var trace = Helper.TraceRay(vTraceStart, vTraceEnd, pLocal.m_BaseAddress, (int)(Definitions.MASKS.MASK_SHOT_HULL | Definitions.MASKS.CONTENTS_HITBOX)); if (trace.fraction != 1.0f && trace.m_pEnt != IntPtr.Zero) { if (!throughSmoke.IsToggled() && global::HepajSharp.Utils.Utils.LineThroughSmoke(vTraceStart, vTraceEnd)) { return; } var target = new C_CSPlayer(trace.m_pEnt); if (target.IsValid() && target.GetClassID() == Definitions.EClassIds.CCSPlayer && target.IsAlive() /* && target.GetHealth() > 0*/ && target.IsEnemy()) //GetHealth kell ha nem ellenőrzünk ClassID-t { if (autopistol.IsToggled()) { if (weapon.IsPistol()) { if (!weapon.CanFire()) { pCmd.buttons &= ~Definitions.IN_ATTACK; } else { pCmd.buttons |= Definitions.IN_ATTACK; } } else { pCmd.buttons |= Definitions.IN_ATTACK; } } else { pCmd.buttons |= Definitions.IN_ATTACK; } } } } }