Beispiel #1
0
        public bool OnCast(Character caster, string args)
        {
            args = args.Replace(" at ", "");

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

            int duration = 3; // 3 rounds, base

            if (caster.species == Globals.eSpecies.Arachnid || Autonomy.EntityBuilding.EntityLists.ARACHNID.Contains(caster.entity))
            {
                duration += caster.Level / 2;
            }
            else if (caster.IsSpellWarmingProfession && caster.preppedSpell == GameSpell.GetSpell((int)GameSpell.GameSpellID.Create_Web))
            {
                duration += Skills.GetSkillLevel(caster.magic) / 3;
            }

            duration += Rules.Dice.Next(-1, 1);

            if (target == null)
            {
                Cell targetCell = Map.GetCellRelevantToCell(caster.CurrentCell, args, false);

                if (targetCell != null)
                {
                    AreaEffect effect = new AreaEffect(Effect.EffectTypes.Web, Cell.GRAPHIC_WEB, Skills.GetSkillLevel(caster.magic), duration, caster, targetCell);
                    targetCell.EmitSound(ReferenceSpell.SoundFile);
                }
            }
            else
            {
                AreaEffect effect = new AreaEffect(Effect.EffectTypes.Web, Cell.GRAPHIC_WEB, Skills.GetSkillLevel(caster.magic), duration, caster, target.CurrentCell);
                if (target.CurrentCell != null)
                {
                    target.CurrentCell.EmitSound(ReferenceSpell.SoundFile);
                }
            }

            if (target == null)
            {
                caster.WriteToDisplay("You cast " + ReferenceSpell.Name + ".");
            }
            else
            {
                caster.WriteToDisplay("You cast " + ReferenceSpell.Name + " at " + target.GetNameForActionResult(true).Replace("The ", "the "));
            }
            return(true);
        }
        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);
        }