Exemplo n.º 1
0
        public new IMapleItem Copy()
        {
            var ret = new Equip(ItemId, Position, IsRing)
            {
                Str          = Str,
                Dex          = Dex,
                Int          = Int,
                Luk          = Luk,
                Hp           = Hp,
                Mp           = Mp,
                Matk         = Matk,
                Mdef         = Mdef,
                Watk         = Watk,
                Wdef         = Wdef,
                Acc          = Acc,
                Avoid        = Avoid,
                Hands        = Hands,
                Speed        = Speed,
                Jump         = Jump,
                Flag         = Flag,
                Locked       = Locked,
                UpgradeSlots = UpgradeSlots,
                Level        = Level,
                Vicious      = Vicious,
                Owner        = Owner,
                Quantity     = Quantity
            };

            return(ret);
        }
Exemplo n.º 2
0
        public static void UnEquip(MapleClient c, short src, short dst)
        {
            byte srcSlot = (byte)src;
            byte dstSlot = (byte)dst;

            Equip source = c.Player.Inventorys[MapleInventoryType.Equipped.Value].Inventory.FirstOrDefault(x => x.Key == srcSlot).Value as Equip;
            Equip target = c.Player.Inventorys[MapleInventoryType.Equip.Value].Inventory.FirstOrDefault(x => x.Key == dstSlot).Value as Equip;

            if (dstSlot > 127)
            {
                Console.WriteLine("Unequipping to negative slot. ({0}: {1}->{2})", c.Player.Name, srcSlot, dstSlot);
            }
            if (source == null)
            {
                return;
            }
            if (target != null && (srcSlot > 127 || srcSlot == 0))
            {
                // do not allow switching with equip
                c.Send(PacketCreator.GetInventoryFull());
                return;
            }

            c.Player.Inventorys[MapleInventoryType.Equipped.Value].RemoveSlot(srcSlot);
            if (target != null)
            {
                c.Player.Inventorys[MapleInventoryType.Equip.Value].RemoveSlot(dstSlot);
            }
            source.Position = dstSlot;
            c.Player.Inventorys[MapleInventoryType.Equip.Value].AddFromDb(source);
            if (target != null)
            {
                target.Position = srcSlot;
                c.Player.Inventorys[MapleInventoryType.Equipped.Value].AddFromDb(target);
            }
            c.Send(PacketCreator.MoveInventoryItem(MapleInventoryType.Equip, src, dst, 1));
            c.Player.EquipChanged();
        }
Exemplo n.º 3
0
        public IMapleItem ToItem()
        {
            IMapleItem         newitem;
            MapleInventoryType type = MapleItemInformationProvider.Instance.GetInventoryType(ItemId);

            if (type == MapleInventoryType.Equip)
            {
                newitem = new Equip(ItemId, 0xFF)
                {
                    Expiration = Expire,
                    UniqueId   = UniqueId
                };
                ((Equip)newitem).IsRing = IsRing;
            }
            else
            {
                newitem = new Item(ItemId, 0xFF, Quantity)
                {
                    Expiration = Expire,
                    UniqueId   = UniqueId
                };
            }
            return(newitem);
        }
