private static void PaintTraverse_AfterPaintTraverse(IntPtr pPanel, uint vguiPanel) { if (!(menu.Children[0] as GUIManager.ToggleMenu).IsToggled()) { return; } for (int i = 1; i < CEngineClient.Instance.GetMaxClients(); i++) { if (i == CEngineClient.Instance.GetLocalPlayer()) { continue; } var pTarget = new C_CSPlayer(i); //TODO: cache this to Array if (!pTarget.IsPlayer()) { continue; } if (!pTarget.IsAlive() || pTarget.IsDormant() || !pTarget.IsEnemy()) { continue; } var vOrigin = pTarget.GetOrigin(); var vHead = Utils.Utils.GetEntityBone(pTarget, Bones.HEAD_0); vHead.Z += 14; Vector3 vScreenOrigin = new Vector3(), vScreenHead = new Vector3(); if (!Utils.Utils.WorldToScreen(vHead, ref vScreenHead) || !Utils.Utils.WorldToScreen(vOrigin, ref vScreenOrigin)) { continue; } var height = Math.Abs(vScreenHead.Y - vScreenOrigin.Y); var width = height * 0.65f; Drawing.DrawOutlineRect((int)vScreenHead.X - (int)width / 2, (int)vScreenHead.Y, (int)width, (int)height, new Color(255, 255, 255, 255)); Drawing.DrawText((int)vScreenOrigin.X, (int)vScreenOrigin.Y, pTarget.GetName(i), new Color(255, 255, 255), true); } }
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; } } } } }