Ejemplo n.º 1
0
        // hitmarker bonk
        public static void OV_hitmark(int index, Vector3 point, bool worldspace, EPlayerHit newHit)
        {
            if (!PlayerUI.window.isEnabled || ((bool)(typeof(PlayerUI).GetField("isOverlayed", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null)) && !((bool)(typeof(PlayerUI).GetField("isReverting", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null)))))
            {
                return;
            }
            if (index < 0 || index >= PlayerLifeUI.hitmarkers.Length)
            {
                return;
            }
            if (!Provider.modeConfigData.Gameplay.Hitmarkers)
            {
                return;
            }
            HitmarkerInfo hitmarkerInfo = PlayerLifeUI.hitmarkers[index];

            hitmarkerInfo.lastHit    = Time.realtimeSinceStartup;
            hitmarkerInfo.hit        = newHit;
            hitmarkerInfo.point      = point;
            hitmarkerInfo.worldspace = (worldspace || OptionsSettings.hitmarker);
            if (newHit == EPlayerHit.CRITICAL) // if headshot
            {
                if (G.Settings.WeaponOptions.HitmarkerBonk)
                {
                    MainCamera.instance.GetComponent <AudioSource>().PlayOneShot(AssetUtilities.BonkClip, 2 /* volume */);
                }
                else
                {
                    MainCamera.instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Sounds/General/Hit"), 0.5f /* volume */);
                }
            }
        }
