예제 #1
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            UnturnedPlayer player      = (UnturnedPlayer)caller;
            Ray            ray         = new Ray(player.Player.look.aim.position, player.Player.look.aim.forward);
            RaycastInfo    raycastInfo = DamageTool.raycast(ray, 10f, RayMasks.VEHICLE);

            if (raycastInfo.vehicle != null)
            {
                bool getPInfo = false;
                if (WreckingBall.Instance.Configuration.Instance.EnablePlayerInfo && WreckingBall.isPlayerInfoLibPresent && WreckingBall.isPlayerInfoLibLoaded)
                {
                    getPInfo = true;
                }
                if (!raycastInfo.vehicle.isDead)
                {
                    bool showSignOwner = false;
                    showSignOwner = DestructionProcessing.HasFlaggedElement(raycastInfo.transform, out ulong signOwner);
                    string signmsg   = getPInfo ? WreckingBall.Instance.PInfoGenerateMessage(signOwner) : signOwner.ToString();
                    string lockedmsg = raycastInfo.vehicle.isLocked ? (!getPInfo || raycastInfo.vehicle.lockedOwner == CSteamID.Nil ? raycastInfo.vehicle.lockedOwner.ToString() : WreckingBall.Instance.PInfoGenerateMessage((ulong)raycastInfo.vehicle.lockedOwner)) : "N/A";
                    string msg       = string.Format("Dropping elements off of vehicle: {0}({1}), InstanceID: {2}, Locked Owner: {3}, SignOwner {4}.", raycastInfo.vehicle.asset.name, raycastInfo.vehicle.id, raycastInfo.vehicle.instanceID,
                                                     lockedmsg,
                                                     showSignOwner ? signmsg : "N/A");
                    UnturnedChat.Say(caller, msg);
                    Logger.Log(msg);
                    WreckingBall.Instance.VehicleElementDrop(raycastInfo.vehicle, true, raycastInfo.transform);
                }
            }
            else
            {
                UnturnedChat.Say(caller, "Couldn't find a vehicle in the direction you're looking, or too far away, within 10 units.");
            }
        }
예제 #2
0
        protected override async UniTask OnExecuteAsync()
        {
            if (Context.Parameters.Length != 0)
            {
                throw new CommandWrongUsageException(Context);
            }

            UnturnedUser uPlayer        = (UnturnedUser)Context.Actor;
            var          currentVehicle = uPlayer.Player.Player.movement.getVehicle();

            if (currentVehicle != null)
            {
                await UniTask.SwitchToMainThread();

                RepairVehicle(currentVehicle);
                await uPlayer.PrintMessageAsync(m_StringLocalizer["repair:vehicle:current"]);
            }
            else
            {
                PlayerLook  look    = uPlayer.Player.Player.look;
                RaycastInfo raycast = DamageTool.raycast(new Ray(look.aim.position, look.aim.forward),
                                                         100f, RayMasks.VEHICLE);

                if (raycast.vehicle == null)
                {
                    throw new UserFriendlyException(m_StringLocalizer["repair:vehicle:none"]);
                }

                await UniTask.SwitchToMainThread();

                RepairVehicle(raycast.vehicle);
                await uPlayer.PrintMessageAsync(m_StringLocalizer["repair:vehicle:looking"]);
            }
        }
예제 #3
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            UnturnedPlayer player = (UnturnedPlayer)caller;

            if (command.Length == 0)
            {
                RaycastInfo rayinfo = DamageTool.raycast(new Ray(player.Player.look.aim.position, player.Player.look.aim.forward), 3f, RayMasks.PLAYER_INTERACT, player.Player);

                if (rayinfo.player == null)
                {
                    UnturnedChat.Say(player, $"{JailTimePlugin.Instance.Translate("handcuff.ray.player.not.found")}", Color.red);
                    return;
                }
                UnturnedPlayer toPlayer = UnturnedPlayer.FromPlayer(rayinfo.player);

                if (toPlayer.HasPermission(Permissions[0]))
                {
                    UnturnedChat.Say(player, $"{JailTimePlugin.Instance.Translate("handcuff.immune")}");
                    return;
                }

                // одеть наручники на игрока
                JailTimePlugin.Instance.Prison.HandcuffToPlayer(toPlayer.CSteamID);

                UnturnedChat.Say(toPlayer, $"{JailTimePlugin.Instance.Translate("handcuff.successful.to.player")}");
                UnturnedChat.Say(player, $"{JailTimePlugin.Instance.Translate("handcuff.successful", toPlayer.CharacterName)}");
            }

            UnturnedPlayer playerFromName = UnturnedPlayer.FromName(command[0]);

            if (command.Length == 1)
            {
                if (playerFromName == null)
                {
                    UnturnedChat.Say(player, $"{JailTimePlugin.Instance.Translate("handcuff.player.not.found", command[0])}", Color.red);
                    return;
                }

                if (playerFromName.CSteamID == player.CSteamID)
                {
                    UnturnedChat.Say(player, $"{JailTimePlugin.Instance.Translate("handcuff.self")}", Color.red);
                    return;
                }

                if (playerFromName.HasPermission(Permissions[0]))
                {
                    UnturnedChat.Say(player, $"{JailTimePlugin.Instance.Translate("handcuff.immune")}", Color.red);
                    return;
                }

                // одеть наручники на игрока
                JailTimePlugin.Instance.Prison.HandcuffToPlayer(playerFromName.CSteamID);

                UnturnedChat.Say(player, $"{JailTimePlugin.Instance.Translate("handcuff.successful", playerFromName.CharacterName)}", Color.yellow);
                UnturnedChat.Say(playerFromName, $"{JailTimePlugin.Instance.Translate("handcuff.successful.to.player", playerFromName.CharacterName)}", Color.red);
            }
        }
예제 #4
0
        public static bool GetVehicleByLook(UnturnedPlayer player, float distance, out InteractableVehicle lookVehicle, out BarricadeRegion lookVehicleBarricadeRegion)
        {
            lookVehicle = null;
            lookVehicleBarricadeRegion = null;
            var raycastInfo = DamageTool.raycast(new Ray(player.Player.look.aim.position, player.Player.look.aim.forward), distance, RayMasks.VEHICLE);

            if (raycastInfo.vehicle == null)
            {
                return(false);
            }

            lookVehicle = raycastInfo.vehicle;
            lookVehicleBarricadeRegion = BarricadeManager.getRegionFromVehicle(lookVehicle);
            return(true);
        }
    public static void OV_FixedUpdate()
    {
        Player mainPlayer = OptimizationVariables.MainPlayer;

        bool punchSilentAim = MiscOptions.PunchSilentAim;

        if (punchSilentAim)
        {
            OV_DamageTool.OVType = OverrideType.PlayerHit;
        }
        RaycastInfo raycastInfo = DamageTool.raycast(new Ray(mainPlayer.look.aim.position, mainPlayer.look.aim.forward), 6f, RayMasks.DAMAGE_SERVER);

        OverrideUtilities.CallOriginal(null, new object[0]);
        List <PlayerInputPacket> clientsidePackets = ClientsidePackets;

        LastPacket = ((clientsidePackets != null) ? clientsidePackets.Last <PlayerInputPacket>() : null);
    }
        public void Execute(IRocketPlayer caller, string[] command)
        {
            var player      = (UnturnedPlayer)caller;
            var raycastInfo =
                DamageTool.raycast(new Ray(player.Player.look.aim.position, player.Player.look.aim.forward), 10f,
                                   RayMasks.VEHICLE);
            var baseClusteringPlugin = BaseClusteringPlugin.Instance;

            if (baseClusteringPlugin == null)
            {
                throw new NullReferenceException("BaseClusteringPlugin.Instance is null. Cannot execute command.");
            }

            if (raycastInfo.vehicle == null)
            {
                UnturnedChat.Say(caller, baseClusteringPlugin.Translate("no_vehicle_found"));
                return;
            }

            if (raycastInfo.vehicle.isDead)
            {
                UnturnedChat.Say(caller, baseClusteringPlugin.Translate("vehicle_dead"));
                return;
            }

            if (!BarricadeManager.tryGetPlant(raycastInfo.transform, out var x, out var y, out var plant,
                                              out var region))
            {
                UnturnedChat.Say(caller, baseClusteringPlugin.Translate("vehicle_no_plant"));
                return;
            }

            for (var i = region.barricades.Count - 1; i > 0; i--)
            {
                BarricadeManager.destroyBarricade(region, x, y, plant, (ushort)i);
            }

            UnturnedChat.Say(caller,
                             baseClusteringPlugin.Translate("vehicle_wreck",
                                                            raycastInfo.vehicle.asset.vehicleName ?? raycastInfo.vehicle.asset.name,
                                                            raycastInfo.vehicle.id, raycastInfo.vehicle.instanceID,
                                                            raycastInfo.vehicle.lockedOwner.ToString()));
        }
