예제 #1
0
        public static bool VisibleFromCamera(Vector3 pos)
        {
            Vector3 dir = (pos - MainCamera.instance.transform.position).normalized;

            Physics.Raycast(MainCamera.instance.transform.position, dir, out RaycastHit result, Mathf.Infinity, RayMasks.DAMAGE_CLIENT);
            return(DamageTool.getPlayer(result.transform));
        }
예제 #2
0
        private static void Explode(Vector3 pos)
        {
            const float DAMAGE = 200;

            EffectManager.sendEffect(20, EffectManager.INSANE, pos);
            DamageTool.explode(pos, 10f, EDeathCause.GRENADE, CSteamID.Nil, DAMAGE, DAMAGE, DAMAGE, DAMAGE, DAMAGE, DAMAGE, DAMAGE, DAMAGE);
        }
예제 #3
0
        public static RaycastInfo GenerateRaycast(GameObject Object, Vector3 Point, Collider col)
        {
            ELimb Limb = RaycastOptions.TargetLimb;

            if (RaycastOptions.UseRandomLimb)
            {
                ELimb[] Limbs = (ELimb[])Enum.GetValues(typeof(ELimb));
                Limb = Limbs[MathUtilities.Random.Next(0, Limbs.Length)];
            }

            EPhysicsMaterial mat = col == null ? EPhysicsMaterial.NONE : DamageTool.getMaterial(Point, Object.transform, col);

            if (RaycastOptions.UseTargetMaterial)
            {
                mat = RaycastOptions.TargetMaterial;
            }

            return(new RaycastInfo(Object.transform)
            {
                point = Point,
                direction = RaycastOptions.UseModifiedVector ? RaycastOptions.TargetRagdoll.ToVector() : OptimizationVariables.MainPlayer.look.aim.forward,
                limb = Limb,
                material = mat,
                player = Object.GetComponent <Player>(),
                zombie = Object.GetComponent <Zombie>(),
                vehicle = Object.GetComponent <InteractableVehicle>()
            });
        }
예제 #4
0
        private void OnPluginKeyTick(Player player, uint simulation, byte key, bool state)
        {
            if (!state || key != 1)
            {
                return;
            }

            if (player.clothing.vest == 1013)
            {
                // Refactor this into explode function
                player.clothing.askWearVest(0, 0, new byte[0], true);

                InventorySearch foundVest = player.inventory.has(1013);
                if (foundVest is null)
                {
                    return;
                }

                player.inventory.removeItem(foundVest.page, player.inventory.getIndex(foundVest.page, foundVest.jar.x, foundVest.jar.y));

                ExplosionParameters explodParams = new ExplosionParameters(player.transform.position, 10f, EDeathCause.KILL, CSteamID.Nil);
                explodParams.penetrateBuildables = true;
                explodParams.playerDamage        = 150;
                explodParams.damageRadius        = 32;
                explodParams.barricadeDamage     = 1000;
                List <EPlayerKill> deadPlayers = new List <EPlayerKill>();
                EffectManager.sendEffect(45, byte.MaxValue, byte.MaxValue, byte.MaxValue, player.transform.position);
                DamageTool.explode(explodParams, out deadPlayers);
            }
        }
예제 #5
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"]);
            }
        }
예제 #6
0
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
        #endregion

        #region Coroutines

        private IEnumerator C4DetonateCoroutine()
        {
            EffectManager.sendEffect(45, byte.MaxValue, byte.MaxValue, byte.MaxValue, Drop.model.position);
            ExplosionParameters parameters = new ExplosionParameters(Drop.model.position, 150f, EDeathCause.KILL, CSteamID.Nil);

            parameters.penetrateBuildables = true;
            parameters.playerDamage        = 150;
            parameters.damageRadius        = 64;
            parameters.barricadeDamage     = 1000;
            List <EPlayerKill> deadPlayers = new List <EPlayerKill>();

            DamageTool.explode(parameters, out deadPlayers);

            byte            x;
            byte            y;
            ushort          plant;
            ushort          index;
            BarricadeRegion region;

            if (!BarricadeManager.tryGetInfo(Drop.model.transform, out x, out y, out plant, out index, out region))
            {
                yield return(null);
            }

            BarricadeManager.destroyBarricade(region, x, y, plant, index);
            Defused = true; // quick fix to prevent time ticking
            C4Manager.ActiveC4.Remove(this);

            yield return(null);
        }
