Example #1
0
        /// <summary>
        /// Get's an item object from the shop at slot specified.
        /// </summary>
        public static SRItem GetItemFromShop(string npc_servername, byte tabNumber, byte tabSlot)
        {
            List <NameValueCollection> result = Database.GetResultFromQuery("SELECT * FROM shops WHERE model_servername='" + npc_servername + "' AND tab=" + tabNumber + " AND slot=" + tabSlot);

            if (result.Count > 0)
            {
                SRItem item = SRItem.Create(result[0]["item_servername"], new SRRentable(0));
                if (item.isEquipable())
                {
                    SREquipable equip = (SREquipable)item;
                    equip.Plus       = byte.Parse(result[0]["plus"]);
                    equip.Durability = uint.Parse(result[0]["durability"]);
                    // Add magic options
                    if (result[0]["magic_params"] != "")
                    {
                        string[] mParams = result[0]["magic_params"].Split('|');
                        xList <SRMagicOption> magicOptions = new xList <SRMagicOption>(mParams.Length);
                        for (byte j = 0; j < mParams.Length; j++)
                        {
                            ulong param = ulong.Parse(mParams[j]);
                            magicOptions[j]       = new SRMagicOption((uint)(param & uint.MaxValue));
                            magicOptions[j].Value = (uint)(param >> 32);
                        }
                        equip.MagicOptions = magicOptions;
                    }
                    else
                    {
                        equip.MagicOptions = new xList <SRMagicOption>();
                    }
                }
                return(item);
            }
            return(null);
        }
Example #2
0
        /// <summary>
        /// Called if any item or quantity is picked up.
        /// </summary>
        public void OnItemPickedUp(SRItem item, ushort quantity)
        {
            Window w = Window.Get;

            if (w.Character_cbxMessagePicks.Checked)
            {
                if (!item.isEquipable())
                {
                    w.LogMessageFilter(DataManager.GetUIFormat("UIIT_MSG_STATE_GET_ITEM_NONEXPENDABLE", item.Name));
                }
                else
                {
                    w.LogMessageFilter(DataManager.GetUIFormat("UIIT_MSG_STATE_GET_ITEM_EXPENDABLE", item.Name, quantity));
                }
            }
        }
            public static void CreatePickUpPacket(SRItem item, byte inventorySlot)
            {
                Packet p = new Packet(Agent.Opcode.SERVER_INVENTORY_ITEM_MOVEMENT);

                p.WriteByte(1);                 // Success
                p.WriteByte(SRTypes.InventoryItemMovement.GroundToInventory);
                p.WriteByte(inventorySlot);
                p.WriteUInt(item.Rentable.ID);
                if (item.Rentable.RentableType == SRRentable.Type.LimitedTime)
                {
                    p.WriteUShort(item.Rentable.CanDelete);
                    p.WriteUInt(item.Rentable.PeriodBeginTime);
                    p.WriteUInt(item.Rentable.PeriodEndTime);
                }
                else if (item.Rentable.RentableType == SRRentable.Type.LimitedDistance)
                {
                    p.WriteUShort(item.Rentable.CanDelete);
                    p.WriteUShort(item.Rentable.CanRecharge);
                    p.WriteUInt(item.Rentable.MeterRateTime);
                }
                else if (item.Rentable.RentableType == SRRentable.Type.Package)
                {
                    p.WriteUShort(item.Rentable.CanDelete);
                    p.WriteUShort(item.Rentable.CanRecharge);
                    p.WriteUInt(item.Rentable.PeriodBeginTime);
                    p.WriteUInt(item.Rentable.PeriodEndTime);
                    p.WriteUInt(item.Rentable.PackingTime);
                }
                p.WriteUInt(item.ID);
                if (item.isEquipable())
                {
                    SREquipable equip = (SREquipable)item;
                    p.WriteByte(equip.Plus);
                    p.WriteULong(equip.Variance);
                    p.WriteUInt(equip.Durability);
                    p.WriteByte(equip.MagicOptions.Count);
                    for (byte j = 0; j < equip.MagicOptions.Count; j++)
                    {
                        p.WriteUInt(equip.MagicOptions[j].ID);
                        p.WriteUInt(equip.MagicOptions[j].Value);
                    }
                    // 1 = Socket
                    p.WriteByte(1);
                    if (equip.Sockets != null)
                    {
                        p.WriteByte(equip.Sockets.Count);
                        for (byte j = 0; j < equip.Sockets.Count; j++)
                        {
                            p.WriteByte(equip.Sockets[j].Slot);
                            p.WriteUInt(equip.Sockets[j].ID);
                            p.WriteUInt(equip.Sockets[j].Value);
                        }
                    }
                    else
                    {
                        p.WriteByte(0);
                    }
                    // 2 = Advanced elixir
                    p.WriteByte(2);
                    if (equip.AdvancedElixirs != null)
                    {
                        p.WriteByte(equip.AdvancedElixirs.Count);
                        for (byte j = 0; j < equip.AdvancedElixirs.Count; j++)
                        {
                            p.WriteByte(equip.AdvancedElixirs[j].Slot);
                            p.WriteUInt(equip.AdvancedElixirs[j].ID);
                            p.WriteUInt(equip.AdvancedElixirs[j].Value);
                        }
                    }
                    else
                    {
                        p.WriteByte(0);
                    }
                }
                else if (item.isCoS())
                {
                    SRCoS cos = (SRCoS)item;
                    if (cos.isPet())
                    {
                        // ITEM_COS_P
                        p.WriteByte(cos.StateType);
                        if (cos.StateType != SRCoS.State.NeverSummoned)
                        {
                            p.WriteUInt(cos.ModelID);
                            p.WriteAscii(cos.ModelName);
                            if (cos.ID4 == 2)
                            {
                                p.WriteUInt(cos.Rentable.PeriodEndTime);
                            }
                            p.WriteByte(cos.unkByte01);
                        }
                    }
                    else if (cos.isTransform())
                    {
                        if (cos.ModelID == 0)
                        {
                            cos.ModelID = new SRModel("MOB_CH_MANGNYANG").ID;
                        }
                        p.WriteUInt(cos.ModelID);
                    }
                    else if (cos.isCube())
                    {
                        p.WriteUInt(cos.Quantity);
                    }
                }
                else if (item.isEtc())
                {
                    SREtc etc = (SREtc)item;
                    p.WriteUShort(etc.Quantity);
                    if (etc.isAlchemy())
                    {
                        if (item.ID4 == 1 || item.ID4 == 2)
                        {
                            // MAGIC/ATRIBUTTE STONE
                            p.WriteByte(etc.AssimilationProbability);
                        }
                    }
                    else if (item.ID3 == 14 && item.ID4 == 2)
                    {
                        // ITEM_MALL_GACHA_CARD_WIN
                        // ITEM_MALL_GACHA_CARD_LOSE
                        p.WriteByte(0);                         // paramCount
                    }
                }
                Bot.Get.Proxy.Agent.InjectToClient(p);
            }
