Example #1
0
        public static void Handle(Entities.GameClient client, ItemPacket packet)
        {
            if (client.Booth != null)
            {
                return;
            }

            if (client.Inventory.ContainsByUID(packet.UID))
            {
                Data.ItemInfo ToBless = client.Inventory.GetItemByUID(packet.UID);
                if (ToBless.CurrentDura < ToBless.MaxDura)
                {
                    using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_LOW_DURA))
                        client.Send(msg);
                    return;
                }
                if (ToBless.IsGarment() || ToBless.IsArrow() || ToBless.IsBottle() ||
                    ToBless.IsSteed() || ToBless.IsMisc())
                {
                    using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_INVALID_UPGRADE))
                        client.Send(msg);
                    return;
                }

                if (ToBless != null)
                {
                    byte RequiredTortoiseGems = 5;
                    byte SetBless             = 1;
                    switch (ToBless.Bless)
                    {
                    case 0:
                        RequiredTortoiseGems = 5;
                        break;

                    case 1:
                        RequiredTortoiseGems = 1;
                        SetBless             = 3;
                        break;

                    case 3:
                        RequiredTortoiseGems = 3;
                        SetBless             = 5;
                        break;

                    case 5:
                        RequiredTortoiseGems = 5;
                        SetBless             = 7;
                        break;

                    default:
                        return;
                    }
                    byte TortoiseAmount;
                    if (!client.Inventory.ContainsByID(700073, out TortoiseAmount))
                    {
                        using (var msg = Packets.Message.MessageCore.CreateSystem(
                                   client.Name,
                                   string.Format(Core.MessageConst.ITEM_AMOUNT_FAIL, "TortoiseGem's")))
                            client.Send(msg);
                        return;
                    }
                    if (TortoiseAmount < RequiredTortoiseGems)
                    {
                        using (var msg = Packets.Message.MessageCore.CreateSystem(
                                   client.Name,
                                   string.Format(Core.MessageConst.ITEM_AMOUNT_FAIL, "TortoiseGem's")))
                            client.Send(msg);
                        return;
                    }
                    byte Removed;
                    client.Inventory.RemoveItem(700073, RequiredTortoiseGems, out Removed);
                    Database.CharacterDatabase.SaveInventory(client, ToBless, client.Inventory.GetPositionFromItemUID(ToBless.UID));
                    ToBless.Bless = SetBless;
                    ToBless.SendPacket(client, 3);
                    client.Send(packet);
                }
            }
        }
Example #2
0
        public static void Handle(Entities.GameClient client, ItemPacket packet)
        {
            if (client.Booth != null)
            {
                return;
            }
            if (!client.Alive)
            {
                return;
            }

            if (!client.Inventory.ContainsByUID(packet.UID) && client.Inventory.ContainsByUID(packet.Data1))
            {
                using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_NOT_FOUND))
                    client.Send(msg);
                return;
            }

            Data.ItemInfo ToUpgrade = client.Inventory.GetItemByUID(packet.UID);
            if (ToUpgrade.CurrentDura < ToUpgrade.MaxDura)
            {
                return;
            }

            Data.ItemInfo Meteor = client.Inventory.GetItemByUID(packet.Data1);
            if (Meteor == null || ToUpgrade == null)
            {
                using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_NOT_FOUND))
                    client.Send(msg);
                return;
            }
            if (ToUpgrade.IsGarment() || ToUpgrade.IsArrow() || ToUpgrade.IsBottle() ||
                ToUpgrade.IsSteed() || ToUpgrade.IsMisc())
            {
                using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_INVALID_UPGRADE))
                    client.Send(msg);
                return;
            }
            if (ToUpgrade.RequiredLevel >= 120)
            {
                using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_MAX_LEVEL))
                    client.Send(msg);
                return;                 // max level
            }
            if (Meteor.ItemID != 1088001 && Meteor.ItemID != 1088002)
            {
                using (var msg = Packets.Message.MessageCore.CreateSystem(
                           client.Name,
                           string.Format(Core.MessageConst.ITEM_AMOUNT_FAIL, "Meteor- or Meteortear's")))
                    client.Send(msg);
                return;
            }

            uint NewID = ToUpgrade.ItemID + 10;
            int  loop  = 4;

            while (!Core.Kernel.ItemInfos.Contains(NewID))
            {
                NewID += 10;
                loop--;
                if (loop <= 0)
                {
                    break;
                }
            }

            if (Core.Kernel.ItemInfos.Contains(NewID))
            {
                Data.ItemInfo newItem;
                if (Core.Kernel.ItemInfos.TrySelect(NewID, out newItem))
                {
                    if (newItem.RequiredLevel > ToUpgrade.RequiredLevel && newItem.TypeName == ToUpgrade.TypeName)
                    {
                        if (Calculations.BasicCalculations.ChanceSuccess(Core.NumericConst.LevelUpgradeChance))
                        {
                            Data.ItemInfo NewUpgradedItem = newItem.Copy();
                            NewUpgradedItem.SetStats(ToUpgrade);

                            client.Inventory.RemoveItemByUID(ToUpgrade.UID);
                            client.Inventory.RemoveItemByUID(Meteor.UID);

                            if (Calculations.BasicCalculations.ChanceSuccess(Core.NumericConst.FirstSocketChance) &&
                                NewUpgradedItem.Gem1 == Enums.SocketGem.NoSocket)
                            {
                                NewUpgradedItem.Gem1 = Enums.SocketGem.EmptySocket;
                            }
                            else if (Calculations.BasicCalculations.ChanceSuccess(Core.NumericConst.SecondSocketChance) &&
                                     NewUpgradedItem.Gem2 == Enums.SocketGem.NoSocket)
                            {
                                NewUpgradedItem.Gem2 = Enums.SocketGem.EmptySocket;
                            }

                            client.Inventory.AddItem(NewUpgradedItem);
                        }
                    }
                }
            }
        }
