public void OV_ballistics()
        {
            if (Provider.isServer || MiscOptions.PanicMode)
            {
                OverrideUtilities.CallOriginal(this, Array.Empty <object>());
                return;
            }
            if (Time.realtimeSinceStartup - PlayerLifeUI.hitmarkers[0].lastHit > PlayerUI.HIT_TIME)
            {
                PlayerLifeUI.hitmarkers[0].hitBuildImage.isVisible    = false;
                PlayerLifeUI.hitmarkers[0].hitCriticalImage.isVisible = false;
                PlayerLifeUI.hitmarkers[0].hitEntitiyImage.isVisible  = false;
            }
            ItemGunAsset itemGunAsset = (ItemGunAsset)Player.player.equipment.asset;
            PlayerLook   look         = Player.player.look;

            if (itemGunAsset.projectile != null)
            {
                return;
            }
            List <BulletInfo> list = (List <BulletInfo>)OV_UseableGun.BulletsField.GetValue(this);

            if (list.Count == 0)
            {
                return;
            }
            RaycastInfo raycastInfo = null;

            if (RaycastOptions.Enabled)
            {
                RaycastUtilities.GenerateRaycast(out raycastInfo);
            }
            if (Provider.modeConfigData.Gameplay.Ballistics)
            {
                if (raycastInfo == null)
                {
                    if (AimbotCoroutines.IsAiming && AimbotCoroutines.LockedObject != null)
                    {
                        Vector3    aimPosition = AimbotCoroutines.GetAimPosition(AimbotCoroutines.LockedObject.transform, "Skull");
                        Ray        aimRay      = VectorUtilities.GetAimRay(look.aim.position, aimPosition);
                        float      maxDistance = Vector3.Distance(look.aim.position, aimPosition);
                        RaycastHit raycastHit;
                        if (!Physics.Raycast(aimRay, out raycastHit, maxDistance, RayMasks.DAMAGE_SERVER))
                        {
                            raycastInfo = RaycastUtilities.GenerateOriginalRaycast(aimRay, itemGunAsset.range, RayMasks.ENEMY, null);
                        }
                    }
                    if (raycastInfo == null)
                    {
                        OverrideUtilities.CallOriginal(this, Array.Empty <object>());
                        return;
                    }
                }
                for (int i = 0; i < list.Count; i++)
                {
                    BulletInfo bulletInfo = list[i];
                    float      num        = Vector3.Distance(Player.player.transform.position, raycastInfo.point);
                    if ((float)bulletInfo.steps * itemGunAsset.ballisticTravel >= num)
                    {
                        EPlayerHit newHit = OV_UseableGun.CalcHitMarker(itemGunAsset, ref raycastInfo);
                        PlayerUI.hitmark(0, Vector3.zero, false, newHit);
                        Player.player.input.sendRaycast(raycastInfo);
                        bulletInfo.steps = 254;
                    }
                }
                for (int j = list.Count - 1; j >= 0; j--)
                {
                    BulletInfo bulletInfo2 = list[j];
                    bulletInfo2.steps += 1;
                    if (bulletInfo2.steps >= itemGunAsset.ballisticSteps)
                    {
                        list.RemoveAt(j);
                    }
                }
                return;
            }
            if (raycastInfo == null)
            {
                OverrideUtilities.CallOriginal(this, Array.Empty <object>());
                return;
            }
            for (int k = 0; k < list.Count; k++)
            {
                EPlayerHit newHit2 = OV_UseableGun.CalcHitMarker(itemGunAsset, ref raycastInfo);
                PlayerUI.hitmark(0, Vector3.zero, false, newHit2);
                Player.player.input.sendRaycast(raycastInfo);
            }
            list.Clear();
        }
Esempio n. 2
0
        // Token: 0x0600023A RID: 570 RVA: 0x000155C4 File Offset: 0x000137C4
        public static bool GetTargetObject(out GameObject Object, out Vector3 Point, float Range)
        {
            float num  = Range + 1f;
            float num2 = RaycastOptions.SilentAimFOV;

            Object = null;
            Point  = Vector3.zero;
            Vector3 position = Player.player.look.aim.position;
            Vector3 forward  = Player.player.look.aim.forward;

            foreach (GameObject gameObject in RaycastUtilities.Objects)
            {
                if (gameObject)
                {
                    Player component = gameObject.GetComponent <Player>();
                    if (!component || (!component.life.isDead && !FriendUtilities.IsFriendly(component) && (!RaycastOptions.WallCheck || RaycastUtilities.WallCheck(gameObject.transform))))
                    {
                        Zombie componentInParent  = gameObject.GetComponentInParent <Zombie>();
                        Animal componentInParent2 = gameObject.GetComponentInParent <Animal>();
                        if ((!componentInParent || !componentInParent.isDead) && (!componentInParent2 || !componentInParent2.isDead))
                        {
                            if (!gameObject.GetComponent <RaycastComponent>())
                            {
                                gameObject.AddComponent <RaycastComponent>();
                            }
                            Transform transform = gameObject.transform;
                            Vector3   vector    = transform.position;
                            float     num3      = Vector3.Distance(position, vector);
                            if (num3 <= Range)
                            {
                                if (RaycastOptions.SilentAimUseFOV)
                                {
                                    if (transform.CompareTag("Player") || transform.CompareTag("Enemy") || transform.CompareTag("Zombie") || transform.CompareTag("Animal"))
                                    {
                                        foreach (Transform transform2 in transform.GetComponentsInChildren <Transform>())
                                        {
                                            if (transform2.name.Equals("Skull"))
                                            {
                                                vector = transform2.position + new Vector3(0f, 0.4f, 0f);
                                                break;
                                            }
                                        }
                                    }
                                    float angleDelta = VectorUtilities.GetAngleDelta(position, forward, vector);
                                    if (angleDelta > num2)
                                    {
                                        continue;
                                    }
                                    num2 = angleDelta;
                                }
                                else if (num3 > num)
                                {
                                    continue;
                                }
                                if (SphereUtilities.GetRaycast(gameObject, position, out Point))
                                {
                                    Object = gameObject;
                                    num    = num3;
                                }
                            }
                        }
                    }
                }
            }
            return(Object != null);
        }