Example #4
0
        /// <summary>
        /// Try to equip or unequip an item from the inventory. Return success.
        /// </summary>
        public bool EquipItem(byte slotInventory, bool useInventoryAvatar = false)
        {
            SRItem item = InfoManager.Character.Inventory[slotInventory];

            if (item != null && item.isEquipable())
            {
                if (slotInventory < 13)
                {
                    // UnEquip

                    // Find an empty slot
                    int newSlot = InfoManager.Character.Inventory.FindIndex(i => i == null, 13);
                    if (newSlot != -1)
                    {
                        PacketBuilder.MoveItem(slotInventory, (byte)newSlot, useInventoryAvatar ? SRTypes.InventoryItemMovement.AvatarToInventory : SRTypes.InventoryItemMovement.InventoryToInventory);
                        return(true);
                    }
                }
                else
                {
                    // Equip
                    switch ((SRTypes.Equipable)item.ID3)
                    {
                    case SRTypes.Equipable.Garment:                          // GARMENT
                    case SRTypes.Equipable.Protector:                        // PROTECTOR
                    case SRTypes.Equipable.Armor:                            // ARMOR
                    case SRTypes.Equipable.Robe:                             // ROBE
                    case SRTypes.Equipable.LightArmor:                       // LIGHT ARMOR
                    case SRTypes.Equipable.HeavyArmor:                       // HEAVY ARMOR
                        switch ((SRTypes.SetPart)item.ID4)
                        {
                        case SRTypes.SetPart.Head:                                         // HEAD
                            PacketBuilder.MoveItem(slotInventory, 0, SRTypes.InventoryItemMovement.InventoryToInventory);
                            return(true);

                        case SRTypes.SetPart.Shoulders:                                         // SHOULDERS
                            PacketBuilder.MoveItem(slotInventory, 2, SRTypes.InventoryItemMovement.InventoryToInventory);
                            return(true);

                        case SRTypes.SetPart.Chest:                                         // CHEST
                            PacketBuilder.MoveItem(slotInventory, 1, SRTypes.InventoryItemMovement.InventoryToInventory);
                            return(true);

                        case SRTypes.SetPart.Pants:                                         // PANTS
                            PacketBuilder.MoveItem(slotInventory, 4, SRTypes.InventoryItemMovement.InventoryToInventory);
                            return(true);

                        case SRTypes.SetPart.Gloves:                                         // GLOVES
                            PacketBuilder.MoveItem(slotInventory, 3, SRTypes.InventoryItemMovement.InventoryToInventory);
                            return(true);

                        case SRTypes.SetPart.Boots:                                         // BOOTS
                            PacketBuilder.MoveItem(slotInventory, 5, SRTypes.InventoryItemMovement.InventoryToInventory);
                            return(true);
                        }
                        break;

                    case SRTypes.Equipable.Shield:
                        PacketBuilder.MoveItem(slotInventory, 7, SRTypes.InventoryItemMovement.InventoryToInventory);
                        return(true);

                    case SRTypes.Equipable.AccesoriesCH:                             // ACCESSORIES (CH)
                    case SRTypes.Equipable.AccesoriesEU:                             // ACCESSORIES (EU)
                        switch ((SRTypes.AccesoriesPart)item.ID4)
                        {
                        case SRTypes.AccesoriesPart.Earring:                                         // Earring
                            PacketBuilder.MoveItem(slotInventory, 9, SRTypes.InventoryItemMovement.InventoryToInventory);
                            return(true);

                        case SRTypes.AccesoriesPart.Necklace:                                         // Necklace
                            PacketBuilder.MoveItem(slotInventory, 10, SRTypes.InventoryItemMovement.InventoryToInventory);
                            return(true);

                        case SRTypes.AccesoriesPart.Ring:                                         // Ring
                            if (InfoManager.Character.Inventory[12] == null)
                            {
                                PacketBuilder.MoveItem(slotInventory, 12, SRTypes.InventoryItemMovement.InventoryToInventory);
                            }
                            else
                            {
                                PacketBuilder.MoveItem(slotInventory, 11, SRTypes.InventoryItemMovement.InventoryToInventory);
                            }
                            return(true);
                        }
                        break;

                    case SRTypes.Equipable.Weapon:                             // WEAPONS (CH & EU)
                        PacketBuilder.MoveItem(slotInventory, 6, SRTypes.InventoryItemMovement.InventoryToInventory);
                        return(true);

                    case SRTypes.Equipable.Job:                             // JOB SUIT
                        PacketBuilder.MoveItem(slotInventory, 8, SRTypes.InventoryItemMovement.InventoryToInventory);
                        return(true);

                    case SRTypes.Equipable.Avatar:                             // Avatar
                        switch ((SRTypes.AvatarPart)item.ID4)
                        {
                        case SRTypes.AvatarPart.Hat:                                         // Hat
                            PacketBuilder.MoveItem(slotInventory, 0, SRTypes.InventoryItemMovement.InventoryToAvatar);
                            return(true);

                        case SRTypes.AvatarPart.Dress:                                         // Dress
                            PacketBuilder.MoveItem(slotInventory, 1, SRTypes.InventoryItemMovement.InventoryToAvatar);
                            return(true);

                        case SRTypes.AvatarPart.Accessory:                                         // Accessory
                            PacketBuilder.MoveItem(slotInventory, 2, SRTypes.InventoryItemMovement.InventoryToAvatar);
                            return(true);

                        case SRTypes.AvatarPart.Flag:                                         // Flag
                            PacketBuilder.MoveItem(slotInventory, 3, SRTypes.InventoryItemMovement.InventoryToAvatar);
                            return(true);
                        }
                        break;

                    case SRTypes.Equipable.DevilSpirit:                             // Devil Spirit
                        PacketBuilder.MoveItem(slotInventory, 4, SRTypes.InventoryItemMovement.InventoryToAvatar);
                        return(true);
                    }
                }
            }
            return(false);
        }