示例#1
0
        public static byte[] SendNpcItemList(Npc n, byte bag)
        {
            Packet p = new Packet(200);
            p.WriteHexString("00"); // unknown
            p.WriteInt(n.NpcID);
            p.WriteByte(bag); // bag
            p.WriteShort(n.Bags[bag].ItemCount);
            foreach (BaseItem i in n.Bags[bag].Items)
            {
                p.WriteShort(i.ReferenceID);
                p.WriteByte(i.bType);
                p.WriteByte(i.bKind);
                p.WriteShort(i.VisualID);
                p.WriteInt(i.Price);
                p.WriteHexString("00 00"); // some quest item, only guild master thingy
                p.WriteByte(i.RequiredClass);
                p.WriteShort(i.Amount);
                p.WriteByte(i.Slot);
                p.WriteHexString("00");

                if (i is Equipment)
                {
                    Equipment e = i as Equipment;
                    p.WriteShort(e.RequiredLevel);
                    p.WriteShort(e.RequiredDexterity);
                    p.WriteShort(e.RequiredStrength);
                    p.WriteShort(e.RequiredStamina);
                    p.WriteShort(e.RequiredEnergy);
                    p.WriteByte(e.MaxImbueTries);
                    p.WriteHexString("00"); // something
                    p.WriteShort(e.Durability);
                    p.WriteShort(e.Durability);
                    p.WriteShort(e.Damage);
                    p.WriteShort(e.Defence);
                    p.WriteShort(e.AttackRating);
                    if (e is Cape)
                    {
                        Cape c = e as Cape;
                        p.WriteHexString("00 00"); // faster run
                        p.WriteHexString("01 00"); // decrease times of durability
                        p.WriteByte(c.PolishImbueTries); // polish imbue tries
                        p.WriteHexString("00"); // something
                        p.WriteShort(c.MaxPolishImbueTries); // polish max tries
                        p.WriteHexString("00 00 00 00 00 00 00 00 00 00 00 00 00 00"); // something
                    }
                    else
                    {
                        p.WriteShort(e.AttackSpeed);
                        p.WriteShort(e.AttackRange);
                        p.WriteShort(e.IncMaxLife);
                        p.WriteShort(e.IncMaxMana);
                        p.WriteShort(e.IncLifeRegen);
                        p.WriteShort(e.IncManaRegen);
                        p.WriteShort(e.Critical);
                        p.WriteHexString("00 00 00 00 00 00 00 00");
                    }
                }
                if (i is PotionItem)
                {
                    PotionItem pot = i as PotionItem;
                    p.WriteShort(pot.HealHp);
                    p.WriteShort(pot.HealMana);
                }
            }

            return p.GetWrittenBuffer(PacketIds.SendNpcItemList);
        }
示例#2
0
        public List<Npc> GetNpcsByMapId(int mapId)
        {
            DbParameter mapIdParameter = _db.CreateParameter(DbNames.GETNPCSBYMAPID_ID_PARAMETER, mapId);
            mapIdParameter.DbType = System.Data.DbType.Int32;

            _db.Open();

            DbDataReader reader = _db.ExcecuteReader(DbNames.GETNPCSBYMAPID_STOREDPROC, System.Data.CommandType.StoredProcedure, mapIdParameter);

            int ordinalNPC_MAPID = reader.GetOrdinal(DbNames.NPC_MAPID);
            int ordinalNPC_NPCID = reader.GetOrdinal(DbNames.NPC_NPCID);
            int ordinalNPC_NPCTYPE = reader.GetOrdinal(DbNames.NPC_NPCTYPE);
            int ordinalNPC_POSX = reader.GetOrdinal(DbNames.NPC_POSX);
            int ordinalNPC_POSY = reader.GetOrdinal(DbNames.NPC_POSY);
            int ordinalNPC_DIRECTION = reader.GetOrdinal(DbNames.NPC_DIRECTION);

            List<Npc> listNpcs = new List<Npc>();

            while (reader.Read())
            {
                Npc p = new Npc
                {
                    NpcID = reader.GetInt32(ordinalNPC_NPCID),
                    MapID = reader.GetInt32(ordinalNPC_MAPID),
                    NpcType = reader.GetByte(ordinalNPC_NPCTYPE),
                    X = reader.GetInt16(ordinalNPC_POSX),
                    Y = reader.GetInt16(ordinalNPC_POSY),
                    Direction = reader.GetInt16(ordinalNPC_DIRECTION)
                };

                listNpcs.Add(p);
            }

            reader.Close();
            _db.Close();

            foreach (Npc n in listNpcs)
            {
                for (byte i = 0; i < 4; i++)
                {
                    var bagItems = GetAllItemsInNpcBag(i, n.NpcID);
                    n.Bags.Add(new Bag(bagItems));
                }
            }

            return listNpcs;
        }