Esempio n. 1
0
 public short getFirstPlace(byte type, int backPack, InventoryItem item)
 {
     Inventory result;
     for (short i = 0; i < 48 + backPack * 12; i++)
     {
         result = Inventory.SingleOrDefault(c => c.Type.Equals(type) && c.Slot.Equals(i));
         if (result == null)
             return i;
     }
     return -1;
 }
Esempio n. 2
0
        public Inventory CreateItem(InventoryItem newItem, Character character)
        {
            short Slot = -1;
            IEnumerable<InventoryItem> slotfree = null;
            Inventory inv = null;
            if (ServerManager.GetItem(newItem.ItemVNum).Type != 0)
            {
                slotfree = character.LoadBySlotAllowed(newItem.ItemVNum, newItem.Amount);
                inv = getFirstSlot(slotfree);
            }
            bool modified = false;
            Inventory newInventory = null;
            if (inv != null)
            {
                Slot = inv.Slot;
                newItem.Amount = (short)(newItem.Amount + inv.InventoryItem.Amount);
                modified = true;
            }
            else
                Slot = getFirstPlace(ServerManager.GetItem(newItem.ItemVNum).Type, character.BackPack, newItem);
            if (Slot != -1)
            {

                if (modified == false)
                    newInventory = new Inventory()
                    {
                        CharacterId = character.CharacterId,
                        InventoryItemId = newItem.InventoryItemId,
                        Slot = Slot,
                        Type = ServerManager.GetItem(newItem.ItemVNum).Type,
                        InventoryItem = newItem,
                        InventoryId = generateInventoryId(),
                    };
                else
                    newInventory = new Inventory()
                    {
                        CharacterId = character.CharacterId,
                        InventoryItemId = newItem.InventoryItemId,
                        Slot = Slot,
                        Type = ServerManager.GetItem(newItem.ItemVNum).Type,
                        InventoryItem = newItem,
                        InventoryId = inv.InventoryId,
                    };
                InsertOrUpdate(ref newInventory);

            }
            return newInventory;
        }