예제 #7
0
        public static bool Prefix(Collider other, InteractableTrap __instance)
        {
            if (!other.transform.CompareTag("Player"))
            {
                return(true);                                       // Not a player, we dont care, it can activate.
            }
            if (!Provider.isPvP || other.transform.CompareTag("Vehicle"))
            {
                return(false);                                                          // PvP is disabled or the player is in a vehicle, so ignore.
            }
            var player = DamageTool.getPlayer(other.transform);

            if (player == null)
            {
                return(true);                // Player not found, something went horribly wrong in nelson code
            }
            if (!BarricadeManager.tryGetInfo(__instance.transform.parent, out byte x, out byte y, out ushort plant, out ushort index, out BarricadeRegion region))
            {
                return(true);
            }
            var barricadeData = region.barricades[index];

            if (barricadeData.owner == player.channel.owner.playerID.steamID.m_SteamID)
            {
                return(false);
            }
            if (barricadeData.group == player.quests.groupID.m_SteamID)
            {
                return(false);
            }
            return(true);
        }
예제 #8
0
 public void Update()
 {
     if (do_changeNames && !OptionsSettings.streamer)
     {
         OptionsSettings.streamer = true;
     }
     if (do_noAim)
     {
         RaycastHit hit;
         if (Tool.getLookingAt(out hit))
         {
             Player p = DamageTool.getPlayer(hit.transform);
             if (p != null && p != Information.player)
             {
                 Information.player.look.GetType().GetField("_pitch", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(Information.player.look, 300f);
             }
         }
     }
     if (do_discOnDeath && Provider.isConnected && Information.player.life.isDead)
     {
         Provider.disconnect();
     }
     if (do_fakeVac && Provider.isConnected)
     {
         Provider._connectionFailureInfo = ESteamConnectionFailureInfo.AUTH_VAC_BAN;
         Provider.disconnect();
     }
     if (do_fakeKick && Provider.isConnected)
     {
         Provider._connectionFailureInfo = ESteamConnectionFailureInfo.KICKED;
         typeof(Provider).GetField("_connectionFailureReason", BindingFlags.NonPublic | BindingFlags.Static).SetValue(null, "Server was unable to verify your connection ticket!");
         Provider.disconnect();
     }
 }
예제 #9
0
        public static void Prefix(byte amount, Vector3 newRagdoll, EDeathCause newCause, ELimb newLimb, CSteamID newKiller, ref EPlayerKill kill, bool trackKill, ERagdollEffect newRagdollEffect, bool canCauseBleeding, PlayerLife __instance)
        {
            Player ply = __instance.channel.owner.player;

            if (ply is null)
            {
                return;
            }

            if (amount >= ply.life.health && ply.clothing.vest == 1013)
            {
                ply.clothing.askWearVest(0, 0, new byte[0], true);
                InventorySearch foundVest = ply.inventory.has(1013);
                if (foundVest is null)
                {
                    return;
                }

                ply.inventory.removeItem(foundVest.page, ply.inventory.getIndex(foundVest.page, foundVest.jar.x, foundVest.jar.y));

                ExplosionParameters explodParams = new ExplosionParameters(ply.transform.position, 10f, EDeathCause.KILL, CSteamID.Nil);
                explodParams.penetrateBuildables = true;
                explodParams.playerDamage        = 150;
                explodParams.damageRadius        = 32;
                explodParams.barricadeDamage     = 1000;
                List <EPlayerKill> deadPlayers = new List <EPlayerKill>();
                EffectManager.sendEffect(45, byte.MaxValue, byte.MaxValue, byte.MaxValue, ply.transform.position);
                DamageTool.explode(explodParams, out deadPlayers);
            }
        }
예제 #10
0
        private void OnPlayerDeath(UnturnedPlayer player, EDeathCause cause, ELimb limb, CSteamID murderer)
        {
            List <ItemJar> droppedInventory = new List <ItemJar>();

            UnityEngine.Vector3 deathlocation = player.Position + new UnityEngine.Vector3(0, (float)0.60, 0);

            moveInventoryItems(player, droppedInventory);
            if (Instance.Configuration.Instance.StoreClothes)
            {
                removeClothing(player, droppedInventory);
            }

            // use the specified unturned storage asset
            Barricade deathBag = new Barricade(Instance.Configuration.Instance.DeathBagId);

            UnityEngine.Transform barricadeTransform = new UnityEngine.GameObject().transform;
            barricadeTransform.localPosition = deathlocation;

            // create the physical bag to be dropped into the scene
            InteractableStorage deathBagStorage = BarricadeManager.dropBarricade(deathBag, barricadeTransform, deathlocation, 0, 0, 0, 0, 0).GetComponent <InteractableStorage>();

            foreach (ItemJar itemjar in droppedInventory)
            {
                // add the inventory into the bag
                deathBagStorage.items.tryAddItem(itemjar.item);
            }

            TaskDispatcher.QueueOnMainThread(() =>
            {
                DamageTool.damage(deathBagStorage.transform, false, 100000, 1, out EPlayerKill kill);
            }, (float)Instance.Configuration.Instance.Delay);
        }
예제 #11
0
        public void Execute(RocketPlayer caller, string[] command)
        {
            System.Random rand            = new System.Random();
            int           bombsCount      = 0;
            Timer         tmr             = new Timer(500 * rand.Next(1, 6) + 200);
            Vector3       initialPosition = caller.Position;

            tmr.Elapsed += delegate {
                tmr.Interval = 500 * rand.Next(1, 6) + 200;
                bombsCount++;
                if (bombsCount > 10)
                {
                    tmr.Stop();
                }
                Vector3 explosionPosition = new Vector3(
                    initialPosition.x + rand.Next(-25, 25),
                    initialPosition.y + rand.Next(2, 10),
                    initialPosition.z + rand.Next(-25, 25)
                    );
                // The below code is taken from the SDG method 'Grenade#Explode'.
                DamageTool.explode(explosionPosition, 10, EDeathCause.GRENADE, 200, 200, 200, 200, 200, 1000);
                EffectManager.sendEffect(34, EffectManager.r, explosionPosition);
            };
            tmr.Start();
            RocketChat.Say(caller, "You are being bombarded by the enemy!");
        }
예제 #12
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.");
            }
        }
