Exemple #1
0
 public static Item[] GetAllItemsFromGround(Cell groundCell)
 {
     Item[] tempItemList = new Item[groundCell.Items.Count];
     groundCell.Items.CopyTo(tempItemList, 0);
     foreach (Item item in tempItemList)
     {
         groundCell.Remove(item);
     }
     return(tempItemList);
 }
Exemple #2
0
 public static Item RemoveItemFromGround(string itemName, Cell groundCell)
 {
     foreach (Item item in new List <Item>(groundCell.Items))
     {
         if (item.name.ToLower() == itemName.ToLower() || (int.TryParse(itemName, out int uniqueID) && uniqueID == item.UniqueID))
         {
             groundCell.Remove(item);
             return(item);
         }
     }
     return(null);
 }
        public bool OnCast(Character caster, string args)
        {
            args = args.Replace(ReferenceSpell.Command, "");
            args = args.Trim();

            Character target = ReferenceSpell.FindAndConfirmSpellTarget(caster, args);
            Cell      dCell  = null;

            if (target == null)
            {
                dCell = Map.GetCellRelevantToCell(caster.CurrentCell, args, false);
            }
            else
            {
                dCell = target.CurrentCell;
            }

            if (dCell == null && target == null)
            {
                return(false);
            }

            //var tCell = Map.GetCellRelevantToCell(caster.CurrentCell, args, true);

            if (dCell != null)
            {
                // destroy all but attuned items
                foreach (var item in new List <Item>(dCell.Items))
                {
                    if (item.attunedID <= 0 && !item.IsArtifact() && !((item is Corpse) && (item as Corpse).IsPlayerCorpse))
                    {
                        dCell.Remove(item);
                    }
                }

                // do spell damage
                foreach (Character chr in dCell.Characters.Values)
                {
                    if (Combat.DoSpellDamage(caster, chr, null, Skills.GetSkillLevel(caster.magic) * 10, ReferenceSpell.Name.ToLower()) == 1)
                    {
                        Rules.GiveAEKillExp(caster, chr);
                    }
                }

                // destroy walls for a while
                if (!dCell.IsMagicDead)
                {
                    if (dCell.DisplayGraphic == Cell.GRAPHIC_WALL)
                    {
                        var newDispGraphic = Rules.RollD(1, 20) >= 10 ? Cell.GRAPHIC_RUINS_LEFT : Cell.GRAPHIC_RUINS_RIGHT;

                        var effect = new AreaEffect(Effect.EffectTypes.Illusion, newDispGraphic, 0, (int)Skills.GetSkillLevel(caster.magic) * 6, caster, dCell);
                        dCell.SendShout("a wall crumbling.");
                    }
                    else if (dCell.DisplayGraphic == Cell.GRAPHIC_RUINS_LEFT || dCell.DisplayGraphic == Cell.GRAPHIC_RUINS_RIGHT)
                    {
                        var newDispGraphic = Rules.RollD(1, 20) >= 10 ? Cell.GRAPHIC_BARREN_LEFT : Cell.GRAPHIC_BARREN_RIGHT;

                        var effect = new AreaEffect(Effect.EffectTypes.Illusion, newDispGraphic, 0, (int)Skills.GetSkillLevel(caster.magic) * 6, caster, dCell);
                        dCell.SendShout("stone crumbling to dust.");
                    }
                }
            }

            ReferenceSpell.SendGenericCastMessage(caster, null, true);

            return(true);
        }