public void Hydrofabricate()
        {
            List <Cell> CellList = PickCone(4 + Level, 30 + Level, AllowVis.OnlyVisible);

            CellList = CellList.OrderBy(cell => cell.ManhattanDistanceTo(ParentObject.CurrentCell)).ToList();

            if (!this.ParentObject.pPhysics.CurrentCell.ParentZone.IsWorldMap())
            {
                base.PlayWorldSound("splashcast", 1.5f, 0, true, null);
                XDidY(ParentObject, "materialize", "a torrential flood", "!", "C", null);
                for (int index = 0; index < CellList.Count; index++)
                {
                    Cell C = CellList[index];

                    if (C.ParentZone.IsActive() && C.IsVisible())
                    {
                        TextConsole.LoadScrapBuffers();
                        ScreenBuffer scrapBuffer = TextConsole.ScrapBuffer;
                        XRLCore.Core.RenderMapToBuffer(TextConsole.ScrapBuffer);
                        scrapBuffer.Goto(C.X, C.Y);
                        scrapBuffer.Write(GetRandomBlueFlashes() + "\a");
                        Popup._TextConsole.DrawBuffer(scrapBuffer);
                        Thread.Sleep(10);
                        XRLCore.Core.RenderMapToBuffer(scrapBuffer);
                        scrapBuffer.Goto(C.X, C.Y);
                        scrapBuffer.Write(GetRandomBlueFlashes() + "\u0489");
                        Popup._TextConsole.DrawBuffer(scrapBuffer);
                        Thread.Sleep(10);

                        var Roll = Stat.Random(1, 100);

                        if (Roll <= 50)
                        {
                            if (Roll >= 90)
                            {
                                base.PlayWorldSound("flood1", 1.5f, 0, true, null);
                            }
                            else if (Roll >= 60)
                            {
                                base.PlayWorldSound("flood2", 1.5f, 0, true, null);
                            }
                            else if (Roll >= 30)
                            {
                                base.PlayWorldSound("flood3", 1.5f, 0, true, null);
                            }
                            else
                            {
                            }
                        }

                        if (C.HasObjectWithPart("Combat") || C.HasObjectWithPart("Brain"))
                        {
                            var cObj = C.GetFirstObjectWithPart("Combat");
                            if (cObj != ParentObject)
                            {
                                cObj.Push(ParentObject.CurrentCell.GetDirectionFromCell(cObj.CurrentCell), 1000, 4);
                                cObj.TakeDamage(2 * Level, "Drowned in a torrent of liquid.", null, DeathReason: "from %t torrent-blast.", ThirdPersonDeathReason: null, ParentObject, ParentObject, ParentObject);
                                cObj.GetAngryAt(ParentObject, -50);
                            }
                        }

                        C.Splash("{{B|~}}");
                        C.AddObject("SaltyWaterPuddle");
                    }
                }
            }
        }
        public void CastDarkness()
        {
            try
            {
                int ParentsEgoModifer = ParentObject.Statistics["Ego"].Modifier;

                int         MaximumRadius = Math.Min(1 + (Level / 2), 4);
                List <Cell> Cells         = PickBurst(MaximumRadius, 8 + Level, false, AllowVis.OnlyExplored);

                int Ran1 = Stat.Random(1, 100);

                if (!this.ParentObject.pPhysics.CurrentCell.ParentZone.IsWorldMap())
                {
                    if (Stat.Random(1, 100) < Ran1)
                    {
                        base.PlayWorldSound("darknesscast", 15f, 0, true, null);
                    }
                    else
                    {
                        base.PlayWorldSound("darknesscastdeep", 15f, 0, true, null);
                    }

                    for (int index = 0; index < Cells.Count; index++)
                    {
                        Cell C = Cells[index];

                        if (C.ParentZone.IsActive() && C.IsVisible())
                        {
                            TextConsole.LoadScrapBuffers();
                            ScreenBuffer scrapBuffer = TextConsole.ScrapBuffer;
                            XRLCore.Core.RenderMapToBuffer(TextConsole.ScrapBuffer);
                            scrapBuffer.Goto(C.X, C.Y);
                            scrapBuffer.Write(GetDarknesBlips() + "\a");
                            Popup._TextConsole.DrawBuffer(scrapBuffer);
                            Thread.Sleep(10);
                            XRLCore.Core.RenderMapToBuffer(scrapBuffer);
                            scrapBuffer.Goto(C.X, C.Y);
                            scrapBuffer.Write(GetDarknesBlips() + "\u0489");
                            Popup._TextConsole.DrawBuffer(scrapBuffer);
                            Thread.Sleep(5);

                            var Roll = Stat.Random(1, 100);
                            if (Roll <= 10)
                            {
                                base.PlayWorldSound("darkness", 15f, 0, true, null);
                            }

                            if (C.HasObjectWithPart("Combat") || C.HasObjectWithPart("Brain"))
                            {
                                var cObj = C.GetFirstObjectWithPart("Combat");
                                if (cObj != ParentObject)
                                {
                                    if (cObj.MakeSave(Stat: "Ego", Difficulty: 5 + Level, Attacker: ParentObject, AttackerStat: "Ego"))
                                    {
                                        cObj.ApplyEffect(new Confused(ParentsEgoModifer * 10, Level, (ParentsEgoModifer + Level) / 2));
                                    }
                                }
                            }

                            GameObject gameObject = C.AddObject("MagicalDarkness");

                            MagicalDarkness Darkness = gameObject.GetPart <MagicalDarkness>();

                            // AddPlayerMessage("Status Check: Setting up Objects");

                            int Ran2 = Stat.Random(0, 3);
                            Darkness.Duration = ((Level * (10 + ParentsEgoModifer) / 2) + Ran2);
                        }
                    }
                }
                CooldownMyActivatedAbility(ShadowAreaEffectActivatedAbilityID, 60);
            }
            catch
            {
            }
        }
        public void ApplyCombustExplosion(Cell C, List <Cell> UsedCells, List <GameObject> Hit, int Force, bool bLocal, bool bShow, GameObject Owner, string BonusDamage, bool?Phase, bool Neutron = false, float DamageModifier = 1f)
        {
            TextConsole  textConsole = Look._TextConsole;
            ScreenBuffer scrapBuffer = TextConsole.ScrapBuffer;

            if (bShow)
            {
                TextConsole.LoadScrapBuffers();
                XRLCore.Core.RenderMapToBuffer(scrapBuffer);
            }
            CleanQueue <Cell>   cleanQueue  = new CleanQueue <Cell>();
            CleanQueue <int>    cleanQueue2 = new CleanQueue <int>();
            CleanQueue <string> cleanQueue3 = new CleanQueue <string>();

            cleanQueue.Enqueue(C);
            cleanQueue2.Enqueue(Force);
            cleanQueue3.Enqueue(".");
            UsedCells.Add(C);
            while (cleanQueue.Count > 0)
            {
                Cell   cell = cleanQueue.Dequeue();
                int    num  = cleanQueue2.Dequeue();
                string text = cleanQueue3.Dequeue();
                for (int i = 0; i < UsedCells.Count; i++)
                {
                    Cell cell2 = UsedCells[i];
                    if (cell2 == null)
                    {
                        return;
                    }
                    if (cell2.ParentZone == XRLCore.Core.Game.ZoneManager.ActiveZone)
                    {
                        scrapBuffer.Goto(cell2.X, cell2.Y);
                        int num2 = Stat.Random(1, 3);
                        if (num2 == 1)
                        {
                            scrapBuffer.Write((Phase != null) ? ((!(Phase == true)) ? "&Y*" : "&K*") : "&M*");
                        }
                        else if (num2 == 2)
                        {
                            scrapBuffer.Write((Phase != null) ? ((!(Phase == true)) ? "&R*" : "&b*") : "&G*");
                        }
                        else
                        {
                            scrapBuffer.Write((Phase != null) ? ((!(Phase == true)) ? "&W*" : "&c*") : "&m*");
                        }
                    }
                }
                if (bShow && C.ParentZone != null && C.ParentZone.IsActive())
                {
                    textConsole.DrawBuffer(scrapBuffer, null, false);
                    if (Force < 100000)
                    {
                        Thread.Sleep(5);
                    }
                }
                List <Cell> list;
                if (bLocal)
                {
                    list = cell.GetLocalAdjacentCells(1, false);
                }
                else
                {
                    list = cell.GetAdjacentCells(true);
                }
                for (int j = 0; j < UsedCells.Count; j++)
                {
                    Cell item = UsedCells[j];
                    if (list.CleanContains(item))
                    {
                        list.Remove(item);
                    }
                }
                int    num3   = 0;
                Damage damage = null;
                Event  @event = null;
                foreach (GameObject gameObject in cell.GetObjectsWithPart("Physics"))
                {
                    if (!Hit.Contains(gameObject))
                    {
                        Hit.Add(gameObject);
                        if (gameObject.PhaseMatches(0))
                        {
                            num3 += gameObject.Weight;
                            if (damage == null || !string.IsNullOrEmpty(BonusDamage))
                            {
                                damage = new Damage((int)(DamageModifier * (float)num / 250f));
                                if (!string.IsNullOrEmpty(BonusDamage))
                                {
                                    damage.Amount += BonusDamage.RollCached();
                                }
                                damage.AddAttribute("Explosion");
                                damage.AddAttribute("Heat");
                                damage.AddAttribute("Fire");
                                damage.AddAttribute("Concussion");
                                if (cell != C)
                                {
                                    damage.AddAttribute("Accidental");
                                }
                            }
                            if (@event == null || !string.IsNullOrEmpty(BonusDamage))
                            {
                                @event = Event.New("TakeDamage", 0, 0, 0);
                                @event.SetParameter("Damage", damage);
                                @event.SetParameter("Owner", Owner);
                                @event.SetParameter("Attacker", Owner);
                                if (Neutron)
                                {
                                    if (gameObject.IsPlayer())
                                    {
                                        gameObject.pPhysics.LastDeathReason = "Crushed under the weight of a thousand suns.";
                                    }
                                    @event.SetParameter("Message", "from being crushed under the weight of a thousand suns.");
                                }
                                else
                                {
                                    @event.SetParameter("Message", "from %t explosion!");
                                }
                            }
                            gameObject.FireEvent(@event);
                        }
                    }
                }
                System.Random random = new System.Random();
                for (int k = 0; k < list.Count; k++)
                {
                    int  index = random.Next(0, list.Count);
                    Cell value = list[k];
                    list[k]     = list[index];
                    list[index] = value;
                }
                Damage damage2 = null;
                Event  event2  = null;
                for (; ;)
                {
IL_44B:
                    int l = 0;
                    while (l < list.Count)
                    {
                        Cell cell3 = list[l];
                        if (!bLocal)
                        {
                            goto IL_4AD;
                        }
                        if (cell3.X != 0)
                        {
                            if (cell3.X != 79)
                            {
                                if (cell3.Y != 0)
                                {
                                    if (cell3.Y != 24)
                                    {
                                        goto IL_4AD;
                                    }
                                }
                            }
                        }
IL_68C:
                        l++;
                        continue;
IL_4AD:
                        foreach (GameObject gameObject2 in cell3.GetObjectsWithPart("Physics"))
                        {
                            if (!Hit.Contains(gameObject2))
                            {
                                Hit.Add(gameObject2);
                                if (gameObject2.PhaseMatches(0))
                                {
                                    if (damage2 == null || !string.IsNullOrEmpty(BonusDamage))
                                    {
                                        damage2 = new Damage(num / 250);
                                        if (!string.IsNullOrEmpty(BonusDamage))
                                        {
                                            damage2.Amount += BonusDamage.RollCached();
                                        }
                                        damage2.AddAttribute("Explosion");
                                        damage2.AddAttribute("Accidental");
                                        damage2.AddAttribute("Heat");
                                        damage2.AddAttribute("Fire");
                                        damage2.AddAttribute("Concussion");
                                    }
                                    if (event2 == null || !string.IsNullOrEmpty(BonusDamage))
                                    {
                                        event2 = Event.New("TakeDamage", 0, 0, 0);
                                        event2.SetParameter("Damage", damage2);
                                        event2.SetParameter("Owner", Owner);
                                        event2.SetParameter("Attacker", Owner);
                                        if (Neutron)
                                        {
                                            if (gameObject2.IsPlayer())
                                            {
                                                gameObject2.pPhysics.LastDeathReason = "Crushed under the weight of a thousand suns.";
                                            }
                                            event2.SetParameter("Message", "from being crushed under the weight of a thousand suns.");
                                        }
                                        else
                                        {
                                            event2.SetParameter("Message", "from %t explosion!");
                                        }
                                    }
                                    gameObject2.FireEvent(event2);
                                }
                            }
                            if (gameObject2.PhaseMatches(0))
                            {
                                int weight = gameObject2.Weight;
                                if (weight > num)
                                {
                                    list.Remove(cell3);
                                    goto IL_44B;
                                }
                                if (weight > 0)
                                {
                                    gameObject2.Move((!(text == ".")) ? text : Directions.GetRandomDirection(), EnergyCost: 1000);
                                }
                            }
                        }
                        if (cell3.IsSolid())
                        {
                            list.Remove(cell3);
                            goto IL_44B;
                        }
                        goto IL_68C;
                    }
                    break;
                }
                if (list.Count > 0)
                {
                    int num4 = (num - num3) / list.Count;
                    if (num4 > 100)
                    {
                        foreach (Cell cell4 in list)
                        {
                            if (cell4 != null && !UsedCells.Contains(cell4))
                            {
                                UsedCells.Add(cell4);
                                cleanQueue.Enqueue(cell4);
                                cleanQueue2.Enqueue(num4);
                                cleanQueue3.Enqueue(cell.GetDirectionFromCell(cell4));
                            }
                        }
                    }
                }
            }
        }