Example #1
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!");
        }
Example #2
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);
            }
        }
Example #3
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);
        }
Example #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);
            }
        }
Example #5
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);
        }
Example #6
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);
        }
Example #7
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"]);
        }
Example #8
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)!");
            }
        }
Example #9
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());
                }
            }
        }
Example #10
0
        public static IEnumerator SendAirstrike(UnturnedPlayer uCaller, Vector3 Position)
        {
            Vector3        callerPosition = new Vector3();
            List <Vector3> StrikeList     = new List <Vector3>();

            Instance.Vectors.Add(Position);

            EffectManager.sendEffect(Instance.Configuration.Instance.AirstrikeLocationEffectID, EffectManager.INSANE, GetGround(Position).Value);

            if (Instance.Configuration.Instance.LogAirstrikes)
            {
                callerPosition  = uCaller.Position;
                AirstrikeCount += 1;
            }
            if (Instance.Configuration.Instance.BroadcastAirstrikes)
            {
                UnturnedChat.Say($"Incomming Airstrike in {Instance.Configuration.Instance.StartDelay} Seconds! The Location is marked on your Map! Get into cover!", Color.yellow);
            }

            foreach (SteamPlayer sPlayer in Provider.clients)
            {
                UnturnedPlayer uPlayer = UnturnedPlayer.FromSteamPlayer(sPlayer);
                uPlayer.Player.quests.askSetMarker(uPlayer.CSteamID, true, Position);
            }
            yield return(new WaitForSeconds(Instance.Configuration.Instance.StartDelay));

            Instance.Vectors.Remove(Position);

            DateTime beforeStrike = DateTime.Now;

            for (int i = 0; i < Instance.Configuration.Instance.StrikeCount; i++)
            {
                yield return(new WaitForSeconds(UnityEngine.Random.Range(Instance.Configuration.Instance.StrikeDelayMin, Instance.Configuration.Instance.StrikeDelayMax)));

                Vector3 airstrikeLocation = new Vector3(UnityEngine.Random.Range(Position.x - Instance.Configuration.Instance.DamageIntensity, Position.x + Instance.Configuration.Instance.DamageRadius), Position.y + 300, UnityEngine.Random.Range(Position.z - Instance.Configuration.Instance.DamageRadius, Position.z + Instance.Configuration.Instance.DamageRadius));
                Ray     airstrikeRay      = new Ray(airstrikeLocation, Vector3.down);

                if (Physics.Raycast(airstrikeRay, out RaycastHit Hit))
                {
                    EffectManager.sendEffect(Instance.Configuration.Instance.StrikeExplosionEffectID, EffectManager.INSANE, Hit.point);
                    List <EPlayerKill> killList = new List <EPlayerKill>();
                    DamageTool.explode(Hit.point, Instance.Configuration.Instance.DamageIntensity, EDeathCause.MISSILE, uCaller.CSteamID, 200, 200, 200, 200, 200, 200, 200, 200, out killList, EExplosionDamageType.CONVENTIONAL, 32, true, false, EDamageOrigin.Rocket_Explosion, ERagdollEffect.NONE);
                    killList.Clear();
                    if (Instance.Configuration.Instance.LogAirstrikes)
                    {
                        StrikeList.Add(Hit.point);
                    }
                }
            }
            DateTime afterStrike = DateTime.Now;

            if (Instance.Configuration.Instance.LogAirstrikes)
            {
                LogAirstrike($"[{DateTime.Now.ToString("yyy/MM/dd h:mm:ss tt")}]\n\nUser:\n{uCaller.DisplayName} [{uCaller.Id}].\n\nAirstrike Start Delay:\n{Instance.Configuration.Instance.StartDelay} seconds.\n\nStrikes:\n{Instance.Configuration.Instance.StrikeCount}.\n\nAverage Strike Time:\n{(Instance.Configuration.Instance.StrikeDelayMin + Instance.Configuration.Instance.StrikeDelayMax) / 2} seconds.\n\nCaller Position:\n{callerPosition}.\n\nAirstrike Location:\n{Position}.\n\nDistance from Caller:\n{(int)Vector3.Distance(callerPosition, Position)}M.\n\nDamage Intensity:\n{Instance.Configuration.Instance.DamageIntensity}.\n\nStrike Radius:\n{Instance.Configuration.Instance.DamageRadius}M.\n\nAirstrikes this Uptime: {AirstrikeCount}.\n\nThis Airstrike lasted {Math.Round((afterStrike - beforeStrike).TotalSeconds, 2)} Seconds.", StrikeList);
                StrikeList.Clear();
            }

            if (Instance.Configuration.Instance.BroadcastAirstrikes)
            {
                UnturnedChat.Say("The Airstrike is over!", Color.yellow);
            }

            foreach (SteamPlayer sPlayer in Provider.clients)
            {
                UnturnedPlayer uPlayer = UnturnedPlayer.FromSteamPlayer(sPlayer);
                uPlayer.Player.quests.askSetMarker(uPlayer.CSteamID, false, Position);
            }
            yield return(new WaitForSeconds(Instance.Configuration.Instance.LocationFadeTime));

            EffectManager.askEffectClearByID(Instance.Configuration.Instance.AirstrikeLocationEffectID, uCaller.CSteamID);
        }
