private static void HandleChooseRandomHair(GameSession session, PacketReader packet) { byte selection = packet.ReadByte(); if (selection == 0) // player chose previous hair { Dictionary <ItemSlot, Item> cosmetics = session.Player.Inventory.Cosmetics; //Remove current hair if (cosmetics.Remove(ItemSlot.HR, out Item newHair)) { newHair.Slot = -1; DatabaseManager.Items.Delete(newHair.Uid); session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, newHair)); } cosmetics[ItemSlot.HR] = session.Player.HairInventory.RandomHair; // apply the previous hair session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(session.FieldPlayer, session.Player.HairInventory.RandomHair, ItemSlot.HR)); Item voucher = new Item(20300246) { }; // Chic Salon Voucher InventoryController.Add(session, voucher, true); session.Send(BeautyPacket.ChooseRandomHair(voucher.Id)); } else // player chose new hair { session.Send(BeautyPacket.ChooseRandomHair()); } session.Player.HairInventory.RandomHair = null; // remove random hair option from hair inventory }
private static void HandleChangeToSavedHair(GameSession session, PacketReader packet) { long hairUid = packet.ReadLong(); Item hair = session.Player.HairInventory.SavedHair.FirstOrDefault(x => x.Uid == hairUid); if (hair == null) { return; } BeautyMetadata beautyShop = BeautyMetadataStorage.GetShopById(510); if (!PayWithShopTokenCost(session, beautyShop)) { return; } Dictionary <ItemSlot, Item> cosmetics = session.Player.Inventory.Cosmetics; if (cosmetics.Remove(hair.ItemSlot, out Item removeItem)) { removeItem.Slot = -1; session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, removeItem)); } cosmetics[removeItem.ItemSlot] = hair; session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(session.FieldPlayer, hair, hair.ItemSlot)); session.Send(BeautyPacket.ChangetoSavedHair()); }
private static void HandleUnequipItem(GameSession session, PacketReader packet) { long itemUid = packet.ReadLong(); // Unequip gear KeyValuePair <ItemSlot, Item> kvpEquips = session.Player.Equips.FirstOrDefault(x => x.Value.Uid == itemUid); if (kvpEquips.Value != null) { if (session.Player.Equips.Remove(kvpEquips.Key, out Item unequipItem)) { unequipItem.Slot = -1; InventoryController.Add(session, unequipItem, false); session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, unequipItem)); DecreaseStats(session, unequipItem); } return; } // Unequip cosmetics KeyValuePair <ItemSlot, Item> kvpCosmetics = session.Player.Cosmetics.FirstOrDefault(x => x.Value.Uid == itemUid); if (kvpCosmetics.Value != null) { if (session.Player.Cosmetics.Remove(kvpCosmetics.Key, out Item unequipItem)) { unequipItem.Slot = -1; InventoryController.Add(session, unequipItem, false); session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, unequipItem)); } } }
public static void ChangeFace(GameSession session, int faceId, out Item previousFace, out Item newFace) { Random random = Random.Shared; // Grab random preset color ColorPaletteMetadata palette = ColorPaletteMetadataStorage.GetMetadata(1); // pick from palette 2. Seems like it's the correct palette for basic face colors int indexColor = random.Next(palette.DefaultColors.Count); MixedColor color = palette.DefaultColors[indexColor]; newFace = new(faceId) { Color = EquipColor.Argb(color, indexColor, palette.PaletteId), IsEquipped = true, OwnerCharacterId = session.Player.CharacterId, OwnerCharacterName = session.Player.Name }; Dictionary <ItemSlot, Item> cosmetics = session.Player.Inventory.Cosmetics; //Remove old face if (cosmetics.Remove(ItemSlot.FA, out previousFace)) { previousFace.Slot = -1; DatabaseManager.Items.Delete(previousFace.Uid); session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.Player.FieldPlayer, previousFace)); } cosmetics[ItemSlot.FA] = newFace; } }
private static void HandleRandomHair(GameSession session, PacketReader packet) { int shopId = packet.ReadInt(); bool useVoucher = packet.ReadBool(); BeautyMetadata beautyShop = BeautyMetadataStorage.GetShopById(shopId); List <BeautyItem> beautyItems = BeautyMetadataStorage.GetGenderItems(beautyShop.ShopId, session.Player.Gender); if (!HandleShopPay(session, beautyShop, useVoucher)) { return; } // Grab random hair Random random = new Random(); int indexHair = random.Next(beautyItems.Count); BeautyItem chosenHair = beautyItems[indexHair]; //Grab a preset hair and length of hair ItemMetadata beautyItemData = ItemMetadataStorage.GetMetadata(chosenHair.ItemId); int indexPreset = random.Next(beautyItemData.HairPresets.Count); HairPresets chosenPreset = beautyItemData.HairPresets[indexPreset]; //Grab random front hair length double chosenFrontLength = random.NextDouble() * (beautyItemData.HairPresets[indexPreset].MaxScale - beautyItemData.HairPresets[indexPreset].MinScale) + beautyItemData.HairPresets[indexPreset].MinScale; //Grab random back hair length double chosenBackLength = random.NextDouble() * (beautyItemData.HairPresets[indexPreset].MaxScale - beautyItemData.HairPresets[indexPreset].MinScale) + beautyItemData.HairPresets[indexPreset].MinScale; // Grab random preset color ColorPaletteMetadata palette = ColorPaletteMetadataStorage.GetMetadata(2); // pick from palette 2. Seems like it's the correct palette for basic hair colors int indexColor = random.Next(palette.DefaultColors.Count); MixedColor color = palette.DefaultColors[indexColor]; Dictionary <ItemSlot, Item> equippedInventory = session.Player.GetEquippedInventory(InventoryTab.Gear); Item newHair = new Item(chosenHair.ItemId) { Color = EquipColor.Argb(color, indexColor, palette.PaletteId), HairD = new HairData((float)chosenBackLength, (float)chosenFrontLength, chosenPreset.BackPositionCoord, chosenPreset.BackPositionRotation, chosenPreset.FrontPositionCoord, chosenPreset.FrontPositionRotation), IsTemplate = false }; //Remove old hair if (session.Player.Equips.Remove(ItemSlot.HR, out Item previousHair)) { previousHair.Slot = -1; session.Player.HairInventory.RandomHair = previousHair; // store the previous hair session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, previousHair)); } equippedInventory[ItemSlot.HR] = newHair; session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(session.FieldPlayer, newHair, ItemSlot.HR)); session.Send(BeautyPacket.RandomHairOption(previousHair, newHair)); }
private static void ModifyBeauty(GameSession session, PacketReader packet, Item beautyItem) { ItemSlot itemSlot = ItemMetadataStorage.GetSlot(beautyItem.Id); Dictionary <ItemSlot, Item> cosmetics = session.Player.Inventory.Cosmetics; if (cosmetics.TryGetValue(itemSlot, out Item removeItem)) { // Only remove if it isn't the same item if (removeItem.Uid != beautyItem.Uid) { cosmetics.Remove(itemSlot); removeItem.Slot = -1; DatabaseManager.Items.Delete(removeItem.Uid); session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, removeItem)); } } // equip & update new item switch (itemSlot) { case ItemSlot.HR: float backLength = BitConverter.ToSingle(packet.Read(4), 0); CoordF backPositionCoord = packet.Read <CoordF>(); CoordF backPositionRotation = packet.Read <CoordF>(); float frontLength = BitConverter.ToSingle(packet.Read(4), 0); CoordF frontPositionCoord = packet.Read <CoordF>(); CoordF frontPositionRotation = packet.Read <CoordF>(); beautyItem.HairData = new HairData(backLength, frontLength, backPositionCoord, backPositionRotation, frontPositionCoord, frontPositionRotation); cosmetics[itemSlot] = beautyItem; session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(session.FieldPlayer, beautyItem, itemSlot)); break; case ItemSlot.FA: cosmetics[itemSlot] = beautyItem; session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(session.FieldPlayer, beautyItem, itemSlot)); break; case ItemSlot.FD: byte[] faceDecorationPosition = packet.Read(16); beautyItem.FaceDecorationData = faceDecorationPosition; cosmetics[itemSlot] = beautyItem; session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(session.FieldPlayer, beautyItem, itemSlot)); break; } }
private static void ModifyBeauty(GameSession session, PacketReader packet, Item beautyItem) { ItemSlot itemSlot = ItemMetadataStorage.GetSlot(beautyItem.Id); // remove current item if (session.Player.Equips.Remove(itemSlot, out Item removeItem)) { removeItem.Slot = -1; session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, removeItem)); } // equip new item Dictionary <ItemSlot, Item> equippedInventory = session.Player.GetEquippedInventory(InventoryTab.Gear); switch (itemSlot) { case ItemSlot.HR: float backLength = BitConverter.ToSingle(packet.Read(4), 0); CoordF backPositionCoord = packet.Read <CoordF>(); CoordF backPositionRotation = packet.Read <CoordF>(); float frontLength = BitConverter.ToSingle(packet.Read(4), 0); CoordF frontPositionCoord = packet.Read <CoordF>(); CoordF frontPositionRotation = packet.Read <CoordF>(); beautyItem.HairD = new HairData(backLength, frontLength, backPositionCoord, backPositionRotation, frontPositionCoord, frontPositionRotation); equippedInventory[itemSlot] = beautyItem; session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(session.FieldPlayer, beautyItem, itemSlot)); break; case ItemSlot.FA: equippedInventory[itemSlot] = beautyItem; session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(session.FieldPlayer, beautyItem, itemSlot)); break; case ItemSlot.FD: byte[] faceDecorationPosition = packet.Read(16); beautyItem.FaceDecorationD = faceDecorationPosition; equippedInventory[itemSlot] = beautyItem; session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(session.FieldPlayer, beautyItem, itemSlot)); break; } }
private static void HandleUnequipItem(GameSession session, PacketReader packet) { long itemUid = packet.ReadLong(); bool unequipped = false; // Unequip gear foreach ((ItemSlot slot, Item item) in session.Player.Equips) { if (itemUid != item.Uid) { continue; } if (session.Player.Equips.Remove(slot, out Item unequipItem)) { unequipped = true; unequipItem.Slot = -1; InventoryController.Add(session, unequipItem, false); session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, unequipItem)); break; } } if (unequipped) { return; } // Unequip cosmetic foreach ((ItemSlot slot, Item item) in session.Player.Cosmetics) { if (itemUid != item.Uid) { continue; } if (session.Player.Cosmetics.Remove(slot, out Item unequipItem)) { unequipItem.Slot = -1; InventoryController.Add(session, unequipItem, false); session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, unequipItem)); break; } } }
private void HandleUnequipItem(GameSession session, PacketReader packet) { long itemUid = packet.ReadLong(); foreach ((ItemSlot slot, Item item) in session.Player.Equips) { if (itemUid != item.Uid) { continue; } if (session.Player.Equips.Remove(slot, out Item unequipItem)) { InventoryController.Add(session, unequipItem, false); session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, unequipItem)); break; } } }
public static void ChangeHair(GameSession session, int hairId, out Item previousHair, out Item newHair) { Random random = Random.Shared; //Grab a preset hair and length of hair ItemCustomizeMetadata customize = ItemMetadataStorage.GetMetadata(hairId).Customize; int indexPreset = random.Next(customize.HairPresets.Count); HairPresets chosenPreset = customize.HairPresets[indexPreset]; //Grab random front hair length double chosenFrontLength = random.NextDouble() * (customize.HairPresets[indexPreset].MaxScale - customize.HairPresets[indexPreset].MinScale) + customize.HairPresets[indexPreset].MinScale; //Grab random back hair length double chosenBackLength = random.NextDouble() * (customize.HairPresets[indexPreset].MaxScale - customize.HairPresets[indexPreset].MinScale) + customize.HairPresets[indexPreset].MinScale; // Grab random preset color ColorPaletteMetadata palette = ColorPaletteMetadataStorage.GetMetadata(2); // pick from palette 2. Seems like it's the correct palette for basic hair colors int indexColor = random.Next(palette.DefaultColors.Count); MixedColor color = palette.DefaultColors[indexColor]; newHair = new(hairId) { Color = EquipColor.Argb(color, indexColor, palette.PaletteId), HairData = new((float)chosenBackLength, (float)chosenFrontLength, chosenPreset.BackPositionCoord, chosenPreset.BackPositionRotation, chosenPreset.FrontPositionCoord, chosenPreset.FrontPositionRotation), IsEquipped = true, OwnerCharacterId = session.Player.CharacterId, OwnerCharacterName = session.Player.Name }; Dictionary <ItemSlot, Item> cosmetics = session.Player.Inventory.Cosmetics; //Remove old hair if (cosmetics.Remove(ItemSlot.HR, out previousHair)) { previousHair.Slot = -1; session.Player.HairInventory.RandomHair = previousHair; // store the previous hair DatabaseManager.Items.Delete(previousHair.Uid); session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.Player.FieldPlayer, previousHair)); } cosmetics[ItemSlot.HR] = newHair; }
private void HandleUnequipItem(GameSession session, PacketReader packet) { long itemUid = packet.ReadLong(); foreach ((EquipSlot slot, Item item) in session.Player.Equip) { if (itemUid != item.Uid) { continue; } if (session.Player.Equip.Remove(slot, out Item unequipItem)) { session.Inventory.Add(unequipItem); session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, unequipItem)); session.Send(ItemInventoryPacket.Add(unequipItem)); break; } } }
private void HandleEquipItem(GameSession session, PacketReader packet) { long itemUid = packet.ReadLong(); string equipSlotStr = packet.ReadUnicodeString(); if (!Enum.TryParse(equipSlotStr, out ItemSlot equipSlot)) { logger.Warning("Unknown equip slot: " + equipSlotStr); return; } // Remove the item from the users inventory InventoryController.Remove(session, itemUid, out Item item); // TODO: Move unequipped item into the correct slot // Move previously equipped item back to inventory if (session.Player.Equips.Remove(equipSlot, out Item prevItem)) { InventoryController.Add(session, prevItem, false); session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, prevItem)); } // Equip new item session.Player.Equips[equipSlot] = item; session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(session.FieldPlayer, item, equipSlot)); // TODO - Increase stats based on the item stats itself session.Player.Stats.CritRate.Max += 12; session.Player.Stats.CritRate.Total += 12; session.Player.Stats.MinAtk.Max += 15; session.Player.Stats.MinAtk.Total += 15; session.Player.Stats.MaxAtk.Max += 17; session.Player.Stats.MaxAtk.Total += 17; session.Player.Stats.MagAtk.Max += 15; session.Player.Stats.MagAtk.Total += 15; session.Send(StatPacket.SetStats(session.FieldPlayer)); }
private static void HandleUnequipItem(GameSession session, PacketReader packet) { long itemUid = packet.ReadLong(); Player player = session.Player; IInventory inventory = player.Inventory; // Unequip gear (ItemSlot itemSlot, Item item) = inventory.Equips.FirstOrDefault(x => x.Value.Uid == itemUid); if (item is not null) { if (!inventory.Equips.Remove(itemSlot, out Item unequipItem)) { return; } unequipItem.Slot = -1; unequipItem.IsEquipped = false; inventory.AddItem(session, unequipItem, false); session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(player.FieldPlayer, unequipItem)); player.FieldPlayer.ComputeStats(); return; } // Unequip cosmetics (ItemSlot itemSlot2, Item item2) = inventory.Cosmetics.FirstOrDefault(x => x.Value.Uid == itemUid); if (item2 is null) { return; } if (!inventory.Cosmetics.Remove(itemSlot2, out Item unequipItem2)) { return; } unequipItem2.Slot = -1; unequipItem2.IsEquipped = false; inventory.AddItem(session, unequipItem2, false); session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(player.FieldPlayer, unequipItem2)); }
private void HandleEquipItem(GameSession session, PacketReader packet) { long itemUid = packet.ReadLong(); string equipSlotStr = packet.ReadUnicodeString(); if (!Enum.TryParse(equipSlotStr, out ItemSlot equipSlot)) { Logger.Warning("Unknown equip slot: " + equipSlotStr); return; } // Remove the item from the users inventory InventoryController.Remove(session, itemUid, out Item item); // Get correct equipped inventory Dictionary <ItemSlot, Item> equippedInventory = session.Player.GetEquippedInventory(item.InventoryTab); if (equippedInventory == null) { Logger.Warning("equippedInventory was null: " + item.InventoryTab); return; } // Move previously equipped item back to inventory if (equippedInventory.Remove(equipSlot, out Item prevItem)) { prevItem.Slot = item.Slot; InventoryController.Add(session, prevItem, false); session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, prevItem)); } // Handle unequipping pants when equipping dresses // Handle unequipping off-hand when equipping two-handed weapons if (item.IsDress || item.IsTwoHand) { if (equippedInventory.Remove(item.IsDress ? ItemSlot.PA : ItemSlot.LH, out Item prevItem2)) { prevItem2.Slot = -1; if (prevItem == null) { prevItem2.Slot = item.Slot; } InventoryController.Add(session, prevItem2, false); session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, prevItem2)); } } // Handle unequipping dresses when equipping pants // Handle unequipping two-handed main-hands when equipping off-hand weapons if (item.ItemSlot == ItemSlot.PA || item.ItemSlot == ItemSlot.LH) { ItemSlot prevItemSlot = item.ItemSlot == ItemSlot.PA ? ItemSlot.CL : ItemSlot.RH; if (equippedInventory.ContainsKey(prevItemSlot)) { if (equippedInventory[prevItemSlot] != null && equippedInventory[prevItemSlot].IsDress) { if (equippedInventory.Remove(prevItemSlot, out Item prevItem2)) { prevItem2.Slot = item.Slot; InventoryController.Add(session, prevItem2, false); session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, prevItem2)); } } } } // Equip new item equippedInventory[equipSlot] = item; session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(session.FieldPlayer, item, equipSlot)); if (item.InventoryTab == InventoryTab.Gear) { // TODO - Increase stats based on the item stats itself session.Player.Stats.CritRate.Max += 12; session.Player.Stats.CritRate.Total += 12; session.Player.Stats.MinAtk.Max += 15; session.Player.Stats.MinAtk.Total += 15; session.Player.Stats.MaxAtk.Max += 17; session.Player.Stats.MaxAtk.Total += 17; session.Player.Stats.MagAtk.Max += 15; session.Player.Stats.MagAtk.Total += 15; session.Send(StatPacket.SetStats(session.FieldPlayer)); } }
private static void HandleEquipItem(GameSession session, PacketReader packet) { long itemUid = packet.ReadLong(); string equipSlotStr = packet.ReadUnicodeString(); if (!Enum.TryParse(equipSlotStr, out ItemSlot equipSlot)) { Logger.Warn($"Unknown equip slot: {equipSlotStr}"); return; } // Remove the item from the users inventory Inventory inventory = session.Player.Inventory; inventory.RemoveItem(session, itemUid, out Item item); if (item == null) { return; } // Get correct equipped inventory Dictionary <ItemSlot, Item> equippedInventory = session.Player.GetEquippedInventory(item.InventoryTab); if (equippedInventory == null) { Logger.Warn($"equippedInventory was null: {item.InventoryTab}"); return; } // Move previously equipped item back to inventory if (equippedInventory.Remove(equipSlot, out Item prevItem)) { prevItem.Slot = item.Slot; prevItem.IsEquipped = false; inventory.AddItem(session, prevItem, false); session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.Player.FieldPlayer, prevItem)); if (prevItem.InventoryTab == InventoryTab.Gear) { DecreaseStats(session, prevItem); } } // Handle unequipping pants when equipping dresses // Handle unequipping off-hand when equipping two-handed weapons if (item.IsDress || item.IsTwoHand) { if (equippedInventory.Remove(item.IsDress ? ItemSlot.PA : ItemSlot.LH, out Item prevItem2)) { prevItem2.Slot = -1; if (prevItem == null) { prevItem2.Slot = item.Slot; } prevItem2.IsEquipped = false; inventory.AddItem(session, prevItem2, false); session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.Player.FieldPlayer, prevItem2)); } } // Handle unequipping dresses when equipping pants // Handle unequipping two-handed main-hands when equipping off-hand weapons if (item.ItemSlot is ItemSlot.PA or ItemSlot.LH) { ItemSlot prevItemSlot = item.ItemSlot == ItemSlot.PA ? ItemSlot.CL : ItemSlot.RH; if (equippedInventory.ContainsKey(prevItemSlot)) { if (equippedInventory[prevItemSlot] != null && equippedInventory[prevItemSlot].IsDress) { if (equippedInventory.Remove(prevItemSlot, out Item prevItem2)) { prevItem2.Slot = item.Slot; prevItem2.IsEquipped = false; inventory.AddItem(session, prevItem2, false); session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.Player.FieldPlayer, prevItem2)); } } } } // Equip new item item.IsEquipped = true; item.ItemSlot = equipSlot; equippedInventory[equipSlot] = item; session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(session.Player.FieldPlayer, item, equipSlot)); // Add stats if gear if (item.InventoryTab == InventoryTab.Gear) { IncreaseStats(session, item); } }
private void HandleEquipItem(GameSession session, PacketReader packet) { long itemUid = packet.ReadLong(); string equipSlotStr = packet.ReadUnicodeString(); if (!Enum.TryParse(equipSlotStr, out ItemSlot equipSlot)) { logger.Warning("Unknown equip slot: " + equipSlotStr); return; } // Remove the item from the users inventory InventoryController.Remove(session, itemUid, out Item item); // Equip cosmetic if (item.InventoryTab == InventoryTab.Outfit) { // Move previously equipped item back to inventory if (session.Player.Cosmetics.Remove(equipSlot, out Item prevItem)) { prevItem.Slot = item.Slot; InventoryController.Add(session, prevItem, false); session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, prevItem)); } // Handle unequipping off-hand when equipping two-handed weapons if (item.IsTwoHand) { if (session.Player.Cosmetics.Remove(ItemSlot.LH, out Item prevItem2)) { prevItem2.Slot = -1; if (prevItem == null) { prevItem2.Slot = item.Slot; } InventoryController.Add(session, prevItem2, false); session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, prevItem2)); } } // Handle unequipping two-handed main-hands when equipping off-hand weapons if (item.ItemSlot == ItemSlot.LH && session.Player.Cosmetics[ItemSlot.RH] != null && session.Player.Cosmetics[ItemSlot.RH].IsTwoHand) { if (session.Player.Cosmetics.Remove(ItemSlot.RH, out Item prevItem2)) { prevItem2.Slot = item.Slot; InventoryController.Add(session, prevItem2, false); session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, prevItem2)); } } // Equip new item session.Player.Cosmetics[equipSlot] = item; session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(session.FieldPlayer, item, equipSlot)); } // Equip gear else { // Move previously equipped item back to inventory if (session.Player.Equips.Remove(equipSlot, out Item prevItem)) { prevItem.Slot = item.Slot; InventoryController.Add(session, prevItem, false); session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, prevItem)); } // Handle unequipping off-hand when equipping two-handed weapons if (item.IsTwoHand) { if (session.Player.Equips.Remove(ItemSlot.LH, out Item prevItem2)) { prevItem2.Slot = -1; if (prevItem == null) { prevItem2.Slot = item.Slot; } InventoryController.Add(session, prevItem2, false); session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, prevItem2)); } } // Handle unequipping two-handed main-hands when equipping off-hand weapons if (item.ItemSlot == ItemSlot.LH && session.Player.Equips[ItemSlot.RH] != null && session.Player.Equips[ItemSlot.RH].IsTwoHand) { if (session.Player.Equips.Remove(ItemSlot.RH, out Item prevItem2)) { prevItem2.Slot = item.Slot; InventoryController.Add(session, prevItem2, false); session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, prevItem2)); } } // Equip new item session.Player.Equips[equipSlot] = item; session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(session.FieldPlayer, item, equipSlot)); // TODO - Increase stats based on the item stats itself session.Player.Stats.CritRate.Max += 12; session.Player.Stats.CritRate.Total += 12; session.Player.Stats.MinAtk.Max += 15; session.Player.Stats.MinAtk.Total += 15; session.Player.Stats.MaxAtk.Max += 17; session.Player.Stats.MaxAtk.Total += 17; session.Player.Stats.MagAtk.Max += 15; session.Player.Stats.MagAtk.Total += 15; session.Send(StatPacket.SetStats(session.FieldPlayer)); } }