示例#1
0
        private void HandleCollect(GameSession session, PacketReader packet)
        {
            int id = packet.ReadInt();

            packet.ReadInt();

            // Get items and add to inventory
            List <Item> items = session.Player.Mailbox.Collect(id);

            if (items == null)
            {
                return;
            }

            foreach (Item item in items)
            {
                session.Player.Inventory.Remove(item.Uid, out Item removed);
                session.Player.Inventory.Add(item);

                // Item packet, not sure if this is only used for mail, it also doesn't seem to do anything
                session.Send(ItemPacket.ItemData(item));
                // Inventory packets
                session.Send(ItemInventoryPacket.Add(item));
                session.Send(ItemInventoryPacket.MarkItemNew(item, item.Amount));
                // TODO remove these inventory packets
            }

            session.Send(MailPacket.CollectedAmount(id, DateTimeOffset.UtcNow.ToUnixTimeSeconds()));
            session.Send(MailPacket.CollectResponse(id, DateTimeOffset.UtcNow.ToUnixTimeSeconds()));
        }
示例#2
0
        // Adds item
        public static void Add(GameSession session, Item item, bool isNew)
        {
            // Checks if item is stackable or not
            if (item.StackLimit > 1)
            {
                foreach (Item i in session.Player.Inventory.Items.Values)
                {
                    // Checks to see if item exists in database (dictionary)
                    if (i.Id != item.Id || i.Amount >= i.StackLimit)
                    {
                        continue;
                    }
                    // Updates inventory for item amount overflow
                    if ((i.Amount + item.Amount) > i.StackLimit)
                    {
                        int added = i.StackLimit - i.Amount;
                        item.Amount -= added;
                        i.Amount     = i.StackLimit;
                        session.Send(ItemInventoryPacket.Update(i.Uid, i.Amount));
                        session.Send(ItemInventoryPacket.MarkItemNew(i, added));
                    }
                    // Updates item amount
                    else
                    {
                        i.Amount += item.Amount;
                        session.Send(ItemInventoryPacket.Update(i.Uid, i.Amount));
                        session.Send(ItemInventoryPacket.MarkItemNew(i, item.Amount));
                        return;
                    }
                }

                session.Player.Inventory.Add(item);          // Adds item into internal database
                session.Send(ItemInventoryPacket.Add(item)); // Sends packet to add item clientside
                if (isNew)
                {
                    session.Send(ItemInventoryPacket.MarkItemNew(item, item.Amount)); // Marks Item as New
                }
            }
            else
            {
                for (int i = 0; i < item.Amount; i++)
                {
                    Item newItem = new Item(item)
                    {
                        Amount = 1,
                        Slot   = session.Player.Inventory.SlotTaken(item, item.Slot) ? -1 : item.Slot,
                        Uid    = GuidGenerator.Long()
                    };

                    session.Player.Inventory.Add(newItem);
                    session.Send(ItemInventoryPacket.Add(newItem));
                    if (isNew)
                    {
                        session.Send(ItemInventoryPacket.MarkItemNew(newItem, newItem.Amount));
                    }
                }
            }
        }
        public override void Handle(GameSession session, PacketReader packet)
        {
            int objectId = packet.ReadInt();

            packet.ReadByte();

            // TODO: This will be bugged when you have a full inventory, check inventory before looting
            // Remove objectId from Field, make sure item still exists (multiple looters)
            if (!session.FieldManager.RemoveItem(objectId, out Item item))
            {
                return;
            }

            session.Player.Inventory.Add(item);
            session.Send(ItemInventoryPacket.Add(item));
            session.Send(ItemInventoryPacket.MarkItemNew(item, item.Amount));
        }
        public override void Handle(GameSession session, PacketReader packet)
        {
            // No data passed in

            // TODO - Determine item from player's job
            Item tutorialBow = Item.TutorialBow(session.Player);

            // Add the item to the inventory
            session.Inventory.Add(tutorialBow);

            // Send to client
            session.Send(ItemInventoryPacket.Add(tutorialBow));
            session.Send(ItemInventoryPacket.MarkItemNew(tutorialBow));

            // The below packet is sent with the inventory packets, but doesn't seem to be needed
            //session.Send(PacketWriter.Of(0x0105).WriteHexString("3F A6 36 E2 94 98 9B 2F 01 00 00 00 00 00 00 00 FF FF FF FF 89 18 84 5E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 B3 BC BC FF 3D DA C3 FF BA B4 B0 FF 13 00 00 00 05 00 00 00 00 03 00 11 00 0C 00 00 00 00 00 00 00 1B 00 0F 00 00 00 00 00 00 00 1C 00 11 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0E 00 00 00 01 00 00 00 00 00 00 00 00 00 01 01 66 66 66 66 66 66 66 66 08 00 61 00 73 00 61 00 73 00 61 00 73 00 31 00 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"));
            // The below two are kept for future reference in regards to the above
            //session.Send(PacketWriter.Of(0x16).WriteHexString("00 38 69 E6 00 3F A6 36 E2 94 98 9B 2F 00 00 01 00 00 00 00 00 01 00 00 00 00 00 00 00 FF FF FF FF 89 18 84 5E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 B3 BC BC FF 3D DA C3 FF BA B4 B0 FF 13 00 00 00 05 00 00 00 00 03 00 11 00 0C 00 00 00 00 00 00 00 1B 00 0F 00 00 00 00 00 00 00 1C 00 11 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0E 00 00 00 01 00 00 00 00 00 00 00 00 00 01 01 66 66 66 66 66 66 66 66 08 00 61 00 73 00 61 00 73 00 61 00 73 00 31 00 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"));
            //session.Send(PacketWriter.Of(0x16).WriteHexString("08 3F A6 36 E2 94 98 9B 2F 01 00 00 00 00 00"));
        }