Ejemplo n.º 2
0
        public static bool Prefix(UseableGun __instance, ref List <BulletInfo> ___bullets, ref int ___hitmarkerIndex, ref ParticleSystem ___tracerEmitter,
                                  ref Attachments ___thirdAttachments)
        {
            if (Global.AllOff || Hooks.askScreenshot.NeedingSpy)
            {
                ___tracerEmitter.startColor = Color.gray;
                return(true);
            }
            if (!Global.AimEnabled || (Global.AimSettings.RageBot && RageBot.FocusTarget != null && !Global.AimSettings.RBypassOne))
            {
                return(true);
            }

            if ((__instance.equippedGunAsset.projectile == null) && (___bullets != null))
            {
                if (__instance.channel.isOwner)
                {
                    RaycastInfo info2 = null;
                    float       dst   = 0f;

                    if (Global.AimSettings.RageBot)
                    {
                        if (RageBot.FocusTarget != null)
                        {
                            Vector3 AimAt = Aimbot.GetHitbox(RageBot.FocusTarget.player.transform, "Skull");

                            if (AimAt == Vector3.zero || RageBot.FocusTarget.player.stance.prone)
                            {
                                AimAt = RageBot.FocusTarget.player.transform.position + new Vector3(0, 0.005f, 0);
                            }

                            Ray prx = new Ray(Player.player.look.aim.position, (AimAt - Player.player.look.aim.position).normalized);
                            dst   = Vector3.Distance(AimAt, Player.player.look.aim.position);
                            info2 = DamageTool.raycast(prx,
                                                       dst,
                                                       RayMasks.ENEMY,
                                                       Player.player);
                        }
                    }


                    for (int i = 0; i < ___bullets.Count; i++)
                    {
                        BulletInfo info = ___bullets[i];
                        if (Global.AimSettings.RageBot && RageBot.FocusTarget != null && info2 != null && info2.player == RageBot.FocusTarget.player)
                        {
                            if (!((info.steps * __instance.equippedGunAsset.ballisticTravel) < dst))
                            {
                                Player.player.input.sendRaycast(info2);
                                Player.player.input.sendRaycast(info2);
                                info.steps = 254;
                                goto prx;
                            }
                        }

                        byte pellets = info.magazineAsset.pellets;
                        if (__instance.channel.isOwner)
                        {
                            EPlayerHit nONE = EPlayerHit.NONE;
                            if (pellets > 1)
                            {
                                ___hitmarkerIndex = info.pellet;
                            }
                            else if (OptionsSettings.hitmarker)
                            {
                                ___hitmarkerIndex++;
                                if (___hitmarkerIndex >= PlayerLifeUI.hitmarkers.Length)
                                {
                                    ___hitmarkerIndex = 0;
                                }
                            }
                            else
                            {
                                ___hitmarkerIndex = 0;
                            }

                            Ray ray = new Ray(info.pos, info.dir);
                            if (info2 == null)
                            {
                                info2 = DamageTool.raycast(ray,
                                                           !Provider.modeConfigData.Gameplay.Ballistics ? __instance.equippedGunAsset.range : __instance.equippedGunAsset.ballisticTravel,
                                                           RayMasks.DAMAGE_CLIENT,
                                                           __instance.player);
                            }

                            if (((info2.player != null) && (__instance.equippedGunAsset.playerDamageMultiplier.damage > 1f)) && (!__instance.player.quests.isMemberOfSameGroupAs(info2.player) && Provider.isPvP))
                            {
                                if (nONE != EPlayerHit.CRITICAL)
                                {
                                    nONE = (info2.limb != ELimb.SKULL) ? EPlayerHit.ENTITIY : EPlayerHit.CRITICAL;
                                }
                                PlayerUI.hitmark(___hitmarkerIndex, info2.point, pellets > 1, (info2.limb != ELimb.SKULL) ? EPlayerHit.ENTITIY : EPlayerHit.CRITICAL);
                            }
                            else if (((info2.zombie != null) && (__instance.equippedGunAsset.zombieDamageMultiplier.damage > 1f)) || ((info2.animal != null) && (__instance.equippedGunAsset.animalDamageMultiplier.damage > 1f)))
                            {
                                if (nONE != EPlayerHit.CRITICAL)
                                {
                                    nONE = (info2.limb != ELimb.SKULL) ? EPlayerHit.ENTITIY : EPlayerHit.CRITICAL;
                                }
                                PlayerUI.hitmark(___hitmarkerIndex, info2.point, pellets > 1, (info2.limb != ELimb.SKULL) ? EPlayerHit.ENTITIY : EPlayerHit.CRITICAL);
                            }
                            else if (((info2.transform != null) && info2.transform.CompareTag("Barricade")) && (__instance.equippedGunAsset.barricadeDamage > 1f))
                            {
                                ushort num3;
                                if (ushort.TryParse(info2.transform.name, NumberStyles.Any, CultureInfo.InvariantCulture, out num3))
                                {
                                    ItemBarricadeAsset asset = (ItemBarricadeAsset)Assets.find(EAssetType.ITEM, num3);
                                    if ((asset != null) && (asset.isVulnerable || ((ItemWeaponAsset)__instance.player.equipment.asset).isInvulnerable))
                                    {
                                        if (nONE == EPlayerHit.NONE)
                                        {
                                            nONE = EPlayerHit.BUILD;
                                        }
                                        PlayerUI.hitmark(___hitmarkerIndex, info2.point, pellets > 1, EPlayerHit.BUILD);
                                    }
                                }
                            }
                            else if (((info2.transform != null) && info2.transform.CompareTag("Structure")) && (__instance.equippedGunAsset.structureDamage > 1f))
                            {
                                ushort num4;
                                if (ushort.TryParse(info2.transform.name, NumberStyles.Any, CultureInfo.InvariantCulture, out num4))
                                {
                                    ItemStructureAsset asset2 = (ItemStructureAsset)Assets.find(EAssetType.ITEM, num4);
                                    if ((asset2 != null) && (asset2.isVulnerable || ((ItemWeaponAsset)__instance.player.equipment.asset).isInvulnerable))
                                    {
                                        if (nONE == EPlayerHit.NONE)
                                        {
                                            nONE = EPlayerHit.BUILD;
                                        }
                                        PlayerUI.hitmark(___hitmarkerIndex, info2.point, pellets > 1, EPlayerHit.BUILD);
                                    }
                                }
                            }
                            else if (((info2.vehicle != null) && !info2.vehicle.isDead) && (__instance.equippedGunAsset.vehicleDamage > 1f))
                            {
                                if (((info2.vehicle.asset != null) && info2.vehicle.canBeDamaged) && (info2.vehicle.asset.isVulnerable || ((ItemWeaponAsset)__instance.player.equipment.asset).isInvulnerable))
                                {
                                    if (nONE == EPlayerHit.NONE)
                                    {
                                        nONE = EPlayerHit.BUILD;
                                    }
                                    PlayerUI.hitmark(___hitmarkerIndex, info2.point, pellets > 1, EPlayerHit.BUILD);
                                }
                            }
                            else if (((info2.transform != null) && info2.transform.CompareTag("Resource")) && (__instance.equippedGunAsset.resourceDamage > 1f))
                            {
                                byte   num5;
                                byte   num6;
                                ushort num7;
                                if (ResourceManager.tryGetRegion(info2.transform, out num5, out num6, out num7))
                                {
                                    ResourceSpawnpoint spawnpoint = ResourceManager.getResourceSpawnpoint(num5, num6, num7);
                                    if (((spawnpoint != null) && !spawnpoint.isDead) && (spawnpoint.asset.bladeID == ((ItemWeaponAsset)__instance.player.equipment.asset).bladeID))
                                    {
                                        if (nONE == EPlayerHit.NONE)
                                        {
                                            nONE = EPlayerHit.BUILD;
                                        }
                                        PlayerUI.hitmark(___hitmarkerIndex, info2.point, pellets > 1, EPlayerHit.BUILD);
                                    }
                                }
                            }
                            else if ((info2.transform != null) && (__instance.equippedGunAsset.objectDamage > 1f))
                            {
                                InteractableObjectRubble componentInParent = info2.transform.GetComponentInParent <InteractableObjectRubble>();
                                if (componentInParent != null)
                                {
                                    info2.transform = componentInParent.transform;
                                    info2.section   = componentInParent.getSection(info2.collider.transform);
                                    if (!componentInParent.isSectionDead(info2.section) && (componentInParent.asset.rubbleIsVulnerable || ((ItemWeaponAsset)__instance.player.equipment.asset).isInvulnerable))
                                    {
                                        if (nONE == EPlayerHit.NONE)
                                        {
                                            nONE = EPlayerHit.BUILD;
                                        }
                                        PlayerUI.hitmark(___hitmarkerIndex, info2.point, pellets > 1, EPlayerHit.BUILD);
                                    }
                                }
                            }



                            if (Provider.modeConfigData.Gameplay.Ballistics)
                            {
                                if ((info.steps > 0) || (__instance.equippedGunAsset.ballisticSteps <= 1))
                                {
                                    if (__instance.equippedGunAsset.ballisticTravel < 32f)
                                    {
                                        trace(info.pos + ((Vector3)(info.dir * 32f)), info.dir, ref ___tracerEmitter, ref __instance, ref ___thirdAttachments);
                                    }
                                    else
                                    {
                                        trace(info.pos + ((Vector3)(info.dir * UnityEngine.Random.Range(32f, __instance.equippedGunAsset.ballisticTravel))), info.dir, ref ___tracerEmitter, ref __instance, ref ___thirdAttachments);
                                    }
                                }
                            }
                            else if (__instance.equippedGunAsset.range < 32f)
                            {
                                trace(ray.origin + ((Vector3)(ray.direction * 32f)), ray.direction, ref ___tracerEmitter, ref __instance, ref ___thirdAttachments);
                            }
                            else
                            {
                                trace(ray.origin + ((Vector3)(ray.direction * UnityEngine.Random.Range(32f, Mathf.Min(64f, __instance.equippedGunAsset.range)))), ray.direction, ref ___tracerEmitter, ref __instance, ref ___thirdAttachments);
                            }

                            float ballisticDrop = __instance.equippedGunAsset.ballisticDrop;
                            if (info.barrelAsset != null)
                            {
                                ballisticDrop *= info.barrelAsset.ballisticDrop;
                            }

                            info.pos += (Vector3)(info.dir * __instance.equippedGunAsset.ballisticTravel);
                            if (!Global.AimSettings.RageBot)
                            {
                                if (!Global.AimSettings.NoDrop)
                                {
                                    info.dir.y -= ballisticDrop;
                                }
                            }

                            info.dir.Normalize();

                            if (Global.AimSettings.RageBot && RageBot.FocusTarget != null)
                            {
                                goto prx;
                            }

                            if (!__instance.player.input.isRaycastInvalid(info2))
                            {
                                if (nONE != EPlayerHit.NONE)
                                {
                                    int num9;
                                    if (Provider.provider.statisticsService.userStatisticsService.getStatistic("Accuracy_Hit", out num9))
                                    {
                                        Provider.provider.statisticsService.userStatisticsService.setStatistic("Accuracy_Hit", (int)(num9 + 1));
                                    }
                                    if ((nONE == EPlayerHit.CRITICAL) && Provider.provider.statisticsService.userStatisticsService.getStatistic("Headshots", out num9))
                                    {
                                        Provider.provider.statisticsService.userStatisticsService.setStatistic("Headshots", (int)(num9 + 1));
                                    }
                                }
                                __instance.player.input.sendRaycast(info2);
                                info.steps = 0xfe;
                            }
                        }
                    }
                }

prx:
                if (__instance.player.equipment.asset != null)
                {
                    if (Provider.modeConfigData.Gameplay.Ballistics)
                    {
                        for (int k = ___bullets.Count - 1; k >= 0; k--)
                        {
                            BulletInfo info5 = ___bullets[k];
                            info5.steps = (byte)(info5.steps + 1);
                            if (info5.steps >= __instance.equippedGunAsset.ballisticSteps)
                            {
                                ___bullets.RemoveAt(k);
                            }
                        }
                    }
                    else
                    {
                        ___bullets.Clear();
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 3
0
    public void OV_ballistics()
    {
        Useable useable  = OptimizationVariables.MainPlayer.equipment.useable;
        bool    isServer = Provider.isServer;

        if (isServer)
        {
            OverrideUtilities.CallOriginal(useable, new object[0]);
        }
        else
        {
            bool flag = Time.realtimeSinceStartup - PlayerLifeUI.hitmarkers[0].lastHit > PlayerUI.HIT_TIME;
            if (flag)
            {
                PlayerLifeUI.hitmarkers[0].image.isVisible = false;
                //PlayerLifeUI.hitmarkers[0].hitCriticalImage.isVisible = false;
                //PlayerLifeUI.hitmarkers[0].hitEntitiyImage.isVisible = false;
            }
            ItemGunAsset itemGunAsset = (ItemGunAsset)OptimizationVariables.MainPlayer.equipment.asset;
            PlayerLook   look         = OptimizationVariables.MainPlayer.look;
            bool         flag2        = itemGunAsset.projectile != null;
            if (!flag2)
            {
                List <BulletInfo> list = (List <BulletInfo>)OV_UseableGun.BulletsField.GetValue(useable);
                bool flag3             = list.Count == 0;
                if (!flag3)
                {
                    RaycastInfo raycastInfo = null;
                    bool        enabled     = RaycastOptions.Enabled;
                    if (enabled)
                    {
                        RaycastUtilities.GenerateRaycast(out raycastInfo);
                    }
                    bool ballistics = Provider.modeConfigData.Gameplay.Ballistics;
                    if (ballistics)
                    {
                        bool flag4 = raycastInfo == null;
                        if (flag4)
                        {
                            bool noAimbotDrop = AimbotOptions.NoAimbotDrop;
                            if (noAimbotDrop)
                            {
                                bool flag5 = AimbotCoroutines.IsAiming && AimbotCoroutines.LockedObject != null;
                                if (flag5)
                                {
                                    Vector3 aimPosition = AimbotCoroutines.GetAimPosition(AimbotCoroutines.LockedObject.transform, "Skull");
                                    Ray     aimRay      = OV_UseableGun.GetAimRay(look.aim.position, aimPosition);
                                    float   maxDistance = (float)VectorUtilities.GetDistance(look.aim.position, aimPosition);
                                    bool    flag6       = !Physics.Raycast(aimRay, out RaycastHit raycastHit, maxDistance, RayMasks.DAMAGE_SERVER);
                                    if (flag6)
                                    {
                                        raycastInfo = RaycastUtilities.GenerateOriginalRaycast(aimRay, itemGunAsset.range, RayMasks.ENEMY);
                                    }
                                }
                            }
                            bool flag7 = WeaponOptions.NoDrop && raycastInfo == null;
                            if (flag7)
                            {
                                for (int i = 0; i < list.Count; i++)
                                {
                                    BulletInfo  bulletInfo = list[i];
                                    Ray         ray        = new Ray(bulletInfo.pos, bulletInfo.dir);
                                    RaycastInfo info       = DamageTool.raycast(ray, itemGunAsset.ballisticTravel, RayMasks.DAMAGE_CLIENT);
                                    bool        flag8      = OV_UseableGun.IsRaycastInvalid(info);
                                    if (flag8)
                                    {
                                        bulletInfo.pos += bulletInfo.dir * itemGunAsset.ballisticTravel;
                                    }
                                    else
                                    {
                                        EPlayerHit newHit = OV_UseableGun.CalcHitMarker(itemGunAsset, ref info);
                                        PlayerUI.hitmark(0, Vector3.zero, false, newHit);
                                        OptimizationVariables.MainPlayer.input.sendRaycast(info, ERaycastInfoUsage.Gun);
                                        bulletInfo.steps = 254;
                                    }
                                }
                                for (int j = list.Count - 1; j >= 0; j--)
                                {
                                    BulletInfo bulletInfo2 = list[j];
                                    BulletInfo bulletInfo3 = bulletInfo2;
                                    bulletInfo3.steps += 1;
                                    bool flag9 = bulletInfo2.steps >= itemGunAsset.ballisticSteps;
                                    if (flag9)
                                    {
                                        list.RemoveAt(j);
                                    }
                                }
                                return;
                            }
                            bool flag10 = raycastInfo == null;
                            if (flag10)
                            {
                                OverrideUtilities.CallOriginal(useable, new object[0]);
                                return;
                            }
                        }
                        for (int k = 0; k < list.Count; k++)
                        {
                            BulletInfo bulletInfo4 = list[k];
                            double     distance    = VectorUtilities.GetDistance(OptimizationVariables.MainPlayer.transform.position, raycastInfo.point);
                            bool       flag11      = bulletInfo4.steps * itemGunAsset.ballisticTravel < distance;
                            if (!flag11)
                            {
                                EPlayerHit newHit2 = OV_UseableGun.CalcHitMarker(itemGunAsset, ref raycastInfo);
                                PlayerUI.hitmark(0, Vector3.zero, false, newHit2);
                                OptimizationVariables.MainPlayer.input.sendRaycast(raycastInfo, ERaycastInfoUsage.Gun);
                                bulletInfo4.steps = 254;
                            }
                        }
                        for (int l = list.Count - 1; l >= 0; l--)
                        {
                            BulletInfo bulletInfo5 = list[l];
                            BulletInfo bulletInfo6 = bulletInfo5;
                            bulletInfo6.steps += 1;
                            bool flag12 = bulletInfo5.steps >= itemGunAsset.ballisticSteps;
                            if (flag12)
                            {
                                list.RemoveAt(l);
                            }
                        }
                    }
                    else
                    {
                        bool flag13 = raycastInfo != null;
                        if (flag13)
                        {
                            for (int m = 0; m < list.Count; m++)
                            {
                                EPlayerHit newHit3 = OV_UseableGun.CalcHitMarker(itemGunAsset, ref raycastInfo);
                                PlayerUI.hitmark(0, Vector3.zero, false, newHit3);
                                OptimizationVariables.MainPlayer.input.sendRaycast(raycastInfo, ERaycastInfoUsage.Gun);
                            }
                            list.Clear();
                        }
                        else
                        {
                            OverrideUtilities.CallOriginal(useable, new object[0]);
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 4
0
    public static EPlayerHit CalcHitMarker(ItemGunAsset PAsset, ref RaycastInfo ri)
    {
        EPlayerHit eplayerHit = EPlayerHit.NONE;
        bool       flag       = ri == null || PAsset == null;
        EPlayerHit result;

        if (flag)
        {
            result = eplayerHit;
        }
        else
        {
            bool flag2 = ri.animal || ri.player || ri.zombie;
            if (flag2)
            {
                eplayerHit = EPlayerHit.ENTITIY;
                bool flag3 = ri.limb == ELimb.SKULL;
                if (flag3)
                {
                    eplayerHit = EPlayerHit.CRITICAL;
                }
            }
            else
            {
                bool flag4 = ri.transform;
                if (flag4)
                {
                    bool flag5 = ri.transform.CompareTag("Barricade") && PAsset.barricadeDamage > 1f;
                    if (flag5)
                    {
                        InteractableDoorHinge component = ri.transform.GetComponent <InteractableDoorHinge>();
                        bool flag6 = component != null;
                        if (flag6)
                        {
                            ri.transform = component.transform.parent.parent;
                        }
                        bool flag7 = !ushort.TryParse(ri.transform.name, out ushort id);
                        if (flag7)
                        {
                            return(eplayerHit);
                        }
                        ItemBarricadeAsset itemBarricadeAsset = (ItemBarricadeAsset)Assets.find(EAssetType.ITEM, id);
                        bool flag8 = itemBarricadeAsset == null || (!itemBarricadeAsset.isVulnerable && !PAsset.isInvulnerable);
                        if (flag8)
                        {
                            return(eplayerHit);
                        }
                        bool flag9 = eplayerHit == EPlayerHit.NONE;
                        if (flag9)
                        {
                            eplayerHit = EPlayerHit.BUILD;
                        }
                    }
                    else
                    {
                        bool flag10 = ri.transform.CompareTag("Structure") && PAsset.structureDamage > 1f;
                        if (flag10)
                        {
                            bool flag11 = !ushort.TryParse(ri.transform.name, out ushort id2);
                            if (flag11)
                            {
                                return(eplayerHit);
                            }
                            ItemStructureAsset itemStructureAsset = (ItemStructureAsset)Assets.find(EAssetType.ITEM, id2);
                            bool flag12 = itemStructureAsset == null || (!itemStructureAsset.isVulnerable && !PAsset.isInvulnerable);
                            if (flag12)
                            {
                                return(eplayerHit);
                            }
                            bool flag13 = eplayerHit == EPlayerHit.NONE;
                            if (flag13)
                            {
                                eplayerHit = EPlayerHit.BUILD;
                            }
                        }
                        else
                        {
                            bool flag14 = ri.transform.CompareTag("Resource") && PAsset.resourceDamage > 1f;
                            if (flag14)
                            {
                                bool flag15 = !ResourceManager.tryGetRegion(ri.transform, out byte x, out byte y, out ushort index);
                                if (flag15)
                                {
                                    return(eplayerHit);
                                }
                                ResourceSpawnpoint resourceSpawnpoint = ResourceManager.getResourceSpawnpoint(x, y, index);
                                bool flag16 = resourceSpawnpoint == null || resourceSpawnpoint.isDead || !PAsset.hasBladeID(resourceSpawnpoint.asset.bladeID);
                                if (flag16)
                                {
                                    return(eplayerHit);
                                }
                                bool flag17 = eplayerHit == EPlayerHit.NONE;
                                if (flag17)
                                {
                                    eplayerHit = EPlayerHit.BUILD;
                                }
                            }
                            else
                            {
                                bool flag18 = PAsset.objectDamage > 1f;
                                if (flag18)
                                {
                                    InteractableObjectRubble component2 = ri.transform.GetComponent <InteractableObjectRubble>();
                                    bool flag19 = component2 == null;
                                    if (flag19)
                                    {
                                        return(eplayerHit);
                                    }
                                    ri.section = component2.getSection(ri.collider.transform);
                                    bool flag20 = component2.isSectionDead(ri.section) || (!component2.asset.rubbleIsVulnerable && !PAsset.isInvulnerable);
                                    if (flag20)
                                    {
                                        return(eplayerHit);
                                    }
                                    bool flag21 = eplayerHit == EPlayerHit.NONE;
                                    if (flag21)
                                    {
                                        eplayerHit = EPlayerHit.BUILD;
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    bool flag22 = ri.vehicle && !ri.vehicle.isDead && PAsset.vehicleDamage > 1f;
                    if (flag22)
                    {
                        bool flag23 = ri.vehicle.asset != null && (ri.vehicle.asset.isVulnerable || PAsset.isInvulnerable);
                        if (flag23)
                        {
                            bool flag24 = eplayerHit == EPlayerHit.NONE;
                            if (flag24)
                            {
                                eplayerHit = EPlayerHit.BUILD;
                            }
                        }
                    }
                }
            }
            result = eplayerHit;
        }
        return(result);
    }
        // adding an override to only send the silent aim raycast if the bullets are at the end of their travel
        public void OV_ballistics()
        {
            Useable PlayerUse = Player.player.equipment.useable;

            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 PAsset = (ItemGunAsset)Player.player.equipment.asset;
            PlayerLook   Look   = Player.player.look;

            if (PAsset.projectile != null)
            {
                return;
            }

            List <BulletInfo> Bullets = (List <BulletInfo>)BulletsField.GetValue(PlayerUse);

            if (Bullets.Count == 0)
            {
                return;
            }

            Transform   t  = (Player.player.look.perspective == EPlayerPerspective.FIRST ? Player.player.look.aim : G.MainCamera.transform);
            RaycastInfo ri = hkDamageTool.SetupRaycast(new Ray(t.position, t.forward), T.GetGunDistance().Value, RayMasks.DAMAGE_CLIENT);

            if (Provider.modeConfigData.Gameplay.Ballistics)
            {
                for (int i = 0; i < Bullets.Count; i++)
                {
                    BulletInfo bulletInfo = Bullets[i];
                    double     distance   = Vector3.Distance(Player.player.transform.position, ri.point);

                    if (bulletInfo.steps * PAsset.ballisticTravel < distance)
                    {
                        continue;
                    }

                    EPlayerHit eplayerhit = CalcHitMarker(PAsset, ref ri);
                    PlayerUI.hitmark(0, Vector3.zero, false, eplayerhit);
                    Player.player.input.sendRaycast(ri);
                    Weapons.AddTracer(ri);
                    Weapons.AddDamage(ri);
                    bulletInfo.steps = 254;
                }


                for (int k = Bullets.Count - 1; k >= 0; k--)
                {
                    BulletInfo bulletInfo = Bullets[k];
                    bulletInfo.steps += 1;
                    if (bulletInfo.steps >= PAsset.ballisticSteps)
                    {
                        Bullets.RemoveAt(k);
                    }
                }
            }
            else
            {
                for (int i = 0; i < Bullets.Count; i++)
                {
                    EPlayerHit eplayerhit = CalcHitMarker(PAsset, ref ri);
                    PlayerUI.hitmark(0, Vector3.zero, false, eplayerhit);
                    Player.player.input.sendRaycast(ri);
                    Weapons.AddTracer(ri);
                    Weapons.AddDamage(ri);
                }

                Bullets.Clear();
            }
            return;
        }
        public static EPlayerHit CalcHitMarker(ItemGunAsset PAsset, ref RaycastInfo ri)
        {
            EPlayerHit eplayerhit = EPlayerHit.NONE;

            if (ri == null || PAsset == null)
            {
                return(eplayerhit);
            }

            if (ri.animal || ri.player || ri.zombie)
            {
                eplayerhit = EPlayerHit.ENTITIY;
                if (ri.limb == ELimb.SKULL)
                {
                    eplayerhit = EPlayerHit.CRITICAL;
                }
            }
            else if (ri.transform)
            {
                if (ri.transform.CompareTag("Barricade") && PAsset.barricadeDamage > 1f)
                {
                    InteractableDoorHinge component = ri.transform.GetComponent <InteractableDoorHinge>();
                    if (component != null)
                    {
                        ri.transform = component.transform.parent.parent;
                    }

                    if (!ushort.TryParse(ri.transform.name, out ushort id))
                    {
                        return(eplayerhit);
                    }

                    ItemBarricadeAsset itemBarricadeAsset = (ItemBarricadeAsset)Assets.find(EAssetType.ITEM, id);

                    if (itemBarricadeAsset == null || !itemBarricadeAsset.isVulnerable && !PAsset.isInvulnerable)
                    {
                        return(eplayerhit);
                    }

                    if (eplayerhit == EPlayerHit.NONE)
                    {
                        eplayerhit = EPlayerHit.BUILD;
                    }
                }
                else if (ri.transform.CompareTag("Structure") && PAsset.structureDamage > 1f)
                {
                    if (!ushort.TryParse(ri.transform.name, out ushort id2))
                    {
                        return(eplayerhit);
                    }

                    ItemStructureAsset itemStructureAsset = (ItemStructureAsset)Assets.find(EAssetType.ITEM, id2);

                    if (itemStructureAsset == null || !itemStructureAsset.isVulnerable && !PAsset.isInvulnerable)
                    {
                        return(eplayerhit);
                    }

                    if (eplayerhit == EPlayerHit.NONE)
                    {
                        eplayerhit = EPlayerHit.BUILD;
                    }
                }
                else if (ri.transform.CompareTag("Resource") && PAsset.resourceDamage > 1f)
                {
                    if (!ResourceManager.tryGetRegion(ri.transform, out byte x, out byte y, out ushort index))
                    {
                        return(eplayerhit);
                    }

                    ResourceSpawnpoint resourceSpawnpoint = ResourceManager.getResourceSpawnpoint(x, y, index);

                    if (resourceSpawnpoint == null || resourceSpawnpoint.isDead ||
                        resourceSpawnpoint.asset.bladeID != PAsset.bladeID)
                    {
                        return(eplayerhit);
                    }

                    if (eplayerhit == EPlayerHit.NONE)
                    {
                        eplayerhit = EPlayerHit.BUILD;
                    }
                }
                else if (PAsset.objectDamage > 1f)
                {
                    InteractableObjectRubble component2 = ri.transform.GetComponent <InteractableObjectRubble>();

                    if (component2 == null)
                    {
                        return(eplayerhit);
                    }

                    ri.section = component2.getSection(ri.collider.transform);

                    if (component2.isSectionDead(ri.section) ||
                        !component2.asset.rubbleIsVulnerable && !PAsset.isInvulnerable)
                    {
                        return(eplayerhit);
                    }

                    if (eplayerhit == EPlayerHit.NONE)
                    {
                        eplayerhit = EPlayerHit.BUILD;
                    }
                }
            }
            else if (ri.vehicle && !ri.vehicle.isDead && PAsset.vehicleDamage > 1f)
            {
                if (ri.vehicle.asset != null && (ri.vehicle.asset.isVulnerable || PAsset.isInvulnerable))
                {
                    if (eplayerhit == EPlayerHit.NONE)
                    {
                        eplayerhit = EPlayerHit.BUILD;
                    }
                }
            }

            return(eplayerhit);
        }
        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();
        }
Ejemplo n.º 8
0
        // Token: 0x06000118 RID: 280 RVA: 0x0000B6FC File Offset: 0x000098FC
        public static EPlayerHit CalcHitMarker(ItemGunAsset PAsset, ref RaycastInfo ri)
        {
            EPlayerHit eplayerHit = EPlayerHit.NONE;
            bool       flag       = ri == null || PAsset == null;
            bool       flag2      = flag;
            EPlayerHit result;

            if (flag2)
            {
                result = eplayerHit;
            }
            else
            {
                bool flag3 = ri.animal || ri.player || ri.zombie;
                bool flag4 = flag3;
                if (flag4)
                {
                    eplayerHit = EPlayerHit.ENTITIY;
                    bool flag5 = ri.limb == ELimb.SKULL;
                    bool flag6 = flag5;
                    if (flag6)
                    {
                        eplayerHit = EPlayerHit.CRITICAL;
                    }
                }
                else
                {
                    bool flag7 = ri.transform;
                    bool flag8 = flag7;
                    if (flag8)
                    {
                        bool flag9  = ri.transform.CompareTag("Barricade") && PAsset.barricadeDamage > 1f;
                        bool flag10 = flag9;
                        if (flag10)
                        {
                            InteractableDoorHinge component = ri.transform.GetComponent <InteractableDoorHinge>();
                            bool flag11 = component != null;
                            bool flag12 = flag11;
                            if (flag12)
                            {
                                ri.transform = component.transform.parent.parent;
                            }
                            ushort id;
                            bool   flag13 = !ushort.TryParse(ri.transform.name, out id);
                            bool   flag14 = flag13;
                            if (flag14)
                            {
                                return(eplayerHit);
                            }
                            ItemBarricadeAsset itemBarricadeAsset = (ItemBarricadeAsset)Assets.find(EAssetType.ITEM, id);
                            bool flag15 = itemBarricadeAsset == null || (!itemBarricadeAsset.isVulnerable && !PAsset.isInvulnerable);
                            bool flag16 = flag15;
                            if (flag16)
                            {
                                return(eplayerHit);
                            }
                            bool flag17 = eplayerHit == EPlayerHit.NONE;
                            bool flag18 = flag17;
                            if (flag18)
                            {
                                eplayerHit = EPlayerHit.BUILD;
                            }
                        }
                        else
                        {
                            bool flag19 = ri.transform.CompareTag("Structure") && PAsset.structureDamage > 1f;
                            bool flag20 = flag19;
                            if (flag20)
                            {
                                ushort id2;
                                bool   flag21 = !ushort.TryParse(ri.transform.name, out id2);
                                bool   flag22 = flag21;
                                if (flag22)
                                {
                                    return(eplayerHit);
                                }
                                ItemStructureAsset itemStructureAsset = (ItemStructureAsset)Assets.find(EAssetType.ITEM, id2);
                                bool flag23 = itemStructureAsset == null || (!itemStructureAsset.isVulnerable && !PAsset.isInvulnerable);
                                bool flag24 = flag23;
                                if (flag24)
                                {
                                    return(eplayerHit);
                                }
                                bool flag25 = eplayerHit == EPlayerHit.NONE;
                                bool flag26 = flag25;
                                if (flag26)
                                {
                                    eplayerHit = EPlayerHit.BUILD;
                                }
                            }
                            else
                            {
                                bool flag27 = ri.transform.CompareTag("Resource") && PAsset.resourceDamage > 1f;
                                bool flag28 = flag27;
                                if (flag28)
                                {
                                    byte   x;
                                    byte   y;
                                    ushort index;
                                    bool   flag29 = !ResourceManager.tryGetRegion(ri.transform, out x, out y, out index);
                                    bool   flag30 = flag29;
                                    if (flag30)
                                    {
                                        return(eplayerHit);
                                    }
                                    ResourceSpawnpoint resourceSpawnpoint = ResourceManager.getResourceSpawnpoint(x, y, index);
                                    bool flag31 = resourceSpawnpoint == null || resourceSpawnpoint.isDead || resourceSpawnpoint.asset.bladeID != PAsset.bladeID;
                                    bool flag32 = flag31;
                                    if (flag32)
                                    {
                                        return(eplayerHit);
                                    }
                                    bool flag33 = eplayerHit == EPlayerHit.NONE;
                                    bool flag34 = flag33;
                                    if (flag34)
                                    {
                                        eplayerHit = EPlayerHit.BUILD;
                                    }
                                }
                                else
                                {
                                    bool flag35 = PAsset.objectDamage > 1f;
                                    bool flag36 = flag35;
                                    if (flag36)
                                    {
                                        InteractableObjectRubble component2 = ri.transform.GetComponent <InteractableObjectRubble>();
                                        bool flag37 = component2 == null;
                                        bool flag38 = flag37;
                                        if (flag38)
                                        {
                                            return(eplayerHit);
                                        }
                                        ri.section = component2.getSection(ri.collider.transform);
                                        bool flag39 = component2.isSectionDead(ri.section) || (!component2.asset.rubbleIsVulnerable && !PAsset.isInvulnerable);
                                        bool flag40 = flag39;
                                        if (flag40)
                                        {
                                            return(eplayerHit);
                                        }
                                        bool flag41 = eplayerHit == EPlayerHit.NONE;
                                        bool flag42 = flag41;
                                        if (flag42)
                                        {
                                            eplayerHit = EPlayerHit.BUILD;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        bool flag43 = ri.vehicle && !ri.vehicle.isDead && PAsset.vehicleDamage > 1f;
                        bool flag44 = flag43;
                        if (flag44)
                        {
                            bool flag45 = ri.vehicle.asset != null && (ri.vehicle.asset.isVulnerable || PAsset.isInvulnerable);
                            bool flag46 = flag45;
                            if (flag46)
                            {
                                bool flag47 = eplayerHit == EPlayerHit.NONE;
                                bool flag48 = flag47;
                                if (flag48)
                                {
                                    eplayerHit = EPlayerHit.BUILD;
                                }
                            }
                        }
                    }
                }
                result = eplayerHit;
            }
            return(result);
        }
Ejemplo n.º 9
0
        public void OV_ballistics()
        {
            Useable PlayerUse = OptimizationVariables.MainPlayer.equipment.useable;
            
            if (Provider.isServer)
            {
                OverrideUtilities.CallOriginal(PlayerUse);
                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 PAsset = (ItemGunAsset)OptimizationVariables.MainPlayer.equipment.asset;
            PlayerLook Look = OptimizationVariables.MainPlayer.look;

            if (PAsset.projectile != null)
                return;

            List<BulletInfo> Bullets = (List<BulletInfo>)BulletsField.GetValue(PlayerUse);

            if (Bullets.Count == 0)
                return;

            RaycastInfo ri = null;
            
            if (RaycastOptions.Enabled && (!RaycastOptions.HoldKey || HotkeyUtilities.IsHotkeyHeld("_SilentAimKey")))
                RaycastUtilities.GenerateRaycast(out ri);
            
            if (Provider.modeConfigData.Gameplay.Ballistics)
            {
                if (ri == null)
                {
                    if (WeaponOptions.NoDrop && ri == null)
                    {
                        for (int i = 0; i < Bullets.Count; i++)
                        {
                            BulletInfo bulletInfo = Bullets[i];
                            Ray ray = new Ray(bulletInfo.pos, bulletInfo.dir);
                            RaycastInfo rayInfo =
                                DamageTool.raycast(ray, PAsset.ballisticTravel, RayMasks.DAMAGE_CLIENT);

                            if (IsRaycastInvalid(rayInfo))
                                bulletInfo.pos += bulletInfo.dir * PAsset.ballisticTravel;

                            else
                            {
                                EPlayerHit playerHit = CalcHitMarker(PAsset, ref rayInfo);
                                PlayerUI.hitmark(0, Vector3.zero, false, playerHit);
                                OptimizationVariables.MainPlayer.input.sendRaycast(rayInfo);
                                bulletInfo.steps = 254;
                            }
                        }

                        for (int i = Bullets.Count - 1; i >= 0; i--)
                        {
                            BulletInfo bulletInfo = Bullets[i];
                            bulletInfo.steps += 1;

                            if (bulletInfo.steps >= PAsset.ballisticSteps)
                                Bullets.RemoveAt(i);
                        }

                        return;
                    }

                    if (ri == null)
                    {
                        OverrideUtilities.CallOriginal(PlayerUse);
                        return;
                    }
                }
                for (int i = 0; i < Bullets.Count; i++)
                {
                    BulletInfo bulletInfo = Bullets[i];
                    double distance = VectorUtilities.GetDistance(OptimizationVariables.MainPlayer.transform.position, ri.point);

                    if (bulletInfo.steps * PAsset.ballisticTravel < distance)
                        continue;

                    EPlayerHit eplayerhit = CalcHitMarker(PAsset, ref ri);
                    PlayerUI.hitmark(0, Vector3.zero, false, eplayerhit);
                    OptimizationVariables.MainPlayer.input.sendRaycast(ri);
                    bulletInfo.steps = 254;
                }


                for (int k = Bullets.Count - 1; k >= 0; k--)
                {
                    BulletInfo bulletInfo = Bullets[k];
                    bulletInfo.steps += 1;
                    if (bulletInfo.steps >= PAsset.ballisticSteps)
                        Bullets.RemoveAt(k);
                }
            }
            else
            {
                if (ri != null)
                {
                    for (int i = 0; i < Bullets.Count; i++)
                    {
                        EPlayerHit eplayerhit = CalcHitMarker(PAsset, ref ri);
                        PlayerUI.hitmark(0, Vector3.zero, false, eplayerhit);
                        OptimizationVariables.MainPlayer.input.sendRaycast(ri);
                    }
                    
                    Bullets.Clear();
                }
                else
                    OverrideUtilities.CallOriginal(PlayerUse);
            }
        }