コード例 #1
0
 public static void Test_WeaponShotEyes(Character character, Angle2 angle)
 {
     if (WeaponShotEyes.ContainsKey(character.netUser))
     {
         PlayerShotEyes eyes = WeaponShotEyes[character.netUser];
         if (!object.Equals(angle, eyes.angles))
         {
             WeaponShotEyes.Remove(character.netUser);
         }
         else
         {
             eyes.count++;
             if (eyes.count >= (NetCull.sendRate / 5f))
             {
                 PunishDetails = Config.GetMessageTruth("Truth.Punish.Reason.Aimbot.NoRecoil", null, "", 0, new DateTime());
                 PunishDetails = PunishDetails.Replace("%KILLER.NAME%", character.netUser.displayName);
                 PunishDetails = PunishDetails.Replace("%WEAPON%", character.GetComponent <InventoryHolder>().itemRepresentation.datablock.name);
                 Punish(character.netUser, Users.GetBySteamID(character.netUser.userID), HackMethod.AimedHack, false);
                 WeaponShotEyes.Remove(character.netUser);
             }
             else
             {
                 WeaponShotEyes[character.netUser] = eyes;
             }
         }
     }
 }
コード例 #2
0
        public static bool Test_WeaponShot(Character Killer, GameObject hitObj, IBulletWeaponItem weapon, ItemRepresentation rep, Transform transform, Vector3 endPos, bool isHeadshot)
        {
            if ((Killer == null) || (transform == null))
            {
                return(true);
            }
            if (((transform == null) || (Killer == null)) || (Killer.netUser == null))
            {
                return(true);
            }
            if ((float.IsNaN(endPos.x) || float.IsNaN(endPos.y)) || float.IsNaN(endPos.z))
            {
                return(true);
            }
            Character component   = hitObj.GetComponent <Character>();
            NetUser   key         = ((Killer == null) || (Killer.controllable == null)) ? null : Killer.netUser;
            NetUser   user2       = ((component == null) || (component.controllable == null)) ? null : component.netUser;
            Vector3   origin      = Helper.GetEyesRay(Killer).origin;
            float     num         = Vector3.Distance(origin, endPos);
            float     bulletRange = ((BulletWeaponDataBlock)rep.datablock).bulletRange;

            if (component == null)
            {
                if (num > bulletRange)
                {
                    return(true);
                }
                foreach (Collider collider in Physics.OverlapSphere(Killer.eyesRay.origin, 0.2f))
                {
                    IDBase base2 = collider.gameObject.GetComponent <IDBase>();
                    if ((base2 != null) && (base2.idMain is StructureMaster))
                    {
                        return(true);
                    }
                }
                IDMain idMain = IDBase.GetMain(hitObj).idMain;
                if ((idMain.GetComponent <StructureComponent>() == null) && (idMain.GetComponent <SleepingAvatar>() == null))
                {
                    Ray     lookRay  = Helper.GetLookRay(Killer);
                    Vector3 position = hitObj.transform.position;
                    position.y += 0.1f;
                    if (Physics.RaycastAll(lookRay, Vector3.Distance(lookRay.origin, position), -1).Length > 1)
                    {
                        return(true);
                    }
                }
                return(false);
            }
            if ((CheckAimbot && !key.admin) && !component.dead)
            {
                string newValue = Helper.NiceName((user2 != null) ? user2.displayName : component.name);
                if (!WeaponShotEyes.ContainsKey(key))
                {
                    PlayerShotEyes eyes = new PlayerShotEyes {
                        origin = Killer.eyesRay.origin,
                        angles = Killer.eyesAngles,
                        count  = 0
                    };
                    WeaponShotEyes.Add(key, eyes);
                }
                Vector3 vector5 = transform.position - endPos;
                if (vector5.magnitude > 3f)
                {
                    PunishDetails = Config.GetMessageTruth("Truth.Punish.Reason.Aimbot.JackedSilent", key, "", 0, new DateTime());
                    PunishDetails = PunishDetails.Replace("%KILLER.NAME%", key.displayName);
                    PunishDetails = PunishDetails.Replace("%VICTIM.NAME%", newValue);
                    PunishDetails = PunishDetails.Replace("%KILLER.POS%", Killer.transform.position.AsString());
                    PunishDetails = PunishDetails.Replace("%VICTIM.POS%", component.transform.position.AsString());
                    PunishDetails = PunishDetails.Replace("%DISTANCE%", Math.Abs(num).ToString("N1"));
                    PunishDetails = PunishDetails.Replace("%WEAPON%", weapon.datablock.name);
                    Punish(key, Users.GetBySteamID(key.userID), HackMethod.AimedHack, true);
                    return(true);
                }
                if (num < 1f)
                {
                    return(false);
                }
                if (ShotThroughObjectBlock)
                {
                    Vector3    vector3;
                    GameObject obj2 = Helper.GetLineObject(origin, endPos, out vector3, 0x183e1411);
                    if ((obj2 != null) && ((obj2.GetComponent <StructureComponent>() != null) || (obj2.GetComponent <BasicDoor>() != null)))
                    {
                        PunishDetails = Config.GetMessageTruth("Truth.Punish.Reason.Aimbot.ShootBlocked", key, "", 0, new DateTime());
                        PunishDetails = PunishDetails.Replace("%KILLER.NAME%", key.displayName);
                        PunishDetails = PunishDetails.Replace("%VICTIM.NAME%", newValue);
                        PunishDetails = PunishDetails.Replace("%KILLER.POS%", Killer.transform.position.AsString());
                        PunishDetails = PunishDetails.Replace("%VICTIM.POS%", component.transform.position.AsString());
                        PunishDetails = PunishDetails.Replace("%OBJECT%", Helper.NiceName(obj2.name));
                        PunishDetails = PunishDetails.Replace("%OBJECT.NAME%", Helper.NiceName(obj2.name));
                        PunishDetails = PunishDetails.Replace("%OBJECT.POS%", obj2.transform.position.AsString());
                        PunishDetails = PunishDetails.Replace("%POINT%", vector3.AsString());
                        PunishDetails = PunishDetails.Replace("%DISTANCE%", Math.Abs(num).ToString("N1"));
                        PunishDetails = PunishDetails.Replace("%WEAPON.RANGE%", bulletRange.ToString("N1"));
                        PunishDetails = PunishDetails.Replace("%WEAPON%", weapon.datablock.name);
                        if (!Killer.stateFlags.movement)
                        {
                            if (ShotThroughObjectPunish)
                            {
                                Punish(key, Users.GetBySteamID(key.userID), HackMethod.AimedHack, false);
                            }
                            else
                            {
                                Helper.LogError(string.Concat(new object[] { "Blocked [", key.displayName, ":", key.userID, "]: ", PunishDetails }), true);
                            }
                            return(true);
                        }
                        Vector3 pos = key.truthDetector.prevSnap.pos;
                        pos.x = origin.x;
                        pos.z = origin.z;
                        if (Helper.GetLineObject(pos, endPos, out vector3, 0x183e1411) == obj2)
                        {
                            Helper.LogError(string.Concat(new object[] { "Blocked [", key.displayName, ":", key.userID, "]: ", PunishDetails }), true);
                            return(true);
                        }
                    }
                }
                uint num4 = ((uint)Environment.TickCount) - key.truthDetector.prevHitTime;
                if (num4 == Environment.TickCount)
                {
                    num4 = 0;
                }
                key.truthDetector.prevHitTime = (uint)Environment.TickCount;
                if ((num4 > 100) && (num4 < Environment.TickCount))
                {
                    float minShotRateByRange = MinShotRateByRange;
                    float num6 = ((float)num4) / num;
                    Config.Get("SERVER", "Truth.MinShotRateByRange." + weapon.datablock.name, ref minShotRateByRange, true);
                    if (num6 < minShotRateByRange)
                    {
                        PunishDetails = Config.GetMessageTruth("Truth.Punish.Reason.Aimbot.HighFireRate", key, "", 0, new DateTime());
                        PunishDetails = PunishDetails.Replace("%KILLER.NAME%", key.displayName);
                        PunishDetails = PunishDetails.Replace("%VICTIM.NAME%", newValue);
                        PunishDetails = PunishDetails.Replace("%KILLER.POS%", Killer.transform.position.AsString());
                        PunishDetails = PunishDetails.Replace("%VICTIM.POS%", component.transform.position.AsString());
                        PunishDetails = PunishDetails.Replace("%DISTANCE%", Math.Abs(num).ToString("N1"));
                        PunishDetails = PunishDetails.Replace("%WEAPON.RANGE%", bulletRange.ToString("N1"));
                        PunishDetails = PunishDetails.Replace("%WEAPON%", weapon.datablock.name);
                        PunishDetails = PunishDetails.Replace("%SHOTRATE%", num6.ToString("N2"));
                        PunishDetails = PunishDetails.Replace("%MINRATE%", minShotRateByRange.ToString("N2"));
                        Punish(key, Users.GetBySteamID(key.userID), HackMethod.AimedHack, false);
                        return(true);
                    }
                }
                if (CheckShotRange && (Math.Abs(num) > bulletRange))
                {
                    PunishDetails = Config.GetMessageTruth("Truth.Punish.Reason.Aimbot.OverWeaponRange", key, "", 0, new DateTime());
                    PunishDetails = PunishDetails.Replace("%KILLER.NAME%", key.displayName);
                    PunishDetails = PunishDetails.Replace("%VICTIM.NAME%", newValue);
                    PunishDetails = PunishDetails.Replace("%KILLER.POS%", Killer.transform.position.AsString());
                    PunishDetails = PunishDetails.Replace("%VICTIM.POS%", component.transform.position.AsString());
                    PunishDetails = PunishDetails.Replace("%DISTANCE%", Math.Abs(num).ToString("N1"));
                    PunishDetails = PunishDetails.Replace("%WEAPON.RANGE%", bulletRange.ToString("N1"));
                    PunishDetails = PunishDetails.Replace("%WEAPON%", weapon.datablock.name);
                    if (user2 != null)
                    {
                        bool punishBan = (ShotAboveMaxDistance > 0f) && ((num - bulletRange) >= ShotAboveMaxDistance);
                        Punish(key, Users.GetBySteamID(key.userID), HackMethod.AimedHack, punishBan);
                    }
                    else
                    {
                        Broadcast.MessageAll(ViolationColor, PunishDetails, null);
                        Helper.LogError(string.Concat(new object[] { "Noticed [", key.displayName, ":", key.userID, "]: ", PunishDetails }), true);
                    }
                    return(true);
                }
                float num7 = HeadshotAimTime * num;
                if (num4 > num7)
                {
                    key.truthDetector.headshotHold = 0;
                }
                if (isHeadshot)
                {
                    key.truthDetector.headshotHold += (int)num;
                }
                if (key.truthDetector.headshotHold >= HeadshotThreshold)
                {
                    PunishDetails = Config.GetMessageTruth("Truth.Punish.Reason.Aimbot.ThresholdHeadshots", key, "", 0, new DateTime());
                    PunishDetails = PunishDetails.Replace("%KILLER.NAME%", key.displayName);
                    PunishDetails = PunishDetails.Replace("%VICTIM.NAME%", newValue);
                    PunishDetails = PunishDetails.Replace("%KILLER.POS%", Killer.transform.position.AsString());
                    PunishDetails = PunishDetails.Replace("%VICTIM.POS%", component.transform.position.AsString());
                    PunishDetails = PunishDetails.Replace("%DISTANCE%", Math.Abs(num).ToString("N1"));
                    PunishDetails = PunishDetails.Replace("%WEAPON.RANGE%", bulletRange.ToString("N1"));
                    PunishDetails = PunishDetails.Replace("%WEAPON%", weapon.datablock.name);
                    Punish(key, Users.GetBySteamID(key.userID), HackMethod.AimedHack, false);
                    return(true);
                }
            }
            return(false);
        }