Esempio n. 1
0
            protected override void OnTarget(Mobile from, object target)
            {
                if (!SpecialAbilities.Exists(from))
                {
                    return;
                }
                if (from.Backpack == null)
                {
                    return;
                }

                if (!(target is Spellbook))
                {
                    from.SendMessage("That is not a spellbook.");
                    return;
                }

                Spellbook spellbook = target as Spellbook;

                Item item = from.FindItemOnLayer(Layer.FirstValid);

                if (!(spellbook.IsChildOf(from.Backpack) || item == spellbook))
                {
                    from.SendMessage("You may only target spellbooks you have equipped or in your backpack.");
                    return;
                }

                List <SpellScroll> m_Scrolls = from.Backpack.FindItemsByType <SpellScroll>();

                int totalCount = 0;

                Queue m_Queue = new Queue();

                foreach (SpellScroll spellScroll in m_Scrolls)
                {
                    SpellbookType type = GetTypeForSpell(spellScroll.SpellID);

                    if (type != spellbook.SpellbookType)
                    {
                        continue;
                    }

                    if (spellbook.HasSpell(spellScroll.SpellID))
                    {
                        continue;
                    }

                    m_Queue.Enqueue(spellScroll);
                }

                while (m_Queue.Count > 0)
                {
                    SpellScroll spellScroll = (SpellScroll)m_Queue.Dequeue();

                    if (spellbook.HasSpell(spellScroll.SpellID))
                    {
                        continue;
                    }

                    int val = spellScroll.SpellID - spellbook.BookOffset;

                    if (val >= 0 && val < spellbook.BookCount)
                    {
                        totalCount++;

                        spellbook.m_Content |= (ulong)1 << val;
                        ++spellbook.m_Count;

                        spellbook.InvalidateProperties();

                        if (spellScroll.Amount > 1)
                        {
                            spellScroll.Amount--;
                        }

                        else
                        {
                            spellScroll.Delete();
                        }
                    }
                }

                if (totalCount > 0)
                {
                    from.SendSound(0x249);
                    from.SendMessage("You add " + totalCount.ToString() + " spells into the spellbook.");
                }

                else
                {
                    if (m_Scrolls.Count == 0)
                    {
                        from.SendMessage("You do not have any spell scrolls in your backpack.");
                    }

                    else
                    {
                        from.SendMessage("That spellbook already has those spells present within.");
                    }
                }
            }
        public void FillBook(Spellbook spb, Mobile from, bool gump)
        {
            if (spb is BookOfChivalry || spb is BookOfBushido || spb is BookOfNinjitsu)    //NOTE:tookout druid cause dont have:ENDNOTE || spb is DruidSpellbook)
            {
                from.SendMessage("That spellbook is not supported.");
                return;
            }

            if (al_GlobalEntry == null)
            {
                InitArray();
            }

            int numSpellMissing = 0;
            int numSpellFilled  = 0;

            for (int sid = spb.BookOffset; sid < spb.BookOffset + spb.BookCount; sid++)
            {
                int tid = sid;
                if (spb.HasSpell(sid))
                {
                    continue;
                }

                if (tid >= 100 && tid <= 115)
                {
                    tid -= 36;
                }
                else if (tid > 64)
                {
                    continue;
                }

                if (((ScrollEntry)al_GlobalEntry[tid]).Amount <= 0)
                {
                    numSpellMissing++;
                    continue;
                }

                ((ScrollEntry)al_GlobalEntry[tid]).Amount--;
                int val = sid - spb.BookOffset;

                if (val >= 0 && val < spb.BookCount)                   // double check
                {
                    spb.Content |= (ulong)1 << val;

                    numSpellFilled++;

                    spb.InvalidateProperties();
                }
            }

            from.SendMessage(numSpellFilled.ToString() + " spells are added to the book. ");
            if (numSpellMissing > 0)
            {
                from.SendMessage("There are still " + numSpellMissing.ToString() + " spells missing.");
            }
            else
            {
                from.SendMessage("Now the spell book is complete.");
            }

            if (gump)
            {
                from.SendGump(new ResourceStorageKeyScribersTomeGump(from, this));
            }
        }
        public void FillBook(Spellbook spb, Mobile from, bool gump)
        {
        	if (spb is BookOfChivalry || spb is BookOfBushido || spb is BookOfNinjitsu)//NOTE:tookout druid cause dont have:ENDNOTE || spb is DruidSpellbook)
            {
                from.SendMessage("That spellbook is not supported.");
                return;
            }

            if (al_GlobalEntry == null)
                InitArray();

            int numSpellMissing = 0;
            int numSpellFilled = 0;
            for (int sid = spb.BookOffset; sid < spb.BookOffset + spb.BookCount; sid++)
            {
                int tid = sid;
                if (spb.HasSpell(sid))
                    continue;

                if (tid >= 100 && tid <= 115)
                    tid -= 36;
                else if (tid > 64)
                    continue;

                if (((ScrollEntry)al_GlobalEntry[tid]).Amount <= 0)
                {
                    numSpellMissing++;
                    continue;
                }

                ((ScrollEntry)al_GlobalEntry[tid]).Amount --;
					int val = sid - spb.BookOffset;

				if ( val >= 0 && val < spb.BookCount ) // double check
				{
					spb.Content |= (ulong)1 << val;

                    numSpellFilled++;

					spb.InvalidateProperties();
                }
            
            }

            from.SendMessage(numSpellFilled.ToString() + " spells are added to the book. ");
            if (numSpellMissing > 0)
                from.SendMessage("There are still " + numSpellMissing.ToString() + " spells missing.");
            else
                from.SendMessage("Now the spell book is complete.");

            if (gump)
                from.SendGump(new ResourceStorageKeyScribersTomeGump(from, this));
        }