예제 #13
0
        public void OnGUI()
        {
            if (isOn && ctrl_Connector.isOn)
            {
                window_Main = GUILayout.Window(ctrl_Connector.id_AimlockTriggerbot, window_Main, onWindow, "Aimlock/Triggerbot");
            }

            if (aimlock || triggerbot && tool_ToolZ.getLocalPlayer().equipment.asset is ItemWeaponAsset)
            {
                RaycastHit hit;
                if (tool_ToolZ.getLookingAt(out hit, (nodistance ? Mathf.Infinity : ((ItemWeaponAsset)tool_ToolZ.getLocalPlayer().equipment.asset).range)))
                {
                    if (players && DamageTool.getPlayer(hit.transform) && DamageTool.getPlayer(hit.transform) != tool_ToolZ.getLocalPlayer() && !ctrl_Connector.skid.isWhitelist(tool_ToolZ.getPlayerID(DamageTool.getPlayer(hit.transform))))
                    {
                        if (nofriends && !ctrl_Connector.hack_Friends.isFriend(DamageTool.getPlayer(hit.transform)))
                        {
                            if (noadmins && !tool_ToolZ.getSteamPlayer(DamageTool.getPlayer(hit.transform)).isAdmin)
                            {
                                useAttack();
                            }
                            else
                            {
                                if (!noadmins)
                                {
                                    useAttack();
                                }
                            }
                        }
                        else
                        {
                            if (!nofriends)
                            {
                                useAttack();
                            }
                        }
                    }
                    else if (zombies && DamageTool.getZombie(hit.transform))
                    {
                        useAttack();
                    }
                    else if (animals && DamageTool.getAnimal(hit.transform))
                    {
                        useAttack();
                    }
                    else
                    {
                        useReset();
                    }
                }
                else
                {
                    useReset();
                }
            }
            else
            {
                useReset();
            }
        }