Esempio n. 3
0
        public void MoveItem(Character character, short type, short slot, short amount, short destslot, out Inventory inv, out Inventory invdest)
        {
            inv = LoadBySlotAndType(slot, type);
            invdest = LoadBySlotAndType(destslot, type);
            if (amount <= inv.InventoryItem.Amount)
            {
                if (invdest == null)
                {
                    if (inv.InventoryItem.Amount == amount)
                    {
                        inv.Slot = destslot;
                        InsertOrUpdate(ref inv);
                    }
                    else
                    {
                        inv.InventoryItem.Amount = (short)(inv.InventoryItem.Amount - amount);

                        InventoryItem itemDest = new InventoryItem
                        {
                            Amount = amount,
                            Color = inv.InventoryItem.Color,
                            Concentrate = inv.InventoryItem.Concentrate,
                            CriticalLuckRate = inv.InventoryItem.CriticalLuckRate,
                            CriticalRate = inv.InventoryItem.CriticalRate,
                            DamageMaximum = inv.InventoryItem.DamageMaximum,
                            DamageMinimum = inv.InventoryItem.DamageMinimum,
                            DarkElement = inv.InventoryItem.DarkElement,
                            DistanceDefence = inv.InventoryItem.DistanceDefence,
                            DistanceDefenceDodge = inv.InventoryItem.DistanceDefenceDodge,
                            DefenceDodge = inv.InventoryItem.DefenceDodge,
                            ElementRate = inv.InventoryItem.ElementRate,
                            FireElement = inv.InventoryItem.FireElement,
                            HitRate = inv.InventoryItem.HitRate,
                            ItemVNum = inv.InventoryItem.ItemVNum,
                            LightElement = inv.InventoryItem.LightElement,
                            MagicDefence = inv.InventoryItem.MagicDefence,
                            RangeDefence = inv.InventoryItem.RangeDefence,
                            Rare = inv.InventoryItem.Rare,
                            SlDefence = inv.InventoryItem.SlDefence,
                            SlElement = inv.InventoryItem.SlElement,
                            SlHit = inv.InventoryItem.SlHit,
                            SlHP = inv.InventoryItem.SlHP,
                            Upgrade = inv.InventoryItem.Upgrade,
                            WaterElement = inv.InventoryItem.WaterElement,
                            InventoryItemId = generateInventoryItemId(),

                        };

                        InsertOrUpdate(ref inv);

                        Inventory invDest = new Inventory
                        {
                            CharacterId = character.CharacterId,
                            InventoryItemId = itemDest.InventoryItemId,
                            Slot = destslot,
                            Type = inv.Type,
                            InventoryId = generateInventoryId(),
                            InventoryItem = itemDest,
                        };
                        InsertOrUpdate(ref invDest);
                        invdest = invDest;
                    }

                }
                else
                {

                    if (invdest.InventoryItem.ItemVNum == inv.InventoryItem.ItemVNum && inv.Type != 0)
                    {

                        if (invdest.InventoryItem.Amount + amount > 99)
                        {
                            short saveItemCount = invdest.InventoryItem.Amount;
                            invdest.InventoryItem.Amount = 99;
                            inv.InventoryItem.Amount = (short)(saveItemCount + inv.InventoryItem.Amount - 99);

                            InsertOrUpdate(ref inv);
                            InsertOrUpdate(ref invdest);

                        }
                        else
                        {
                            short saveItemCount = invdest.InventoryItem.Amount;
                            invdest.InventoryItem.Amount = (short)(saveItemCount + amount);
                            inv.InventoryItem.Amount = (short)(inv.InventoryItem.Amount - amount);
                            InsertOrUpdate(ref inv);
                            InsertOrUpdate(ref invdest);

                        }
                    }
                    else
                    {
                        invdest.Slot = inv.Slot;
                        inv.Slot = 99;
                        InsertOrUpdate(ref inv);
                        InsertOrUpdate(ref invdest);
                        inv.Slot = destslot;
                        InsertOrUpdate(ref inv);
                    }
                }
            }
            inv = LoadBySlotAndType(slot, type);
            invdest = LoadBySlotAndType(destslot, type);
        }
