Esempio n. 1
0
        public static void Drop(MapleClient c, MapleInventoryType type, byte srcSlot, short quantity)
        {
            MapleItemInformationProvider ii = MapleItemInformationProvider.Instance;

            if (srcSlot > 127)
            {
                type = MapleInventoryType.Equipped;
            }
            IMapleItem source = c.Player.Inventorys[type.Value].Inventory[srcSlot];

            if (quantity > ii.GetSlotMax(c, source.ItemId))
            {
                //try
                //{
                //    c.getChannelServer().getWorldInterface().broadcastGMMessage(c.Player.getName(), PacketCreator.serverNotice(0, c.Player.getName() + " is dropping more than slotMax.").getBytes());
                //}
                //catch (Throwable u)
                //{
                //}
            }
            if (quantity < 0 || quantity == 0 && !ii.IsThrowingStar(source.ItemId) && !ii.IsBullet(source.ItemId))
            {
                //String message = "Dropping " + quantity + " " + (source == null ? "?" : source.ItemId) + " (" +type.name() + "/" + srcSlot + ")";
                //log.info(MapleClient.getLogMessage(c, message));
                c.Close(); // disconnect the client as is inventory is inconsistent with the serverside inventory
                return;
            }
            Point dropPos = c.Player.Position;

            if (quantity < source.Quantity && !ii.IsThrowingStar(source.ItemId) && !ii.IsBullet(source.ItemId))
            {
                IMapleItem target = source.Copy();
                target.Quantity  = quantity;
                source.Quantity -= quantity;
                c.Send(PacketCreator.DropInventoryItemUpdate(type, source));
                bool weddingRing = source.ItemId == 1112804;
                bool liRing      = source.ItemId == 1112405;
                if (weddingRing)
                {
                    c.Player.Map.disappearingItemDrop(c.Player, c.Player, target, dropPos);
                }
                else if (liRing)
                {
                    c.Player.Map.disappearingItemDrop(c.Player, c.Player, target, dropPos);
                }
                else if (c.Player.Map.Everlast)
                {
                    if (ii.IsDropRestricted(target.ItemId))
                    {
                        c.Player.Map.disappearingItemDrop(c.Player, c.Player, target, dropPos);
                    }
                    else
                    {
                        c.Player.Map.spawnItemDrop(c.Player, c.Player, target, dropPos, true, false);
                    }
                }
                else
                {
                    if (ii.IsDropRestricted(target.ItemId))
                    {
                        c.Player.Map.disappearingItemDrop(c.Player, c.Player, target, dropPos);
                    }
                    else
                    {
                        c.Player.Map.spawnItemDrop(c.Player, c.Player, target, dropPos, true, false);
                    }
                }
            }
            else
            {
                c.Player.Inventorys[type.Value].RemoveSlot(srcSlot);
                c.Send(PacketCreator.DropInventoryItem(srcSlot > 127 ? MapleInventoryType.Equip : type, srcSlot));
                bool liRing = source.ItemId == 1112405;
                if (srcSlot > 127)
                {
                    c.Player.EquipChanged();
                }
                if (c.Player.Map.Everlast)
                {
                    if (ii.IsDropRestricted(source.ItemId))
                    {
                        c.Player.Map.disappearingItemDrop(c.Player, c.Player, source, dropPos);
                    }
                    else
                    {
                        c.Player.Map.spawnItemDrop(c.Player, c.Player, source, dropPos, true, false);
                        if (liRing)
                        {
                            c.Player.Map.disappearingItemDrop(c.Player, c.Player, source, dropPos);
                        }
                        else
                        {
                            c.Player.Map.spawnItemDrop(c.Player, c.Player, source, dropPos, true, true);
                        }
                    }
                }
                else
                {
                    if (ii.IsDropRestricted(source.ItemId))
                    {
                        c.Player.Map.disappearingItemDrop(c.Player, c.Player, source, dropPos);
                    }
                    else
                    {
                        if (liRing)
                        {
                            c.Player.Map.disappearingItemDrop(c.Player, c.Player, source, dropPos);
                        }
                        else
                        {
                            c.Player.Map.spawnItemDrop(c.Player, c.Player, source, dropPos, true, true);
                        }
                    }
                }
            }
        }