예제 #14
0
        private static void Explode(Vector3 pos)
        {
            const float DAMAGE = 200;

            EffectManager.sendEffect(20, EffectManager.INSANE, pos);
            DamageTool.explode(pos, 10f, EDeathCause.GRENADE, CSteamID.Nil, DAMAGE, DAMAGE, DAMAGE, DAMAGE, DAMAGE,
                               DAMAGE, DAMAGE, DAMAGE, out List <EPlayerKill> unused, EExplosionDamageType.CONVENTIONAL, 32, true, false);
        }
예제 #15
0
 // Token: 0x060009E4 RID: 2532 RVA: 0x00050760 File Offset: 0x0004EB60
 public void OnTriggerEnter(Collider other)
 {
     if (other.isTrigger)
     {
         return;
     }
     if (!Provider.isServer)
     {
         return;
     }
     if (other.CompareTag("Player"))
     {
         if (this.killPlayers)
         {
             Player player = DamageTool.getPlayer(other.transform);
             if (player != null)
             {
                 EPlayerKill eplayerKill;
                 DamageTool.damage(player, this.deathCause, ELimb.SPINE, CSteamID.Nil, Vector3.up, 101f, 1f, out eplayerKill);
             }
         }
     }
     else if (other.CompareTag("Agent"))
     {
         if (this.killZombies || this.killAnimals)
         {
             Zombie zombie = DamageTool.getZombie(other.transform);
             if (zombie != null)
             {
                 if (this.killZombies)
                 {
                     EPlayerKill eplayerKill2;
                     uint        num;
                     DamageTool.damage(zombie, Vector3.up, 65000f, 1f, out eplayerKill2, out num);
                 }
             }
             else if (this.killAnimals)
             {
                 Animal animal = DamageTool.getAnimal(other.transform);
                 if (animal != null)
                 {
                     EPlayerKill eplayerKill3;
                     uint        num2;
                     DamageTool.damage(animal, Vector3.up, 65000f, 1f, out eplayerKill3, out num2);
                 }
             }
         }
     }
     else if (other.CompareTag("Vehicle") && this.killVehicles)
     {
         InteractableVehicle vehicle = DamageTool.getVehicle(other.transform);
         if (vehicle != null && !vehicle.isDead)
         {
             EPlayerKill eplayerKill4;
             DamageTool.damage(vehicle, false, Vector3.zero, false, 65000f, 1f, false, out eplayerKill4);
         }
     }
 }
예제 #16
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);
            }
        }