Esempio n. 4
0
        public void BuyShop(string packet)
        {
            string[] packetsplit = packet.Split(' ');
            long owner; long.TryParse(packetsplit[3], out owner);
            short type; short.TryParse(packetsplit[2], out type);
            short slot; short.TryParse(packetsplit[4], out slot);
            short amount; short.TryParse(packetsplit[5], out amount);
            if (type == 1)//usershop
            {
                KeyValuePair<long, MapShop> shop = Session.CurrentMap.ShopUserList.FirstOrDefault(mapshop => mapshop.Value.OwnerId.Equals(owner));
                PersonalShopItem item = shop.Value.Items.FirstOrDefault(i => i.Slot.Equals(slot));
                if (amount > item.Amount)
                    amount = item.Amount;
                if (item.Price * amount < Session.Character.Gold)
                {
                    Session.Character.Gold -= item.Price * amount;
                    Session.Client.SendPacket(Session.Character.GenerateGold());
                    InventoryItem newItem = new InventoryItem()
                    {
                        InventoryItemId = Session.Character.InventoryList.generateInventoryItemId(),
                        Amount = amount,
                        ItemVNum = item.ItemVNum,
                        Rare = item.Rare,
                        Upgrade = item.Upgrade,
                        Color = item.Color,
                        Concentrate = item.Concentrate,
                        CriticalLuckRate = item.CriticalLuckRate,
                        CriticalRate = item.CriticalRate,
                        DamageMaximum = item.DamageMaximum,
                        DamageMinimum = item.DamageMinimum,
                        DarkElement = item.DarkElement,
                        DistanceDefence = item.DistanceDefence,
                        DistanceDefenceDodge = item.DistanceDefenceDodge,
                        DefenceDodge = item.DefenceDodge,
                        ElementRate = item.ElementRate,
                        FireElement = item.FireElement,
                        HitRate = item.HitRate,
                        LightElement = item.LightElement,
                        MagicDefence = item.MagicDefence,
                        RangeDefence = item.RangeDefence,
                        SlDefence = item.SlDefence,
                        SpXp = item.SpXp,
                        SpLevel = item.SpLevel,
                        SlElement = item.SlElement,
                        SlHit = item.SlHit,
                        SlHP = item.SlHP,
                        WaterElement = item.WaterElement,
                    };

                    Inventory inv = Session.Character.InventoryList.CreateItem(newItem, Session.Character);
                    if (inv != null)
                    {
                        short Slot = inv.Slot;
                        if (Slot != -1)
                            Session.Client.SendPacket(Session.Character.GenerateInventoryAdd(newItem.ItemVNum, inv.InventoryItem.Amount, inv.Type, Slot, newItem.Rare, newItem.Color, newItem.Upgrade));
                    }
                    ClientLinkManager.Instance.BuyValidate(Session, shop, slot, amount);
                    KeyValuePair<long, MapShop> shop2 = Session.CurrentMap.ShopUserList.FirstOrDefault(s => s.Value.OwnerId.Equals(owner));
                    loadShopItem(owner, shop2);
                }
                else
                {
                    Session.Client.SendPacket(Session.Character.GenerateShopMemo(3, Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY")));
                }

            }
            else
            {

                Npc npc = Session.CurrentMap.Npcs.FirstOrDefault(n => n.NpcId.Equals((short)owner));

                ShopItem item = npc.Shop.ShopItems.FirstOrDefault(it => it.Slot.Equals(slot));
                long price = ServerManager.GetItem(item.ItemVNum).Price * amount;

                if (price > 0 && price <= Session.Character.Gold)
                {

                    Session.Client.SendPacket(Session.Character.GenerateShopMemo(1, String.Format(Language.Instance.GetMessageFromKey("BUY_ITEM_VALIDE"), ServerManager.GetItem(item.ItemVNum).Name, amount)));

                    Session.Character.Gold -= price;
                    Session.Client.SendPacket(Session.Character.GenerateGold());

                    InventoryItem newItem = new InventoryItem()
                    {
                        InventoryItemId = Session.Character.InventoryList.generateInventoryItemId(),
                        Amount = amount,
                        ItemVNum = item.ItemVNum,
                        Rare = item.Rare,
                        Upgrade = item.Upgrade,
                        Color = item.Color,
                        Concentrate = 0,
                        CriticalLuckRate = 0,
                        CriticalRate = 0,
                        DamageMaximum = 0,
                        DamageMinimum = 0,
                        DarkElement = 0,
                        DistanceDefence = 0,
                        DistanceDefenceDodge= 0,
                        DefenceDodge = 0,
                        ElementRate = 0,
                        FireElement = 0,
                        HitRate = 0,
                        LightElement = 0,
                        MagicDefence = 0,
                        RangeDefence = 0,
                        SpXp = 0,
                        SpLevel = 0,
                        SlDefence = 0,
                        SlElement = 0,
                        SlHit = 0,
                        SlHP = 0,
                        WaterElement = 0,
                    };

                    Inventory inv = Session.Character.InventoryList.CreateItem(newItem, Session.Character);
                    if (inv != null)
                    {
                        short Slot = inv.Slot;
                        if (Slot != -1)
                            Session.Client.SendPacket(Session.Character.GenerateInventoryAdd(newItem.ItemVNum, inv.InventoryItem.Amount, inv.Type, Slot, newItem.Rare, newItem.Color, newItem.Upgrade));
                    }

                }
                else
                {
                    Session.Client.SendPacket(Session.Character.GenerateShopMemo(3, Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY")));
                }
            }
        }
Esempio n. 5
0
        public int RarifyItem(InventoryItemDTO item, InventoryItem.RarifyMode mode, InventoryItem.RarifyProtection protection)
        {
            double rare1 = 50;
            double rare2 = 35;
            double rare3 = 25;
            double rare4 = 10;
            double rare5 = 10;
            double rare6 = 5;
            double rare7 = 1;
            double reducedchancefactor = 1.1;

            short itempricevnum = 0;
            short goldprice = 500;
            double reducedpricefactor = 0.5;

            if (protection == InventoryItem.RarifyProtection.RedAmulet)
            {
                rare1 = rare1 * reducedchancefactor;
                rare2 = rare2 * reducedchancefactor;
                rare3 = rare3 * reducedchancefactor;
                rare4 = rare4 * reducedchancefactor;
                rare5 = rare5 * reducedchancefactor;
                rare6 = rare6 * reducedchancefactor;
                rare7 = rare7 * reducedchancefactor;
            }
            switch (mode)
            {
                case InventoryItem.RarifyMode.Free:
                    break;
                case InventoryItem.RarifyMode.Reduced:
                    //TODO: Reduced Item Amount
                    Session.Character.Gold = Session.Character.Gold - (long)(goldprice * reducedpricefactor);
                    break;
                case InventoryItem.RarifyMode.Normal:
                    //TODO: Normal Item Amount
                    Session.Character.Gold = Session.Character.Gold - goldprice;
                    break;
            }

            Random r = new Random();
            int rnd = r.Next(100);
            if (rnd <= rare7)
            {
                return item.Rare = 7;
            }
            else if (rnd <= rare6)
            {
                return item.Rare = 6;
            }
            else if (rnd <= rare5)
            {
                return item.Rare = 5;
            }
            else if (rnd <= rare4)
            {
                return item.Rare = 4;
            }
            else if (rnd <= rare3)
            {
                return item.Rare = 3;
            }
            else if (rnd <= rare2)
            {
                return item.Rare = 2;
            }
            else if (rnd <= rare1)
            {
                return item.Rare = 1;
            }
            else
            {
                if (protection == InventoryItem.RarifyProtection.None)
                {
                    //TODO: Item Destroy
                    return -1;
                }
                else
                {
                    return 0;
                }
            }
        }
Esempio n. 6
0
        public int UpgradeItem(InventoryItemDTO item, InventoryItem.UpgradeMode mode, InventoryItem.UpgradeProtection protection)
        {
            #region Upgrade Stats
            short[] upsuccess = { 100, 100, 90, 80, 60, 40, 20, 10, 5, 1 };
            short[] upfix = { 0, 0, 10, 15, 20, 20, 20, 20, 15, 10 };
            #endregion
            short itempricevnum1 = 0;
            short itempricevnum2 = 0;
            short goldprice = 500;
            double reducedpricefactor = 0.5;

            switch (mode)
            {
                case InventoryItem.UpgradeMode.Free:
                    break;
                case InventoryItem.UpgradeMode.Reduced:
                    //TODO: Reduced Item Amount
                    Session.Character.Gold = Session.Character.Gold - (long)(goldprice * reducedpricefactor);
                    break;
                case InventoryItem.UpgradeMode.Normal:
                    //TODO: Normal Item Amount
                    Session.Character.Gold = Session.Character.Gold - goldprice;
                    break;
            }

            Random r = new Random();
            int rnd = r.Next(100);
            if (rnd <= upsuccess[item.Upgrade + 1])
            {
                item.Upgrade++;
                return 2;
            }
            else if (rnd <= upfix[item.Upgrade + 1])
            {

                return 1;
            }
            else
            {
                if (protection == InventoryItem.UpgradeProtection.None)
                {
                    //TODO: Item Destroy
                    return -1;
                }
                else
                {
                    return 0;
                }
            }
        }
Esempio n. 7
0
        public void CreateItem(string packet)
        {
            string[] packetsplit = packet.Split(' ');
            short amount = 1;
            short vnum, rare = 0, upgrade = 0, color = 0, level = 0;
            ItemDTO iteminfo = null;
            if (packetsplit.Length != 5 && packetsplit.Length != 4)
            {
                Session.Client.SendPacket(Session.Character.GenerateSay("$CreateItem ITEMID RARE UPGRADE", 10));
                Session.Client.SendPacket(Session.Character.GenerateSay("$CreateItem SPID UPGRADE WINGS", 10));
                Session.Client.SendPacket(Session.Character.GenerateSay("$CreateItem ITEMID COLOR", 10));
                Session.Client.SendPacket(Session.Character.GenerateSay("$CreateItem ITEMID AMOUNT", 10));
            }
            else if (Int16.TryParse(packetsplit[2], out vnum))
            {
                iteminfo = ServerManager.GetItem(vnum);
                if (iteminfo != null)
                {
                    if (iteminfo.Colored)
                    {
                        Int16.TryParse(packetsplit[3], out color);
                    }
                    else if (iteminfo.Type == 0)
                    {
                        if (packetsplit.Length == 5)
                        {
                            if (iteminfo.EquipmentSlot == Convert.ToByte((short)EquipmentType.Sp))
                            {
                                Int16.TryParse(packetsplit[3], out upgrade);
                                Int16.TryParse(packetsplit[4], out color);
                                level = 1;
                            }
                            else
                            {
                                Int16.TryParse(packetsplit[3], out rare);
                                Int16.TryParse(packetsplit[4], out upgrade);
                            }

                        }
                    }
                    else
                    {
                        Int16.TryParse(packetsplit[3], out amount);
                    }
                    InventoryItem newItem = new InventoryItem()
                    {
                        InventoryItemId = Session.Character.InventoryList.generateInventoryItemId(),
                        Amount = amount,
                        ItemVNum = vnum,
                        Rare = rare,
                        Upgrade = upgrade,
                        Color = color,
                        Concentrate = 0,
                        CriticalLuckRate = 0,
                        CriticalRate = 0,
                        DamageMaximum = 0,
                        DamageMinimum = 0,
                        DarkElement = 0,
                        DistanceDefence = 0,
                        DistanceDefenceDodge = 0,
                        DefenceDodge = 0,
                        ElementRate = 0,
                        FireElement = 0,
                        HitRate = 0,
                        LightElement = 0,
                        MagicDefence = 0,
                        RangeDefence = 0,
                        SpXp = 0,
                        SpLevel = level,
                        SlDefence = 0,
                        SlElement = 0,
                        SlHit = 0,
                        SlHP = 0,
                        WaterElement = 0,

                    };
                    Inventory inv = Session.Character.InventoryList.CreateItem(newItem, Session.Character);
                    if (inv != null)
                    {
                        short Slot = inv.Slot;
                        if (Slot != -1)
                            Session.Client.SendPacket(Session.Character.GenerateInventoryAdd(vnum, inv.InventoryItem.Amount, iteminfo.Type, Slot, rare, color, upgrade));
                    }
                }
            }
        }
Esempio n. 8
0
 public string GenerateEInfo(InventoryItem item)
 {
     throw new NotImplementedException();
 }
Esempio n. 9
0
        public void UpgradeItem(Inventory item, InventoryItem.UpgradeMode mode, InventoryItem.UpgradeProtection protection)
        {
            if (item.InventoryItem.Upgrade < 10)
            {
                short[] upsuccess = { 100, 100, 90, 80, 60, 40, 20, 10, 5, 1 };
                short[] upfix = { 0, 0, 10, 15, 20, 20, 20, 20, 15, 10 };

                //short itempricevnum1 = 0;
                //short itempricevnum2 = 0;
                short goldprice = 500;
                double reducedpricefactor = 0.5;

                switch (mode)
                {
                    case InventoryItem.UpgradeMode.Free:
                        break;

                    case InventoryItem.UpgradeMode.Reduced:
                        //TODO: Reduced Item Amount
                        Session.Character.Gold = Session.Character.Gold - (long)(goldprice * reducedpricefactor);
                        break;

                    case InventoryItem.UpgradeMode.Normal:
                        //TODO: Normal Item Amount
                        Session.Character.Gold = Session.Character.Gold - goldprice;
                        break;
                }

                Random r = new Random();
                int rnd = r.Next(100);
                if (rnd <= upsuccess[item.InventoryItem.Upgrade])
                {
                    Session.Client.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_SUCCESS"), 12));
                    Session.Client.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_SUCCESS"), 0));
                    Session.Client.SendPacket(Session.Character.GenerateEff(3005));
                    Session.Character.InventoryList.LoadByInventoryItem(item.InventoryItemId).InventoryItem.Upgrade++;
                    Session.Client.SendPacket(Session.Character.GenerateInventoryAdd(item.InventoryItem.ItemVNum, item.InventoryItem.Amount, item.Type, item.Slot, item.InventoryItem.Rare, item.InventoryItem.Color, item.InventoryItem.Upgrade));
                }
                else if (rnd <= upfix[item.InventoryItem.Upgrade])
                {
                    Session.Client.SendPacket(Session.Character.GenerateEff(3004));
                    Session.Client.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_FIXED"), 11));
                    Session.Client.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FIXED"), 0));
                }
                else
                {
                    if (protection == InventoryItem.UpgradeProtection.None)
                    {
                        Session.Client.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_FAILED"), 11));
                        Session.Client.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED"), 0));
                        DeleteItem(item.Type, item.Slot);
                    }
                    else
                    {
                        Session.Client.SendPacket(Session.Character.GenerateEff(3004));
                        Session.Client.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_FAILED_ITEM_SAVED"), 11));
                        Session.Client.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED_ITEM_SAVED"), 0));
                    }
                }
            }
            else
            {
                Session.Client.SendPacket(Session.Character.GenerateEff(3004));
                Session.Client.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_FAILED_ITEM_SAVED"), 11));
                Session.Client.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED_ITEM_SAVED"), 0));
            }
        }
Esempio n. 10
0
        public void RarifyItem(Inventory item, InventoryItem.RarifyMode mode, InventoryItem.RarifyProtection protection)
        {
            double rare1 = 50;
            double rare2 = 35;
            double rare3 = 25;
            double rare4 = 10;
            double rare5 = 10;
            double rare6 = 5;
            double rare7 = 1;
            double reducedchancefactor = 1.1;

            //short itempricevnum = 0;
            short goldprice = 500;
            double reducedpricefactor = 0.5;

            if (protection == InventoryItem.RarifyProtection.RedAmulet)
            {
                rare1 = rare1 * reducedchancefactor;
                rare2 = rare2 * reducedchancefactor;
                rare3 = rare3 * reducedchancefactor;
                rare4 = rare4 * reducedchancefactor;
                rare5 = rare5 * reducedchancefactor;
                rare6 = rare6 * reducedchancefactor;
                rare7 = rare7 * reducedchancefactor;
            }
            switch (mode)
            {
                case InventoryItem.RarifyMode.Free:
                    break;

                case InventoryItem.RarifyMode.Reduced:
                    //TODO: Reduced Item Amount
                    Session.Character.Gold = Session.Character.Gold - (long)(goldprice * reducedpricefactor);
                    break;

                case InventoryItem.RarifyMode.Normal:
                    //TODO: Normal Item Amount
                    Session.Character.Gold = Session.Character.Gold - goldprice;
                    break;
            }

            Random r = new Random();
            int rnd = r.Next(100);
            if (rnd <= rare7 && !(protection == InventoryItem.RarifyProtection.Scroll && item.InventoryItem.Rare >= 7))
            {
                Session.Client.SendPacket(Session.Character.GenerateSay(String.Format(Language.Instance.GetMessageFromKey("RARIFY_SUCCESS"), 7), 12));
                Session.Client.SendPacket(Session.Character.GenerateMsg(String.Format(Language.Instance.GetMessageFromKey("RARIFY_SUCCESS"), 7), 0));
                Session.Client.SendPacket(Session.Character.GenerateEff(3005));
                Session.Character.InventoryList.LoadByInventoryItem(item.InventoryItemId).InventoryItem.Rare = 7;
                Session.Client.SendPacket(Session.Character.GenerateInventoryAdd(item.InventoryItem.ItemVNum, item.InventoryItem.Amount, item.Type, item.Slot, item.InventoryItem.Rare, item.InventoryItem.Color, item.InventoryItem.Upgrade));
            }
            else if (rnd <= rare6 && !(protection == InventoryItem.RarifyProtection.Scroll && item.InventoryItem.Rare >= 6))
            {
                Session.Client.SendPacket(Session.Character.GenerateSay(String.Format(Language.Instance.GetMessageFromKey("RARIFY_SUCCESS"), 6), 12));
                Session.Client.SendPacket(Session.Character.GenerateMsg(String.Format(Language.Instance.GetMessageFromKey("RARIFY_SUCCESS"), 6), 0));
                Session.Client.SendPacket(Session.Character.GenerateEff(3005));
                Session.Character.InventoryList.LoadByInventoryItem(item.InventoryItemId).InventoryItem.Rare = 6;
                Session.Client.SendPacket(Session.Character.GenerateInventoryAdd(item.InventoryItem.ItemVNum, item.InventoryItem.Amount, item.Type, item.Slot, item.InventoryItem.Rare, item.InventoryItem.Color, item.InventoryItem.Upgrade));
            }
            else if (rnd <= rare5 && !(protection == InventoryItem.RarifyProtection.Scroll && item.InventoryItem.Rare >= 5))
            {
                Session.Client.SendPacket(Session.Character.GenerateSay(String.Format(Language.Instance.GetMessageFromKey("RARIFY_SUCCESS"), 5), 12));
                Session.Client.SendPacket(Session.Character.GenerateMsg(String.Format(Language.Instance.GetMessageFromKey("RARIFY_SUCCESS"), 5), 0));
                Session.Client.SendPacket(Session.Character.GenerateInventoryAdd(item.InventoryItem.ItemVNum, item.InventoryItem.Amount, item.Type, item.Slot, item.InventoryItem.Rare, item.InventoryItem.Color, item.InventoryItem.Upgrade));
                Session.Client.SendPacket(Session.Character.GenerateEff(3005));
                Session.Character.InventoryList.LoadByInventoryItem(item.InventoryItemId).InventoryItem.Rare = 5;
            }
            else if (rnd <= rare4 && !(protection == InventoryItem.RarifyProtection.Scroll && item.InventoryItem.Rare >= 4))
            {
                Session.Client.SendPacket(Session.Character.GenerateSay(String.Format(Language.Instance.GetMessageFromKey("RARIFY_SUCCESS"), 4), 12));
                Session.Client.SendPacket(Session.Character.GenerateMsg(String.Format(Language.Instance.GetMessageFromKey("RARIFY_SUCCESS"), 4), 0));
                Session.Client.SendPacket(Session.Character.GenerateEff(3005));
                Session.Character.InventoryList.LoadByInventoryItem(item.InventoryItemId).InventoryItem.Rare = 4;
                Session.Client.SendPacket(Session.Character.GenerateInventoryAdd(item.InventoryItem.ItemVNum, item.InventoryItem.Amount, item.Type, item.Slot, item.InventoryItem.Rare, item.InventoryItem.Color, item.InventoryItem.Upgrade));
            }
            else if (rnd <= rare3 && !(protection == InventoryItem.RarifyProtection.Scroll && item.InventoryItem.Rare >= 3))
            {
                Session.Client.SendPacket(Session.Character.GenerateSay(String.Format(Language.Instance.GetMessageFromKey("RARIFY_SUCCESS"), 3), 12));
                Session.Client.SendPacket(Session.Character.GenerateMsg(String.Format(Language.Instance.GetMessageFromKey("RARIFY_SUCCESS"), 3), 0));
                Session.Client.SendPacket(Session.Character.GenerateEff(3005));
                Session.Character.InventoryList.LoadByInventoryItem(item.InventoryItemId).InventoryItem.Rare = 3;
                Session.Client.SendPacket(Session.Character.GenerateInventoryAdd(item.InventoryItem.ItemVNum, item.InventoryItem.Amount, item.Type, item.Slot, item.InventoryItem.Rare, item.InventoryItem.Color, item.InventoryItem.Upgrade));
            }
            else if (rnd <= rare2 && !(protection == InventoryItem.RarifyProtection.Scroll && item.InventoryItem.Rare >= 2))
            {
                Session.Client.SendPacket(Session.Character.GenerateSay(String.Format(Language.Instance.GetMessageFromKey("RARIFY_SUCCESS"), 2), 12));
                Session.Client.SendPacket(Session.Character.GenerateMsg(String.Format(Language.Instance.GetMessageFromKey("RARIFY_SUCCESS"), 2), 0));
                Session.Client.SendPacket(Session.Character.GenerateEff(3005));
                Session.Character.InventoryList.LoadByInventoryItem(item.InventoryItemId).InventoryItem.Rare = 2;
                Session.Client.SendPacket(Session.Character.GenerateInventoryAdd(item.InventoryItem.ItemVNum, item.InventoryItem.Amount, item.Type, item.Slot, item.InventoryItem.Rare, item.InventoryItem.Color, item.InventoryItem.Upgrade));
            }
            else if (rnd <= rare1 && !(protection == InventoryItem.RarifyProtection.Scroll && item.InventoryItem.Rare >= 1))
            {
                Session.Client.SendPacket(Session.Character.GenerateSay(String.Format(Language.Instance.GetMessageFromKey("RARIFY_SUCCESS"), 1), 12));
                Session.Client.SendPacket(Session.Character.GenerateMsg(String.Format(Language.Instance.GetMessageFromKey("RARIFY_SUCCESS"), 1), 0));
                Session.Client.SendPacket(Session.Character.GenerateEff(3005));
                Session.Character.InventoryList.LoadByInventoryItem(item.InventoryItemId).InventoryItem.Rare = 1;
                Session.Client.SendPacket(Session.Character.GenerateInventoryAdd(item.InventoryItem.ItemVNum, item.InventoryItem.Amount, item.Type, item.Slot, item.InventoryItem.Rare, item.InventoryItem.Color, item.InventoryItem.Upgrade));
            }
            else
            {
                if (protection == InventoryItem.RarifyProtection.None)
                {
                    DeleteItem(item.Type, item.Slot);
                    Session.Client.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("RARIFY_FAILED"), 11));
                    Session.Client.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("RARIFY_FAILED"), 0));
                }
                else
                {
                    Session.Client.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("RARIFY_FAILED_ITEM_SAVED"), 11));
                    Session.Client.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("RARIFY_FAILED_ITEM_SAVED"), 0));
                    Session.Client.SendPacket(Session.Character.GenerateEff(3004));
                    Session.Character.InventoryList.LoadByInventoryItem(item.InventoryItemId).InventoryItem.IsFixed = true;

                }
            }
        }