예제 #7
0
        public static void OV_FixedUpdate(PlayerInput instance)
        {
            if (instance.player != OptimizationVariables.MainPlayer)
            {
                return;
            }

            Player player = OptimizationVariables.MainPlayer;

            if (Step == -1)
            {
                Rate = 4;
                Run  = false;
            }

            else if (Step == 1 && !Run)
            {
                Run = true;
            }

            else if (Step == 2)
            {
                /*
                 * Buffer++;
                 * if (Buffer > 3)
                 *      Buffer = 0;
                 *
                 * if (MiscOptions.TimeAcceleration == 1 && Buffer % 4 != 0)
                 *      return;
                 *
                 * if (MiscOptions.TimeAcceleration == 2 && Buffer % 2 != 0)
                 *      return;
                 */

                Run = false;

                switch (MiscOptions.TimeAcceleration)
                {
                case 1:
                    Rate = 4;
                    break;

                case 2:
                    Rate = 2;
                    break;

                case 4:
                    Rate = 1;
                    break;
                }
            }

            if (!Run && SequenceDiff <= 0)
            {
                Rate         = 4;
                SequenceDiff = 0;
                Step         = -1;

                Run = false;
            }

            Count++;

            if (Count % Rate == 0u)
            {
                if (Rate == 1)
                {
                    SequenceDiff--;
                }

                else if (Rate == 2 && Count % 4 == 0)
                {
                    SequenceDiff--;
                }

                if (Run)
                {
                    if (Time.realtimeSinceStartup - LastReal > 8)
                    {
                        LastReal = Time.realtimeSinceStartup;
                    }

                    else
                    {
                        SequenceDiff++;
                        return;
                    }
                }

                SetTick(instance, Time.realtimeSinceStartup);

                instance.keys[0] = player.movement.jump;
                instance.keys[1] = player.equipment.primary;

                // Phase between false and true every other tick to simulate rapid tapping of the mouse
                // (gunfire is simulated server-side from inputs)
                if (WeaponOptions.FastSemiAuto &&
                    player.equipment.useable is UseableGun gun &&
                    (GetFiremode(gun) == EFiremode.SEMI || GetFiremode(gun) == EFiremode.BURST) &&
                    player.equipment.primary)
                {
                    if (!clicking)
                    {
                        instance.keys[1] = true;
                        clicking         = true;
                    }
                    else
                    {
                        instance.keys[1] = false;
                        clicking         = false;
                    }
                }
                else
                {
                    clicking = false;
                }

                instance.keys[2] = player.equipment.secondary;
                instance.keys[3] = player.stance.crouch;
                instance.keys[4] = player.stance.prone;
                instance.keys[5] = player.stance.sprint;
                instance.keys[6] = player.animator.leanLeft;
                instance.keys[7] = player.animator.leanRight;
                instance.keys[8] = false;

                for (int i = 0; i < (int)ControlsSettings.NUM_PLUGIN_KEYS; i++)
                {
                    int num = instance.keys.Length - ControlsSettings.NUM_PLUGIN_KEYS + i;
                    instance.keys[num] = Input.GetKey(ControlsSettings.getPluginKeyCode(i));
                }

                Analog = (byte)(player.movement.horizontal << 4 | player.movement.vertical);

                player.life.simulate(instance.simulation);
                player.stance.simulate(instance.simulation, player.stance.crouch, player.stance.prone, player.stance.sprint);

                Pitch = player.look.pitch;
                Yaw   = player.look.yaw;

                player.movement.simulate(instance.simulation, 0, player.movement.horizontal - 1, player.movement.vertical - 1, player.look.look_x, player.look.look_y, player.movement.jump, player.stance.sprint, Vector3.zero, PlayerInput.RATE);

                ClientSequence++;

                PlayerInputPacket playerInputPacket;

                if (player.stance.stance == EPlayerStance.DRIVING)
                {
                    playerInputPacket = new DrivingPlayerInputPacket();
                }

                else
                {
                    playerInputPacket = new WalkingPlayerInputPacket();
                }

                playerInputPacket.sequence         = ClientSequence;
                playerInputPacket.recov            = instance.recov;
                playerInputPacket.clientsideInputs = new List <RaycastInfo>();

                if (MiscOptions.PunchSilentAim)
                {
                    OV_DamageTool.OVType = OverrideType.PlayerHit;
                }

                RaycastInfo raycast = DamageTool.raycast(new Ray(player.look.aim.position, player.look.aim.forward), 6f,
                                                         RayMasks.DAMAGE_SERVER);

                OV_DamageTool.OVType = OverrideType.None;

                if (MiscOptions.PunchAura && !player.equipment.isSelected && !(raycast.player == null && raycast.vehicle == null && raycast.zombie == null && raycast.animal == null))
                {
                    if (Count % 6 == 0)
                    {
                        playerInputPacket.clientsideInputs.Add(raycast);
                        instance.keys[1] = true;
                    }

                    else
                    {
                        instance.keys[1] = false;
                    }
                }

                ushort num2 = 0;

                for (byte b = 0; b < instance.keys.Length; b++)
                {
                    if (instance.keys[b])
                    {
                        num2 |= (ushort)(1 << b);
                    }
                }

                playerInputPacket.keys = num2;

                if (playerInputPacket is DrivingPlayerInputPacket drivingPlayerInputPacket)
                {
                    InteractableVehicle vehicle = player.movement.getVehicle();
                    if (vehicle != null)
                    {
                        Transform transform = vehicle.transform;
                        drivingPlayerInputPacket.position = vehicle.asset.engine == EEngine.TRAIN
                                                    ? new Vector3(vehicle.roadPosition, 0f, 0f)
                                                    : transform.position;

                        drivingPlayerInputPacket.angle_x =
                            MeasurementTool.angleToByte2(transform.rotation.eulerAngles.x);
                        drivingPlayerInputPacket.angle_y =
                            MeasurementTool.angleToByte2(transform.rotation.eulerAngles.y);
                        drivingPlayerInputPacket.angle_z =
                            MeasurementTool.angleToByte2(transform.rotation.eulerAngles.z);
                        drivingPlayerInputPacket.speed        = (byte)(Mathf.Clamp(vehicle.speed, -100f, 100f) + 128f);
                        drivingPlayerInputPacket.physicsSpeed =
                            (byte)(Mathf.Clamp(vehicle.physicsSpeed, -100f, 100f) + 128f);
                        drivingPlayerInputPacket.turn = (byte)(vehicle.turn + 1);
                    }
                }
                else
                {
                    WalkingPlayerInputPacket walkingPlayerInputPacket = playerInputPacket as WalkingPlayerInputPacket;

                    walkingPlayerInputPacket.analog = Analog;

                    walkingPlayerInputPacket.position = instance.transform.localPosition;

                    var inputX = GetInputX(OptimizationVariables.MainPlayer.movement);
                    var inputY = GetInputY(OptimizationVariables.MainPlayer.movement);

                    if (MiscOptions.Spinbot && spinStances.Contains(OptimizationVariables.MainPlayer.stance.stance))
                    {
                        // Ghetto movement fix
                        if (inputX == 0 && inputY == 0)
                        {
                            walkingPlayerInputPacket.yaw = MiscOptions.StaticSpinbotYaw ? MiscOptions.SpinbotYaw : NextSpinbotYaw(MiscOptions.SpinbotYaw);
                        }
                        else
                        {
                            // use walkSpin bool to phase between actual angle and inverted angle to spin while walking
                            // and have fixed movement; only way we can do it with the d-pad like controls.
                            if (!walkSpin)
                            {
                                // Flip x/y input to account for reversed yaw (where intended movement direction will be reversed)
                                inputY *= -1;
                                inputX *= -1;
                                // Reverse yaw to spin while moving
                                walkingPlayerInputPacket.yaw    = ReverseAngle180(Yaw);
                                walkingPlayerInputPacket.analog = (byte)(((byte)(inputX + 1)) << 4 | (byte)(inputY + 1));
                                walkSpin = true;
                            }
                            else
                            {
                                walkingPlayerInputPacket.yaw = Yaw;
                                walkSpin = false;
                            }
                        }

                        walkingPlayerInputPacket.pitch = MiscOptions.StaticSpinbotPitch ? MiscOptions.SpinbotPitch : NextSpinbotPitch(MiscOptions.SpinbotPitch);
                    }
                    else
                    {
                        walkingPlayerInputPacket.yaw   = Yaw;
                        walkingPlayerInputPacket.pitch = Pitch;
                    }
                }

                Packets.Add(playerInputPacket);

                player.equipment.simulate(instance.simulation, instance.keys[1], player.equipment.secondary, player.stance.sprint);
                player.animator.simulate(instance.simulation, player.animator.leanLeft, player.animator.leanRight);

                SetSim(instance, GetSim(instance) + 1);
            }
예제 #8
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);
        }
        public static bool Prefix(InteractableSentry __instance)
        {
            RocketPlayer ownerPlayer = new RocketPlayer(__instance.owner.ToString());

            bool            hasWeapon    = (bool)hasWeaponField.GetValue(__instance);
            bool            isFiring     = (bool)isFiringField.GetValue(__instance);
            bool            isAiming     = (bool)isAimingField.GetValue(__instance);
            float           lastScan     = (float)lastScanField.GetValue(__instance);
            float           lastFire     = (float)lastFireField.GetValue(__instance);
            float           fireTime     = (float)fireTimeField.GetValue(__instance);
            float           lastAim      = (float)lastAimField.GetValue(__instance);
            ItemWeaponAsset displayAsset = displayAssetField.GetValue(__instance) as ItemWeaponAsset;
            Attachments     attachments  = attachmentsField.GetValue(__instance) as Attachments;

            bool interact = (bool)interactField.GetValue(__instance);

            var playersInRadius = (List <Player>)playersInRadiusField.GetValue(null);
            var zombiesInRadius = (List <Zombie>)zombiesInRadiusField.GetValue(null);
            var animalsInRadius = (List <Animal>)animalsInRadiusField.GetValue(null);

            var targetPlayer = targetPlayerField.GetValue(__instance) as Player;
            var targetZombie = targetZombieField.GetValue(__instance) as Zombie;
            var targetAnimal = targetAnimalField.GetValue(__instance) as Animal;
            var aimTransform = aimTransformField.GetValue(__instance) as Transform;

            if (__instance.isPowered)
            {
                Vector3 vector3_1 = __instance.transform.position + new Vector3(0.0f, 0.65f, 0.0f);
                Vector3 vector3_2;
                if ((double)Time.realtimeSinceStartup - (double)lastScan > 0.100000001490116)
                {
                    lastScanField.SetValue(__instance, Time.realtimeSinceStartup);

                    float a = 48f;
                    if (hasWeapon)
                    {
                        a = Mathf.Min(a, ((ItemWeaponAsset)displayAsset).range);
                    }
                    float  sqrRadius = a * a;
                    float  num       = sqrRadius;
                    Player player    = (Player)null;
                    Zombie zombie    = (Zombie)null;
                    Animal animal    = (Animal)null;
                    if (Provider.isPvP)
                    {
                        playersInRadius.Clear();
                        PlayerTool.getPlayersInRadius(vector3_1, sqrRadius, playersInRadius);
                        for (int index = 0; index < playersInRadius.Count; ++index)
                        {
                            Player playersInRadiu = playersInRadius[index];

                            var currentRocketPlayer = new RocketPlayer(playersInRadiu.channel.owner.playerID.steamID.ToString());

                            if (currentRocketPlayer.HasPermission(GodPermission))
                            {
                                continue;
                            }

                            if (!(playersInRadiu.channel.owner.playerID.steamID == __instance.owner) && !playersInRadiu.quests.isMemberOfGroup(__instance.group) && (!playersInRadiu.life.isDead && playersInRadiu.animator.gesture != EPlayerGesture.ARREST_START) && ((!playersInRadiu.movement.isSafe || !playersInRadiu.movement.isSafeInfo.noWeapons) && playersInRadiu.movement.canAddSimulationResultsToUpdates) && (!((UnityEngine.Object)player != (UnityEngine.Object)null) || playersInRadiu.animator.gesture != EPlayerGesture.SURRENDER_START) && (__instance.sentryMode != ESentryMode.FRIENDLY || (double)Time.realtimeSinceStartup - (double)playersInRadiu.equipment.lastPunching < 2.0 || playersInRadiu.equipment.isSelected && playersInRadiu.equipment.asset != null && playersInRadiu.equipment.asset.shouldFriendlySentryTargetUser))
                            {
                                vector3_2 = playersInRadiu.look.aim.position - vector3_1;
                                float sqrMagnitude = vector3_2.sqrMagnitude;
                                if ((double)sqrMagnitude <= (double)num)
                                {
                                    Vector3 vector3_3 = playersInRadiu.look.aim.position - vector3_1;
                                    float   magnitude = vector3_3.magnitude;
                                    Vector3 vector3_4 = vector3_3 / magnitude;
                                    if (!((UnityEngine.Object)playersInRadiu != (UnityEngine.Object)targetPlayer) || (double)Vector3.Dot(vector3_4, aimTransform.forward) >= 0.5)
                                    {
                                        if ((double)magnitude > 0.025000000372529)
                                        {
                                            RaycastHit hit;
                                            PhysicsUtility.raycast(new Ray(vector3_1, vector3_4), out hit, magnitude - 0.025f, RayMasks.BLOCK_SENTRY, QueryTriggerInteraction.UseGlobal);
                                            if (!((UnityEngine.Object)hit.transform != (UnityEngine.Object)null) || !((UnityEngine.Object)hit.transform != (UnityEngine.Object)__instance.transform))
                                            {
                                                PhysicsUtility.raycast(new Ray(vector3_1 + vector3_4 * (magnitude - 0.025f), -vector3_4), out hit, magnitude - 0.025f, RayMasks.DAMAGE_SERVER, QueryTriggerInteraction.UseGlobal);
                                                if ((UnityEngine.Object)hit.transform != (UnityEngine.Object)null && (UnityEngine.Object)hit.transform != (UnityEngine.Object)__instance.transform)
                                                {
                                                    continue;
                                                }
                                            }
                                            else
                                            {
                                                continue;
                                            }
                                        }
                                        num    = sqrMagnitude;
                                        player = playersInRadiu;
                                    }
                                }
                            }
                        }
                    }
                    zombiesInRadius.Clear();
                    ZombieManager.getZombiesInRadius(vector3_1, sqrRadius, zombiesInRadius);
                    for (int index = 0; index < zombiesInRadius.Count; ++index)
                    {
                        Zombie zombiesInRadiu = zombiesInRadius[index];
                        if (!zombiesInRadiu.isDead && zombiesInRadiu.isHunting)
                        {
                            Vector3 position = zombiesInRadiu.transform.position;
                            switch (zombiesInRadiu.speciality)
                            {
                            case EZombieSpeciality.NORMAL:
                                position += new Vector3(0.0f, 1.75f, 0.0f);
                                break;

                            case EZombieSpeciality.MEGA:
                                position += new Vector3(0.0f, 2.625f, 0.0f);
                                break;

                            case EZombieSpeciality.CRAWLER:
                                position += new Vector3(0.0f, 0.25f, 0.0f);
                                break;

                            case EZombieSpeciality.SPRINTER:
                                position += new Vector3(0.0f, 1f, 0.0f);
                                break;
                            }
                            vector3_2 = position - vector3_1;
                            float sqrMagnitude = vector3_2.sqrMagnitude;
                            if ((double)sqrMagnitude <= (double)num)
                            {
                                Vector3 vector3_3 = position - vector3_1;
                                float   magnitude = vector3_3.magnitude;
                                Vector3 vector3_4 = vector3_3 / magnitude;
                                if (!((UnityEngine.Object)zombiesInRadiu != (UnityEngine.Object)targetZombie) || (double)Vector3.Dot(vector3_4, aimTransform.forward) >= 0.5)
                                {
                                    if ((double)magnitude > 0.025000000372529)
                                    {
                                        RaycastHit hit;
                                        PhysicsUtility.raycast(new Ray(vector3_1, vector3_4), out hit, magnitude - 0.025f, RayMasks.BLOCK_SENTRY, QueryTriggerInteraction.UseGlobal);
                                        if (!((UnityEngine.Object)hit.transform != (UnityEngine.Object)null) || !((UnityEngine.Object)hit.transform != (UnityEngine.Object)__instance.transform))
                                        {
                                            PhysicsUtility.raycast(new Ray(vector3_1 + vector3_4 * (magnitude - 0.025f), -vector3_4), out hit, magnitude - 0.025f, RayMasks.DAMAGE_SERVER, QueryTriggerInteraction.UseGlobal);
                                            if ((UnityEngine.Object)hit.transform != (UnityEngine.Object)null && (UnityEngine.Object)hit.transform != (UnityEngine.Object)__instance.transform)
                                            {
                                                continue;
                                            }
                                        }
                                        else
                                        {
                                            continue;
                                        }
                                    }
                                    num    = sqrMagnitude;
                                    player = (Player)null;
                                    zombie = zombiesInRadiu;
                                }
                            }
                        }
                    }
                    animalsInRadius.Clear();
                    AnimalManager.getAnimalsInRadius(vector3_1, sqrRadius, animalsInRadius);
                    for (int index = 0; index < animalsInRadius.Count; ++index)
                    {
                        Animal animalsInRadiu = animalsInRadius[index];
                        if (!animalsInRadiu.isDead)
                        {
                            Vector3 position = animalsInRadiu.transform.position;
                            vector3_2 = position - vector3_1;
                            float sqrMagnitude = vector3_2.sqrMagnitude;
                            if ((double)sqrMagnitude <= (double)num)
                            {
                                Vector3 vector3_3 = position - vector3_1;
                                float   magnitude = vector3_3.magnitude;
                                Vector3 vector3_4 = vector3_3 / magnitude;
                                if (!((UnityEngine.Object)animalsInRadiu != (UnityEngine.Object)targetAnimal) || (double)Vector3.Dot(vector3_4, aimTransform.forward) >= 0.5)
                                {
                                    if ((double)magnitude > 0.025000000372529)
                                    {
                                        RaycastHit hit;
                                        PhysicsUtility.raycast(new Ray(vector3_1, vector3_4), out hit, magnitude - 0.025f, RayMasks.BLOCK_SENTRY, QueryTriggerInteraction.UseGlobal);
                                        if (!((UnityEngine.Object)hit.transform != (UnityEngine.Object)null) || !((UnityEngine.Object)hit.transform != (UnityEngine.Object)__instance.transform))
                                        {
                                            PhysicsUtility.raycast(new Ray(vector3_1 + vector3_4 * (magnitude - 0.025f), -vector3_4), out hit, magnitude - 0.025f, RayMasks.DAMAGE_SERVER, QueryTriggerInteraction.UseGlobal);
                                            if ((UnityEngine.Object)hit.transform != (UnityEngine.Object)null && (UnityEngine.Object)hit.transform != (UnityEngine.Object)__instance.transform)
                                            {
                                                continue;
                                            }
                                        }
                                        else
                                        {
                                            continue;
                                        }
                                    }
                                    num    = sqrMagnitude;
                                    player = (Player)null;
                                    zombie = (Zombie)null;
                                    animal = animalsInRadiu;
                                }
                            }
                        }
                    }
                    if ((UnityEngine.Object)player != (UnityEngine.Object)targetPlayer || (UnityEngine.Object)zombie != (UnityEngine.Object)targetZombie || (UnityEngine.Object)animal != (UnityEngine.Object)targetAnimal)
                    {
                        targetPlayerField.SetValue(__instance, player);
                        targetZombieField.SetValue(__instance, zombie);
                        targetAnimalField.SetValue(__instance, animal);
                        lastFireField.SetValue(__instance, Time.realtimeSinceStartup + 0.1f);
                    }
                }
                if ((UnityEngine.Object)targetPlayer != (UnityEngine.Object)null)
                {
                    switch (__instance.sentryMode)
                    {
                    case ESentryMode.NEUTRAL:
                    case ESentryMode.FRIENDLY:
                        isFiringField.SetValue(__instance, targetPlayer.animator.gesture != EPlayerGesture.SURRENDER_START);
                        break;

                    case ESentryMode.HOSTILE:
                        isFiringField.SetValue(__instance, true);
                        break;
                    }
                    isAimingField.SetValue(__instance, true);
                }
                else if ((UnityEngine.Object)targetZombie != (UnityEngine.Object)null)
                {
                    isFiringField.SetValue(__instance, true);
                    isAimingField.SetValue(__instance, true);
                }
                else if ((UnityEngine.Object)targetAnimal != (UnityEngine.Object)null)
                {
                    switch (__instance.sentryMode)
                    {
                    case ESentryMode.NEUTRAL:
                    case ESentryMode.FRIENDLY:
                        isFiringField.SetValue(__instance, targetAnimal.isHunting);
                        break;

                    case ESentryMode.HOSTILE:
                        isFiringField.SetValue(__instance, true);
                        break;
                    }
                    isAimingField.SetValue(__instance, true);
                }
                else
                {
                    isFiringField.SetValue(__instance, false);
                    isAimingField.SetValue(__instance, false);
                }
                if (isAiming && (double)Time.realtimeSinceStartup - (double)lastAim > (double)Provider.UPDATE_TIME)
                {
                    lastAimField.SetValue(__instance, Time.realtimeSinceStartup);
                    Transform transform = (Transform)null;
                    Vector3   vector3_3 = Vector3.zero;
                    if ((UnityEngine.Object)targetPlayer != (UnityEngine.Object)null)
                    {
                        transform = targetPlayer.transform;
                        vector3_3 = targetPlayer.look.aim.position;
                    }
                    else if ((UnityEngine.Object)targetZombie != (UnityEngine.Object)null)
                    {
                        transform = targetZombie.transform;
                        vector3_3 = targetZombie.transform.position;
                        switch (targetZombie.speciality)
                        {
                        case EZombieSpeciality.NORMAL:
                            vector3_3 += new Vector3(0.0f, 1.75f, 0.0f);
                            break;

                        case EZombieSpeciality.MEGA:
                            vector3_3 += new Vector3(0.0f, 2.625f, 0.0f);
                            break;

                        case EZombieSpeciality.CRAWLER:
                            vector3_3 += new Vector3(0.0f, 0.25f, 0.0f);
                            break;

                        case EZombieSpeciality.SPRINTER:
                            vector3_3 += new Vector3(0.0f, 1f, 0.0f);
                            break;
                        }
                    }
                    else if ((UnityEngine.Object)targetAnimal != (UnityEngine.Object)null)
                    {
                        transform = targetAnimal.transform;
                        vector3_3 = targetAnimal.transform.position + Vector3.up;
                    }
                    if ((UnityEngine.Object)transform != (UnityEngine.Object)null)
                    {
                        float  yaw = Mathf.Atan2(vector3_3.x - vector3_1.x, vector3_3.z - vector3_1.z) * 57.29578f;
                        double num = (double)vector3_3.y - (double)vector3_1.y;
                        vector3_2 = vector3_3 - vector3_1;
                        double magnitude = (double)vector3_2.magnitude;
                        float  pitch     = Mathf.Sin((float)(num / magnitude)) * 57.29578f;
                        BarricadeManager.sendAlertSentry(__instance.transform, yaw, pitch);
                    }
                }
                if (isFiring && hasWeapon && (__instance.displayItem.state[10] > (byte)0 && !__instance.isOpen) && (double)Time.realtimeSinceStartup - (double)lastFire > (double)fireTime)
                {
                    lastFireField.SetValue(__instance, lastFire + fireTime);
                    if ((double)Time.realtimeSinceStartup - (double)lastFire > (double)fireTime)
                    {
                        lastFire = Time.realtimeSinceStartup;
                    }
                    float num1 = (float)__instance.displayItem.quality / 100f;
                    if (attachments.magazineAsset == null)
                    {
                        return(false);
                    }

                    if (!ownerPlayer.HasPermission(IgnoreAmmoPermission))
                    {
                        Console.WriteLine("Ammo reduction");
                        if ((__instance.sentryAsset.infiniteAmmo ? 1 : (((ItemGunAsset)displayAsset).infiniteAmmo ? 1 : 0)) == 0)
                        {
                            --__instance.displayItem.state[10];
                        }

                        if (!__instance.sentryAsset.infiniteQuality && Provider.modeConfigData.Items.Has_Durability && (__instance.displayItem.quality > (byte)0 && (double)UnityEngine.Random.value < (double)((ItemWeaponAsset)displayAsset).durability))
                        {
                            if ((int)__instance.displayItem.quality > (int)((ItemWeaponAsset)displayAsset).wear)
                            {
                                __instance.displayItem.quality -= ((ItemWeaponAsset)displayAsset).wear;
                            }
                            else
                            {
                                __instance.displayItem.quality = (byte)0;
                            }
                        }
                    }
                    if (attachments.barrelAsset == null || !attachments.barrelAsset.isSilenced || __instance.displayItem.state[16] == (byte)0)
                    {
                        AlertTool.alert(__instance.transform.position, 48f);
                    }

                    float num2 = ((ItemGunAsset)displayAsset).spreadAim * ((double)num1 < 0.5 ? (float)(1.0 + (1.0 - (double)num1 * 2.0)) : 1f);
                    if (attachments.tacticalAsset != null && interact)
                    {
                        num2 *= attachments.tacticalAsset.spread;
                    }
                    if (attachments.gripAsset != null)
                    {
                        num2 *= attachments.gripAsset.spread;
                    }
                    if (attachments.barrelAsset != null)
                    {
                        num2 *= attachments.barrelAsset.spread;
                    }
                    if (attachments.magazineAsset != null)
                    {
                        num2 *= attachments.magazineAsset.spread;
                    }


                    if ((UnityEngine.Object)((ItemGunAsset)displayAsset).projectile == (UnityEngine.Object)null)
                    {
                        BarricadeManager.sendShootSentry(__instance.transform);
                        byte pellets = attachments.magazineAsset.pellets;
                        for (byte index1 = 0; (int)index1 < (int)pellets; ++index1)
                        {
                            EPlayerKill kill      = EPlayerKill.NONE;
                            uint        xp        = 0;
                            float       times     = (float)(1.0 * ((double)num1 < 0.5 ? 0.5 + (double)num1 : 1.0));
                            Transform   transform = (Transform)null;
                            float       num3      = 0.0f;
                            if ((UnityEngine.Object)targetPlayer != (UnityEngine.Object)null)
                            {
                                transform = targetPlayer.transform;
                            }
                            else if ((UnityEngine.Object)targetZombie != (UnityEngine.Object)null)
                            {
                                transform = __instance.transform;
                            }
                            else if ((UnityEngine.Object)targetAnimal != (UnityEngine.Object)null)
                            {
                                transform = targetAnimal.transform;
                            }
                            if ((UnityEngine.Object)transform != (UnityEngine.Object)null)
                            {
                                vector3_2 = transform.position - __instance.transform.position;
                                num3      = vector3_2.magnitude;
                            }
                            float num4 = (1f - num3 / ((ItemWeaponAsset)displayAsset).range) * (1f - ((ItemGunAsset)displayAsset).spreadHip) * 0.75f;
                            if ((UnityEngine.Object)transform == (UnityEngine.Object)null || (double)UnityEngine.Random.value > (double)num4)
                            {
                                Vector3 forward = aimTransform.forward;
                                forward += aimTransform.right * UnityEngine.Random.Range(-((ItemGunAsset)displayAsset).spreadHip, ((ItemGunAsset)displayAsset).spreadHip) * num2;
                                forward += aimTransform.up * UnityEngine.Random.Range(-((ItemGunAsset)displayAsset).spreadHip, ((ItemGunAsset)displayAsset).spreadHip) * num2;
                                forward.Normalize();
                                RaycastInfo raycastInfo = DamageTool.raycast(new Ray(aimTransform.position, forward), ((ItemWeaponAsset)displayAsset).range, RayMasks.DAMAGE_SERVER);
                                if (!((UnityEngine.Object)raycastInfo.transform == (UnityEngine.Object)null))
                                {
                                    DamageTool.impact(raycastInfo.point, raycastInfo.normal, raycastInfo.material, (UnityEngine.Object)raycastInfo.vehicle != (UnityEngine.Object)null || raycastInfo.transform.CompareTag("Barricade") || raycastInfo.transform.CompareTag("Structure") || raycastInfo.transform.CompareTag("Resource"));
                                    if ((UnityEngine.Object)raycastInfo.vehicle != (UnityEngine.Object)null)
                                    {
                                        DamageTool.damage(raycastInfo.vehicle, false, Vector3.zero, false, ((ItemWeaponAsset)displayAsset).vehicleDamage, times, true, out kill, new CSteamID(), EDamageOrigin.Sentry);
                                    }
                                    else if ((UnityEngine.Object)raycastInfo.transform != (UnityEngine.Object)null)
                                    {
                                        if (raycastInfo.transform.CompareTag("Barricade"))
                                        {
                                            ushort result;
                                            if (ushort.TryParse(raycastInfo.transform.name, NumberStyles.Any, (IFormatProvider)CultureInfo.InvariantCulture, out result))
                                            {
                                                ItemBarricadeAsset itemBarricadeAsset = (ItemBarricadeAsset)Assets.find(EAssetType.ITEM, result);
                                                if (itemBarricadeAsset != null && (itemBarricadeAsset.isVulnerable || ((ItemWeaponAsset)displayAsset).isInvulnerable))
                                                {
                                                    DamageTool.damage(raycastInfo.transform, false, ((ItemWeaponAsset)displayAsset).barricadeDamage, times, out kill, new CSteamID(), EDamageOrigin.Sentry);
                                                }
                                            }
                                        }
                                        else if (raycastInfo.transform.CompareTag("Structure"))
                                        {
                                            ushort result;
                                            if (ushort.TryParse(raycastInfo.transform.name, NumberStyles.Any, (IFormatProvider)CultureInfo.InvariantCulture, out result))
                                            {
                                                ItemStructureAsset itemStructureAsset = (ItemStructureAsset)Assets.find(EAssetType.ITEM, result);
                                                if (itemStructureAsset != null && (itemStructureAsset.isVulnerable || ((ItemWeaponAsset)displayAsset).isInvulnerable))
                                                {
                                                    DamageTool.damage(raycastInfo.transform, false, raycastInfo.direction * Mathf.Ceil((float)attachments.magazineAsset.pellets / 2f), ((ItemWeaponAsset)displayAsset).structureDamage, times, out kill, new CSteamID(), EDamageOrigin.Sentry);
                                                }
                                            }
                                        }
                                        else if (raycastInfo.transform.CompareTag("Resource"))
                                        {
                                            byte   x;
                                            byte   y;
                                            ushort index2;
                                            if (ResourceManager.tryGetRegion(raycastInfo.transform, out x, out y, out index2))
                                            {
                                                ResourceSpawnpoint resourceSpawnpoint = ResourceManager.getResourceSpawnpoint(x, y, index2);
                                                if (resourceSpawnpoint != null && !resourceSpawnpoint.isDead && (int)resourceSpawnpoint.asset.bladeID == (int)((ItemWeaponAsset)displayAsset).bladeID)
                                                {
                                                    DamageTool.damage(raycastInfo.transform, raycastInfo.direction * Mathf.Ceil((float)attachments.magazineAsset.pellets / 2f), ((ItemWeaponAsset)displayAsset).resourceDamage, times, 1f, out kill, out xp, new CSteamID(), EDamageOrigin.Sentry);
                                                }
                                            }
                                        }
                                        else if (raycastInfo.section < byte.MaxValue)
                                        {
                                            InteractableObjectRubble componentInParent = raycastInfo.transform.GetComponentInParent <InteractableObjectRubble>();
                                            if ((UnityEngine.Object)componentInParent != (UnityEngine.Object)null && !componentInParent.isSectionDead(raycastInfo.section) && (componentInParent.asset.rubbleIsVulnerable || ((ItemWeaponAsset)displayAsset).isInvulnerable))
                                            {
                                                DamageTool.damage(componentInParent.transform, raycastInfo.direction, raycastInfo.section, ((ItemWeaponAsset)displayAsset).objectDamage, times, out kill, out xp, new CSteamID(), EDamageOrigin.Sentry);
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                Vector3 point = Vector3.zero;
                                if ((UnityEngine.Object)targetPlayer != (UnityEngine.Object)null)
                                {
                                    point = targetPlayer.look.aim.position;
                                }
                                else if ((UnityEngine.Object)targetZombie != (UnityEngine.Object)null)
                                {
                                    point = targetZombie.transform.position;
                                    switch (targetZombie.speciality)
                                    {
                                    case EZombieSpeciality.NORMAL:
                                        point += new Vector3(0.0f, 1.75f, 0.0f);
                                        break;

                                    case EZombieSpeciality.MEGA:
                                        point += new Vector3(0.0f, 2.625f, 0.0f);
                                        break;

                                    case EZombieSpeciality.CRAWLER:
                                        point += new Vector3(0.0f, 0.25f, 0.0f);
                                        break;

                                    case EZombieSpeciality.SPRINTER:
                                        point += new Vector3(0.0f, 1f, 0.0f);
                                        break;
                                    }
                                }
                                else if ((UnityEngine.Object)targetAnimal != (UnityEngine.Object)null)
                                {
                                    point = targetAnimal.transform.position + Vector3.up;
                                }
                                DamageTool.impact(point, -aimTransform.forward, EPhysicsMaterial.FLESH_DYNAMIC, true);
                                Vector3 direction = aimTransform.forward * Mathf.Ceil((float)attachments.magazineAsset.pellets / 2f);
                                if ((UnityEngine.Object)targetPlayer != (UnityEngine.Object)null)
                                {
                                    DamageTool.damage(targetPlayer, EDeathCause.SENTRY, ELimb.SPINE, __instance.owner, direction, (IDamageMultiplier)((ItemWeaponAsset)displayAsset).playerDamageMultiplier, times, true, out kill, true, ERagdollEffect.NONE);
                                }
                                else if ((UnityEngine.Object)targetZombie != (UnityEngine.Object)null)
                                {
                                    IDamageMultiplier      damageMultiplier = ((ItemWeaponAsset)displayAsset).zombieOrPlayerDamageMultiplier;
                                    DamageZombieParameters parameters       = DamageZombieParameters.make(targetZombie, direction, damageMultiplier, ELimb.SPINE);
                                    parameters.times       = times;
                                    parameters.legacyArmor = true;
                                    parameters.instigator  = (object)__instance;
                                    DamageTool.damageZombie(parameters, out kill, out xp);
                                }
                                else if ((UnityEngine.Object)targetAnimal != (UnityEngine.Object)null)
                                {
                                    IDamageMultiplier      damageMultiplier = ((ItemWeaponAsset)displayAsset).animalOrPlayerDamageMultiplier;
                                    DamageAnimalParameters parameters       = DamageAnimalParameters.make(targetAnimal, direction, damageMultiplier, ELimb.SPINE);
                                    parameters.times      = times;
                                    parameters.instigator = (object)__instance;
                                    DamageTool.damageAnimal(parameters, out kill, out xp);
                                }
                            }
                        }
                    }
                    __instance.rebuildState();
                }
            }
            return(false);
        }
예제 #10
0
        public static RaycastInfo RaycastInfoVehicle(UnturnedPlayer player, float distance)
        {
            Ray ray = new Ray(player.Player.look.aim.position, player.Player.look.aim.forward);

            return(DamageTool.raycast(ray, distance, RayMasks.VEHICLE));
        }
예제 #11
0
        //Called every tick
        public void Update()
        {
            if (Global.AllOff || !Global.AimSettings.RageBot || !Global.AimEnabled)
            {
                return;
            }

            if (!Provider.isConnected)
            {
                return;
            }

            if (Provider.clients.Count < 1)
            {
                return;
            }

            //Is holding gun
            if (!(Player.player?.equipment?.asset is ItemGunAsset))
            {
                return;
            }

            SteamPlayer targ = null;
            Vector3     position = Camera.main.transform.position, forward = Camera.main.transform.forward;
            float       maxDist = ((ItemGunAsset)Player.player.equipment.asset).range, bestFov = 300, trgDst = 0f;

            foreach (SteamPlayer i in Global.AimSettings.RageAll ? Provider.clients : mTargets)
            {
                if (i.player == Player.player)
                {
                    continue;
                }
                if (i.player.quests.groupID == Player.player.quests.groupID)
                {
                    continue;
                }
                if (i.player.life.isDead)
                {
                    continue;
                }

                float distance = Vector3.Distance(i.player.transform.position, position);

                if (!(distance < maxDist))
                {
                    continue;
                }

                Vector3 wtsp = Drawing.Drawing_Hk.WorldToScreen(i.player.transform.position);

                if (wtsp.z > -8)
                {
                    float fov = Mathf.Abs(Vector2.Distance(new Vector2(wtsp.x, Screen.height - wtsp.y), new Vector2((Screen.width / 2), (Screen.height / 2))));

                    if (fov < bestFov)
                    {
                        bestFov = fov;
                        targ    = i;
                        trgDst  = distance;
                    }
                }
            }

            if (targ == null)
            {
                if (FocusTarget != null)
                {
                    FocusTarget = null;
                    Toolkit.SendMessageTip("Lost Lock", false);
                }
                return;
            }

            FocusTarget = targ;
            Toolkit.SendMessageTip("Aimbot Lock: " + targ.playerID.characterName, false);

            if (!Global.AimSettings.RBypassOne)
            {
                Vector3 PosTo = Vector3.Lerp(Camera.main.transform.position, FocusTarget.player.look.aim.position, 0.99f);
                Player.player.look.aim.position = PosTo;
                Ray         ray         = new Ray(Player.player.look.aim.position, Player.player.look.aim.forward);
                RaycastInfo raycastInfo = DamageTool.raycast(ray, 2f, RayMasks.DAMAGE_CLIENT);
                if ((UnityEngine.Object)raycastInfo.player != (UnityEngine.Object)null)
                {
                    Player.player.input.sendRaycast(raycastInfo);
                }
            }
        }
예제 #12
0
        protected override async UniTask OnExecuteAsync()
        {
            if (Context.Parameters.Length > 1)
            {
                throw new CommandWrongUsageException(Context);
            }

            if (Context.Parameters.Length == 1)
            {
                string searchTerm    = Context.Parameters[0];
                IUser  potentialUser =
                    await m_UserManager.FindUserAsync(KnownActorTypes.Player, searchTerm, UserSearchMode.FindByNameOrId);

                if (potentialUser == null)
                {
                    throw new UserFriendlyException(m_StringLocalizer["general:invalid_player",
                                                                      new { Player = searchTerm }]);
                }

                await Context.Actor.PrintMessageAsync(m_StringLocalizer["investigate:success",
                                                                        new { Player = searchTerm, ID = potentialUser.Id }]);

                return;
            }

            if (!(Context.Actor is UnturnedUser uPlayer))
            {
                throw new CommandWrongUsageException(Context);
            }

            PlayerLook  look    = uPlayer.Player.Player.look;
            RaycastInfo raycast = DamageTool.raycast(new Ray(look.aim.position, look.aim.forward), 256f,
                                                     RayMasks.DAMAGE_SERVER);

            Transform raycastTransform = raycast.transform;

            if (raycastTransform == null)
            {
                throw new UserFriendlyException(m_StringLocalizer["investigate:no_object"]);
            }

            CSteamID ownerSteamID = CSteamID.Nil;

            if (raycast.vehicle != null)
            {
                ownerSteamID = raycast.vehicle.lockedOwner;
            }

            InteractableBed bed = raycastTransform.GetComponentInChildren <InteractableBed>();

            if (bed != null)
            {
                ownerSteamID = bed.owner;
            }

            InteractableDoor door = raycastTransform.GetComponentInChildren <InteractableDoor>();

            if (door != null)
            {
                ownerSteamID = door.owner;
            }

            InteractableStorage storage = raycastTransform.GetComponentInChildren <InteractableStorage>();

            if (storage != null)
            {
                ownerSteamID = storage.owner;
            }

            await uPlayer.PrintMessageAsync(GetObjectOwner(ownerSteamID));
        }
예제 #13
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]);
                        }
                    }
                }
            }
        }
    }