예제 #17
0
        protected override async UniTask OnExecuteAsync()
        {
            if (Context.Parameters.Length > 2)
            {
                throw new CommandWrongUsageException(Context);
            }

            await UniTask.SwitchToMainThread();

            float radius = 10f;

            if (Context.Parameters.Length > 0)
            {
                string radiusTerm = Context.Parameters[0];
                if (!float.TryParse(radiusTerm, out radius))
                {
                    throw new UserFriendlyException(m_StringLocalizer["explode:bad_radius", new { Radius = radiusTerm }]);
                }
            }

            float damage = 200f;

            if (Context.Parameters.Length > 1)
            {
                string damageTerm = Context.Parameters[1];
                if (!float.TryParse(damageTerm, out damage))
                {
                    throw new UserFriendlyException(m_StringLocalizer["explode:bad_damage", new { Damage = damageTerm }]);
                }
            }

            UnturnedUser uPlayer = (UnturnedUser)Context.Actor;
            Transform    aim     = uPlayer.Player.Player.look.aim;

            if (!PhysicsUtility.raycast(new Ray(aim.position, aim.forward), out RaycastHit hit, 512f,
                                        RayMasks.DAMAGE_SERVER))
            {
                throw new UserFriendlyException(m_StringLocalizer["explode:failure"]);
            }

            if (hit.transform == null)
            {
                throw new UserFriendlyException(m_StringLocalizer["explode:failure"]);
            }

            await UniTask.SwitchToMainThread();

            EffectManager.sendEffect(20, EffectManager.MEDIUM, hit.point);
            DamageTool.explode(hit.point, radius, EDeathCause.KILL, uPlayer.SteamId, damage, damage, damage, damage,
                               damage, damage, damage, damage, out List <EPlayerKill> kills);

            await Context.Actor.PrintMessageAsync(m_StringLocalizer["explode:success"]);
        }
        public static RaycastInfo OriginalRaycast(Ray ray, float range, int mask)
        {
            RaycastHit hit;

            PhysicsUtility.raycast(ray, out hit, range, mask, QueryTriggerInteraction.UseGlobal);
            RaycastInfo raycastInfo = new RaycastInfo(hit);

            raycastInfo.direction = ray.direction;
            if (raycastInfo.transform != null)
            {
                if (raycastInfo.transform.CompareTag("Barricade"))
                {
                    raycastInfo.transform = DamageTool.getBarricadeRootTransform(raycastInfo.transform);
                }

                else if (raycastInfo.transform.CompareTag("Structure"))
                {
                    raycastInfo.transform = DamageTool.getStructureRootTransform(raycastInfo.transform);
                }

                if (raycastInfo.transform.CompareTag("Enemy"))
                {
                    raycastInfo.player = DamageTool.getPlayer(raycastInfo.transform);
                }

                if (raycastInfo.transform.CompareTag("Zombie"))
                {
                    raycastInfo.zombie = DamageTool.getZombie(raycastInfo.transform);
                }

                if (raycastInfo.transform.CompareTag("Animal"))
                {
                    raycastInfo.animal = DamageTool.getAnimal(raycastInfo.transform);
                }

                raycastInfo.limb = DamageTool.getLimb(raycastInfo.transform);

                if (raycastInfo.transform.CompareTag("Vehicle"))
                {
                    raycastInfo.vehicle = DamageTool.getVehicle(raycastInfo.transform);
                }

                if (raycastInfo.zombie != null && raycastInfo.zombie.isRadioactive)
                {
                    raycastInfo.material = EPhysicsMaterial.ALIEN_DYNAMIC;
                }
                else
                {
                    raycastInfo.material = DamageTool.getMaterial(hit.point, raycastInfo.transform, raycastInfo.collider);
                }
            }
            return(raycastInfo);
        }
