Esempio n. 1
0
        /// <summary>Whether the given Item is needed for an active Quest</summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public bool RequiresItem(Asda2ItemId item)
        {
            for (int index1 = 0; index1 < m_RequireItemsQuests.Count; ++index1)
            {
                Quest requireItemsQuest = m_RequireItemsQuests[index1];
                for (int index2 = 0; index2 < requireItemsQuest.Template.CollectableItems.Length; ++index2)
                {
                    Asda2ItemStackDescription collectableItem = requireItemsQuest.Template.CollectableItems[index2];
                    if (collectableItem.ItemId == item)
                    {
                        return(requireItemsQuest.CollectedItems[index2] < collectableItem.Amount);
                    }
                }

                for (int index2 = 0; index2 < requireItemsQuest.Template.CollectableSourceItems.Length; ++index2)
                {
                    Asda2ItemStackDescription collectableSourceItem =
                        requireItemsQuest.Template.CollectableSourceItems[index2];
                    if (collectableSourceItem.ItemId == item)
                    {
                        return(requireItemsQuest.CollectedSourceItems[index2] < collectableSourceItem.Amount);
                    }
                }
            }

            return(false);
        }
Esempio n. 2
0
            public override void Process(CmdTrigger <RealmServerCmdArgs> trigger)
            {
                string            str      = trigger.Text.NextModifiers();
                Asda2ItemId       id       = trigger.Text.NextEnum <Asda2ItemId>(Asda2ItemId.None);
                Asda2ItemTemplate template = Asda2ItemMgr.GetTemplate(id);

                if (template == null)
                {
                    trigger.Reply("Invalid ItemId.");
                }
                else
                {
                    int amount = trigger.Text.NextInt(1);
                    if (id == Asda2ItemId.Gold20551)
                    {
                        ((Character)trigger.Args.Target).AddMoney((uint)amount);
                        ((Character)trigger.Args.Target).SendMoneyUpdate();
                    }
                    else
                    {
                        uint num1 = trigger.Text.NextUInt(1U);
                        str.Contains("a");
                        int num2 = 0;
                        while ((long)num2 < (long)num1 &&
                               InventoryCommand.ItemAddCommand.AddItem((Character)trigger.Args.Target, template,
                                                                       amount, trigger.Args.Character))
                        {
                            ++num2;
                        }
                    }
                }
            }
Esempio n. 3
0
 /// <summary>Returns the ItemTemplate with the given id</summary>
 public static ItemTemplate GetTemplate(Asda2ItemId id)
 {
     if ((long)id >= Templates.Length)
     {
         return(null);
     }
     return(Templates[(uint)id]);
 }
Esempio n. 4
0
 /// <summary>Returns the ItemTemplate with the given id</summary>
 public static ItemTemplate GetTemplate(Asda2ItemId id)
 {
     if ((long)id >= (long)ItemMgr.Templates.Length)
     {
         return((ItemTemplate)null);
     }
     return(ItemMgr.Templates[(uint)id]);
 }
Esempio n. 5
0
 public Asda2ItemStackTemplate(Asda2ItemId id)
     : this(Asda2ItemMgr.GetTemplate(id), 1)
 {
     if (m_Template == null)
     {
         throw new ArgumentException("ItemId " + id + " is invalid.");
     }
 }
Esempio n. 6
0
 public Asda2ItemStackTemplate(Asda2ItemId id, int amount)
 {
     this = new Asda2ItemStackTemplate(Asda2ItemMgr.GetTemplate(id), amount);
     if (m_Template == null)
     {
         throw new ArgumentException("id " + id + " is invalid.");
     }
 }
 public Asda2ItemStackTemplate(Asda2ItemId id)
 {
     this = new Asda2ItemStackTemplate(Asda2ItemMgr.GetTemplate(id), 1);
     if (this.m_Template == null)
     {
         throw new ArgumentException("ItemId " + (object)id + " is invalid.");
     }
 }