Example #3
0
        public static void Handle(Entities.GameClient client, ItemPacket packet)
        {
            if (client.Booth != null)
            {
                return;
            }
            if (!client.Alive)
            {
                return;
            }

            if (!client.Inventory.ContainsByUID(packet.UID) && client.Inventory.ContainsByUID(packet.Data1))
            {
                using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_NOT_FOUND))
                    client.Send(msg);
                return;
            }

            Data.ItemInfo ToUpgrade = client.Inventory.GetItemByUID(packet.UID);
            if (ToUpgrade.CurrentDura < ToUpgrade.MaxDura)
            {
                using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_LOW_DURA))
                    client.Send(msg);
                return;
            }

            Data.ItemInfo Dragonball = client.Inventory.GetItemByUID(packet.Data1);
            if (Dragonball == null || ToUpgrade == null)
            {
                using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_NOT_FOUND))
                    client.Send(msg);
                return;
            }
            if (ToUpgrade.IsGarment() || ToUpgrade.IsArrow() || ToUpgrade.IsBottle() ||
                ToUpgrade.IsSteed() || ToUpgrade.IsMisc())
            {
                using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_INVALID_UPGRADE))
                    client.Send(msg);
                return;
            }
            if (ToUpgrade.Quality >= 9)
            {
                using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_SUPER))
                    client.Send(msg);
                return;                 // super
            }
            if (Dragonball.ItemID != 1088000)
            {
                using (var msg = Packets.Message.MessageCore.CreateSystem(
                           client.Name,
                           string.Format(Core.MessageConst.ITEM_AMOUNT_FAIL, "Dragonball's")))
                    client.Send(msg);
                return;
            }

            uint NewID = ToUpgrade.ItemID;

            if (ToUpgrade.Quality >= 6)
            {
                NewID = (ToUpgrade.ItemID + 1);
            }
            else
            {
                while ((NewID % 10) < 6)
                {
                    NewID++;
                }
            }

            if (Core.Kernel.ItemInfos.Contains(NewID))
            {
                Data.ItemInfo newItem;
                if (Core.Kernel.ItemInfos.TrySelect(NewID, out newItem))
                {
                    if (newItem.Quality > ToUpgrade.Quality && newItem.Name == ToUpgrade.Name)
                    {
                        if (Calculations.BasicCalculations.ChanceSuccess(Core.NumericConst.QualityUpgradeChance))
                        {
                            Data.ItemInfo NewUpgradedItem = newItem.Copy();
                            NewUpgradedItem.SetStats(ToUpgrade);

                            client.Inventory.RemoveItemByUID(ToUpgrade.UID);
                            client.Inventory.RemoveItemByUID(Dragonball.UID);

                            if (Calculations.BasicCalculations.ChanceSuccess(Core.NumericConst.FirstSocketChance) &&
                                NewUpgradedItem.Gem1 == Enums.SocketGem.NoSocket)
                            {
                                NewUpgradedItem.Gem1 = Enums.SocketGem.EmptySocket;
                            }
                            else if (Calculations.BasicCalculations.ChanceSuccess(Core.NumericConst.SecondSocketChance) &&
                                     NewUpgradedItem.Gem2 == Enums.SocketGem.NoSocket)
                            {
                                NewUpgradedItem.Gem2 = Enums.SocketGem.EmptySocket;
                            }

                            client.Inventory.AddItem(NewUpgradedItem);
                        }
                    }
                }
            }
        }
        public static void Handle(Entities.GameClient client, DataPacket packet)
        {
            if (client.Booth != null)
            {
                return;
            }
            using (var socket = new GemSocketingPacket(packet))
            {
                if (!client.Inventory.ContainsByUID(socket.ItemUID) &&
                    !client.Inventory.ContainsByUID(socket.GemUID))
                {
                    return;
                }

                Data.ItemInfo SocketItem = client.Inventory.GetItemByUID(socket.ItemUID);
                if (SocketItem.CurrentDura < SocketItem.MaxDura)
                {
                    return;
                }
                if (!socket.RemoveGem)
                {
                    if (SocketItem.Gem1 != Enums.SocketGem.EmptySocket && socket.Socket == 1)
                    {
                        return;
                    }
                    else if (SocketItem.Gem2 != Enums.SocketGem.EmptySocket)
                    {
                        return;
                    }

                    Data.ItemInfo Gem = client.Inventory.GetItemByUID(socket.GemUID);
                    if (Gem == null || SocketItem == null)
                    {
                        return;
                    }
                    if (SocketItem.IsGarment() || SocketItem.IsArrow() || SocketItem.IsBottle() ||
                        SocketItem.IsSteed() || SocketItem.IsMisc() || SocketItem.IsFan() || SocketItem.IsTower())
                    {
                        return;
                    }

                    Enums.SocketGem gem = (Enums.SocketGem)(Gem.ItemID % 100);

                    if (gem != Enums.SocketGem.NormalThunderGem &&
                        gem != Enums.SocketGem.RefinedThunderGem &&
                        gem != Enums.SocketGem.SuperThunderGem &&
                        gem != Enums.SocketGem.NormalGloryGem &&
                        gem != Enums.SocketGem.RefinedGloryGem &&
                        gem != Enums.SocketGem.SuperGloryGem)
                    {
                        if (socket.Socket == 1)
                        {
                            SocketItem.Gem1 = gem;
                        }
                        else
                        {
                            SocketItem.Gem2 = gem;
                        }

                        Database.CharacterDatabase.SaveInventory(client, SocketItem, client.Inventory.GetPositionFromItemUID(SocketItem.UID));
                        client.Inventory.RemoveItemByUID(Gem.UID);
                        SocketItem.SendPacket(client, 3);
                    }
                }
                else
                {
                    if (SocketItem.Gem1 == Enums.SocketGem.EmptySocket && socket.Socket == 1 ||
                        SocketItem.Gem1 == Enums.SocketGem.NoSocket && socket.Socket == 1)
                    {
                        return;
                    }
                    else if (SocketItem.Gem2 == Enums.SocketGem.EmptySocket && socket.Socket != 1 ||
                             SocketItem.Gem2 == Enums.SocketGem.NoSocket && socket.Socket != 1)
                    {
                        return;
                    }

                    if (socket.Socket == 1)
                    {
                        SocketItem.Gem1 = Enums.SocketGem.EmptySocket;
                    }
                    else
                    {
                        SocketItem.Gem2 = Enums.SocketGem.EmptySocket;
                    }

                    Database.CharacterDatabase.SaveInventory(client, SocketItem, client.Inventory.GetPositionFromItemUID(SocketItem.UID));
                    SocketItem.SendPacket(client, 3);
                }
            }
        }