Example #11
0
 private static void Explode(Vector3 pos)
 {
     EffectManager.sendEffect(20, EffectManager.INSANE, pos);
     DamageTool.explode(pos, 10f, EDeathCause.GRENADE, 200, 200, 200, 200, 200, 200, 200, 200);
 }
Example #12
0
        public static IEnumerator AutoStrike()
        {
            const float DAMAGE = 200;

            while (Airstrikes.Instance.Configuration.Instance.AutoAirstrike == true)
            {
                foreach (Config.Location Preset in Airstrikes.Instance.Configuration.Instance.Locations)
                {
                    Vector3 centerPoint     = new API().StringToVector3(Preset.Coords);
                    string  centerPointName = Preset.Name;
                    int     minutes         = Airstrikes.Instance.Configuration.Instance.MinutesBetweenAirstrikes - 1;
                    int     amt             = Airstrikes.Instance.Configuration.Instance.MinutesBetweenAirstrikes + 1;

                    // x minutes left...
                    for (int i = 0; i < minutes; i++)
                    {
                        amt--;

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

                            UnturnedChat.Say(Airstrikes.Instance.Translate("global_airstrike", centerPointName, amt), hexColor ?? default(Color));
                        }
                        else
                        {
                            UnturnedChat.Say(Airstrikes.Instance.Translate("global_airstrike", centerPointName, amt), UnturnedChat.GetColorFromName(Airstrikes.Instance.Configuration.Instance.GlobalMessageColor, Color.green));
                        }

                        yield return(new WaitForSeconds(60f));
                    }

                    // 1 minute left...
                    Airstrikes.Instance.Vectors.Add(centerPoint);

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

                        UnturnedChat.Say(Airstrikes.Instance.Translate("global_airstrike", centerPointName, 1), hexColor ?? default(Color));
                    }
                    else
                    {
                        UnturnedChat.Say(Airstrikes.Instance.Translate("global_airstrike", centerPointName, 1), UnturnedChat.GetColorFromName(Airstrikes.Instance.Configuration.Instance.GlobalMessageColor, Color.green));
                    }

                    yield return(new WaitForSeconds(60f));

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

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

                    yield return(new WaitForSeconds(3f));

                    Airstrikes.Instance.Vectors.Remove(centerPoint);

                    // strike...
                    for (int i = 0; i < (Preset.StrikeCount + 1); i++)
                    {
                        yield return(new WaitForSeconds(Preset.StrikeSpeed));

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

                        if (Physics.Raycast(impactRay, out RaycastHit hit))
                        {
                            EffectManager.sendEffect(20, EffectManager.INSANE, hit.point);
                            DamageTool.explode(hit.point, Preset.DamageIntensity, EDeathCause.MISSILE, CSteamID.Nil, DAMAGE, DAMAGE, DAMAGE, DAMAGE, DAMAGE, DAMAGE, DAMAGE, DAMAGE);
                            Airstrikes.WriteDebug(hit.point.ToString());
                        }
                    }
                }
            }
        }