Esempio n. 8
0
        /// <summary>
        /// Tries to add an Item with the given template and amount ot the given slot.
        /// Make sure the given targetSlot is valid before calling this method.
        /// </summary>
        /// <returns>The result (InventoryError.OK in case that it worked)</returns>
        public InventoryError TryAdd(Asda2ItemId id, ref int amount, int targetSlot, ItemReceptionType reception = ItemReceptionType.Receive)
        {
            var templ = ItemMgr.GetTemplate(id);

            if (templ != null)
            {
                return(TryAdd(templ, ref amount, targetSlot, reception));
            }
            return(InventoryError.ITEM_NOT_FOUND);
        }
Esempio n. 9
0
        /// <summary>
        /// Tries to add ONE new item with the given template to the given slot.
        /// Make sure the given targetSlot is valid before calling this method.
        /// </summary>
        /// <returns>The result (InventoryError.OK in case that it worked)</returns>
        public InventoryError TryAdd(Asda2ItemId id, int targetSlot, ItemReceptionType reception = ItemReceptionType.Receive)
        {
            var templ = ItemMgr.GetTemplate(id);

            if (templ != null)
            {
                return(TryAdd(templ, targetSlot, reception));
            }
            return(InventoryError.Invalid);
        }
Esempio n. 10
0
        public ItemRecord AddItem(Asda2ItemId item)
        {
            ItemTemplate template = ItemMgr.GetTemplate(item);

            if (template == null)
            {
                return(null);
            }
            return(AddItem(template));
        }
Esempio n. 11
0
        public static Item CreateItem(Asda2ItemId templateId, Character owner, int amount)
        {
            ItemTemplate template = ItemMgr.GetTemplate(templateId);

            if (template != null)
            {
                return(CreateItem(template, owner, amount));
            }
            return(null);
        }
Esempio n. 12
0
        /// <summary>
        /// Tries to add ONE new item with the given template to the given slot.
        /// Make sure the given targetSlot is valid before calling this method.
        /// </summary>
        /// <returns>The result (InventoryError.OK in case that it worked)</returns>
        public InventoryError TryAdd(Asda2ItemId id, InventorySlot targetSlot,
                                     ItemReceptionType reception = ItemReceptionType.Receive)
        {
            ItemTemplate template = ItemMgr.GetTemplate(id);

            if (template != null)
            {
                return(this.TryAdd(template, (int)targetSlot, reception));
            }
            return(InventoryError.ITEM_NOT_FOUND);
        }
Esempio n. 13
0
        /// <summary>
        /// Tries to add an item with the given template and amount
        /// </summary>
        /// <returns>The result (InventoryError.OK in case that it worked)</returns>
        public InventoryError TryAdd(Asda2ItemId templId, ref int amount,
                                     ItemReceptionType reception = ItemReceptionType.Receive)
        {
            ItemTemplate template = ItemMgr.GetTemplate(templId);

            if (template != null)
            {
                return(this.TryAdd(template, ref amount, reception));
            }
            return(InventoryError.ITEM_NOT_FOUND);
        }
Esempio n. 14
0
        /// <summary>
        /// Tries to add a new item with the given template and amount ot the given slot.
        /// Make sure the given targetSlot is valid before calling this method.
        /// If slot is occupied, method will find another unoccupied slot.
        /// </summary>
        /// <returns>The result (InventoryError.OK in case that it worked)</returns>
        public InventoryError TryAdd(Asda2ItemId id, ref int amount, InventorySlot targetSlot,
                                     ItemReceptionType reception = ItemReceptionType.Receive)
        {
            ItemTemplate template = ItemMgr.GetTemplate(id);

            if (template != null)
            {
                return(TryAdd(template, ref amount, (int)targetSlot, reception));
            }
            return(InventoryError.Invalid);
        }
Esempio n. 15
0
        public static void SendBuyError(IPacketReceiver client, IEntity vendor, Asda2ItemId itemEntryId, BuyItemError error)
        {
            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_BUY_FAILED, 8 + 4 + 1))
            {
                packet.Write(vendor.EntityId);
                packet.Write((uint)itemEntryId);
                packet.Write((byte)error);

                client.Send(packet, addEnd: false);
            }
        }
