private static void HandleModifySkin(GameSession session, PacketReader packet) { byte unk = packet.ReadByte(); SkinColor skinColor = packet.Read <SkinColor>(); bool useVoucher = packet.ReadBool(); BeautyMetadata beautyShop = BeautyMetadataStorage.GetShopById(501); if (!HandleShopPay(session, beautyShop, useVoucher)) { return; } session.Player.SkinColor = skinColor; Console.WriteLine(skinColor); session.FieldManager.BroadcastPacket(SkinColorPacket.Update(session.FieldPlayer, skinColor)); }
private static void HandleDyeItem(GameSession session, PacketReader packet) { BeautyMetadata beautyShop = BeautyMetadataStorage.GetShopById(506); byte itemCount = packet.ReadByte(); short[] quantity = new short[itemCount]; bool[] useVoucher = new bool[itemCount]; byte[] unk1 = new byte[itemCount]; long[] unk2 = new long[itemCount]; int[] unk3 = new int[itemCount]; long[] itemUid = new long[itemCount]; int[] itemId = new int[itemCount]; EquipColor[] equipColor = new EquipColor[itemCount]; HatData[] hatData = new HatData[itemCount]; for (int i = 0; i < itemCount; i++) { quantity[i] = packet.ReadShort(); // should always be one useVoucher[i] = packet.ReadBool(); unk1[i] = packet.ReadByte(); // just 0 unk2[i] = packet.ReadLong(); // just 0 unk3[i] = packet.ReadInt(); // also 0 itemUid[i] = packet.ReadLong(); itemId[i] = packet.ReadInt(); equipColor[i] = packet.Read <EquipColor>(); Item item = session.Player.GetEquippedItem(itemUid[i]); if (item == null) { return; } if (item.ItemSlot == ItemSlot.CP) { hatData[i] = packet.Read <HatData>(); } if (!HandleShopPay(session, beautyShop, useVoucher[i])) { return; } item.Color = equipColor[i]; session.FieldManager.BroadcastPacket(ItemExtraDataPacket.Update(session.FieldPlayer, item)); } }
private static void HandleModifyExistingBeauty(GameSession session, PacketReader packet) { byte unk = packet.ReadByte(); bool useVoucher = packet.ReadBool(); long beautyItemUid = packet.ReadLong(); EquipColor equipColor = packet.Read <EquipColor>(); int colorIndex = packet.ReadInt(); Item beautyItem = session.Player.Equips.FirstOrDefault(x => x.Value.Uid == beautyItemUid).Value; BeautyMetadata beautyShop = BeautyMetadataStorage.GetCosmeticShopByItemId(beautyItem.Id); if (!HandleShopPay(session, beautyShop, useVoucher)) { return; } beautyItem.Color = equipColor; ModifyBeauty(session, packet, beautyItem); }
private static void HandleBeautyVoucher(GameSession session, PacketReader packet) { long itemUid = packet.ReadLong(); Item voucher = session.Player.Inventory.Items[itemUid]; if (voucher == null || voucher.Function.Name != "ItemChangeBeauty") { return; } BeautyMetadata beautyShop = BeautyMetadataStorage.GetShopById(voucher.Function.Id); if (beautyShop == null) { return; } List <BeautyItem> beautyItems = BeautyMetadataStorage.GetGenderItems(beautyShop.ShopId, session.Player.Gender); session.Player.ShopId = beautyShop.ShopId; session.Send(BeautyPacket.LoadBeautyShop(beautyShop, beautyItems)); InventoryController.Consume(session, voucher.Uid, 1); }
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 = RandomProvider.Get(); 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]; Item newHair = new Item(chosenHair.ItemId) { Color = EquipColor.Argb(color, indexColor, palette.PaletteId), HairData = new HairData((float)chosenBackLength, (float)chosenFrontLength, chosenPreset.BackPositionCoord, chosenPreset.BackPositionRotation, chosenPreset.FrontPositionCoord, chosenPreset.FrontPositionRotation), IsTemplate = false, 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 Item previousHair)) { previousHair.Slot = -1; session.Player.HairInventory.RandomHair = previousHair; // store the previous hair DatabaseManager.Items.Delete(previousHair.Uid); session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, previousHair)); } cosmetics[ItemSlot.HR] = newHair; session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(session.FieldPlayer, newHair, ItemSlot.HR)); session.Send(BeautyPacket.RandomHairOption(previousHair, newHair)); }