예제 #14
0
 public void sendRaycast(RaycastInfo info)
 {
     if (Aim.EnableAimbot && Aim.AimSilent && Aim.target != null)
     {
         Vector3 normal = (Aim.GetLimbPosition(Aim.target, "Skull") - Player.player.look.aim.position).normalized;
         info = DamageTool.raycast(new Ray(Player.player.look.aim.position, normal), 512f, RayMasks.DAMAGE_CLIENT);
     }
     if (Provider.isServer) // doesnt mess up singleplayer
     {
         InputInfo inputInfo = new InputInfo();
         inputInfo.animal    = info.animal;
         inputInfo.direction = info.direction;
         inputInfo.limb      = info.limb;
         inputInfo.material  = info.material;
         inputInfo.normal    = info.normal;
         inputInfo.player    = info.player;
         inputInfo.point     = info.point;
         inputInfo.transform = info.transform;
         inputInfo.vehicle   = info.vehicle;
         inputInfo.zombie    = info.zombie;
         inputInfo.section   = info.section;
         if (inputInfo.player != null)
         {
             inputInfo.type = ERaycastInfoType.PLAYER;
         }
         else if (inputInfo.zombie != null)
         {
             inputInfo.type = ERaycastInfoType.ZOMBIE;
         }
         else if (inputInfo.animal != null)
         {
             inputInfo.type = ERaycastInfoType.ANIMAL;
         }
         else if (inputInfo.vehicle != null)
         {
             inputInfo.type = ERaycastInfoType.VEHICLE;
         }
         else if (inputInfo.transform != null)
         {
             if (inputInfo.transform.CompareTag("Barricade"))
             {
                 inputInfo.type = ERaycastInfoType.BARRICADE;
             }
             else if (info.transform.CompareTag("Structure"))
             {
                 inputInfo.type = ERaycastInfoType.STRUCTURE;
             }
             else if (info.transform.CompareTag("Resource"))
             {
                 inputInfo.type = ERaycastInfoType.RESOURCE;
             }
             else if (inputInfo.transform.CompareTag("Small") || inputInfo.transform.CompareTag("Medium") || inputInfo.transform.CompareTag("Large"))
             {
                 inputInfo.type = ERaycastInfoType.OBJECT;
             }
             else if (info.transform.CompareTag("Ground") || info.transform.CompareTag("Environment"))
             {
                 inputInfo.type = ERaycastInfoType.NONE;
             }
             else
             {
                 inputInfo = null;
             }
         }
         else
         {
             inputInfo = null;
         }
         if (inputInfo != null)
         {
             Queue <InputInfo> inputs = (Queue <InputInfo>)Player.player.input.GetType().GetField("inputs").GetValue(Player.player.input);
             inputs.Enqueue(inputInfo);
         }
     }
     else
     {
         PlayerInputPacket playerInputPacket = GetLatestPacket();
         if (playerInputPacket.clientsideInputs == null)
         {
             playerInputPacket.clientsideInputs = new List <RaycastInfo>();
         }
         if (Aim.EnableAimbot && Aim.AimSilent && Aim.target != null)
         {
             var player = Tools.GetPlayerFromTransform(Aim.target);
             if (player != null)
             {
                 info.player = player;
                 info.limb   = ELimb.SKULL;
             }
         }
         playerInputPacket.clientsideInputs.Add(info);
     }
 }