Esempio n. 11
0
        public string GenerateSlInfo(InventoryItem inventoryItem,int type)
        {
            Item iteminfo = ServerManager.GetItem(inventoryItem.ItemVNum);
            int freepoint = ServersData.SpPoint(inventoryItem.SpLevel, inventoryItem.Upgrade) - inventoryItem.SlHit - inventoryItem.SlHP - inventoryItem.SlElement - inventoryItem.SlDefence;

            int SlElement = ServersData.SlPoint(inventoryItem.SlElement,2);
            int SlHP = ServersData.SlPoint(inventoryItem.SlHP,3);
            int SlDefence = ServersData.SlPoint(inventoryItem.SlDefence,1);
            int SlHit = ServersData.SlPoint(inventoryItem.SlHit,0);
            string skill = "-1"; //sk.sk.sk.sk.sk...
            return $"slinfo {type} {inventoryItem.ItemVNum} {iteminfo.Morph} {inventoryItem.SpLevel} {iteminfo.LevelJobMinimum} {iteminfo.ReputationMinimum+1} 0 0 0 0 0 0 0 {iteminfo.FireResistance} {iteminfo.WaterResistance} {iteminfo.LightResistance} {iteminfo.DarkResistance} 0 {inventoryItem.SpXp} {ServersData.SpXPData[inventoryItem.SpLevel-1]} {skill} {inventoryItem.InventoryItemId} {freepoint} {SlHit} {SlDefence} {SlElement} {SlHP} {inventoryItem.Upgrade} - 1 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0";
        }