Exemple #1
0
        internal static void DoReverseAimbot(Entity sender)
        {
            const string aimFrom = "j_head";
            const string aimAt   = "j_mainroot";

            BaseScript.OnInterval(1, () =>
            {
                if (!sender.IsAlive || sender.SessionTeam == "spectator" || sender.SessionState != "playing")
                {
                    return(true);
                }

                if (!sender.IsFieldTrue("EnableReverseAimbot"))
                {
                    return(false);
                }

                Entity target = null;

                foreach (Entity ent in BaseScript.Players)
                {
                    if (!ent.IsAlive || ent == sender)
                    {
                        continue;
                    }

                    if (sender.SessionTeam == ent.SessionTeam && (sender.SessionTeam != "none" || ent.SessionTeam == "spectator"))
                    {
                        continue;
                    }

                    if (!GSCFunctions.SightTracePassed(sender.GetTagOrigin(aimFrom), ent.GetTagOrigin(aimAt), false))
                    {
                        continue;
                    }

                    if (target != null)
                    {
                        if (GSCFunctions.Closer(target.GetTagOrigin(aimAt), sender.GetTagOrigin(aimFrom), ent.GetTagOrigin(aimAt)))
                        {
                            target = ent;
                        }
                    }
                    else
                    {
                        target = ent;
                    }

                    if (target != null && target.IsAlive)
                    {
                        Vector3 aim = GSCFunctions.VectorToAngles(target.GetTagOrigin(aimAt) - sender.GetTagOrigin(aimFrom));
                        aim.Z       = sender.GetPlayerAngles().Z;

                        sender.SetPlayerAngles(aim + new Vector3(0, -180, 0));
                    }
                }

                return(true);
            });
        }