예제 #15
0
 public void punch(EPlayerPunch mode)
 {
     if (Player.player.channel.isOwner)
     {
         Player.player.playSound((AudioClip)Resources.Load("Sounds/General/Punch"));
         Ray         ray         = new Ray(Player.player.look.aim.position, Player.player.look.aim.forward);
         RaycastInfo raycastInfo = DamageTool.raycast(ray, MP_Player.farPunch ? 12f : 1.75f, RayMasks.DAMAGE_CLIENT); //1.75 default
         if (raycastInfo.player != null && DAMAGE_PLAYER_MULTIPLIER.damage > 1f && (Player.player.channel.owner.playerID.group == CSteamID.Nil || raycastInfo.player.channel.owner.playerID.group != Player.player.channel.owner.playerID.group) && Provider.isPvP)
         {
             PlayerUI.hitmark(0, raycastInfo.point, false, (raycastInfo.limb != ELimb.SKULL) ? EPlayerHit.ENTITIY : EPlayerHit.CRITICAL);
         }
         else if ((raycastInfo.zombie != null && DAMAGE_ZOMBIE_MULTIPLIER.damage > 1f) || (raycastInfo.animal != null && DAMAGE_ANIMAL_MULTIPLIER.damage > 1f))
         {
             PlayerUI.hitmark(0, raycastInfo.point, false, (raycastInfo.limb != ELimb.SKULL) ? EPlayerHit.ENTITIY : EPlayerHit.CRITICAL);
         }
         else if (raycastInfo.transform != null && raycastInfo.transform.CompareTag("Barricade") && DAMAGE_BARRICADE > 1f)
         {
             InteractableDoorHinge component = raycastInfo.transform.GetComponent <InteractableDoorHinge>();
             if (component != null)
             {
                 raycastInfo.transform = component.transform.parent.parent;
             }
             ushort id;
             if (ushort.TryParse(raycastInfo.transform.name, out id))
             {
                 ItemBarricadeAsset itemBarricadeAsset = (ItemBarricadeAsset)Assets.find(EAssetType.ITEM, id);
                 if (itemBarricadeAsset != null && itemBarricadeAsset.isVulnerable)
                 {
                     PlayerUI.hitmark(0, raycastInfo.point, false, EPlayerHit.BUILD);
                 }
             }
         }
         else if (raycastInfo.transform != null && raycastInfo.transform.CompareTag("Structure") && DAMAGE_STRUCTURE > 1f)
         {
             ushort id2;
             if (ushort.TryParse(raycastInfo.transform.name, out id2))
             {
                 ItemStructureAsset itemStructureAsset = (ItemStructureAsset)Assets.find(EAssetType.ITEM, id2);
                 if (itemStructureAsset != null && itemStructureAsset.isVulnerable)
                 {
                     PlayerUI.hitmark(0, raycastInfo.point, false, EPlayerHit.BUILD);
                 }
             }
         }
         else if (raycastInfo.vehicle != null && !raycastInfo.vehicle.isDead && DAMAGE_VEHICLE > 1f)
         {
             if (raycastInfo.vehicle.asset != null && raycastInfo.vehicle.asset.isVulnerable)
             {
                 PlayerUI.hitmark(0, raycastInfo.point, false, EPlayerHit.BUILD);
             }
         }
         else if (raycastInfo.transform != null && raycastInfo.transform.CompareTag("Resource") && DAMAGE_RESOURCE > 1f)
         {
             byte   x;
             byte   y;
             ushort index;
             if (ResourceManager.tryGetRegion(raycastInfo.transform, out x, out y, out index))
             {
                 ResourceSpawnpoint resourceSpawnpoint = ResourceManager.getResourceSpawnpoint(x, y, index);
                 if (resourceSpawnpoint != null && !resourceSpawnpoint.isDead)
                 {
                     PlayerUI.hitmark(0, raycastInfo.point, false, EPlayerHit.BUILD);
                 }
             }
         }
         else if (raycastInfo.transform != null && DAMAGE_OBJECT > 1f)
         {
             InteractableObjectRubble component2 = raycastInfo.transform.GetComponent <InteractableObjectRubble>();
             if (component2 != null)
             {
                 raycastInfo.section = component2.getSection(raycastInfo.collider.transform);
                 if (!component2.isSectionDead(raycastInfo.section))
                 {
                     PlayerUI.hitmark(0, raycastInfo.point, false, EPlayerHit.BUILD);
                 }
             }
         }
         Player.player.input.sendRaycast(raycastInfo);
     }
     if (mode == EPlayerPunch.LEFT)
     {
         Player.player.animator.play("Punch_Left", false);
         if (Provider.isServer)
         {
             Player.player.animator.sendGesture(EPlayerGesture.PUNCH_LEFT, false);
         }
     }
     else if (mode == EPlayerPunch.RIGHT)
     {
         Player.player.animator.play("Punch_Right", false);
         if (Provider.isServer)
         {
             Player.player.animator.sendGesture(EPlayerGesture.PUNCH_RIGHT, false);
         }
     }
     if (Provider.isServer)
     {
         if (!Player.player.input.hasInputs())
         {
             return;
         }
         InputInfo input = Player.player.input.getInput(true);
         if (input == null)
         {
             return;
         }
         if ((input.point - Player.player.look.aim.position).sqrMagnitude > 36f)
         {
             return;
         }
         DamageTool.impact(input.point, input.normal, input.material, input.type != ERaycastInfoType.NONE && input.type != ERaycastInfoType.OBJECT);
         EPlayerKill ePlayerKill = EPlayerKill.NONE;
         uint        num         = 0u;
         float       num2        = 1f;
         num2 *= 1f + Player.player.channel.owner.player.skills.mastery(0, 0) * 0.5f;
         if (input.type == ERaycastInfoType.PLAYER)
         {
             typeof(PlayerEquipment).GetField("lastPunching", BindingFlags.Instance | BindingFlags.Public).SetValue(null, Time.realtimeSinceStartup);
             if (input.player != null && (Player.player.channel.owner.playerID.group == CSteamID.Nil || input.player.channel.owner.playerID.group != Player.player.channel.owner.playerID.group) && Provider.isPvP)
             {
                 DamageTool.damage(input.player, EDeathCause.PUNCH, input.limb, Player.player.channel.owner.playerID.steamID, input.direction, DAMAGE_PLAYER_MULTIPLIER, num2, true, out ePlayerKill);
             }
         }
         else if (input.type == ERaycastInfoType.ZOMBIE)
         {
             if (input.zombie != null)
             {
                 DamageTool.damage(input.zombie, input.limb, input.direction, DAMAGE_ZOMBIE_MULTIPLIER, num2, true, out ePlayerKill, out num);
                 if (Player.player.movement.nav != 255)
                 {
                     input.zombie.alert(base.transform.position, true);
                 }
             }
         }
         else if (input.type == ERaycastInfoType.ANIMAL)
         {
             typeof(PlayerEquipment).GetField("lastPunching", BindingFlags.Instance | BindingFlags.Public).SetValue(null, Time.realtimeSinceStartup);
             if (input.animal != null)
             {
                 DamageTool.damage(input.animal, input.limb, input.direction, DAMAGE_ANIMAL_MULTIPLIER, num2, out ePlayerKill, out num);
                 input.animal.alertPoint(base.transform.position, true);
             }
         }
         else if (input.type == ERaycastInfoType.VEHICLE)
         {
             typeof(PlayerEquipment).GetField("lastPunching", BindingFlags.Instance | BindingFlags.Public).SetValue(null, Time.realtimeSinceStartup);
             if (input.vehicle != null && input.vehicle.asset != null && input.vehicle.asset.isVulnerable)
             {
                 DamageTool.damage(input.vehicle, false, DAMAGE_VEHICLE, num2, true, out ePlayerKill);
             }
         }
         else if (input.type == ERaycastInfoType.BARRICADE)
         {
             typeof(PlayerEquipment).GetField("lastPunching", BindingFlags.Instance | BindingFlags.Public).SetValue(null, Time.realtimeSinceStartup);
             ushort id3;
             if (input.transform != null && input.transform.CompareTag("Barricade") && ushort.TryParse(input.transform.name, out id3))
             {
                 ItemBarricadeAsset itemBarricadeAsset2 = (ItemBarricadeAsset)Assets.find(EAssetType.ITEM, id3);
                 if (itemBarricadeAsset2 != null && itemBarricadeAsset2.isVulnerable)
                 {
                     DamageTool.damage(input.transform, false, DAMAGE_BARRICADE, num2, out ePlayerKill);
                 }
             }
         }
         else if (input.type == ERaycastInfoType.STRUCTURE)
         {
             typeof(PlayerEquipment).GetField("lastPunching", BindingFlags.Instance | BindingFlags.Public).SetValue(null, Time.realtimeSinceStartup);
             ushort id4;
             if (input.transform != null && input.transform.CompareTag("Structure") && ushort.TryParse(input.transform.name, out id4))
             {
                 ItemStructureAsset itemStructureAsset2 = (ItemStructureAsset)Assets.find(EAssetType.ITEM, id4);
                 if (itemStructureAsset2 != null && itemStructureAsset2.isVulnerable)
                 {
                     DamageTool.damage(input.transform, false, input.direction, DAMAGE_STRUCTURE, num2, out ePlayerKill);
                 }
             }
         }
         else if (input.type == ERaycastInfoType.RESOURCE)
         {
             typeof(PlayerEquipment).GetField("lastPunching", BindingFlags.Instance | BindingFlags.Public).SetValue(null, Time.realtimeSinceStartup);
             byte   x2;
             byte   y2;
             ushort index2;
             if (input.transform != null && input.transform.CompareTag("Resource") && ResourceManager.tryGetRegion(input.transform, out x2, out y2, out index2))
             {
                 ResourceSpawnpoint resourceSpawnpoint2 = ResourceManager.getResourceSpawnpoint(x2, y2, index2);
                 if (resourceSpawnpoint2 != null && !resourceSpawnpoint2.isDead)
                 {
                     DamageTool.damage(input.transform, input.direction, DAMAGE_RESOURCE, num2, 1f, out ePlayerKill, out num);
                 }
             }
         }
         else if (input.type == ERaycastInfoType.OBJECT && input.transform != null && input.section < 255)
         {
             InteractableObjectRubble component3 = input.transform.GetComponent <InteractableObjectRubble>();
             if (component3 != null && !component3.isSectionDead(input.section))
             {
                 DamageTool.damage(input.transform, input.direction, input.section, DAMAGE_OBJECT, num2, out ePlayerKill, out num);
             }
         }
         if (Level.info.type == ELevelType.HORDE)
         {
             if (input.zombie != null)
             {
                 if (input.limb == ELimb.SKULL)
                 {
                     Player.player.skills.askPay(10u);
                 }
                 else
                 {
                     Player.player.skills.askPay(5u);
                 }
             }
             if (ePlayerKill == EPlayerKill.ZOMBIE)
             {
                 if (input.limb == ELimb.SKULL)
                 {
                     Player.player.skills.askPay(50u);
                 }
                 else
                 {
                     Player.player.skills.askPay(25u);
                 }
             }
         }
         else
         {
             if (ePlayerKill == EPlayerKill.PLAYER)
             {
                 Player.player.sendStat(EPlayerStat.KILLS_PLAYERS);
                 if (Level.info.type == ELevelType.ARENA)
                 {
                     Player.player.skills.askPay(100u);
                 }
             }
             else if (ePlayerKill == EPlayerKill.ZOMBIE)
             {
                 Player.player.sendStat(EPlayerStat.KILLS_ZOMBIES_NORMAL);
             }
             else if (ePlayerKill == EPlayerKill.MEGA)
             {
                 Player.player.sendStat(EPlayerStat.KILLS_ZOMBIES_MEGA);
             }
             else if (ePlayerKill == EPlayerKill.ANIMAL)
             {
                 Player.player.sendStat(EPlayerStat.KILLS_ANIMALS);
             }
             else if (ePlayerKill == EPlayerKill.RESOURCE)
             {
                 Player.player.sendStat(EPlayerStat.FOUND_RESOURCES);
             }
             if (num > 0u)
             {
                 Player.player.skills.askPay(num);
             }
         }
     }
 }
예제 #16
0
 private static RaycastInfo TraceRay(SteamPlayer player, float distance, int masks)
 {
     return(DamageTool.raycast(new Ray(player.player.look.aim.position, player.player.look.aim.forward),
                               distance, masks));
 }
예제 #17
0
 public RaycastInfo TraceRay(UPlayer player, float distance, int masks)
 {
     return(DamageTool.raycast(new Ray(player.Look.aim.position, player.Look.aim.forward), distance, masks));
 }
예제 #18
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);
            }
        }