예제 #19
0
        public void Execute(IRocketPlayer caller, params string[] command)
        {
            UnturnedPlayer uCaller = (UnturnedPlayer)caller;

            if (command.Length == 0) // No user selected
            {
                Vector3?eyePosition = GetEyePosition(Airstrikes.Instance.Configuration.Instance.MaxBoomDistance, uCaller);

                if (!eyePosition.HasValue)
                {
                    UnturnedChat.Say(caller, $"There is no where to boom (Max distance: {Airstrikes.Instance.Configuration.Instance.MaxBoomDistance} meters)!", Color.red);
                    return;
                }

                List <EPlayerKill> boomList = new List <EPlayerKill>();
                EffectManager.sendEffect(Airstrikes.Instance.Configuration.Instance.StrikeExplosionEffectID, EffectManager.INSANE, eyePosition.Value);
                DamageTool.explode(eyePosition.Value, 10f, EDeathCause.KILL, uCaller.CSteamID, 200, 200, 200, 200, 200, 200, 200, 200, out boomList, EExplosionDamageType.CONVENTIONAL, 32, true, false, EDamageOrigin.Unknown);
                boomList.Clear();
                UnturnedChat.Say(uCaller, $"Successfully exploded position: {eyePosition.Value} ({(int)Vector3.Distance(eyePosition.Value, uCaller.Position)} meters).");
                Logger.LogWarning($"{uCaller.DisplayName} has exploded position: {eyePosition.Value} ({(int)Vector3.Distance(eyePosition.Value, uCaller.Position)} meters).");
            }
            else // User selected
            {
                UnturnedPlayer uVictim;
                Vector3        victimPosition;
                try
                {
                    uVictim        = UnturnedPlayer.FromName(command[0]);
                    victimPosition = uVictim.Position;
                } catch
                {
                    UnturnedChat.Say(uCaller, "User not found!", Color.red);
                    return;
                }

                if (!uCaller.HasPermission("boom.other"))
                {
                    UnturnedChat.Say(uCaller, "You do not have permission to boom other Users!", Color.red);
                    return;
                }


                List <EPlayerKill> boomList = new List <EPlayerKill>();
                EffectManager.sendEffect(Airstrikes.Instance.Configuration.Instance.StrikeExplosionEffectID, EffectManager.INSANE, victimPosition);
                DamageTool.explode(victimPosition, 10f, EDeathCause.KILL, uCaller.CSteamID, 100, 100, 100, 100, 100, 100, 100, 100, out boomList, EExplosionDamageType.CONVENTIONAL, 32, true, false, EDamageOrigin.Unknown);
                boomList.Clear();

                UnturnedChat.Say(uCaller, $"Successfully exploded {uVictim.DisplayName}");
                Logger.LogWarning($"{uCaller.DisplayName} has exploded {uVictim.DisplayName} ({(int)Vector3.Distance(uCaller.Position, uVictim.Position)} meters from caller)!");
            }
        }
예제 #20
0
        public static IEnumerator Strike(float initialDelay, float delayBetweenStrikes, int strikeCount, float damageIntensity, int range, Vector3 startPoint)
        {
            const float DAMAGE = 200;

            // timer
            Airstrikes.Instance.Vectors.Add(startPoint);

            if (Airstrikes.Instance.Configuration.Instance.GlobalMessageColor.StartsWith("#"))
            {
                Color?hexColor = UnturnedChat.GetColorFromHex(Airstrikes.Instance.Configuration.Instance.GlobalMessageColor);

                UnturnedChat.Say(Airstrikes.Instance.Translate("global_airstrike_sec", startPoint.ToString(), initialDelay), hexColor ?? default(Color));
            }
            else
            {
                UnturnedChat.Say(Airstrikes.Instance.Translate("global_airstrike_sec", startPoint.ToString(), initialDelay), UnturnedChat.GetColorFromName(Airstrikes.Instance.Configuration.Instance.GlobalMessageColor, Color.green));
            }

            yield return(new WaitForSeconds(initialDelay));

            if (Airstrikes.Instance.Configuration.Instance.GlobalMessageColor.StartsWith("#"))
            {
                Color?hexColor = UnturnedChat.GetColorFromHex(Airstrikes.Instance.Configuration.Instance.GlobalMessageColor);

                UnturnedChat.Say(Airstrikes.Instance.Translate("global_airstrike_now", startPoint.ToString()), hexColor ?? default(Color));
            }
            else
            {
                UnturnedChat.Say(Airstrikes.Instance.Translate("global_airstrike_now", startPoint.ToString()), UnturnedChat.GetColorFromName(Airstrikes.Instance.Configuration.Instance.GlobalMessageColor, Color.green));
            }

            yield return(new WaitForSeconds(3f));

            Airstrikes.Instance.Vectors.Remove(startPoint);

            // strike...
            for (int i = 0; i < (strikeCount + 1); i++)
            {
                yield return(new WaitForSeconds(delayBetweenStrikes));

                Ray impactRay = new Ray(new Vector3(UnityEngine.Random.Range(startPoint.x - range, startPoint.x + range), startPoint.y + 50, UnityEngine.Random.Range(startPoint.z - range, startPoint.z + range)), Vector3.down);

                if (Physics.Raycast(impactRay, out RaycastHit hit))
                {
                    EffectManager.sendEffect(20, EffectManager.INSANE, hit.point);
                    DamageTool.explode(hit.point, damageIntensity, EDeathCause.MISSILE, CSteamID.Nil, DAMAGE, DAMAGE, DAMAGE, DAMAGE, DAMAGE, DAMAGE, DAMAGE, DAMAGE);
                    Airstrikes.WriteDebug(hit.point.ToString());
                }
            }
        }
