예제 #1
0
        void HandleMirrorImageDataRequest(GetMirrorImageData packet)
        {
            ObjectGuid guid = packet.UnitGUID;

            // Get unit for which data is needed by client
            Unit unit = Global.ObjAccessor.GetUnit(GetPlayer(), guid);

            if (!unit)
            {
                return;
            }

            if (!unit.HasAuraType(AuraType.CloneCaster))
            {
                return;
            }

            // Get creator of the unit (SPELL_AURA_CLONE_CASTER does not stack)
            Unit creator = unit.GetAuraEffectsByType(AuraType.CloneCaster).FirstOrDefault().GetCaster();

            if (!creator)
            {
                return;
            }

            Player player = creator.ToPlayer();

            if (player)
            {
                MirrorImageComponentedData data = new MirrorImageComponentedData();
                data.UnitGUID  = guid;
                data.DisplayID = (int)creator.GetDisplayId();
                data.RaceID    = (byte)creator.GetRace();
                data.Gender    = (byte)creator.GetGender();
                data.ClassID   = (byte)creator.GetClass();

                Guild guild = player.GetGuild();

                data.SkinColor      = player.GetByteValue(PlayerFields.Bytes, PlayerFieldOffsets.BytesOffsetSkinId);
                data.FaceVariation  = player.GetByteValue(PlayerFields.Bytes, PlayerFieldOffsets.BytesOffsetFaceId);
                data.HairVariation  = player.GetByteValue(PlayerFields.Bytes, PlayerFieldOffsets.BytesOffsetHairStyleId);
                data.HairColor      = player.GetByteValue(PlayerFields.Bytes, PlayerFieldOffsets.BytesOffsetHairColorId);
                data.BeardVariation = player.GetByteValue(PlayerFields.Bytes2, PlayerFieldOffsets.Bytes2OffsetFacialStyle);
                for (int i = 0; i < PlayerConst.CustomDisplaySize; ++i)
                {
                    data.CustomDisplay[i] = player.GetByteValue(PlayerFields.Bytes2, (byte)(PlayerFieldOffsets.Bytes2OffsetCustomDisplayOption + i));
                }
                data.GuildGUID = (guild ? guild.GetGUID() : ObjectGuid.Empty);

                byte[] itemSlots =
                {
                    EquipmentSlot.Head,
                    EquipmentSlot.Shoulders,
                    EquipmentSlot.Shirt,
                    EquipmentSlot.Chest,
                    EquipmentSlot.Waist,
                    EquipmentSlot.Legs,
                    EquipmentSlot.Feet,
                    EquipmentSlot.Wrist,
                    EquipmentSlot.Hands,
                    EquipmentSlot.Tabard,
                    EquipmentSlot.Cloak
                };

                // Display items in visible slots
                foreach (var slot in itemSlots)
                {
                    uint itemDisplayId;
                    Item item = player.GetItemByPos(InventorySlots.Bag0, slot);
                    if ((slot == EquipmentSlot.Head && player.HasFlag(PlayerFields.Flags, PlayerFlags.HideHelm)) ||
                        (slot == EquipmentSlot.Cloak && player.HasFlag(PlayerFields.Flags, PlayerFlags.HideCloak)))
                    {
                        itemDisplayId = 0;
                    }
                    else if (item)
                    {
                        itemDisplayId = item.GetDisplayId(player);
                    }
                    else
                    {
                        itemDisplayId = 0;
                    }

                    data.ItemDisplayID.Add((int)itemDisplayId);
                }

                SendPacket(data);
            }
            else
            {
                MirrorImageCreatureData data = new MirrorImageCreatureData();
                data.UnitGUID  = guid;
                data.DisplayID = (int)creator.GetDisplayId();
                SendPacket(data);
            }
        }
예제 #2
0
        void HandleMirrorImageDataRequest(GetMirrorImageData packet)
        {
            ObjectGuid guid = packet.UnitGUID;

            // Get unit for which data is needed by client
            Unit unit = Global.ObjAccessor.GetUnit(GetPlayer(), guid);

            if (!unit)
            {
                return;
            }

            if (!unit.HasAuraType(AuraType.CloneCaster))
            {
                return;
            }

            // Get creator of the unit (SPELL_AURA_CLONE_CASTER does not stack)
            Unit creator = unit.GetAuraEffectsByType(AuraType.CloneCaster).FirstOrDefault().GetCaster();

            if (!creator)
            {
                return;
            }

            Player player = creator.ToPlayer();

            if (player)
            {
                MirrorImageComponentedData mirrorImageComponentedData = new MirrorImageComponentedData();
                mirrorImageComponentedData.UnitGUID  = guid;
                mirrorImageComponentedData.DisplayID = (int)creator.GetDisplayId();
                mirrorImageComponentedData.RaceID    = (byte)creator.GetRace();
                mirrorImageComponentedData.Gender    = (byte)creator.GetGender();
                mirrorImageComponentedData.ClassID   = (byte)creator.GetClass();

                foreach (var customization in player.m_playerData.Customizations)
                {
                    mirrorImageComponentedData.Customizations.Add(new ChrCustomizationChoice(customization.ChrCustomizationOptionID, customization.ChrCustomizationChoiceID));
                }

                Guild guild = player.GetGuild();
                mirrorImageComponentedData.GuildGUID = (guild ? guild.GetGUID() : ObjectGuid.Empty);

                byte[] itemSlots =
                {
                    EquipmentSlot.Head,
                    EquipmentSlot.Shoulders,
                    EquipmentSlot.Shirt,
                    EquipmentSlot.Chest,
                    EquipmentSlot.Waist,
                    EquipmentSlot.Legs,
                    EquipmentSlot.Feet,
                    EquipmentSlot.Wrist,
                    EquipmentSlot.Hands,
                    EquipmentSlot.Tabard,
                    EquipmentSlot.Cloak
                };

                // Display items in visible slots
                foreach (var slot in itemSlots)
                {
                    uint itemDisplayId;
                    Item item = player.GetItemByPos(InventorySlots.Bag0, slot);
                    if (item != null)
                    {
                        itemDisplayId = item.GetDisplayId(player);
                    }
                    else
                    {
                        itemDisplayId = 0;
                    }

                    mirrorImageComponentedData.ItemDisplayID.Add((int)itemDisplayId);
                }

                SendPacket(mirrorImageComponentedData);
            }
            else
            {
                MirrorImageCreatureData data = new MirrorImageCreatureData();
                data.UnitGUID  = guid;
                data.DisplayID = (int)creator.GetDisplayId();
                SendPacket(data);
            }
        }