Exemplo n.º 4
0
        public static void Equip(MapleClient c, short src, short dst)
        {
            MapleItemInformationProvider ii = MapleItemInformationProvider.Instance;

            byte srcSlot = (byte)src;
            byte dstSlot = (byte)dst;

            Equip source = c.Player.Inventorys[MapleInventoryType.Equip.Value].Inventory.FirstOrDefault(x => x.Key == srcSlot).Value as Equip;
            Equip target = c.Player.Inventorys[MapleInventoryType.Equipped.Value].Inventory.FirstOrDefault(x => x.Key == dstSlot).Value as Equip;

            if (source == null)
            {
                return;
            }
            if (!c.Player.IsGm)
            {
                switch (source.ItemId)
                {
                case 1002140:     // Wizet Invincible Hat
                case 1042003:     // Wizet Plain Suit
                case 1062007:     // Wizet Plain Suit Pants
                case 1322013:     // Wizet Secret Agent Suitcase
                    RemoveAllById(c, source.ItemId, false);
                    c.Player.DropMessage(PacketCreator.ServerMessageType.Popup, "无法佩带此物品");
                    return;
                }
            }
            int  reqLevel = ii.GetReqLevel(source.ItemId);
            int  reqStr   = ii.GetReqStr(source.ItemId);
            int  reqDex   = ii.GetReqDex(source.ItemId);
            int  reqInt   = ii.GetReqInt(source.ItemId);
            int  reqLuk   = ii.GetReqLuk(source.ItemId);
            bool cashSlot = false;

            if (source.ItemId == 1812006)
            {
                RemoveAllById(c, source.ItemId, false);
                c.Player.DropMessage(PacketCreator.ServerMessageType.Popup, "物品已被封印");
                return;
            }
            if (dstSlot < 0x9D)
            {
                cashSlot = true;
            }
            if (!ii.IsCash(source.ItemId))
            {
                string type = ii.GetType(source.ItemId);
                if ((type.Equals("Cp", StringComparison.CurrentCultureIgnoreCase) && dstSlot != 0xFF) ||
                    (type.Equals("Af", StringComparison.CurrentCultureIgnoreCase) && dstSlot != 0xFE) ||
                    (type.Equals("Ay", StringComparison.CurrentCultureIgnoreCase) && dstSlot != 0xFD) ||
                    (type.Equals("Ae", StringComparison.CurrentCultureIgnoreCase) && dstSlot != 0xFC) ||
                    ((type.Equals("Ma", StringComparison.CurrentCultureIgnoreCase) || type.Equals("MaPn", StringComparison.CurrentCultureIgnoreCase)) && dstSlot != 0xFB) ||
                    (type.Equals("Pn", StringComparison.CurrentCultureIgnoreCase) && dstSlot != 0xFA) ||
                    (type.Equals("So", StringComparison.CurrentCultureIgnoreCase) && dstSlot != 0xF9) ||
                    (type.Equals("Gv", StringComparison.CurrentCultureIgnoreCase) && dstSlot != 0xF8) ||
                    (type.Equals("Sr", StringComparison.CurrentCultureIgnoreCase) && dstSlot != 0xF7) ||
                    (type.Equals("Si", StringComparison.CurrentCultureIgnoreCase) && dstSlot != 0xF6) ||
                    ((type.Equals("Wp", StringComparison.CurrentCultureIgnoreCase) || type.Equals("WpSi", StringComparison.CurrentCultureIgnoreCase)) && dstSlot != 0xF5) ||
                    (type.Equals("Pe", StringComparison.CurrentCultureIgnoreCase) && dstSlot != 0xEF))
                {
                    c.Send(PacketCreator.EnableActions());
                    return;
                }
            }
            if ((ii.GetName(source.ItemId).Contains("(Male)") && !c.Player.Gender) ||
                (ii.GetName(source.ItemId).Contains("(Female)") && c.Player.Gender) ||
                reqLevel > c.Player.Level ||
                reqStr > c.Player.Localstr ||
                reqDex > c.Player.Localdex ||
                reqInt > c.Player.Localint ||
                reqLuk > c.Player.Localluk ||
                (cashSlot && !ii.IsCash(source.ItemId)))
            {
                c.Send(PacketCreator.EnableActions());
                return;
            }

            switch (dstSlot)
            {
            case 0xFA:
            {
                // unequip the overall
                IMapleItem top;
                if (c.Player.Inventorys[MapleInventoryType.Equipped.Value].Inventory.TryGetValue(0xFB, out top) && ii.IsOverall(top.ItemId))
                {
                    if (c.Player.Inventorys[MapleInventoryType.Equip.Value].IsFull())
                    {
                        c.Send(PacketCreator.GetInventoryFull());
                        c.Send(PacketCreator.GetShowInventoryFull());
                        return;
                    }
                    UnEquip(c, -5, c.Player.Inventorys[MapleInventoryType.Equip.Value].GetNextFreeSlot());
                }
            }
            break;

            case 0xFB:
            {        // unequip the bottom and top
                IMapleItem top    = c.Player.Inventorys[MapleInventoryType.Equipped.Value].Inventory.FirstOrDefault(x => x.Key == 0xFB).Value;
                IMapleItem bottom = c.Player.Inventorys[MapleInventoryType.Equipped.Value].Inventory.FirstOrDefault(x => x.Key == 0xFA).Value;
                if (top != null && ii.IsOverall(source.ItemId))
                {
                    if (c.Player.Inventorys[MapleInventoryType.Equip.Value].IsFull(bottom != null && ii.IsOverall(source.ItemId) ? 1 : 0))
                    {
                        c.Send(PacketCreator.GetInventoryFull());
                        c.Send(PacketCreator.GetShowInventoryFull());
                        return;
                    }
                    UnEquip(c, -5, c.Player.Inventorys[MapleInventoryType.Equip.Value].GetNextFreeSlot());
                }
                if (bottom != null && ii.IsOverall(source.ItemId))
                {
                    if (c.Player.Inventorys[MapleInventoryType.Equip.Value].IsFull())
                    {
                        c.Send(PacketCreator.GetInventoryFull());
                        c.Send(PacketCreator.GetShowInventoryFull());
                        return;
                    }
                    UnEquip(c, -6, c.Player.Inventorys[MapleInventoryType.Equip.Value].GetNextFreeSlot());
                }
            }
            break;

            case 0xF6:
                // check if weapon is two-handed
                IMapleItem weapon;
                if (c.Player.Inventorys[MapleInventoryType.Equipped.Value].Inventory.TryGetValue(0xF5, out weapon) && ii.IsTwoHanded(weapon.ItemId))
                {
                    if (c.Player.Inventorys[MapleInventoryType.Equip.Value].IsFull())
                    {
                        c.Send(PacketCreator.GetInventoryFull());
                        c.Send(PacketCreator.GetShowInventoryFull());
                        return;
                    }
                    UnEquip(c, -11, c.Player.Inventorys[MapleInventoryType.Equip.Value].GetNextFreeSlot());
                }
                break;

            case 0xF5:
                IMapleItem shield;
                if (c.Player.Inventorys[MapleInventoryType.Equipped.Value].Inventory.TryGetValue(0xF6, out shield) && ii.IsTwoHanded(source.ItemId))
                {
                    if (c.Player.Inventorys[MapleInventoryType.Equip.Value].IsFull())
                    {
                        c.Send(PacketCreator.GetInventoryFull());
                        c.Send(PacketCreator.GetShowInventoryFull());
                        return;
                    }
                    UnEquip(c, -10, c.Player.Inventorys[MapleInventoryType.Equip.Value].GetNextFreeSlot());
                }
                break;

            case 0xEE:
                //if (c.Player.Mount != null)
                //{
                //    c.Player.getMount().setItemId(source.ItemId);
                //}
                break;
            }

            source = c.Player.Inventorys[MapleInventoryType.Equip.Value].Inventory.FirstOrDefault(x => x.Key == srcSlot).Value as Equip;
            target = c.Player.Inventorys[MapleInventoryType.Equipped.Value].Inventory.FirstOrDefault(x => x.Key == dstSlot).Value as Equip;

            c.Player.Inventorys[MapleInventoryType.Equip.Value].RemoveSlot(srcSlot);

            if (target != null)
            {
                c.Player.Inventorys[MapleInventoryType.Equipped.Value].RemoveSlot(dstSlot);
            }

            source.Position = dstSlot;

            c.Player.Inventorys[MapleInventoryType.Equipped.Value].AddFromDb(source);

            if (target != null)
            {
                target.Position = srcSlot;
                c.Player.Inventorys[MapleInventoryType.Equip.Value].AddFromDb(target);
            }

            if (c.Player.GetBuffedValue(MapleBuffStat.Booster) != null && ii.IsWeapon(source.ItemId))
            {
                c.Player.CancelBuffStats(MapleBuffStat.Booster);
            }

            c.Send(PacketCreator.MoveInventoryItem(MapleInventoryType.Equip, src, dst, 2));
            c.Player.EquipChanged();
        }