Ejemplo n.º 1
0
 public void SetCustomizations(List <ChrCustomizationChoice> customizations)
 {
     ClearDynamicUpdateFieldValues(m_values.ModifyValue(m_corpseData).ModifyValue(m_corpseData.Customizations));
     foreach (var customization in customizations)
     {
         var newChoice = new ChrCustomizationChoice();
         newChoice.ChrCustomizationOptionID = customization.ChrCustomizationOptionID;
         newChoice.ChrCustomizationChoiceID = customization.ChrCustomizationChoiceID;
         AddDynamicUpdateFieldValue(m_values.ModifyValue(m_corpseData).ModifyValue(m_corpseData.Customizations), newChoice);
     }
 }
Ejemplo n.º 2
0
        public override void Read()
        {
            var customizationCount = _worldPacket.ReadUInt32();

            NewSex = _worldPacket.ReadUInt8();

            for (var i = 0; i < customizationCount; ++i)
            {
                Customizations[i] = new ChrCustomizationChoice()
                {
                    ChrCustomizationOptionID = _worldPacket.ReadUInt32(),
                    ChrCustomizationChoiceID = _worldPacket.ReadUInt32()
                };
            }

            Customizations.Sort();
        }
Ejemplo n.º 3
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.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)
                {
                    var chrCustomizationChoice = new ChrCustomizationChoice();
                    chrCustomizationChoice.ChrCustomizationOptionID = customization.ChrCustomizationOptionID;
                    chrCustomizationChoice.ChrCustomizationChoiceID = customization.ChrCustomizationChoiceID;
                    mirrorImageComponentedData.Customizations.Add(chrCustomizationChoice);
                }

                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();
                data.UnitGUID  = guid;
                data.DisplayID = (int)creator.GetDisplayId();
                SendPacket(data);
            }
        }
Ejemplo n.º 4
0
        static bool HandleModifyGenderCommand(StringArguments args, CommandHandler handler)
        {
            if (args.Empty())
            {
                return(false);
            }

            Player target = handler.GetSelectedPlayerOrSelf();

            if (!target)
            {
                handler.SendSysMessage(CypherStrings.PlayerNotFound);
                return(false);
            }

            PlayerInfo info = Global.ObjectMgr.GetPlayerInfo(target.GetRace(), target.GetClass());

            if (info == null)
            {
                return(false);
            }

            string gender_str = args.NextString();
            Gender gender;

            if (gender_str == "male")            // MALE
            {
                if (target.GetGender() == Gender.Male)
                {
                    return(true);
                }

                gender = Gender.Male;
            }
            else if (gender_str == "female")    // FEMALE
            {
                if (target.GetGender() == Gender.Female)
                {
                    return(true);
                }

                gender = Gender.Female;
            }
            else
            {
                handler.SendSysMessage(CypherStrings.MustMaleOrFemale);
                return(false);
            }

            // Set gender
            target.SetGender(gender);
            target.SetNativeSex(gender);

            // Change display ID
            target.InitDisplayIds();

            target.RestoreDisplayId(false);
            Global.CharacterCacheStorage.UpdateCharacterGender(target.GetGUID(), (byte)gender);

            // Generate random customizations
            List <ChrCustomizationChoice> customizations = new List <ChrCustomizationChoice>();

            var          options      = Global.DB2Mgr.GetCustomiztionOptions(target.GetRace(), gender);
            WorldSession worldSession = target.GetSession();

            foreach (ChrCustomizationOptionRecord option in options)
            {
                ChrCustomizationReqRecord optionReq = CliDB.ChrCustomizationReqStorage.LookupByKey(option.ChrCustomizationReqID);
                if (optionReq != null && !worldSession.MeetsChrCustomizationReq(optionReq, target.GetClass(), false, customizations))
                {
                    continue;
                }

                // Loop over the options until the first one fits
                var choicesForOption = Global.DB2Mgr.GetCustomiztionChoices(option.Id);
                foreach (ChrCustomizationChoiceRecord choiceForOption in choicesForOption)
                {
                    var choiceReq = CliDB.ChrCustomizationReqStorage.LookupByKey(choiceForOption.ChrCustomizationReqID);
                    if (choiceReq != null && !worldSession.MeetsChrCustomizationReq(choiceReq, target.GetClass(), false, customizations))
                    {
                        continue;
                    }

                    ChrCustomizationChoiceRecord choiceEntry = choicesForOption[0];
                    ChrCustomizationChoice       choice      = new ChrCustomizationChoice();
                    choice.ChrCustomizationOptionID = option.Id;
                    choice.ChrCustomizationChoiceID = choiceEntry.Id;
                    customizations.Add(choice);
                    break;
                }
            }

            target.SetCustomizations(customizations);

            handler.SendSysMessage(CypherStrings.YouChangeGender, handler.GetNameLink(target), gender);

            if (handler.NeedReportToTarget(target))
            {
                target.SendSysMessage(CypherStrings.YourGenderChanged, gender, handler.GetNameLink());
            }

            return(true);
        }