/// <summary> /// Handling the Use action from the ItemPacket. /// </summary> /// <param name="client">The client.</param> /// <param name="item">The item packet.</param> public static void Handle(Entities.GameClient client, ItemPacket packet) { uint uid = packet.UID; if (client.Inventory.ContainsByUID(uid)) { Data.ItemInfo useitem = client.Inventory[uid]; if (useitem.IsMisc()) { if (!Core.Kernel.ItemScriptEngine.Invoke(useitem.ItemID, new object[] { client, useitem })) { using (var fmsg = Packets.Message.MessageCore.CreateSystem(client.Name, string.Format(Core.MessageConst.INVALD_ITEM_USE, useitem.Name, useitem.ItemID))) client.Send(fmsg); } } else { if (!client.Alive) { return; } Enums.ItemLocation loc = (Enums.ItemLocation)packet.Data1; client.Equipments.Equip(useitem, loc, true); } } // else (Reason this is commented out is because it disconnected the client if switching equips too fast lmao. // client.NetworkClient.Disconnect("Using invalid item."); }
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); } } }
public static void Handle(Entities.GameClient client, DataPacket packet) { using (var composition = new CompositionPacket(packet)) { if (!client.Inventory.ContainsByUID(composition.MainItem)) { using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_NOT_FOUND)) client.Send(msg); return; } if (!client.Inventory.ContainsByUID(composition.MinorItem)) { using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_NOT_FOUND)) client.Send(msg); return; } Data.ItemInfo MainItem = client.Inventory.GetItemByUID(composition.MainItem); if (MainItem.IsGarment() || MainItem.IsArrow() || MainItem.IsBottle() || MainItem.IsMisc() || MainItem.IsMountArmor()) { using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_INVALID_UPGRADE)) client.Send(msg); return; } if (MainItem.CurrentDura < MainItem.MaxDura) { using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_LOW_DURA)) client.Send(msg); return; } Data.ItemInfo MinorItem = client.Inventory.GetItemByUID(composition.MinorItem); if (MainItem.Plus >= Core.NumericConst.MaxPlus) { using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_MAX_PLUS)) client.Send(msg); return; } if (MinorItem.Plus == 0) { using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_NO_PLUS)) client.Send(msg); return; } if (MinorItem.Plus < MainItem.Plus) { using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_LOW_PLUS)) client.Send(msg); return; } //ushort[] CompositionPoints = new ushort[12] { 20, 20, 80, 240, 720, 2160, 6480, 19440, 58320, 2700, 5500, 9000 }; //ushort AddPoints = (CompositionPoints[MainItem.Plus] / 2); switch (composition.CompositionType) { case Enums.CompositionType.SteedComposition: { int color1 = (int)MainItem.SocketAndRGB; int color2 = (int)MinorItem.SocketAndRGB; int B1 = color1 & 0xFF; int B2 = color2 & 0xFF; int G1 = (color1 >> 8) & 0xFF; int G2 = (color2 >> 8) & 0xFF; int R1 = (color1 >> 16) & 0xFF; int R2 = (color2 >> 16) & 0xFF; int newB = (int)Math.Floor(0.9 * B1) + (int)Math.Floor(0.1 * B2); int newG = (int)Math.Floor(0.9 * G1) + (int)Math.Floor(0.1 * G2); int newR = (int)Math.Floor(0.9 * R1) + (int)Math.Floor(0.1 * R2); uint NewColor = (uint)(newB | (newG << 8) | (newR << 16)); if (NewColor == MainItem.SocketAndRGB) { return; } MainItem.SocketAndRGB = NewColor; goto case Enums.CompositionType.BonusCompositionA; } case Enums.CompositionType.BonusCompositionA: case Enums.CompositionType.BonusCompositionB: { //uint CompositionPoints = Calculations.BasicCalculations.CompositionPoints(MinorItem.Plus); client.Inventory.RemoveItemByUID(MinorItem.UID); if (MainItem.Composition > 0) { MainItem.Plus++; MainItem.Composition = 0; } else { MainItem.Composition = 1; } Database.CharacterDatabase.SaveInventory(client, MainItem, client.Inventory.GetPositionFromItemUID(MainItem.UID)); MainItem.SendPacket(client, 3); break; } } } }
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, 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); } } } } }
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); } } }