public CustomSpellScrollCopyTarget( PlayerMobile m, CustomMageSpell Spell )
            : base(8, false, TargetFlags.None)
        {
            spell = Spell;

            m.SendMessage( "Choose the scroll you wish to copy this spell to." );
        }
        public static void CastCustomMageSpell( Mobile m, CustomMageSpell Spell )
        {
            if( !IsMageCheck( m, true ) )
                return;

            CustomMageSpell spell = DupeCustomMageSpell( Spell );
            spell.Caster = m;
            BaseCustomSpell.SpellInitiator( spell );
        }
 public RecurrentDamageTimer( Mobile target, CustomMageSpell spell )
     : base(TimeSpan.FromSeconds( spell.RepDelay ))
 {
     m_target = target as Mobile;
     m_spell = spell;
 }
 public MageChainEffectTimer( CustomMageSpell cms )
     : base(TimeSpan.FromSeconds( cms.DamageDelay ))
 {
     spell = cms;
 }
        public override void OnResponse( NetState sender, RelayInfo info )
        {
            PlayerMobile from = sender.Mobile as PlayerMobile;

            if( from == null || from.Deleted )
                return;

            if( info.ButtonID == 0 )
                return;

            if( Scroll == null || Scroll.Deleted || !Scroll.IsChildOf(from.Backpack) )
            {
                from.SendMessage( "The scroll must be in your backpack for you to edit it" );
                from.SendGump( new CustomSpellScrollGump( from, Scroll ) );
                return;
            }

            FeatList requiredFeat;
            try
            {
                requiredFeat = (FeatList)(Enum.Parse(typeof(FeatList), info.GetTextEntry(20).Text));
            }
            catch (Exception)
            {
                from.SendMessage(String.Format("Was unable to find a feat named {0}", info.GetTextEntry(20).Text));
                from.SendGump(new CustomSpellScrollGump(from, Scroll));
                return;
            }

            CustomMageSpell spell = new CustomMageSpell( null, 1 );
            spell.RequiredFeat = requiredFeat;
            spell.CustomName = info.GetTextEntry(0).Text;
            spell.Damage = GetNumbersFromString( info.GetTextEntry(1).Text );
            spell.Range = GetNumbersFromString( info.GetTextEntry(2).Text );
            spell.ChainedTargets = GetNumbersFromString( info.GetTextEntry(3).Text );
            spell.ChainedDamage = GetNumbersFromString( info.GetTextEntry(4).Text );
            spell.StatusDuration = GetNumbersFromString( info.GetTextEntry(5).Text );
            spell.StatusType = GetNumbersFromString( info.GetTextEntry(6).Text );
            spell.Reps = GetNumbersFromString( info.GetTextEntry(7).Text );
            spell.RepDelay = GetNumbersFromString( info.GetTextEntry(8).Text );
            spell.RepDamage = GetNumbersFromString( info.GetTextEntry(9).Text );
            spell.ExplosionDamage = GetNumbersFromString( info.GetTextEntry(10).Text );
            spell.ExplosionArea = GetNumbersFromString( info.GetTextEntry(11).Text );
            spell.ExplosionSound = GetNumbersFromString( info.GetTextEntry(12).Text );
            spell.ExplosionHue = GetNumbersFromString( info.GetTextEntry(13).Text );
            spell.ExplosionID= GetNumbersFromString( info.GetTextEntry(14).Text );
            spell.EffectSound = GetNumbersFromString( info.GetTextEntry(15).Text );
            spell.EffectHue = GetNumbersFromString( info.GetTextEntry(16).Text );
            spell.EffectID = GetNumbersFromString( info.GetTextEntry(17).Text );
            spell.IconID = GetNumbersFromString( info.GetTextEntry(18).Text );
            spell.ChainedRange = GetNumbersFromString( info.GetTextEntry(19).Text );

            if( CustomSpellScroll.TryToEditSpell(from, spell) )
            {
                from.SendMessage( "You have successfully edited the scroll." );
                Scroll.Spell = spell;
                Scroll.InvalidateProperties();
                return;
            }

            from.SendGump( new CustomSpellScrollGump( from, Scroll ) );
        }
 public override void Deserialize( GenericReader reader )
 {
     base.Deserialize( reader );
      		int version = reader.ReadInt();
      		Spell = DeserializeSpell( reader );
 }
        public static bool TryToEditSpell( PlayerMobile m, CustomMageSpell spell )
        {
            if( m.Feats.GetFeatLevel(FeatList.DamagingEffect) < 3 && spell.Damage > (m.Feats.GetFeatLevel(FeatList.DamagingEffect) * 25) )
                m.SendMessage( "You lack the appropriate knowledge to create a spell that deals that much damage." );

            else if( (spell.ExplosionArea > (m.Feats.GetFeatLevel(FeatList.ExplosiveEffect) * 2)) )
                m.SendMessage( "You lack the appropriate knowledge to create a spell with an explosion area of that magnitude." );

            else if( m.Feats.GetFeatLevel(FeatList.ExplosiveEffect) < 3 && spell.ExplosionDamage > (m.Feats.GetFeatLevel(FeatList.ExplosiveEffect) * 25) )
                m.SendMessage( "You lack the appropriate knowledge to create a spell that deals that much damage from explosion." );

            else if( (spell.Range > (m.Feats.GetFeatLevel(FeatList.RangedEffect) * 5)) )
                m.SendMessage( "You lack the appropriate knowledge to create a spell with that much range." );

            else if( (spell.ChainedRange > (m.Feats.GetFeatLevel(FeatList.ChainEffect) * 5)) )
                m.SendMessage( "You lack the appropriate knowledge to create a spell with that much chained range." );

            else if( (spell.ChainedTargets > (m.Feats.GetFeatLevel(FeatList.ChainEffect) * 2)) )
                m.SendMessage( "You lack the appropriate knowledge to create a spell with that many chained targets." );

            else if( (m.Feats.GetFeatLevel(FeatList.ChainEffect) < 3 && spell.ChainedDamage > (m.Feats.GetFeatLevel(FeatList.ChainEffect) * 25)) )
                m.SendMessage( "You lack the appropriate knowledge to create a spell that deals that much chained damage." );

            else if( spell.StatusType > m.Feats.GetFeatLevel(FeatList.StatusEffect) )
                m.SendMessage( "You lack the appropriate knowledge to create a spell with that status type." );

            else if( spell.StatusDuration > (m.Feats.GetFeatLevel(FeatList.StatusEffect) * 2) )
                m.SendMessage( "You lack the appropriate knowledge to create a spell whose status lasts for that long." );

            else if ( (m.Feats.GetFeatLevel(FeatList.RecurrentEffect) < 3 && spell.RepDamage > (m.Feats.GetFeatLevel(FeatList.RecurrentEffect) * 25)) )
                m.SendMessage( "You lack the appropriate knowledge to create a spell that deals that much recurrent damage." );

            else if( spell.Reps > (m.Feats.GetFeatLevel(FeatList.RecurrentEffect) * 2) )
                m.SendMessage( "You lack the appropriate knowledge to create a spell with that many repetitions." );

            else if( (spell.RepDelay < 11 && m.Feats.GetFeatLevel(FeatList.RecurrentEffect) < 2) || (spell.RepDelay < 6 && m.Feats.GetFeatLevel(FeatList.RecurrentEffect) < 3) )
                m.SendMessage( "You lack the appropriate knowledge to create a spell whose recurrent effect happens so fast." );

            else if(!m.Feats.FeatDictionary.ContainsKey(spell.RequiredFeat))
                m.SendMessage(String.Format("You lack the {0} feat to create this spell.", spell.RequiredFeat));

            else
                return true;

            return false;
        }
 public static void SerializeSpell( GenericWriter writer, CustomMageSpell Spell )
 {
     writer.Write( (int) 2 ); // version
     writer.Write( (string) Spell.GetType().Name );
     //writer.Write((string)Spell.RequiredFeat.ToString());
       			writer.Write( (string) Spell.CustomName );
      		writer.Write( (int) Spell.RepDamage );
     writer.Write( (int) Spell.Damage );
     writer.Write( (int) Spell.Range );
     writer.Write( (int) Spell.ChainedTargets );
     writer.Write( (int) Spell.ChainedDamage );
     writer.Write( (int) Spell.ChainedRange );
     writer.Write( (int) Spell.ExplosionDamage );
     writer.Write( (int) Spell.ExplosionArea );
     writer.Write( (int) Spell.Reps );
     writer.Write( (int) Spell.RepDelay );
     writer.Write( (int) Spell.StatusType );
     writer.Write( (int) Spell.StatusDuration );
     writer.Write( (int) Spell.EffectID );
     writer.Write( (int) Spell.EffectHue );
     writer.Write( (int) Spell.EffectSound );
     writer.Write( (int) Spell.ExplosionID );
     writer.Write( (int) Spell.ExplosionHue );
     writer.Write( (int) Spell.ExplosionSound );
     writer.Write( (int) Spell.IconID );
     writer.Write( (string) Spell.RequiredFeat.ToString());
 }
 public static void GetCustomMageSpellStats( Mobile m, CustomMageSpell spell )
 {
     m.SendMessage( "Name: " + spell.CustomName );
     m.SendMessage( "Mana Cost: " + spell.ManaCost.ToString() );
     m.SendMessage( "Damage: " + spell.Damage.ToString() );
     m.SendMessage( "Range: " + spell.Range.ToString() );
     m.SendMessage( "Chained Targets: " + spell.ChainedTargets.ToString() );
     m.SendMessage( "Chained Damage: " + spell.ChainedDamage.ToString() );
     m.SendMessage( "Chained Range: " + spell.ChainedRange.ToString() );
     m.SendMessage( "Explosion Damage: " + spell.ExplosionDamage.ToString() );
     m.SendMessage( "Explosion Area: " + spell.ExplosionArea.ToString() );
     m.SendMessage( "Repetitions: " + spell.Reps.ToString() );
     m.SendMessage( "Repetition Delay: " + spell.RepDelay.ToString() );
     m.SendMessage( "Repetition Damage: " + spell.RepDamage.ToString() );
     m.SendMessage( "Status Type: " + spell.StatusType.ToString() );
     m.SendMessage( "Status Duration: " + spell.StatusDuration.ToString() );
     m.SendMessage( "Effect ID: " + spell.EffectID.ToString() );
     m.SendMessage( "Effect Hue: " + spell.EffectHue.ToString() );
     m.SendMessage( "Effect Sound: " + spell.EffectSound.ToString() );
     m.SendMessage( "Explosion ID: " + spell.ExplosionID.ToString() );
     m.SendMessage( "Explosion Hue: " + spell.ExplosionHue.ToString() );
     m.SendMessage( "Explosion Sound: " + spell.ExplosionSound.ToString() );
     m.SendMessage( "Icon ID: " + spell.IconID.ToString() );
     m.SendMessage("Required Feat: "+spell.RequiredFeat.ToString());
 }
        public static CustomMageSpell DupeCustomMageSpell( CustomMageSpell Spell )
        {
            CustomMageSpell spell = (CustomMageSpell)Spell.GetNewInstance();

            spell.CustomName = Spell.CustomName;
            spell.Damage = Spell.Damage;
            spell.Range = Spell.Range;
            spell.ChainedTargets = Spell.ChainedTargets;
            spell.ChainedDamage = Spell.ChainedDamage;
            spell.ChainedRange = Spell.ChainedRange;
            spell.ExplosionDamage = Spell.ExplosionDamage;
            spell.ExplosionArea = Spell.ExplosionArea;
            spell.Reps = Spell.Reps;
            spell.RepDelay = Spell.RepDelay;
            spell.RepDamage = Spell.RepDamage;
            spell.StatusType = Spell.StatusType;
            spell.StatusDuration = Spell.StatusDuration;
            spell.EffectID = Spell.EffectID;
            spell.EffectHue = Spell.EffectHue;
            spell.EffectSound = Spell.EffectSound;
            spell.ExplosionID = Spell.ExplosionID;
            spell.ExplosionHue = Spell.ExplosionHue;
            spell.ExplosionSound = Spell.ExplosionSound;
            spell.IconID = Spell.IconID;
            spell.RequiredFeat = Spell.RequiredFeat;

            return spell;
        }