/// <summary> /// Verifies that the composition can be done. /// </summary> /// <param name="player">The player.</param> /// <param name="packet">The packet.</param> /// <param name="mainItem">The main item.</param> /// <param name="minorItem">The minor item.</param> /// <returns>True if the composition can be done, false otherwise.</returns> private static bool VerifyComposition(Models.Entities.Player player, Models.Packets.Items.CompositionPacket packet, out Models.Items.Item mainItem, out Models.Items.Item minorItem) { mainItem = null; minorItem = null; if (!player.Alive) { return(false); } if (!player.Inventory.TryGetItem(packet.MainItemClientId, out mainItem)) { player.SendSystemMessage("COMPOSITION_ITEM_NOT_FOUND"); return(false); } if (!player.Inventory.TryGetItem(packet.MinorItemClientId, out minorItem)) { player.SendSystemMessage("COMPOSITION_ITEM_NOT_FOUND"); return(false); } if (mainItem.IsGarment || mainItem.IsArrow || mainItem.IsBottle || mainItem.IsMountArmor || mainItem.IsMisc) { player.SendSystemMessage("COMPOSITION_ITEM_INVALID"); return(false); } if (mainItem.DbOwnerItem.CurrentDura < mainItem.DbOwnerItem.MaxDura) { player.SendSystemMessage("COMPOSITION_ITEM_LOW_DURA"); return(false); } if (mainItem.DbOwnerItem.Plus >= Data.Constants.GameMode.MaxPlus) { player.SendSystemMessage("COMPOSITION_ITEM_MAX_PLUS"); return(false); } if (minorItem.DbOwnerItem.Plus == 0) { player.SendSystemMessage("COMPOSITION_MINOR_ITEM_NO_PLUS"); return(false); } if (minorItem.DbOwnerItem.Plus < mainItem.DbOwnerItem.Plus) { player.SendSystemMessage("COMPOSITION_MINOR_ITEM_LOW_PLUS"); return(false); } return(true); }
public static bool HandleNormal(Models.Entities.Player player, Models.Packets.Items.CompositionPacket packet) { Models.Items.Item mainItem; Models.Items.Item minorItem; if (VerifyComposition(player, packet, out mainItem, out minorItem)) { DoNormalComposition(player, minorItem, mainItem); } UpdateClient(player, mainItem); return(true); }
public static bool HandleSteed(Models.Entities.Player player, Models.Packets.Items.CompositionPacket packet) { Models.Items.Item mainItem; Models.Items.Item minorItem; if (VerifyComposition(player, packet, out mainItem, out minorItem) && mainItem.IsSteed && minorItem.IsSteed) { player.AddActionLog("SteedComposition", mainItem.DbOwnerItem.Id); int color1 = (int)mainItem.DbOwnerItem.SocketRGB; int color2 = (int)minorItem.DbOwnerItem.SocketRGB; 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.DbOwnerItem.SocketRGB) { return(true); } mainItem.DbOwnerItem.SocketRGB = newColor; DoNormalComposition(player, minorItem, mainItem); } UpdateClient(player, mainItem); return(true); }
public static bool HandleVIP(Models.Entities.Player player, Models.Packets.Items.CompositionPacket packet) { return(HandleNormal(player, packet)); }