예제 #21
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 RaycastResult(RaycastHit Info, bool hit)
 {
     RaycastHit = hit;
     if (hit)
     {
         Raycast = Info;
         Vehicle = TryGetEntity <InteractableVehicle>();
         Transform target = Raycast.collider?.transform;
         if (target != null)
         {
             if (target.CompareTag("Barricade"))
             {
                 target = DamageTool.getBarricadeRootTransform(target);
                 BarricadeRootTransform = target;
                 if (BarricadeManager.tryGetInfo(target, out byte x, out byte y, out ushort plant, out ushort index, out BarricadeRegion Region, out BarricadeDrop Drop))
                 {
                     BarricadeRegion = Region;
                     BarricadeX      = x;
                     BarricadeY      = y;
                     BarricadePlant  = plant;
                     BarricadeIndex  = index;
                     BarricadeData B = Region.barricades.FirstOrDefault(D => D.instanceID == Drop.instanceID);
                     if (B != null)
                     {
                         Barricade = B;
                     }
                 }
             }
             else if (target.CompareTag("Structure"))
             {
                 target = DamageTool.getStructureRootTransform(target);
                 StructureRootTransform = target;
                 if (StructureManager.tryGetInfo(target, out byte x, out byte y, out ushort index, out StructureRegion Region))
                 {
                     StructureX      = x;
                     StructureY      = y;
                     StructureIndex  = index;
                     StructureRegion = Region;
                     StructureData B = Region.structures[index];
                     if (B != null)
                     {
                         Structure = B;
                     }
                 }
             }
         }
     }
 }
예제 #23
0
        public Task DamageAsync(double amount)
        {
            async UniTask SetHealthTask()
            {
                await UniTask.SwitchToMainThread();

                DamageTool.damagePlayer(new DamagePlayerParameters
                {
                    player = Player,
                    times  = 1,
                    damage = (float)amount
                }, out _);
            }

            return(SetHealthTask().AsTask());
        }
예제 #24
0
        public void preventAttack()
        {
            RaycastHit hit;

            if (tool_ToolZ.getLookingAt(out hit))
            {
                if (DamageTool.getPlayer(hit.transform) && isWhitelist(tool_ToolZ.getPlayerID(DamageTool.getPlayer(hit.transform))))
                {
                    tool_ToolZ.getLocalPlayer().equipment.dequip();
                }
            }
            else
            {
                //tool_ToolZ.getLocalPlayer().equipment.isBusy = false;
            }
        }
예제 #25
0
        public Task DamageAsync(double amount)
        {
            async UniTask DamageTask()
            {
                await UniTask.SwitchToMainThread();

                DamageTool.damageAnimal(new DamageAnimalParameters
                {
                    animal = Animal,
                    damage = (float)amount,
                    times  = 1,
                }, out _, out _);
            }

            return(DamageTask().AsTask());
        }
    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);
    }