示例#5
0
        // Example: "item id:20000027"
        private static void ProcessItemCommand(GameSession session, string command)
        {
            Dictionary <string, string> config = command.ToMap();

            int.TryParse(config.GetValueOrDefault("id", "20000027"), out int itemId);
            if (!ItemMetadataStorage.IsValid(itemId))
            {
                session.SendNotice("Invalid item: " + itemId);
                return;
            }

            // Add some bonus attributes to equips and pets
            var stats = new ItemStats();

            if (ItemMetadataStorage.GetTab(itemId) == InventoryType.Gear ||
                ItemMetadataStorage.GetTab(itemId) == InventoryType.Pets)
            {
                var rng = new Random();
                stats.BonusAttributes.Add(ItemStat.Of((ItemAttribute)rng.Next(35), 0.01f));
                stats.BonusAttributes.Add(ItemStat.Of((ItemAttribute)rng.Next(35), 0.01f));
            }

            var item = new Item(itemId)
            {
                Uid          = Environment.TickCount64,
                CreationTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
                Transfer     = TransferFlag.Splitable | TransferFlag.Tradeable,
                Stats        = stats
            };

            int.TryParse(config.GetValueOrDefault("rarity", "5"), out item.Rarity);
            int.TryParse(config.GetValueOrDefault("amount", "1"), out item.Amount);

            // Simulate looting item
            if (session.Inventory.Add(item))
            {
                session.Send(ItemInventoryPacket.Add(item));
                session.Send(ItemInventoryPacket.MarkItemNew(item));
            }
        }
示例#6
0
 // Adds item
 public static void Add(GameSession session, Item item, bool isNew)
 {
     // Checks if item is stackable or not
     if (item.SlotMax > 1)
     {
         foreach (Item i in session.Player.Inventory.Items.Values)
         {
             // Checks to see if item exists in database (dictionary)
             if (i.Id != item.Id || i.Amount >= i.SlotMax)
             {
                 continue;
             }
             // Updates inventory for item amount overflow
             if ((i.Amount + item.Amount) > i.SlotMax)
             {
                 int added = i.SlotMax - i.Amount;
                 item.Amount -= added;
                 i.Amount     = i.SlotMax;
                 session.Send(ItemInventoryPacket.Update(i.Uid, i.Amount));
                 session.Send(ItemInventoryPacket.MarkItemNew(i, added));
             }
             // Updates item amount
             else
             {
                 i.Amount += item.Amount;
                 session.Send(ItemInventoryPacket.Update(i.Uid, i.Amount));
                 session.Send(ItemInventoryPacket.MarkItemNew(i, item.Amount));
                 return;
             }
         }
     }
     session.Player.Inventory.Add(item);          // Adds item into internal database
     session.Send(ItemInventoryPacket.Add(item)); // Sends packet to add item clientside
     if (isNew)
     {
         session.Send(ItemInventoryPacket.MarkItemNew(item, item.Amount)); // Marks Item as New
     }
 }
    public static void Add(GameSession session, Item item)
    {
        // Checks if item is stackable or not
        if (item.SlotMax > 1)
        {
            foreach (Item i in session.Player.Inventory.Items.Values)
            {
                // Continue if inventory item id doesn't match or it is at max amount
                if (i.Id != item.Id || i.Amount >= i.SlotMax)
                {
                    continue;
                }
                // Updates inventory for item amount overflow
                if ((i.Amount + item.Amount) > i.SlotMax)
                {
                    int added = i.SlotMax - i.Amount; // For marking item new with correct added amount

                    item.Amount = item.Amount - (i.SlotMax - i.Amount);
                    i.Amount    = i.SlotMax;
                    session.Send(ItemInventoryPacket.Update(i.Uid, i.Amount));
                    session.Send(ItemInventoryPacket.MarkItemNew(i, added));
                }
                // Updates item amount
                else
                {
                    i.Amount = i.Amount + item.Amount;
                    session.Send(ItemInventoryPacket.Update(i.Uid, i.Amount));
                    session.Send(ItemInventoryPacket.MarkItemNew(i, item.Amount));
                    return;
                }
            }
        }
        // Add item to inventory if cannot stack any further
        session.Player.Inventory.Add(item);
        session.Send(ItemInventoryPacket.Add(item));
        session.Send(ItemInventoryPacket.MarkItemNew(item, item.Amount));
    }
