public void EndFill(Mobile from, object o) { if (!IsChildOf(from.Backpack) && !IsChildOf(from.BankBox)) { from.SendMessage("That tome must be in your backpack or bankbox for you to use it."); return; } if (!(o is Spellbook)) { from.SendMessage(32, "That isn't a Spellbook."); return; } Spellbook book = (Spellbook)o; if (!book.IsChildOf(from.Backpack) && !book.IsChildOf(from.BankBox)) { from.SendMessage("That spell book must be in your backpack or bankbox for you to fill it from the tome."); return; } FillBook(book, from, true); }
private void CraftEnhancedSpellbook_Callback(Mobile from, Item item, bool target) { PlayerMobile player = from as PlayerMobile; Spellbook spellbook = item as Spellbook; //Player or Item is Invalid if (player == null || item == null) { return; } //Target Non-Enhanced Spellbook if (spellbook == null || !(item is EnhancedSpellbook)) { player.SendMessage("You must target a basic spellbook."); return; } //Spellbook Isn't In Inventory or Equipped if (!spellbook.IsChildOf(player)) { player.SendMessage("You must target a spellbook that you have equipped or that is in your backpack."); return; } //Spellbook Has Spells In It if (spellbook.SpellCount > 0) { player.SendMessage("You must target an empty spellbook."); return; } double inscriptionSkillRequired = 100; switch (m_EnhancedSpellbookType) { case EnhancedSpellbookType.Wizard: inscriptionSkillRequired = 80; break; case EnhancedSpellbookType.Warlock: inscriptionSkillRequired = 80; break; case EnhancedSpellbookType.Summoner: inscriptionSkillRequired = 80; break; case EnhancedSpellbookType.Fire: inscriptionSkillRequired = 90; break; case EnhancedSpellbookType.Energy: inscriptionSkillRequired = 90; break; case EnhancedSpellbookType.Slayer: inscriptionSkillRequired = 100; break; } //Player Has Insufficient Inscription if (player.Skills[SkillName.Inscribe].Value < inscriptionSkillRequired) { player.SendMessage("You lack the neccessary Inscription skill to use this tome"); return; } EnhancedSpellbook enhancedSpellbook; if (m_EnhancedSpellbookType == EnhancedSpellbookType.Slayer) { enhancedSpellbook = new EnhancedSpellbook(EnhancedSpellbookType.Slayer, m_SlayerGroup); } else { enhancedSpellbook = new EnhancedSpellbook(m_EnhancedSpellbookType); } enhancedSpellbook.CraftedBy = player; player.Backpack.AddItem(enhancedSpellbook); player.SendMessage("You craft an enhanced spellbook"); from.PlaySound(0x249); spellbook.Delete(); Delete(); }
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."); } } }