Пример #1
0
        /// <summary>
        /// Analyzes packet and saves it, if its part of the loot.
        /// </summary>
        /// <param name="packet">Packet</param>
        public void AnalyzePacket(Packet packet)
        {
            if (packet is MobileIncoming)
            {
                MobileIncoming p = (MobileIncoming)packet;

                if (!m_Mobiles.ContainsKey(p.Serial))
                {
                    Mobile m = new Mobile(p.Serial);
                    m.Body      = p.ModelId;
                    m.Hue       = (int)p.Hue;
                    m.Notoriety = (Notoriety)p.Notoriety;
                    m.Female    = (p.Flag & 0x2) == 1 ? true : false;
                    m.Blessed   = (p.Flag & 0x8) == 1 ? true : false;

                    m_Mobiles.Add(p.Serial, m);
                }
                else
                {
                    Mobile m = m_Mobiles[p.Serial];

                    m.Body      = p.ModelId;
                    m.Hue       = (int)p.Hue;
                    m.Notoriety = (Notoriety)p.Notoriety;
                    m.Female    = (p.Flag & 0x2) == 1 ? true : false;
                    m.Blessed   = (p.Flag & 0x8) == 1 ? true : false;
                }
            }

            /*else if ( packet is MobileStat )
             * {
             *      MobileStat p = (MobileStat) packet;
             *
             *      if ( m_Mobiles.ContainsKey( p.Serial ) )
             *      {
             *              Mobile m = m_Mobiles[ p.Serial ];
             *
             *              if ( m.Name == null )
             *                      m.Name = p.Name;
             *      }
             * }*/
            else if (packet is DeathAnimation)
            {
                DeathAnimation p = (DeathAnimation)packet;

                if (m_Mobiles.ContainsKey(p.Serial))
                {
                    Mobile m = m_Mobiles[p.Serial];

                    if (m.Corpse == 0)
                    {
                        m.Corpse = p.Corpse;

                        if (!m_Corpses.ContainsKey(p.Corpse))
                        {
                            m_Corpses.Add(p.Corpse, m);
                        }
                    }
                }
            }
            else if (packet is ContainerContentUpdate)
            {
                ContainerContentUpdate p = (ContainerContentUpdate)packet;

                if (m_Corpses.ContainsKey(p.ContSerial))
                {
                    Mobile m = m_Corpses[p.ContSerial];

                    if (m.CorpseContainer == 0)
                    {
                        m.CorpseContainer = p.Serial;
                        m_Filter.AddMobile(m.Name);

                        if (!m_CorpseContainers.ContainsKey(p.Serial))
                        {
                            m_CorpseContainers.Add(p.Serial, m);
                        }
                    }
                }
            }
            else if (packet is ContainerContent)
            {
                ContainerContent p = (ContainerContent)packet;

                foreach (ContainerContent.ContainedItem i in p.Items)
                {
                    if (m_CorpseContainers.ContainsKey(i.ContSerial))
                    {
                        Mobile m = m_CorpseContainers[i.ContSerial];

                        if (!m.Loot.ContainsKey(i.Serial))
                        {
                            Item item;

                            if (!m_Items.ContainsKey(i.Serial))
                            {
                                item = new Item(i.Serial);
                                m_Items.Add(i.Serial, item);
                            }
                            else
                            {
                                item = m_Items[i.Serial];
                            }

                            item.ItemID = i.ItemId;
                            item.Hue    = i.Hue;
                            item.Amount = i.Amount;

                            m.Loot.Add(i.Serial, item);
                        }
                    }
                }
            }
            else if (packet is ObjectProperties)
            {
                ObjectProperties p = (ObjectProperties)packet;

                if (m_Corpses.ContainsKey(p.Serial))
                {
                    Mobile m = m_Corpses[p.Serial];

                    if (m.CorpseName == null && p.Properties.Length > 0)
                    {
                        ObjectProperties.Property prop = p.Properties[0];
                        m.CorpseName = LocalizedList.Construct(prop.Number, prop.Arguments);
                    }
                }
                else if (m_Mobiles.ContainsKey(p.Serial))
                {
                    Mobile m = m_Mobiles[p.Serial];

                    if (p.Properties.Length > 0)
                    {
                        m.Name = LocalizedList.Construct(p.Properties[0].Number, p.Properties[0].Arguments);
                    }
                }
                else
                {
                    Item item;

                    if (!m_Items.ContainsKey(p.Serial))
                    {
                        item = new Item(p.Serial);
                        m_Items.Add(p.Serial, item);
                    }
                    else
                    {
                        item = m_Items[p.Serial];
                    }

                    if (item.Name != null)
                    {
                        return;
                    }

                    for (int i = 0; i < p.Properties.Length; i++)
                    {
                        ObjectProperties.Property prop = p.Properties[i];

                        item.ParseProperty(i, prop.Number, prop.Arguments);
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Analyzes packet and saves it, if it is related to vendors.
        /// </summary>
        /// <param name="packet">Packet.</param>
        public void AnalyzePacket(Packet packet)
        {
            if (packet is MobileIncoming)
            {
                MobileIncoming p = (MobileIncoming)packet;

                if (!m_Vendors.ContainsKey(p.Serial) && p.Notoriety == Notoriety.Invulnerable)
                {
                    Vendor m = new Vendor(p.Serial);
                    m.Body      = p.ModelId;
                    m.Hue       = (int)p.Hue;
                    m.Notoriety = (Notoriety)p.Notoriety;
                    m.Female    = (p.Flag & 0x2) == 1 ? true : false;
                    m.Blessed   = (p.Flag & 0x8) == 1 ? true : false;

                    foreach (MobileIncoming.EquipInfo i in p.Equipment)
                    {
                        Item item = new Item(i.Serial);
                        item.ItemID = i.ItemId;
                        item.Layer  = (Layer)i.Layer;
                        item.Hue    = i.Hue;
                        m.Items.Add(item);
                        m_Items.Add(i.Serial, item);

                        if (item.Layer == Layer.ShopBuy)
                        {
                            m_Shops.Add(item.Serial, m);
                        }
                    }

                    m_Vendors.Add(p.Serial, m);
                }
            }
            else if (packet is ContainerContent)
            {
                ContainerContent p = (ContainerContent)packet;

                foreach (ContainerContent.ContainedItem i in p.Items)
                {
                    if (m_Shops.ContainsKey(i.ContSerial))
                    {
                        Vendor m = m_Shops[i.ContSerial];

                        if (!m.Shop.ContainsKey(i.Serial))
                        {
                            VendorItem item = new VendorItem(i.Serial);

                            if (!m_Items.ContainsKey(i.Serial))
                            {
                                m_Items.Add(i.Serial, item);
                            }

                            item.ItemID = i.ItemId;
                            item.Hue    = i.Hue;
                            item.Amount = i.Amount;

                            m.Shop.Add(i.Serial, item);
                        }
                    }
                }
            }
            else if (packet is BuyInfo)
            {
                BuyInfo p = (BuyInfo)packet;

                if (m_Shops.ContainsKey(p.VendorSerial))
                {
                    m_Prices  = new int[p.ItemCount];
                    m_Counter = 0;

                    for (int i = 0; i < p.ItemCount; i++)
                    {
                        m_Prices[i] = p.List[i].Price;
                    }
                }
            }
            else if (packet is ObjectProperties)
            {
                ObjectProperties p = (ObjectProperties)packet;

                if (m_Items.ContainsKey(p.Serial))
                {
                    Item item = m_Items[p.Serial];

                    if (item.Name != null)
                    {
                        return;
                    }

                    for (int i = 0; i < p.Properties.Length; i++)
                    {
                        ObjectProperties.Property prop = p.Properties[i];
                        item.ParseProperty(i, prop.Number, prop.Arguments);
                    }

                    if (item is VendorItem && m_Prices != null && m_Counter < m_Prices.Length)
                    {
                        ((VendorItem)item).SellPrice = m_Prices[m_Counter++];
                    }
                }
                else if (m_Vendors.ContainsKey(p.Serial))
                {
                    Mobile m = m_Vendors[p.Serial];

                    if (m.Name == null && p.Properties.Length > 0)
                    {
                        m.Name = LocalizedList.Construct(p.Properties[0].Number, p.Properties[0].Arguments);
                    }
                }
            }
        }