Esempio n. 16
0
 public bool Contains(Asda2ItemId id)
 {
     foreach (var item in m_inventory.Items)
     {
         if (item != null && item.EntryId == (uint)id)
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 17
0
        /// <summary>
        /// Sends the quest update add item.
        /// </summary>
        /// <param name="chr">The client.</param>
        public static void SendUpdateItems(Asda2ItemId item, int diff, Character chr)
        {
            // Obsolete
            //using (var pckt = new RealmPacketOut(RealmServerOpCode.SMSG_QUESTUPDATE_ADD_ITEM, 0))
            //{
            //    //pckt.Write((uint)item);
            //    //pckt.Write(diff);

            //    //chr.Client.Send(pckt);
            //}
        }
Esempio n. 18
0
 public static void SendEnchantLog(IPacketReceivingEntity owner, Asda2ItemId entryId, uint enchantId)
 {
     using (RealmPacketOut packet = new RealmPacketOut((PacketId)RealmServerOpCode.SMSG_ENCHANTMENTLOG, 25))
     {
         packet.Write((ulong)owner.EntityId);
         packet.Write((ulong)owner.EntityId);
         packet.Write((uint)entryId);
         packet.Write(enchantId);
         packet.Write((byte)0);
         owner.Send(packet, false);
     }
 }
Esempio n. 19
0
        public static void SendBuyItem(IPacketReceiver client, IEntity vendor, Asda2ItemId itemId, int numItemsPurchased, int remainingAmount)
        {
            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_BUY_ITEM, 8 + 4 + 4 + 4))
            {
                packet.Write(vendor.EntityId);
                packet.Write((uint)itemId);
                packet.Write(numItemsPurchased);
                packet.Write(remainingAmount);

                client.Send(packet, addEnd: false);
            }
        }
Esempio n. 20
0
        public bool Contains(Asda2ItemId id)
        {
            foreach (Item obj in this.m_inventory.Items)
            {
                if (obj != null && (Asda2ItemId)obj.EntryId == id)
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 21
0
        /// <summary>Returns the ItemTemplate with the given id</summary>
        public static ItemTemplate GetTemplateForced(Asda2ItemId id)
        {
            ItemTemplate itemTemplate = (long)id < (long)Templates.Length
        ? Templates[(uint)id]
        : null;

            if (itemTemplate == null)
            {
                throw new ContentException("Requested ItemTemplate does not exist: {0}", (object)id);
            }
            return(itemTemplate);
        }
Esempio n. 22
0
        public static void SendEnchantLog(IPacketReceivingEntity owner, Asda2ItemId entryId, uint enchantId)
        {
            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_ENCHANTMENTLOG, 25))
            {
                packet.Write(owner.EntityId);
                packet.Write(owner.EntityId);
                packet.Write((uint)entryId);
                packet.Write((uint)enchantId);                 // cast maybe unneeded
                packet.Write((byte)0);

                owner.Send(packet, addEnd: false);
            }
        }
Esempio n. 23
0
        /// <summary>Returns the ItemTemplate with the given id</summary>
        public static Asda2ItemTemplate GetTemplateForced(Asda2ItemId id)
        {
            Asda2ItemTemplate asda2ItemTemplate = (long)id < (long)Asda2ItemMgr.Templates.Length
                ? Asda2ItemMgr.Templates[(uint)id]
                : (Asda2ItemTemplate)null;

            if (asda2ItemTemplate == null)
            {
                throw new ContentException("Requested ItemTemplate does not exist: {0}", new object[1]
                {
                    (object)id
                });
            }
            return(asda2ItemTemplate);
        }
