예제 #1
0
파일: PT_Npc.cs 프로젝트: KalOnline/KaLua
        public static void BuyNpcItem(Client client, PacketIn packet)
        {
            int npcWorldId = (int)packet.ReadUInt32();
            byte v1     = packet.ReadByte();
            byte amount = packet.ReadByte();

            int totalPrice = 0;

            ushort[] items   = new ushort[amount];
            ushort[] amounts = new ushort[amount];
            for(int i=0;i<amount;i++)
            {
                items[i]   = packet.ReadUShort();
                amounts[i] = packet.ReadUShort();

                // TODO, calculate correct price
                totalPrice += 100 * amounts[i];
            }

            // TODO, add geon amount check
            for(int i=0;i<amount;i++)
            {
                // should be items, not player items
                PlayerItem item = PlayerItem.Get((int)items[i]);
                client.Character.Player.Inventory.Items.Add(item);
                // update AddToInventory with generic item-object
                client.Send(new Packets.AddToInventory((int)items[i],(int)amounts[i]),"Buy Item");
                // update amout of geons !
            }
        }
예제 #2
0
파일: PT_Npc.cs 프로젝트: sgentens/KaLua
        public static void BuyNpcItem(Client client, PacketIn packet)
        {
            int  npcWorldId = (int)packet.ReadUInt32();
            byte v1         = packet.ReadByte();
            byte amount     = packet.ReadByte();

            int totalPrice = 0;

            ushort[] items   = new ushort[amount];
            ushort[] amounts = new ushort[amount];
            for (int i = 0; i < amount; i++)
            {
                items[i]   = packet.ReadUShort();
                amounts[i] = packet.ReadUShort();

                // TODO, calculate correct price
                totalPrice += 100 * amounts[i];
            }

            // TODO, add geon amount check
            for (int i = 0; i < amount; i++)
            {
                // should be items, not player items
                PlayerItem item = PlayerItem.Get((int)items[i]);
                client.Character.Player.Inventory.Items.Add(item);
                // update AddToInventory with generic item-object
                client.Send(new Packets.AddToInventory((int)items[i], (int)amounts[i]), "Buy Item");
                // update amout of geons !
            }
        }