示例#8
0
        // Adds item
        public static void Add(GameSession session, Item item, bool isNew)
        {
            // item is currency
            if (item.Id.ToString().StartsWith("9"))
            {
                switch (item.Id)
                {
                case 90000001:     // Meso
                    session.Player.Wallet.Meso.Modify(item.Amount);
                    break;

                case 90000006:     // Valor Token
                    session.Player.Wallet.ValorToken.Modify(item.Amount);
                    break;

                case 90000004:     // Meret
                case 90000011:     // Meret
                case 90000015:     // Meret
                case 90000016:     // Meret
                    session.Player.Account.Meret.Modify(item.Amount);
                    break;

                case 90000013:     // Rue
                    session.Player.Wallet.Rue.Modify(item.Amount);
                    break;

                case 90000014:     // Havi
                    session.Player.Wallet.HaviFruit.Modify(item.Amount);
                    break;

                case 90000017:     // Treva
                    session.Player.Wallet.Treva.Modify(item.Amount);
                    break;

                case 90000021:     // Guild Funds
                    if (session.Player.Guild != null)
                    {
                        session.Player.Guild.Funds += item.Amount;
                        session.Player.Guild.BroadcastPacketGuild(GuildPacket.UpdateGuildFunds(session.Player.Guild.Funds));
                        DatabaseManager.Guilds.Update(session.Player.Guild);
                    }
                    break;
                }
                return;
            }
            // TODO: Find a way to categorize items appropriately
            else if (item.Id.ToString().StartsWith("501") ||
                     item.Id.ToString().StartsWith("502") ||
                     item.Id.ToString().StartsWith("503") ||
                     item.Id.ToString().StartsWith("504") ||
                     item.Id.ToString().StartsWith("505"))
            {
                if (session.Player.Account.Home == null)
                {
                    return;
                }

                Home home = GameServer.HomeManager.GetHomeById(session.Player.Account.Home.Id);
                if (home == null)
                {
                    return;
                }

                _ = home.AddWarehouseItem(session, item.Id, item.Amount, item);
                session.Send(WarehouseInventoryPacket.GainItemMessage(item, item.Amount));
                return;
            }

            // Checks if item is stackable or not
            if (item.StackLimit > 1)
            {
                foreach (Item i in session.Player.Inventory.Items.Values)
                {
                    // Checks to see if item exists in database (dictionary)
                    if (i.Id != item.Id || i.Amount >= i.StackLimit || i.Rarity != item.Rarity)
                    {
                        continue;
                    }
                    // Updates inventory for item amount overflow
                    if ((i.Amount + item.Amount) > i.StackLimit)
                    {
                        int added = i.StackLimit - i.Amount;
                        item.Amount -= added;
                        i.Amount     = i.StackLimit;
                        session.Send(ItemInventoryPacket.Update(i.Uid, i.Amount));
                        session.Send(ItemInventoryPacket.MarkItemNew(i, added));
                    }
                    // Updates item amount
                    else
                    {
                        i.Amount += item.Amount;
                        session.Send(ItemInventoryPacket.Update(i.Uid, i.Amount));
                        session.Send(ItemInventoryPacket.MarkItemNew(i, item.Amount));
                        return;
                    }
                }

                if (!session.Player.Inventory.Add(item)) // Adds item into internal database
                {
                    return;
                }
                session.Send(ItemInventoryPacket.Add(item)); // Sends packet to add item clientside
                if (isNew)
                {
                    session.Send(ItemInventoryPacket.MarkItemNew(item, item.Amount)); // Marks Item as New
                }
                return;
            }

            if (item.Amount == 1)
            {
                if (!session.Player.Inventory.Add(item))
                {
                    return;
                }

                session.Send(ItemInventoryPacket.Add(item));
                if (isNew)
                {
                    session.Send(ItemInventoryPacket.MarkItemNew(item, item.Amount));
                }
                return;
            }

            for (int i = 0; i < item.Amount; i++)
            {
                Item newItem = new Item(item)
                {
                    Amount = 1,
                    Uid    = 0
                };
                newItem.Uid = DatabaseManager.Items.Insert(newItem);

                if (!session.Player.Inventory.Add(newItem))
                {
                    continue;
                }

                session.Send(ItemInventoryPacket.Add(newItem));
                if (isNew)
                {
                    session.Send(ItemInventoryPacket.MarkItemNew(newItem, newItem.Amount));
                }
            }
        }