Esempio n. 24
0
 public bool HasGem(Asda2ItemId id)
 {
     if (m_enchantments != null && m_template.HasSockets)
     {
         for (var i = EnchantSlot.Socket1; i <= EnchantSlot.Socket1 + ItemConstants.MaxSocketCount; i++)
         {
             if (m_enchantments[(int)i] != null &&
                 m_enchantments[(int)i].Entry.GemTemplate != null &&
                 m_enchantments[(int)i].Entry.GemTemplate.ItemId == id)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Esempio n. 25
0
        public bool HasGem(Asda2ItemId id)
        {
            if (m_enchantments != null && m_template.HasSockets)
            {
                for (EnchantSlot enchantSlot = EnchantSlot.Socket1; enchantSlot <= EnchantSlot.Bonus; ++enchantSlot)
                {
                    if (m_enchantments[(int)enchantSlot] != null &&
                        m_enchantments[(int)enchantSlot].Entry.GemTemplate != null &&
                        m_enchantments[(int)enchantSlot].Entry.GemTemplate.ItemId == id)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Esempio n. 26
0
        /// <summary>
        /// Returns the ItemTemplate with the given id
        /// </summary>
        public static ItemTemplate GetTemplateForced(Asda2ItemId id)
        {
            ItemTemplate templ;

            if ((uint)id >= Templates.Length)
            {
                templ = null;
            }
            else
            {
                templ = Templates[(uint)id];
            }

            if (templ == null)
            {
                throw new ContentException("Requested ItemTemplate does not exist: {0}", id);
            }
            return(templ);
        }
Esempio n. 27
0
 /// <summary>
 /// The Quest that requires the given Item
 /// </summary>
 public Quest GetReqItemQuest(Asda2ItemId item)
 {
     for (var j = 0; j < m_RequireItemsQuests.Count; j++)
     {
         var quest = m_RequireItemsQuests[j];
         for (var i = 0; i < quest.Template.CollectableItems.Length; i++)
         {
             var requiredItem = quest.Template.CollectableItems[i];
             if (requiredItem.ItemId == item)
             {
                 return(quest);
             }
         }
         for (var i = 0; i < quest.Template.CollectableSourceItems.Length; i++)
         {
             var requiredItem = quest.Template.CollectableSourceItems[i];
             if (requiredItem.ItemId == item)
             {
                 return(quest);
             }
         }
     }
     return(null);
 }
Esempio n. 28
0
 /// <summary>
 /// Whether the given Item is needed for an active Quest
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public bool RequiresItem(Asda2ItemId item)
 {
     for (var j = 0; j < m_RequireItemsQuests.Count; j++)
     {
         var quest = m_RequireItemsQuests[j];
         for (var i = 0; i < quest.Template.CollectableItems.Length; i++)
         {
             var requiredItem = quest.Template.CollectableItems[i];
             if (requiredItem.ItemId == item)
             {
                 return(quest.CollectedItems[i] < requiredItem.Amount);
             }
         }
         for (var i = 0; i < quest.Template.CollectableSourceItems.Length; i++)
         {
             var collectableSourceItem = quest.Template.CollectableSourceItems[i];
             if (collectableSourceItem.ItemId == item)
             {
                 return(quest.CollectedSourceItems[i] < collectableSourceItem.Amount);
             }
         }
     }
     return(false);
 }
Esempio n. 29
0
        /// <summary>The Quest that requires the given Item</summary>
        public Quest GetReqItemQuest(Asda2ItemId item)
        {
            for (int index1 = 0; index1 < m_RequireItemsQuests.Count; ++index1)
            {
                Quest requireItemsQuest = m_RequireItemsQuests[index1];
                for (int index2 = 0; index2 < requireItemsQuest.Template.CollectableItems.Length; ++index2)
                {
                    if (requireItemsQuest.Template.CollectableItems[index2].ItemId == item)
                    {
                        return(requireItemsQuest);
                    }
                }

                for (int index2 = 0; index2 < requireItemsQuest.Template.CollectableSourceItems.Length; ++index2)
                {
                    if (requireItemsQuest.Template.CollectableSourceItems[index2].ItemId == item)
                    {
                        return(requireItemsQuest);
                    }
                }
            }

            return(null);
        }
Esempio n. 30
0
 public LockKeyEntry(uint index, uint keyId)
 {
     Index = index;
     KeyId = (Asda2ItemId)keyId;
 }