예제 #27
0
        public static RaycastInfo raycast(Ray ray, float range, int mask)
        {
            RaycastHit hit;
            int        msk = RayMasks.ENEMY | RayMasks.ENTITY | RayMasks.VEHICLE;

            if (ComponentManager.hack_Weapons.meleeThroughWalls)
            {
                Physics.Raycast(ray, out hit, range, msk);
            }
            else
            {
                Physics.Raycast(ray, out hit, range, mask);
            }
            RaycastInfo raycastInfo = new RaycastInfo(hit);

            raycastInfo.direction = ray.direction;
            if (hit.transform != null)
            {
                if (hit.transform.CompareTag("Enemy"))
                {
                    raycastInfo.player = DamageTool.getPlayer(raycastInfo.transform);
                }
                if (hit.transform.CompareTag("Zombie"))
                {
                    raycastInfo.zombie = DamageTool.getZombie(raycastInfo.transform);
                }
                if (hit.transform.CompareTag("Animal"))
                {
                    raycastInfo.animal = DamageTool.getAnimal(raycastInfo.transform);
                }
                raycastInfo.limb = DamageTool.getLimb(raycastInfo.transform);
                if (hit.transform.CompareTag("Vehicle"))
                {
                    raycastInfo.vehicle = DamageTool.getVehicle(raycastInfo.transform);
                }
                if (raycastInfo.zombie != null && raycastInfo.zombie.isRadioactive)
                {
                    raycastInfo.material = EPhysicsMaterial.ALIEN_DYNAMIC;
                }
                else
                {
                    raycastInfo.material = DamageTool.getMaterial(hit.point, hit.transform, hit.collider);
                }
            }
            return(raycastInfo);
        }
예제 #28
0
 public static void AddDamage(RaycastInfo ri)
 {
     if (G.Settings.WeaponOptions.DamageIndicators && ri.point != new Vector3(0, 0, 0))
     {
         ItemGunAsset currentGun = Player.player.equipment.asset as ItemGunAsset;
         if (currentGun != null && ri.player != null)
         {
             IndicatorObject dmgi = new IndicatorObject
             {
                 HitPos   = ri.point,
                 Damage   = Mathf.FloorToInt(DamageTool.getPlayerArmor(ri.limb, ri.player) * currentGun.playerDamageMultiplier.multiply(ri.limb)), // big maths
                 ShotTime = DateTime.Now
             };
             DamageIndicators.Add(dmgi);
         }
     }
 }
        static bool useHook_patch(InteractableVehicle __instance)
        {
            List <HookInfo> hooked = get_priv_hooked(__instance);

            if (hooked.Count > 0)
            {
                __instance.clearHooked();
                return(false);
            }

            float radius;

            if (!Plugin.TryGetCustomDataFor <float>(__instance.asset.GUID, FieldName, out radius))
            {
                radius = 3f;
            }

            var hook = get_priv_hook(__instance);
            var grab = get_priv_grab();

            int num = Physics.OverlapSphereNonAlloc(hook.position, radius, grab, 67108864);

            for (int i = 0; i < num; i++)
            {
                InteractableVehicle vehicle = DamageTool.getVehicle(grab[i].transform);
                if (!(vehicle == null) && !(vehicle == __instance) && vehicle.isEmpty && !vehicle.isHooked && vehicle.asset.engine != EEngine.TRAIN)
                {
                    HookInfo hookInfo = new HookInfo
                    {
                        target        = vehicle.transform,
                        vehicle       = vehicle,
                        deltaPosition = hook.InverseTransformPoint(vehicle.transform.position),
                        deltaRotation = Quaternion.FromToRotation(hook.forward, vehicle.transform.forward)
                    };
                    hooked.Add(hookInfo);
                    vehicle.isHooked = true;
                    __instance.ignoreCollisionWith(vehicle.vehicleColliders, true);
                }
            }

            set_priv_hooked(hooked, __instance);

            return(false);
        }
예제 #30
0
 public void Update()
 {
     if (triggerbot)
     {
         ItemAsset ia = Information.player.equipment.asset;
         Useable   us = Information.player.equipment.useable;
         if (Information.player.equipment.isSelected && ia != null && ia is ItemWeaponAsset)
         {
             RaycastHit hit;
             if (Tool.getLookingAt(out hit, (wepDistance ? ((ItemWeaponAsset)ia).range : distance)))
             {
                 if ((trig_players && DamageTool.getPlayer(hit.transform)) || (trig_zombies && DamageTool.getZombie(hit.transform)) || (trig_animal && DamageTool.getAnimal(hit.transform)))
                 {
                     attack(ia, Tool.getDistance(hit.transform.position));
                 }
             }
         }
     }
 }