Exemplo n.º 1
0
        public static void ReadSpellTargetData(Packet packet, PacketSpellData?packetSpellData, uint spellID, params object[] idx)
        {
            packet.ResetBitReader();

            packet.ReadBitsE <TargetFlag>("Flags", ClientVersion.AddedInVersion(ClientVersionBuild.V8_1_5_29683) ? 26 : 25, idx);
            var hasSrcLoc  = packet.ReadBit("HasSrcLocation", idx);
            var hasDstLoc  = packet.ReadBit("HasDstLocation", idx);
            var hasOrient  = packet.ReadBit("HasOrientation", idx);
            var hasMapID   = packet.ReadBit("hasMapID ", idx);
            var nameLength = packet.ReadBits(7);

            var targetUnit = packet.ReadPackedGuid128("Unit", idx);

            if (packetSpellData != null)
            {
                packetSpellData.TargetUnit = targetUnit;
            }
            packet.ReadPackedGuid128("Item", idx);

            if (hasSrcLoc)
            {
                V6_0_2_19033.Parsers.SpellHandler.ReadLocation(packet, "SrcLocation");
            }

            Vector3?dstLocation = null;

            if (hasDstLoc)
            {
                dstLocation = V6_0_2_19033.Parsers.SpellHandler.ReadLocation(packet, "DstLocation");
                if (packetSpellData != null)
                {
                    packetSpellData.DstLocation = dstLocation;
                }
            }

            if (hasOrient)
            {
                packet.ReadSingle("Orientation", idx);
            }

            int mapID = -1;

            if (hasMapID)
            {
                mapID = packet.ReadInt32("MapID", idx);
            }

            if (Settings.UseDBC && dstLocation != null && mapID != -1)
            {
                for (uint i = 0; i < 32; i++)
                {
                    var tuple = Tuple.Create(spellID, i);
                    if (DBC.SpellEffectStores.ContainsKey(tuple))
                    {
                        var effect = DBC.SpellEffectStores[tuple];
                        if ((Targets)effect.ImplicitTarget[0] == Targets.TARGET_DEST_DB || (Targets)effect.ImplicitTarget[1] == Targets.TARGET_DEST_DB)
                        {
                            string effectHelper = $"Spell: { StoreGetters.GetName(StoreNameType.Spell, (int)spellID) } Efffect: { effect.Effect } ({ (SpellEffects)effect.Effect })";

                            var spellTargetPosition = new SpellTargetPosition
                            {
                                ID           = spellID,
                                EffectIndex  = (byte)i,
                                PositionX    = dstLocation.Value.X,
                                PositionY    = dstLocation.Value.Y,
                                PositionZ    = dstLocation.Value.Z,
                                MapID        = (ushort)mapID,
                                EffectHelper = effectHelper
                            };

                            if (!Storage.SpellTargetPositions.ContainsKey(spellTargetPosition))
                            {
                                Storage.SpellTargetPositions.Add(spellTargetPosition);
                            }
                        }
                    }
                }
            }

            packet.ReadWoWString("Name", nameLength, idx);
        }
Exemplo n.º 2
0
        public static void HandleAuraUpdate(Packet packet)
        {
            PacketAuraUpdate packetAuraUpdate = packet.Holder.AuraUpdate = new();

            packet.ReadBit("UpdateAll");
            var guid = packet.ReadPackedGuid128("UnitGUID");

            packetAuraUpdate.Unit = guid;
            var count = packet.ReadUInt32("AurasCount");

            var auras = new List <Aura>();

            for (var i = 0; i < count; ++i)
            {
                var auraEntry = new PacketAuraUpdateEntry();
                packetAuraUpdate.Updates.Add(auraEntry);
                var aura = new Aura();

                auraEntry.Slot = packet.ReadByte("Slot", i);

                packet.ResetBitReader();
                var hasAura = packet.ReadBit("HasAura", i);
                auraEntry.Remove = !hasAura;
                if (hasAura)
                {
                    aura.SpellId = auraEntry.Spell = (uint)packet.ReadInt32 <SpellId>("SpellID", i);
                    if (ClientVersion.AddedInVersion(ClientVersionBuild.V6_2_0_20173))
                    {
                        packet.ReadUInt32("SpellXSpellVisualID", i);
                    }
                    var flags = packet.ReadByteE <AuraFlagMoP>("Flags", i);
                    aura.AuraFlags  = flags;
                    auraEntry.Flags = flags.ToUniversal();
                    packet.ReadInt32("ActiveFlags", i);
                    aura.Level   = packet.ReadUInt16("CastLevel", i);
                    aura.Charges = packet.ReadByte("Applications", i);

                    var int72       = packet.ReadUInt32("Int56 Count", i);
                    var effectCount = packet.ReadUInt32("Effect Count", i);

                    for (var j = 0; j < int72; ++j)
                    {
                        packet.ReadSingle("Points", i, j);
                    }

                    for (var j = 0; j < effectCount; ++j)
                    {
                        packet.ReadSingle("EstimatedPoints", i, j);
                    }

                    packet.ResetBitReader();
                    var hasCasterGUID  = packet.ReadBit("HasCastUnit", i);
                    var hasDuration    = packet.ReadBit("HasDuration", i);
                    var hasMaxDuration = packet.ReadBit("HasRemaining", i);

                    if (hasCasterGUID)
                    {
                        auraEntry.CasterUnit = packet.ReadPackedGuid128("CastUnit", i);
                    }

                    aura.Duration    = hasDuration ? packet.ReadInt32("Duration", i) : 0;
                    aura.MaxDuration = hasMaxDuration ? packet.ReadInt32("Remaining", i) : 0;

                    if (hasDuration)
                    {
                        auraEntry.Duration = aura.Duration;
                    }

                    if (hasMaxDuration)
                    {
                        auraEntry.Remaining = aura.MaxDuration;
                    }

                    auras.Add(aura);
                    packet.AddSniffData(StoreNameType.Spell, (int)aura.SpellId, "AURA_UPDATE");
                }
            }

            if (Storage.Objects.ContainsKey(guid))
            {
                var unit = Storage.Objects[guid].Item1 as Unit;
                if (unit != null)
                {
                    // If this is the first packet that sends auras
                    // (hopefully at spawn time) add it to the "Auras" field,
                    // if not create another row of auras in AddedAuras
                    // (similar to ChangedUpdateFields)

                    if (unit.Auras == null)
                    {
                        unit.Auras = auras;
                    }
                    else
                    {
                        unit.AddedAuras.Add(auras);
                    }
                }
            }
        }
Exemplo n.º 3
0
        public static void HandleQuestQueryResponse(Packet packet)
        {
            packet.ReadInt32("Entry");

            Bit hasData = packet.ReadBit("Has Data");

            if (!hasData)
            {
                return; // nothing to do
            }
            var id = packet.ReadEntry("Quest ID");

            QuestTemplate quest = new QuestTemplate
            {
                ID = (uint)id.Key
            };

            quest.QuestType  = packet.ReadInt32E <QuestType>("QuestType");
            quest.QuestLevel = packet.ReadInt32("QuestLevel");
            quest.QuestScalingFactionGroup = packet.ReadInt32("QuestScalingFactionGroup");
            quest.QuestMaxScalingLevel     = packet.ReadInt32("QuestMaxScalingLevel");
            quest.QuestPackageID           = (uint)packet.ReadInt32("QuestPackageID");
            quest.MinLevel           = packet.ReadInt32("QuestMinLevel");
            quest.QuestSortID        = (QuestSort)packet.ReadInt32("QuestSortID");
            quest.QuestInfoID        = packet.ReadInt32E <QuestInfo>("QuestInfoID");
            quest.SuggestedGroupNum  = (uint)packet.ReadInt32("SuggestedGroupNum");
            quest.RewardNextQuest    = (uint)packet.ReadInt32("RewardNextQuest");
            quest.RewardXPDifficulty = (uint)packet.ReadInt32("RewardXPDifficulty");

            quest.RewardXPMultiplier = packet.ReadSingle("RewardXPMultiplier");

            quest.RewardMoney           = packet.ReadInt32("RewardMoney");
            quest.RewardMoneyDifficulty = (uint)packet.ReadInt32("RewardMoneyDifficulty");

            quest.RewardMoneyMultiplier = packet.ReadSingle("RewardMoneyMultiplier");

            quest.RewardBonusMoney = (uint)packet.ReadInt32("RewardBonusMoney");

            quest.RewardDisplaySpellLegion = new uint?[3];
            for (int i = 0; i < 3; ++i)
            {
                quest.RewardDisplaySpellLegion[i] = (uint)packet.ReadInt32("RewardDisplaySpell", i);
            }

            quest.RewardSpellWod = (uint)packet.ReadInt32("RewardSpell");
            quest.RewardHonorWod = (uint)packet.ReadInt32("RewardHonor");

            quest.RewardKillHonor = packet.ReadSingle("RewardKillHonor");

            quest.RewardArtifactXPDifficulty = (uint)packet.ReadInt32("RewardArtifactXPDifficulty");
            quest.RewardArtifactXPMultiplier = packet.ReadSingle("RewardArtifactXPMultiplier");
            quest.RewardArtifactCategoryID   = (uint)packet.ReadInt32("RewardArtifactCategoryID");

            quest.StartItem = (uint)packet.ReadInt32("StartItem");
            quest.Flags     = packet.ReadInt32E <QuestFlags>("Flags");
            quest.FlagsEx   = packet.ReadInt32E <QuestFlagsEx>("FlagsEx");
            quest.FlagsEx2  = packet.ReadInt32E <QuestFlagsEx2>("FlagsEx2");

            quest.RewardItem       = new uint?[4];
            quest.RewardAmount     = new uint?[4];
            quest.ItemDrop         = new uint?[4];
            quest.ItemDropQuantity = new uint?[4];
            for (int i = 0; i < 4; ++i)
            {
                quest.RewardItem[i]       = (uint)packet.ReadInt32("RewardItems", i);
                quest.RewardAmount[i]     = (uint)packet.ReadInt32("RewardAmount", i);
                quest.ItemDrop[i]         = (uint)packet.ReadInt32("ItemDrop", i);
                quest.ItemDropQuantity[i] = (uint)packet.ReadInt32("ItemDropQuantity", i);
            }

            quest.RewardChoiceItemID        = new uint?[6];
            quest.RewardChoiceItemQuantity  = new uint?[6];
            quest.RewardChoiceItemDisplayID = new uint?[6];
            for (int i = 0; i < 6; ++i) // CliQuestInfoChoiceItem
            {
                quest.RewardChoiceItemID[i]        = (uint)packet.ReadInt32("RewardChoiceItemID", i);
                quest.RewardChoiceItemQuantity[i]  = (uint)packet.ReadInt32("RewardChoiceItemQuantity", i);
                quest.RewardChoiceItemDisplayID[i] = (uint)packet.ReadInt32("RewardChoiceItemDisplayID", i);
            }

            quest.POIContinent = (uint)packet.ReadInt32("POIContinent");

            quest.POIx = packet.ReadSingle("POIx");
            quest.POIy = packet.ReadSingle("POIy");

            quest.POIPriorityWod      = packet.ReadInt32("POIPriority");
            quest.RewardTitle         = (uint)packet.ReadInt32("RewardTitle");
            quest.RewardArenaPoints   = (uint)packet.ReadInt32("RewardArenaPoints");
            quest.RewardSkillLineID   = (uint)packet.ReadInt32("RewardSkillLineID");
            quest.RewardNumSkillUps   = (uint)packet.ReadInt32("RewardNumSkillUps");
            quest.QuestGiverPortrait  = (uint)packet.ReadInt32("PortraitGiver");
            quest.PortraitGiverMount  = (uint)packet.ReadInt32("PortraitGiverMount");
            quest.QuestTurnInPortrait = (uint)packet.ReadInt32("PortraitTurnIn");

            quest.RewardFactionID       = new uint?[5];
            quest.RewardFactionOverride = new int?[5];
            quest.RewardFactionValue    = new int?[5];
            quest.RewardFactionCapIn    = new int?[5];
            for (int i = 0; i < 5; ++i)
            {
                quest.RewardFactionID[i]       = (uint)packet.ReadInt32("RewardFactionID", i);
                quest.RewardFactionValue[i]    = packet.ReadInt32("RewardFactionValue", i);
                quest.RewardFactionOverride[i] = packet.ReadInt32("RewardFactionOverride", i);
                quest.RewardFactionCapIn[i]    = packet.ReadInt32("RewardFactionCapIn", i);
            }

            quest.RewardFactionFlags = (uint)packet.ReadInt32("RewardFactionFlags");

            quest.RewardCurrencyID    = new uint?[4];
            quest.RewardCurrencyCount = new uint?[4];
            for (int i = 0; i < 4; ++i)
            {
                quest.RewardCurrencyID[i]    = (uint)packet.ReadInt32("RewardCurrencyID");
                quest.RewardCurrencyCount[i] = (uint)packet.ReadInt32("RewardCurrencyQty");
            }

            quest.SoundAccept = (uint)packet.ReadInt32("AcceptedSoundKitID");
            quest.SoundTurnIn = (uint)packet.ReadInt32("CompleteSoundKitID");
            quest.AreaGroupID = (uint)packet.ReadInt32("AreaGroupID");
            quest.TimeAllowed = (uint)packet.ReadInt32("TimeAllowed");
            uint objectiveCount = packet.ReadUInt32("ObjectiveCount");

            quest.AllowableRacesWod = packet.ReadUInt64("AllowableRaces");
            quest.QuestRewardID     = packet.ReadInt32("TreasurePickerID");
            quest.Expansion         = packet.ReadInt32("Expansion");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V8_1_5_29683))
            {
                quest.ManagedWorldStateID = packet.ReadInt32("ManagedWorldStateID");
            }

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V8_2_5_31921))
            {
                quest.QuestSessionBonus = packet.ReadInt32("QuestSessionBonus");
            }

            packet.ResetBitReader();

            uint logTitleLen             = 0;
            uint logDescriptionLen       = 0;
            uint questDescriptionLen     = 0;
            uint areaDescriptionLen      = 0;
            uint questGiverTextWindowLen = 0;
            uint questGiverTargetNameLen = 0;
            uint questTurnTextWindowLen  = 0;
            uint questTurnTargetNameLen  = 0;
            uint questCompletionLogLen   = 0;

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V8_1_0_28724) && ClientVersion.RemovedInVersion(ClientVersionBuild.V8_1_5_29683))
            {
                logTitleLen             = packet.ReadBits(10);
                logDescriptionLen       = packet.ReadBits(12);
                questDescriptionLen     = packet.ReadBits(12);
                areaDescriptionLen      = packet.ReadBits(9);
                questGiverTextWindowLen = packet.ReadBits(11);
                questGiverTargetNameLen = packet.ReadBits(9);
                questTurnTextWindowLen  = packet.ReadBits(11);
                questTurnTargetNameLen  = packet.ReadBits(9);
                questCompletionLogLen   = packet.ReadBits(12);
            }
            else
            {
                logTitleLen             = packet.ReadBits(9);
                logDescriptionLen       = packet.ReadBits(12);
                questDescriptionLen     = packet.ReadBits(12);
                areaDescriptionLen      = packet.ReadBits(9);
                questGiverTextWindowLen = packet.ReadBits(10);
                questGiverTargetNameLen = packet.ReadBits(8);
                questTurnTextWindowLen  = packet.ReadBits(10);
                questTurnTargetNameLen  = packet.ReadBits(8);
                questCompletionLogLen   = packet.ReadBits(11);
            }

            for (uint i = 0; i < objectiveCount; ++i)
            {
                var objectiveId = packet.ReadEntry("Id", i);

                QuestObjective questInfoObjective = new QuestObjective
                {
                    ID      = (uint)objectiveId.Key,
                    QuestID = (uint)id.Key
                };
                questInfoObjective.Type              = packet.ReadByteE <QuestRequirementType>("Quest Requirement Type", i);
                questInfoObjective.StorageIndex      = packet.ReadSByte("StorageIndex", i);
                questInfoObjective.Order             = i;
                questInfoObjective.ObjectID          = packet.ReadInt32("ObjectID", i);
                questInfoObjective.Amount            = packet.ReadInt32("Amount", i);
                questInfoObjective.Flags             = (uint)packet.ReadInt32("Flags", i);
                questInfoObjective.Flags2            = packet.ReadUInt32("Flags2", i);
                questInfoObjective.ProgressBarWeight = packet.ReadSingle("ProgressBarWeight", i);

                var visualEffectsCount = packet.ReadUInt32("VisualEffects", i);
                for (var j = 0; j < visualEffectsCount; ++j)
                {
                    QuestVisualEffect questVisualEffect = new QuestVisualEffect
                    {
                        ID           = questInfoObjective.ID,
                        Index        = (uint)j,
                        VisualEffect = packet.ReadInt32("VisualEffectId", i, j)
                    };

                    Storage.QuestVisualEffects.Add(questVisualEffect, packet.TimeSpan);
                }

                packet.ResetBitReader();

                uint descriptionLength = packet.ReadBits(8);
                questInfoObjective.Description = packet.ReadWoWString("Description", descriptionLength, i);

                if (ClientLocale.PacketLocale != LocaleConstant.enUS && questInfoObjective.Description != string.Empty)
                {
                    QuestObjectivesLocale localesQuestObjectives = new QuestObjectivesLocale
                    {
                        ID           = (uint)objectiveId.Key,
                        QuestId      = (uint)id.Key,
                        StorageIndex = questInfoObjective.StorageIndex,
                        Description  = questInfoObjective.Description
                    };

                    Storage.LocalesQuestObjectives.Add(localesQuestObjectives, packet.TimeSpan);
                }

                Storage.QuestObjectives.Add(questInfoObjective, packet.TimeSpan);
            }

            quest.LogTitle             = packet.ReadWoWString("LogTitle", logTitleLen);
            quest.LogDescription       = packet.ReadWoWString("LogDescription", logDescriptionLen);
            quest.QuestDescription     = packet.ReadWoWString("QuestDescription", questDescriptionLen);
            quest.AreaDescription      = packet.ReadWoWString("AreaDescription", areaDescriptionLen);
            quest.QuestGiverTextWindow = packet.ReadWoWString("PortraitGiverText", questGiverTextWindowLen);
            quest.QuestGiverTargetName = packet.ReadWoWString("PortraitGiverName", questGiverTargetNameLen);
            quest.QuestTurnTextWindow  = packet.ReadWoWString("PortraitTurnInText", questTurnTextWindowLen);
            quest.QuestTurnTargetName  = packet.ReadWoWString("PortraitTurnInName", questTurnTargetNameLen);
            quest.QuestCompletionLog   = packet.ReadWoWString("QuestCompletionLog", questCompletionLogLen);

            if (ClientLocale.PacketLocale != LocaleConstant.enUS)
            {
                LocalesQuest localesQuest = new LocalesQuest
                {
                    ID                 = (uint)id.Key,
                    LogTitle           = quest.LogTitle,
                    LogDescription     = quest.LogDescription,
                    QuestDescription   = quest.QuestDescription,
                    AreaDescription    = quest.AreaDescription,
                    PortraitGiverText  = quest.QuestGiverTextWindow,
                    PortraitGiverName  = quest.QuestGiverTargetName,
                    PortraitTurnInText = quest.QuestTurnTextWindow,
                    PortraitTurnInName = quest.QuestTurnTargetName,
                    QuestCompletionLog = quest.QuestCompletionLog
                };

                Storage.LocalesQuests.Add(localesQuest, packet.TimeSpan);
            }

            Storage.QuestTemplates.Add(quest, packet.TimeSpan);
        }
Exemplo n.º 4
0
        public static void ReadCharactersData(Packet packet, params object[] idx)
        {
            packet.ReadPackedGuid128("Guid", idx);

            packet.ReadByte("ListPosition", idx);
            var race  = packet.ReadByteE <Race>("RaceID", idx);
            var klass = packet.ReadByteE <Class>("ClassID", idx);

            packet.ReadByte("SexID", idx);
            packet.ReadByte("SkinID", idx);
            packet.ReadByte("FaceID", idx);
            packet.ReadByte("HairStyle", idx);
            packet.ReadByte("HairColor", idx);
            packet.ReadByte("FacialHairStyle", idx);
            packet.ReadByte("ExperienceLevel", idx);
            var zone  = packet.ReadUInt32 <ZoneId>("ZoneID", idx);
            var mapId = packet.ReadUInt32 <MapId>("MapID", idx);

            var pos = packet.ReadVector3("PreloadPos", idx);

            packet.ReadPackedGuid128("GuildGUID", idx);

            packet.ReadUInt32("Flags", idx);
            packet.ReadUInt32("Flags2", idx);
            packet.ReadUInt32("Flags3", idx);
            packet.ReadUInt32("PetCreatureDisplayID", idx);
            packet.ReadUInt32("PetExperienceLevel", idx);
            packet.ReadUInt32("PetCreatureFamilyID", idx);

            for (uint j = 0; j < 2; ++j)
            {
                packet.ReadUInt32("ProfessionIDs", idx, j);
            }

            for (uint j = 0; j < 23; ++j)
            {
                packet.ReadUInt32("InventoryItem DisplayID", idx, j);
                packet.ReadUInt32("InventoryItem DisplayEnchantID", idx, j);
                packet.ReadByteE <InventoryType>("InventoryItem InvType", idx, j);
            }

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V6_2_4_21315))
            {
                packet.ReadTime("LastPlayedTime", idx);
            }

            packet.ResetBitReader();
            var nameLength = packet.ReadBits("Character Name Length", 6, idx);
            var firstLogin = packet.ReadBit("FirstLogin", idx);

            packet.ReadBit("BoostInProgress", idx);

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V6_1_0_19678))
            {
                packet.ReadBits("Unk Bits141", 5, idx);
            }

            packet.ReadWoWString("Character Name", nameLength, idx);

            if (firstLogin)
            {
                PlayerCreateInfo startPos = new PlayerCreateInfo {
                    Race = race, Class = klass, Map = mapId, Zone = zone, Position = pos, Orientation = 0
                };
                Storage.StartPositions.Add(startPos, packet.TimeSpan);
            }
        }
Exemplo n.º 5
0
        public static void HandleGetGarrisonInfoResult(Packet packet)
        {
            packet.ReadInt32("FactionIndex");
            var garrisonCount = packet.ReadUInt32("GarrisonCount");

            var followerSoftcapCount = packet.ReadUInt32("FollowerSoftCapCount");

            for (var i = 0u; i < followerSoftcapCount; ++i)
            {
                V7_0_3_22248.Parsers.GarrisonHandler.ReadFollowerSoftCapInfo(packet, i);
            }

            for (int i = 0; i < garrisonCount; i++)
            {
                packet.ReadInt32E <GarrisonType>("GarrTypeID", i);
                packet.ReadInt32E <GarrisonSite>("GarrSiteID", i);
                packet.ReadInt32E <GarrisonSiteLevel>("GarrSiteLevelID", i);

                var garrisonBuildingInfoCount          = packet.ReadUInt32("GarrisonBuildingInfoCount", i);
                var garrisonPlotInfoCount              = packet.ReadUInt32("GarrisonPlotInfoCount", i);
                var garrisonFollowerCount              = packet.ReadUInt32("GarrisonFollowerCount", i);
                var autoTroopCount                     = packet.ReadUInt32("GarrisonAutoTroopCount", i);
                var garrisonMissionCount               = packet.ReadUInt32("GarrisonMissionCount", i);
                var garrisonMissionRewardsCount        = packet.ReadUInt32("GarrisonMissionRewardsCount", i);
                var garrisonMissionOvermaxRewardsCount = packet.ReadUInt32("GarrisonMissionOvermaxRewardsCount", i);
                var areaBonusCount                     = packet.ReadUInt32("GarrisonMissionAreaBonusCount", i);
                var talentsCount          = packet.ReadUInt32("Talents", i);
                var collectionsCount      = packet.ReadUInt32("GarrisonCollectionCount", i);
                var eventListCount        = packet.ReadUInt32("GarrisonEventListCount", i);
                var canStartMissionCount  = packet.ReadUInt32("CanStartMission", i);
                var archivedMissionsCount = packet.ReadUInt32("ArchivedMissionsCount", i);

                packet.ReadInt32("NumFollowerActivationsRemaining", i);
                packet.ReadUInt32("NumMissionsStartedToday", i);
                packet.ReadInt32("MinAutoTroopLevel", i);

                for (int j = 0; j < garrisonPlotInfoCount; j++)
                {
                    V6_0_2_19033.Parsers.GarrisonHandler.ReadGarrisonPlotInfo(packet, i, "PlotInfo", j);
                }

                for (int j = 0; j < garrisonMissionCount; j++)
                {
                    ReadGarrisonMission(packet, i, "Mission", j);
                }

                int[] garrisonMissionRewardItemCounts = new int[garrisonMissionRewardsCount];
                for (int j = 0; j < garrisonMissionRewardItemCounts.Length; ++j)
                {
                    garrisonMissionRewardItemCounts[j] = packet.ReadInt32();
                }

                if (ClientVersion.RemovedInVersion(ClientVersionBuild.V9_0_2_36639))
                {
                    for (int j = 0; j < garrisonMissionRewardItemCounts.Length; ++j)
                    {
                        for (int k = 0; k < garrisonMissionRewardItemCounts[j]; ++k)
                        {
                            V7_0_3_22248.Parsers.GarrisonHandler.ReadGarrisonMissionReward(packet, i, "MissionRewards", j, k);
                        }
                    }
                }

                int[] garrisonMissionOvermaxRewardItemCounts = new int[garrisonMissionOvermaxRewardsCount];
                for (int j = 0; j < garrisonMissionOvermaxRewardItemCounts.Length; ++j)
                {
                    garrisonMissionOvermaxRewardItemCounts[j] = packet.ReadInt32();
                }

                if (ClientVersion.RemovedInVersion(ClientVersionBuild.V9_0_2_36639))
                {
                    for (int j = 0; j < garrisonMissionOvermaxRewardItemCounts.Length; ++j)
                    {
                        for (int k = 0; k < garrisonMissionOvermaxRewardItemCounts[j]; ++k)
                        {
                            V7_0_3_22248.Parsers.GarrisonHandler.ReadGarrisonMissionReward(packet, i, "MissionOvermaxRewards", j, k);
                        }
                    }
                }

                for (int j = 0; j < areaBonusCount; j++)
                {
                    ReadGarrisonMissionBonusAbility(packet, i, "MissionAreaBonus", j);
                }

                for (int j = 0; j < collectionsCount; j++)
                {
                    ReadGarrisonCollection(packet, i, "Collection", j);
                }

                for (int j = 0; j < eventListCount; j++)
                {
                    ReadGarrisonEventList(packet, i, "EventList", j);
                }

                for (int j = 0; j < archivedMissionsCount; j++)
                {
                    packet.ReadInt32("ArchivedMissions", i, j);
                }

                for (int j = 0; j < garrisonBuildingInfoCount; j++)
                {
                    ReadGarrisonBuildingInfo(packet, i, "BuildingInfo", j);
                }

                packet.ResetBitReader();

                for (int j = 0; j < canStartMissionCount; j++)
                {
                    packet.ReadBit("CanStartMission", i, j);
                }

                for (int j = 0; j < garrisonFollowerCount; j++)
                {
                    ReadGarrisonFollower(packet, i, "Follower", j);
                }

                for (int j = 0; j < autoTroopCount; j++)
                {
                    ReadGarrisonFollower(packet, i, "AutoTroop", j);
                }

                for (int j = 0; j < talentsCount; j++)
                {
                    ReadGarrisonTalents(packet, i, "Talents", j);
                }

                if (ClientVersion.AddedInVersion(ClientVersionBuild.V9_0_2_36639))
                {
                    for (int j = 0; j < garrisonMissionRewardItemCounts.Length; ++j)
                    {
                        for (int k = 0; k < garrisonMissionRewardItemCounts[j]; ++k)
                        {
                            V7_0_3_22248.Parsers.GarrisonHandler.ReadGarrisonMissionReward(packet, i, "MissionRewards", j, k);
                        }
                    }

                    for (int j = 0; j < garrisonMissionOvermaxRewardItemCounts.Length; ++j)
                    {
                        for (int k = 0; k < garrisonMissionOvermaxRewardItemCounts[j]; ++k)
                        {
                            V7_0_3_22248.Parsers.GarrisonHandler.ReadGarrisonMissionReward(packet, i, "MissionOvermaxRewards", j, k);
                        }
                    }
                }
            }
        }
Exemplo n.º 6
0
        public static void HandleNpcGossip(Packet packet)
        {
            GossipMenu gossip = new GossipMenu();

            WowGuid guid = packet.ReadGuid("GUID");

            gossip.ObjectType  = guid.GetObjectType();
            gossip.ObjectEntry = guid.GetEntry();

            uint menuId = packet.ReadUInt32("Menu Id");

            gossip.Entry = menuId;

            if (ClientVersion.AddedInVersion(ClientType.MistsOfPandaria))
            {
                packet.ReadUInt32("Friendship Faction");
            }

            gossip.TextID = packet.ReadUInt32("Text Id");

            uint count = packet.ReadUInt32("Amount of Options");

            for (int i = 0; i < count; i++)
            {
                GossipMenuOption gossipOption = new GossipMenuOption
                {
                    MenuId = menuId,
                };
                GossipMenuOptionBox gossipMenuOptionBox = new GossipMenuOptionBox
                {
                    MenuId = menuId
                };

                gossipOption.OptionIndex     = gossipMenuOptionBox.OptionIndex = packet.ReadUInt32("Index", i);
                gossipOption.OptionIcon      = packet.ReadByteE <GossipOptionIcon>("Icon", i);
                gossipMenuOptionBox.BoxCoded = packet.ReadBool("Box", i);
                gossipMenuOptionBox.BoxMoney = packet.ReadUInt32("Required money", i);
                gossipOption.OptionText      = packet.ReadCString("Text", i);
                gossipMenuOptionBox.BoxText  = packet.ReadCString("Box Text", i);

                Storage.GossipMenuOptions.Add(gossipOption, packet.TimeSpan);
                if (!gossipMenuOptionBox.IsEmpty)
                {
                    Storage.GossipMenuOptionBoxes.Add(gossipMenuOptionBox, packet.TimeSpan);
                }

                if (ClientLocale.PacketLocale != LocaleConstant.enUS && gossipOption.OptionText != string.Empty)
                {
                    GossipMenuOptionLocale localesGossipMenuOption = new GossipMenuOptionLocale
                    {
                        MenuId      = (uint)gossipOption.MenuId,
                        OptionIndex = gossipOption.OptionIndex,
                        OptionText  = gossipOption.OptionText,
                        BoxText     = gossipMenuOptionBox.BoxText
                    };
                    Storage.LocalesGossipMenuOption.Add(localesGossipMenuOption, packet.TimeSpan);
                }
            }

            uint questgossips = packet.ReadUInt32("Amount of Quest gossips");

            for (int i = 0; i < questgossips; i++)
            {
                packet.ReadUInt32 <QuestId>("Quest ID", i);

                packet.ReadUInt32("Icon", i);
                packet.ReadInt32("Level", i);
                packet.ReadUInt32E <QuestFlags>("Flags", i);
                if (ClientVersion.AddedInVersion(ClientVersionBuild.V5_1_0_16309))
                {
                    packet.ReadUInt32E <QuestFlagsEx>("Flags 2", i);
                }

                packet.ReadBool("Change Icon", i);
                packet.ReadCString("Title", i);
            }

            if (guid.GetObjectType() == ObjectType.Unit)
            {
                if (Storage.Objects.ContainsKey(guid))
                {
                    ((Unit)Storage.Objects[guid].Item1).GossipId = menuId;
                }
            }

            Storage.Gossips.Add(gossip, packet.TimeSpan);
            if (LastGossipOption.HasSelection)
            {
                Storage.GossipMenuOptionActions.Add(new GossipMenuOptionAction {
                    MenuId = LastGossipOption.MenuId, OptionIndex = LastGossipOption.OptionIndex, ActionMenuId = menuId
                }, packet.TimeSpan);
            }

            packet.AddSniffData(StoreNameType.Gossip, (int)menuId, guid.GetEntry().ToString(CultureInfo.InvariantCulture));
        }
Exemplo n.º 7
0
        public static void ReadPlayerChoiceResponse(Packet packet, int choiceId, uint index, params object[] indexes)
        {
            var responseId              = packet.ReadInt32("ResponseID", indexes);
            var choiceArtFileId         = packet.ReadInt32("ChoiceArtFileID", indexes);
            var flags                   = packet.ReadInt32("Flags", indexes);
            var widgetSetId             = packet.ReadUInt32("WidgetSetID", indexes);
            var uiTextureAtlasElementID = 0u;
            var soundKitId              = 0u;

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V8_1_5_29683))
            {
                uiTextureAtlasElementID = packet.ReadUInt32("UiTextureAtlasElementID", indexes);
                soundKitId = packet.ReadUInt32("SoundKitID", indexes);
                if (ClientVersion.RemovedInVersion(ClientVersionBuild.V8_1_5_29683))
                {
                    packet.ReadUInt32("Unk801", indexes);
                }
            }
            var groupID = packet.ReadByte("GroupID", indexes);

            packet.ResetBitReader();
            var answerLength        = packet.ReadBits(9);
            var headerLength        = packet.ReadBits(9);
            var subHeaderLength     = 0u;
            var buttonTooltipLength = 0u;

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V8_1_0_28724))
            {
                subHeaderLength     = packet.ReadBits(7);
                buttonTooltipLength = packet.ReadBits(9);
            }
            var descriptionLength      = packet.ReadBits(11);
            var confirmationTextLength = packet.ReadBits(7);
            var hasRewardQuestID       = false;

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V8_1_5_29683))
            {
                hasRewardQuestID = packet.ReadBit();
            }
            var hasReward = packet.ReadBit();

            if (hasReward)
            {
                V6_0_2_19033.Parsers.QuestHandler.ReadPlayerChoiceResponseReward(packet, choiceId, responseId, "PlayerChoiceResponseReward", indexes);
            }

            var answer        = packet.ReadWoWString("Answer", answerLength, indexes);
            var header        = packet.ReadWoWString("Header", headerLength, indexes);
            var subheader     = packet.ReadWoWString("SubHeader", subHeaderLength, indexes);
            var buttonTooltip = packet.ReadWoWString("ButtonTooltip", buttonTooltipLength, indexes);
            var description   = packet.ReadWoWString("Description", descriptionLength, indexes);
            var confirmation  = packet.ReadWoWString("ConfirmationText", confirmationTextLength, indexes);

            var rewardQuestID = 0u;

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V8_1_5_29683))
            {
                if (hasRewardQuestID)
                {
                    rewardQuestID = packet.ReadUInt32("RewardQuestID", indexes);
                }
            }

            Storage.PlayerChoiceResponses.Add(new PlayerChoiceResponseTemplate
            {
                ChoiceId                = choiceId,
                ResponseId              = responseId,
                Index                   = index,
                ChoiceArtFileId         = choiceArtFileId,
                Flags                   = flags,
                WidgetSetId             = widgetSetId,
                UiTextureAtlasElementID = uiTextureAtlasElementID,
                SoundKitId              = soundKitId,
                GroupId                 = groupID,
                Header                  = header,
                Subheader               = subheader,
                ButtonTooltip           = buttonTooltip,
                Answer                  = answer,
                Description             = description,
                Confirmation            = confirmation,
                RewardQuestID           = rewardQuestID
            }, packet.TimeSpan);

            if (ClientLocale.PacketLocale != LocaleConstant.enUS)
            {
                Storage.PlayerChoiceResponseLocales.Add(new PlayerChoiceResponseLocaleTemplate
                {
                    ChoiceId      = choiceId,
                    ResponseId    = responseId,
                    Locale        = ClientLocale.PacketLocaleString,
                    Header        = header,
                    Subheader     = subheader,
                    ButtonTooltip = buttonTooltip,
                    Description   = description,
                    Answer        = answer,
                    Confirmation  = confirmation
                }, packet.TimeSpan);
            }
        }
Exemplo n.º 8
0
        public static void HandleGroupList(Packet packet)
        {
            var grouptype = packet.ReadByteE <GroupTypeFlag>("Group Type");

            packet.ReadByte("Sub Group");
            packet.ReadByteE <GroupUpdateFlag>("Flags");
            packet.ReadByte("Player Roles Assigned");

            if (grouptype.HasFlag(GroupTypeFlag.LookingForDungeon))
            {
                packet.ReadByteE <InstanceStatus>("Group Type Status");
                packet.ReadLfgEntry("LFG Entry");
                if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_2_2_14545))
                {
                    packet.ReadBool("Unk bool");
                }
            }

            packet.ReadGuid("Group GUID");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_3_0_10958))
            {
                packet.ReadInt32("Counter");
            }

            var numFields = packet.ReadInt32("Member Count");

            for (var i = 0; i < numFields; i++)
            {
                var name = packet.ReadCString("Name", i);
                var guid = packet.ReadGuid("GUID", i);
                StoreGetters.AddName(guid, name);
                packet.ReadByteE <GroupMemberStatusFlag>("Status", i);
                packet.ReadByte("Sub Group", i);
                packet.ReadByteE <GroupUpdateFlag>("Update Flags", i);

                if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_3_0_10958))
                {
                    packet.ReadByteE <LfgRoleFlag>("Role", i);
                }
            }

            packet.ReadGuid("Leader GUID");

            if (numFields <= 0)
            {
                return;
            }

            packet.ReadByteE <LootMethod>("Loot Method");
            packet.ReadGuid("Looter GUID");
            packet.ReadByteE <ItemQuality>("Loot Threshold");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_2_0_10192))
            {
                packet.ReadByteE <MapDifficulty>("Dungeon Difficulty");
            }

            packet.ReadByteE <MapDifficulty>("Raid Difficulty");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_3_0_10958) &&
                ClientVersion.RemovedInVersion(ClientVersionBuild.V4_0_6a_13623))
            {
                packet.ReadByte("Unk Byte"); // Has something to do with difficulty too
            }
        }
Exemplo n.º 9
0
        private static Dictionary <int, UpdateField> ReadValuesUpdateBlock(Packet packet, ObjectType type, object index, bool isCreating)
        {
            var maskSize = packet.ReadByte();

            var updateMask = new int[maskSize];

            for (var i = 0; i < maskSize; i++)
            {
                updateMask[i] = packet.ReadInt32();
            }

            var mask = new BitArray(updateMask);
            var dict = new Dictionary <int, UpdateField>();

            int objectEnd = UpdateFields.GetUpdateField(ObjectField.OBJECT_END);

            for (var i = 0; i < mask.Count; ++i)
            {
                if (!mask[i])
                {
                    continue;
                }

                var blockVal = packet.ReadUpdateField();

                // Don't spam 0 values at create
                if (isCreating && blockVal.UInt32Value == 0)
                {
                    continue;
                }

                string key   = "Block Value " + i;
                string value = blockVal.UInt32Value + "/" + blockVal.SingleValue;

                if (i < objectEnd)
                {
                    key = UpdateFields.GetUpdateFieldName <ObjectField>(i);
                }
                else
                {
                    switch (type)
                    {
                    case ObjectType.Container:
                    {
                        if (i < UpdateFields.GetUpdateField(ItemField.ITEM_END))
                        {
                            goto case ObjectType.Item;
                        }

                        key = UpdateFields.GetUpdateFieldName <ContainerField>(i);
                        break;
                    }

                    case ObjectType.Item:
                    {
                        key = UpdateFields.GetUpdateFieldName <ItemField>(i);
                        break;
                    }

                    case ObjectType.Player:
                    {
                        if (i < UpdateFields.GetUpdateField(UnitField.UNIT_END) || i < UpdateFields.GetUpdateField(UnitField.UNIT_FIELD_END))
                        {
                            goto case ObjectType.Unit;
                        }

                        key = UpdateFields.GetUpdateFieldName <PlayerField>(i);
                        break;
                    }

                    case ObjectType.Unit:
                    {
                        key = UpdateFields.GetUpdateFieldName <UnitField>(i);
                        break;
                    }

                    case ObjectType.GameObject:
                    {
                        key = UpdateFields.GetUpdateFieldName <GameObjectField>(i);
                        break;
                    }

                    case ObjectType.DynamicObject:
                    {
                        key = UpdateFields.GetUpdateFieldName <DynamicObjectField>(i);
                        break;
                    }

                    case ObjectType.Corpse:
                    {
                        key = UpdateFields.GetUpdateFieldName <CorpseField>(i);
                        break;
                    }

                    case ObjectType.AreaTrigger:
                    {
                        key = UpdateFields.GetUpdateFieldName <AreaTriggerField>(i);
                        break;
                    }

                    case ObjectType.SceneObject:
                    {
                        key = UpdateFields.GetUpdateFieldName <SceneObjectField>(i);
                        break;
                    }

                    case ObjectType.Conversation:
                    {
                        key = UpdateFields.GetUpdateFieldName <ConversationField>(i);
                        break;
                    }
                    }
                }

                // HACK...
                if (key == UnitField.UNIT_FIELD_FACTIONTEMPLATE.ToString())
                {
                    packet.AddValue(key, value + $" ({ StoreGetters.GetName(StoreNameType.Faction, (int)blockVal.UInt32Value, false) })", index);
                }
                else
                {
                    packet.AddValue(key, value, index);
                }

                dict.Add(i, blockVal);
            }

            objectEnd = UpdateFields.GetUpdateField(ObjectDynamicField.OBJECT_DYNAMIC_END);
            if (ClientVersion.AddedInVersion(ClientVersionBuild.V5_0_4_16016))
            {
                maskSize   = packet.ReadByte();
                updateMask = new int[maskSize];
                for (var i = 0; i < maskSize; i++)
                {
                    updateMask[i] = packet.ReadInt32();
                }

                mask = new BitArray(updateMask);
                for (var i = 0; i < mask.Count; ++i)
                {
                    if (!mask[i])
                    {
                        continue;
                    }

                    string key = "Dynamic Block Value " + i;
                    if (i < objectEnd)
                    {
                        key = UpdateFields.GetUpdateFieldName <ObjectDynamicField>(i);
                    }
                    else
                    {
                        switch (type)
                        {
                        case ObjectType.Container:
                        {
                            if (i < UpdateFields.GetUpdateField(ItemDynamicField.ITEM_DYNAMIC_END))
                            {
                                goto case ObjectType.Item;
                            }

                            key = UpdateFields.GetUpdateFieldName <ContainerDynamicField>(i);
                            break;
                        }

                        case ObjectType.Item:
                        {
                            key = UpdateFields.GetUpdateFieldName <ItemDynamicField>(i);
                            break;
                        }

                        case ObjectType.Player:
                        {
                            if (i < UpdateFields.GetUpdateField(UnitDynamicField.UNIT_DYNAMIC_END))
                            {
                                goto case ObjectType.Unit;
                            }

                            key = UpdateFields.GetUpdateFieldName <PlayerDynamicField>(i);
                            break;
                        }

                        case ObjectType.Unit:
                        {
                            key = UpdateFields.GetUpdateFieldName <UnitDynamicField>(i);
                            break;
                        }

                        case ObjectType.GameObject:
                        {
                            key = UpdateFields.GetUpdateFieldName <GameObjectDynamicField>(i);
                            break;
                        }

                        case ObjectType.DynamicObject:
                        {
                            key = UpdateFields.GetUpdateFieldName <DynamicObjectDynamicField>(i);
                            break;
                        }

                        case ObjectType.Corpse:
                        {
                            key = UpdateFields.GetUpdateFieldName <CorpseDynamicField>(i);
                            break;
                        }

                        case ObjectType.AreaTrigger:
                        {
                            key = UpdateFields.GetUpdateFieldName <AreaTriggerDynamicField>(i);
                            break;
                        }

                        case ObjectType.SceneObject:
                        {
                            key = UpdateFields.GetUpdateFieldName <SceneObjectDynamicField>(i);
                            break;
                        }

                        case ObjectType.Conversation:
                        {
                            key = UpdateFields.GetUpdateFieldName <ConversationDynamicField>(i);
                            break;
                        }
                        }
                    }

                    var flag = packet.ReadUInt16();
                    var cnt  = flag & 0x7FFF;
                    if ((flag & 0x8000) != 0)
                    {
                        packet.ReadUInt32(key + " Size", index);
                    }

                    var vals = new int[cnt];
                    for (var j = 0; j < cnt; ++j)
                    {
                        vals[j] = packet.ReadInt32();
                    }

                    var fieldMask = new BitArray(vals);
                    for (var j = 0; j < fieldMask.Count; ++j)
                    {
                        if (!fieldMask[j])
                        {
                            continue;
                        }

                        var    blockVal = packet.ReadUpdateField();
                        string value    = blockVal.UInt32Value + "/" + blockVal.SingleValue;
                        packet.AddValue(key, value, index, j);
                    }
                }
            }

            return(dict);
        }
Exemplo n.º 10
0
        public static void HandlePartyMemberStats422(Packet packet)
        {
            if (packet.Opcode == Opcodes.GetOpcode(Opcode.SMSG_PARTY_MEMBER_STATS_FULL, Direction.ServerToClient))
            {
                packet.ReadBool("Add arena opponent");
            }

            packet.ReadPackedGuid("GUID");
            var updateFlags = packet.ReadInt32E <GroupUpdateFlag422>("Update Flags");

            if (updateFlags.HasFlag(GroupUpdateFlag422.Status))
            {
                packet.ReadInt16E <GroupMemberStatusFlag>("Status");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag422.CurrentHealth))
            {
                if (ClientVersion.AddedInVersion(ClientType.WrathOfTheLichKing))
                {
                    packet.ReadInt32("Current Health");
                }
                else
                {
                    packet.ReadUInt16("Current Health");
                }
            }

            if (updateFlags.HasFlag(GroupUpdateFlag422.MaxHealth))
            {
                if (ClientVersion.AddedInVersion(ClientType.WrathOfTheLichKing))
                {
                    packet.ReadInt32("Max Health");
                }
                else
                {
                    packet.ReadUInt16("Max Health");
                }
            }

            if (updateFlags.HasFlag(GroupUpdateFlag422.PowerType))
            {
                packet.ReadByteE <PowerType>("Power type");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag422.CurrentPower))
            {
                packet.ReadInt16("Current Power");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag422.MaxPower))
            {
                packet.ReadInt16("Max Power");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag422.Level))
            {
                packet.ReadInt16("Level");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag422.Zone))
            {
                packet.ReadInt16 <ZoneId>("Zone Id");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag422.Unk100))
            {
                packet.ReadInt16("Unk");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag422.Position))
            {
                packet.ReadInt16("X");
                packet.ReadInt16("Y");
                packet.ReadInt16("Z");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag422.Auras))
            {
                packet.ReadByte("Unk byte");
                var mask = packet.ReadUInt64("Aura mask");
                var cnt  = packet.ReadUInt32("Aura count");
                for (var i = 0; i < cnt; ++i)
                {
                    if (mask == 0) // bad packet
                    {
                        break;
                    }

                    if ((mask & (1ul << i)) == 0)
                    {
                        continue;
                    }

                    packet.ReadUInt32 <SpellId>("Spell Id", i);

                    var aflags = packet.ReadUInt16E <AuraFlag>("Aura Flags", i);
                    if (aflags.HasFlag(AuraFlag.Scalable))
                    {
                        for (var j = 0; j < 3; ++j)
                        {
                            packet.ReadInt32("Effect BasePoints", i, j);
                        }
                    }
                }
            }

            if (updateFlags.HasFlag(GroupUpdateFlag422.PetGuid))
            {
                packet.ReadUInt64("Pet GUID");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag422.PetName))
            {
                packet.ReadCString("Pet Name");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag422.PetModelId))
            {
                packet.ReadUInt16("Pet Model Id");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag422.PetCurrentHealth))
            {
                packet.ReadUInt32("Pet Current Health");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag422.PetMaxHealth))
            {
                packet.ReadUInt32("Pet Max Health");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag422.PetPowerType))
            {
                packet.ReadByteE <PowerType>("Pet Power type");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag422.PetCurrentPower))
            {
                packet.ReadInt16("Pet Current Power");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag422.PetMaxPower))
            {
                packet.ReadInt16("Pet Max Power");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag422.PetAuras))
            {
                packet.ReadByte("Unk byte");
                var mask = packet.ReadUInt64("Pet Aura mask");
                var cnt  = packet.ReadUInt32("Pet Aura count");
                for (var i = 0; i < cnt; ++i)
                {
                    if ((mask & (1ul << i)) == 0)
                    {
                        continue;
                    }

                    packet.ReadUInt32 <SpellId>("Spell Id", i);

                    var aflags = packet.ReadUInt16E <AuraFlag>("Aura Flags", i);
                    if (aflags.HasFlag(AuraFlag.Scalable))
                    {
                        for (var j = 0; j < 3; ++j)
                        {
                            packet.ReadInt32("Effect BasePoints", i, j);
                        }
                    }
                }
            }

            if (updateFlags.HasFlag(GroupUpdateFlag422.VehicleSeat))
            {
                packet.ReadInt32("Vehicle Seat?");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag422.Phase))
            {
                packet.ReadInt32("Unk Int32");

                var count = packet.ReadInt32("Phase Count");
                for (var i = 0; i < count; ++i)
                {
                    packet.ReadInt16("Phase Id");
                }
            }
        }
Exemplo n.º 11
0
        public static void HandlePartyMemberStats(Packet packet)
        {
            if (ClientVersion.AddedInVersion(ClientType.WrathOfTheLichKing) &&
                packet.Opcode == Opcodes.GetOpcode(Opcode.SMSG_PARTY_MEMBER_STATS_FULL, Direction.ServerToClient))
            {
                packet.ReadBool("Add arena opponent");
            }

            packet.ReadPackedGuid("GUID");
            var updateFlags = packet.ReadUInt32E <GroupUpdateFlag>("Update Flags");

            if (updateFlags.HasFlag(GroupUpdateFlag.Status))
            {
                packet.ReadInt16E <GroupMemberStatusFlag>("Status");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.CurrentHealth))
            {
                if (ClientVersion.AddedInVersion(ClientType.WrathOfTheLichKing))
                {
                    packet.ReadInt32("Current Health");
                }
                else
                {
                    packet.ReadUInt16("Current Health");
                }
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.MaxHealth))
            {
                if (ClientVersion.AddedInVersion(ClientType.WrathOfTheLichKing))
                {
                    packet.ReadInt32("Max Health");
                }
                else
                {
                    packet.ReadUInt16("Max Health");
                }
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.PowerType))
            {
                packet.ReadByteE <PowerType>("Power type");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.CurrentPower))
            {
                packet.ReadInt16("Current Power");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.MaxPower))
            {
                packet.ReadInt16("Max Power");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.Level))
            {
                packet.ReadInt16("Level");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.Zone))
            {
                packet.ReadInt16 <ZoneId>("Zone Id");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.Position))
            {
                packet.ReadInt16("Position X");
                packet.ReadInt16("Position Y");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.Auras))
            {
                var auraMask = packet.ReadUInt64("Aura Mask");

                var maxAura = ClientVersion.AddedInVersion(ClientType.WrathOfTheLichKing) ? 64 : 56;
                for (var i = 0; i < maxAura; ++i)
                {
                    if ((auraMask & (1ul << i)) == 0)
                    {
                        continue;
                    }

                    if (ClientVersion.AddedInVersion(ClientType.WrathOfTheLichKing))
                    {
                        packet.ReadUInt32 <SpellId>("Spell Id", i);
                    }
                    else
                    {
                        packet.ReadUInt16 <SpellId>("Spell Id", i);
                    }

                    packet.ReadByteE <AuraFlag>("Aura Flags", i);
                }
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.PetGuid))
            {
                packet.ReadGuid("Pet GUID");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.PetName))
            {
                packet.ReadCString("Pet Name");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.PetModelId))
            {
                packet.ReadInt16("Pet Modelid");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.PetCurrentHealth))
            {
                if (ClientVersion.AddedInVersion(ClientType.WrathOfTheLichKing))
                {
                    packet.ReadInt32("Pet Current Health");
                }
                else
                {
                    packet.ReadUInt16("Pet Current Health");
                }
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.PetMaxHealth))
            {
                if (ClientVersion.AddedInVersion(ClientType.WrathOfTheLichKing))
                {
                    packet.ReadInt32("Pet Max Health");
                }
                else
                {
                    packet.ReadUInt16("Pet Max Health");
                }
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.PetPowerType))
            {
                packet.ReadByteE <PowerType>("Pet Power type");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.PetCurrentPower))
            {
                packet.ReadInt16("Pet Current Power");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.PetMaxPower))
            {
                packet.ReadInt16("Pet Max Power");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.PetAuras))
            {
                var auraMask = packet.ReadUInt64("Pet Auramask");

                var maxAura = ClientVersion.AddedInVersion(ClientType.WrathOfTheLichKing) ? 64 : 56;
                for (var i = 0; i < maxAura; ++i)
                {
                    if ((auraMask & (1ul << i)) == 0)
                    {
                        continue;
                    }

                    if (ClientVersion.AddedInVersion(ClientType.WrathOfTheLichKing))
                    {
                        packet.ReadUInt32 <SpellId>("Spell Id", i);
                    }
                    else
                    {
                        packet.ReadUInt16 <SpellId>("Spell Id", i);
                    }

                    packet.ReadByteE <AuraFlag>("Aura Flags", i);
                }
            }

            if (ClientVersion.AddedInVersion(ClientType.WrathOfTheLichKing) && // no idea when this was added exactly, doesn't exist in 2.4.1
                updateFlags.HasFlag(GroupUpdateFlag.VehicleSeat))
            {
                packet.ReadInt32("Vehicle Seat");
            }
        }
Exemplo n.º 12
0
        public static GossipMessageOption ReadGossipOptionsData(uint menuId, Packet packet, params object[] idx)
        {
            GossipMessageOption gossipMessageOption = new();
            GossipMenuOption    gossipOption        = new GossipMenuOption
            {
                MenuId = menuId
            };
            GossipMenuOptionBox gossipMenuOptionBox = new GossipMenuOptionBox
            {
                MenuId = menuId
            };

            gossipOption.OptionIndex       = gossipMenuOptionBox.OptionIndex = gossipMessageOption.OptionIndex = (uint)packet.ReadInt32("ClientOption", idx);
            gossipOption.OptionIcon        = (GossipOptionIcon?)packet.ReadByte("OptionNPC", idx);
            gossipMessageOption.OptionIcon = (int)gossipOption.OptionIcon;
            gossipMenuOptionBox.BoxCoded   = gossipMessageOption.BoxCoded = packet.ReadByte("OptionFlags", idx) != 0;
            gossipMenuOptionBox.BoxMoney   = gossipMessageOption.BoxCost = (uint)packet.ReadInt32("OptionCost", idx);

            packet.ResetBitReader();
            uint textLen    = packet.ReadBits(12);
            uint confirmLen = packet.ReadBits(12);
            bool hasSpellId = false;

            if (ClientVersion.AddedInVersion(ClientType.Shadowlands))
            {
                packet.ReadBits("Status", 2, idx);
                if (ClientVersion.AddedInVersion(ClientVersionBuild.V9_0_2_36639))
                {
                    hasSpellId = packet.ReadBit();
                }

                uint rewardsCount = packet.ReadUInt32();
                for (uint i = 0; i < rewardsCount; ++i)
                {
                    packet.ResetBitReader();
                    packet.ReadBits("Type", 1, idx, "TreasureItem", i);
                    packet.ReadInt32("ID", idx, "TreasureItem", i);
                    packet.ReadInt32("Quantity", idx, "TreasureItem", i);
                }
            }

            gossipOption.OptionText     = gossipMessageOption.Text = packet.ReadWoWString("Text", textLen, idx);
            gossipMenuOptionBox.BoxText = gossipMessageOption.BoxText = packet.ReadWoWString("Confirm", confirmLen, idx);

            if (hasSpellId)
            {
                packet.ReadInt32("SpellID", idx);
            }

            List <int> boxTextList;
            List <int> optionTextList;

            if (gossipMenuOptionBox.BoxText != string.Empty && SQLDatabase.BroadcastTexts.TryGetValue(gossipMenuOptionBox.BoxText, out boxTextList))
            {
                if (boxTextList.Count == 1)
                {
                    gossipMenuOptionBox.BoxBroadcastTextId = boxTextList[0];
                }
                else
                {
                    gossipMenuOptionBox.BroadcastTextIdHelper += "BoxBroadcastTextID: ";
                    gossipMenuOptionBox.BroadcastTextIdHelper += string.Join(" - ", boxTextList);
                }
            }
            else
            {
                gossipMenuOptionBox.BoxBroadcastTextId = 0;
            }

            if (gossipOption.OptionText != string.Empty && SQLDatabase.BroadcastTexts.TryGetValue(gossipOption.OptionText, out optionTextList))
            {
                if (optionTextList.Count == 1)
                {
                    gossipOption.OptionBroadcastTextId = optionTextList[0];
                }
                else
                {
                    gossipOption.BroadcastTextIDHelper += "OptionBroadcastTextID: ";
                    gossipOption.BroadcastTextIDHelper += string.Join(" - ", optionTextList);
                }
            }
            else
            {
                gossipOption.OptionBroadcastTextId = 0;
            }


            Storage.GossipMenuOptions.Add(gossipOption, packet.TimeSpan);
            if (!gossipMenuOptionBox.IsEmpty)
            {
                Storage.GossipMenuOptionBoxes.Add(gossipMenuOptionBox, packet.TimeSpan);
            }

            return(gossipMessageOption);
        }
Exemplo n.º 13
0
        public static void HandleGuildRoster(Packet packet)
        {
            packet.ReadUInt32("NumAccounts");
            packet.ReadPackedTime("CreateDate");
            packet.ReadUInt32("GuildFlags");
            var int20 = packet.ReadUInt32("MemberDataCount");

            packet.ResetBitReader();
            uint welcomeTextLen = 0;

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V8_2_0_30898))
            {
                welcomeTextLen = packet.ReadBits(11);
            }
            else
            {
                welcomeTextLen = packet.ReadBits(10);
            }
            var infoTextLen = packet.ReadBits(11);

            for (var i = 0; i < int20; ++i)
            {
                packet.ReadPackedGuid128("Guid", i);

                packet.ReadUInt32("RankID", i);
                packet.ReadUInt32 <AreaId>("AreaID", i);
                packet.ReadUInt32("PersonalAchievementPoints", i);
                packet.ReadUInt32("GuildReputation", i);

                packet.ReadSingle("LastSave", i);

                for (var j = 0; j < 2; ++j)
                {
                    packet.ReadUInt32("DbID", i, j);
                    packet.ReadUInt32("Rank", i, j);
                    packet.ReadUInt32("Step", i, j);
                }

                packet.ReadUInt32("VirtualRealmAddress", i);

                packet.ReadByteE <GuildMemberFlag>("Status", i);
                packet.ReadByte("Level", i);
                packet.ReadByteE <Class>("ClassID", i);
                packet.ReadByteE <Gender>("Gender", i);

                packet.ResetBitReader();

                var nameLen         = packet.ReadBits(6);
                var noteLen         = packet.ReadBits(8);
                var officersNoteLen = packet.ReadBits(8);

                packet.ReadBit("Authenticated", i);
                packet.ReadBit("SorEligible", i);

                packet.ReadWoWString("Name", nameLen, i);
                packet.ReadWoWString("Note", noteLen, i);
                packet.ReadWoWString("OfficerNote", officersNoteLen, i);
            }

            packet.ReadWoWString("WelcomeText", welcomeTextLen);
            packet.ReadWoWString("InfoText", infoTextLen);
        }
Exemplo n.º 14
0
        public static PacketSpellData ReadSpellCastData(Packet packet, params object[] idx)
        {
            var packetSpellData = new PacketSpellData();

            packet.ReadPackedGuid128("CasterGUID", idx);
            packetSpellData.Caster = packet.ReadPackedGuid128("CasterUnit", idx);

            packetSpellData.CastGuid = packet.ReadPackedGuid128("CastID", idx);
            packet.ReadPackedGuid128("OriginalCastID", idx);

            var spellID = packetSpellData.Spell = packet.ReadUInt32 <SpellId>("SpellID", idx);

            packet.ReadUInt32("SpellXSpellVisualID", idx);

            packetSpellData.Flags    = packet.ReadUInt32("CastFlags", idx);
            packetSpellData.CastTime = packet.ReadUInt32("CastTime", idx);

            V6_0_2_19033.Parsers.SpellHandler.ReadMissileTrajectoryResult(packet, idx, "MissileTrajectory");

            packetSpellData.AmmoDisplayId = packet.ReadInt32("Ammo.DisplayID", idx);

            packet.ReadByte("DestLocSpellCastIndex", idx);

            V6_0_2_19033.Parsers.SpellHandler.ReadCreatureImmunities(packet, idx, "Immunities");

            V6_0_2_19033.Parsers.SpellHandler.ReadSpellHealPrediction(packet, idx, "Predict");

            packet.ResetBitReader();

            packet.ReadBits("CastFlagsEx", ClientVersion.AddedInVersion(ClientVersionBuild.V7_3_2_25383) ? 23 : 22, idx);
            var hitTargetsCount     = packet.ReadBits("HitTargetsCount", 16, idx);
            var missTargetsCount    = packet.ReadBits("MissTargetsCount", 16, idx);
            var missStatusCount     = packet.ReadBits("MissStatusCount", 16, idx);
            var remainingPowerCount = packet.ReadBits("RemainingPowerCount", 9, idx);

            var hasRuneData = packet.ReadBit("HasRuneData", idx);

            var targetPointsCount = packet.ReadBits("TargetPointsCount", 16, idx);

            for (var i = 0; i < missStatusCount; ++i)
            {
                V6_0_2_19033.Parsers.SpellHandler.ReadSpellMissStatus(packet, idx, "MissStatus", i);
            }

            ReadSpellTargetData(packet, packetSpellData, spellID, idx, "Target");

            for (var i = 0; i < hitTargetsCount; ++i)
            {
                packetSpellData.HitTargets.Add(packet.ReadPackedGuid128("HitTarget", idx, i));
            }
            ;

            for (var i = 0; i < missTargetsCount; ++i)
            {
                packetSpellData.MissedTargets.Add(packet.ReadPackedGuid128("MissTarget", idx, i));
            }

            for (var i = 0; i < remainingPowerCount; ++i)
            {
                V6_0_2_19033.Parsers.SpellHandler.ReadSpellPowerData(packet, idx, "RemainingPower", i);
            }

            if (hasRuneData)
            {
                ReadRuneData(packet, idx, "RemainingRunes");
            }

            for (var i = 0; i < targetPointsCount; ++i)
            {
                packetSpellData.TargetPoints.Add(V6_0_2_19033.Parsers.SpellHandler.ReadLocation(packet, idx, "TargetPoints", i));
            }

            return(packetSpellData);
        }
        public static void HandleFeatureSystemStatus(Packet packet)
        {
            packet.ReadByte("ComplaintStatus");

            packet.ReadUInt32("ScrollOfResurrectionRequestsRemaining");
            packet.ReadUInt32("ScrollOfResurrectionMaxRequestsPerDay");
            packet.ReadUInt32("CfgRealmID");
            packet.ReadInt32("CfgRealmRecID");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V8_2_5_31921))
            {
                packet.ReadUInt32("MaxRecruits", "RAFSystem");
                packet.ReadUInt32("MaxRecruitMonths", "RAFSystem");
                packet.ReadUInt32("MaxRecruitmentUses", "RAFSystem");
                packet.ReadUInt32("DaysInCycle", "RAFSystem");
            }

            packet.ReadUInt32("TwitterPostThrottleLimit");
            packet.ReadUInt32("TwitterPostThrottleCooldown");
            packet.ReadUInt32("TokenPollTimeSeconds");

            if (ClientVersion.RemovedInVersion(ClientVersionBuild.V8_2_5_31921))
            {
                packet.ReadUInt32E <ConsumableTokenRedeem>("TokenRedeemIndex");
            }

            packet.ReadInt64("TokenBalanceAmount");
            packet.ReadUInt32("BpayStoreProductDeliveryDelay");
            packet.ReadUInt32("ClubsPresenceUpdateTimer");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V8_1_0_28724))
            {
                packet.ReadUInt32("HiddenUIClubsPresenceUpdateTimer");
            }

            packet.ResetBitReader();
            packet.ReadBit("VoiceEnabled");
            var hasEuropaTicketSystemStatus = packet.ReadBit("HasEuropaTicketSystemStatus");

            packet.ReadBit("ScrollOfResurrectionEnabled");
            packet.ReadBit("BpayStoreEnabled");
            packet.ReadBit("BpayStoreAvailable");
            packet.ReadBit("BpayStoreDisabledByParentalControls");
            packet.ReadBit("ItemRestorationButtonEnabled");
            packet.ReadBit("BrowserEnabled");
            var hasSessionAlert = packet.ReadBit("HasSessionAlert");

            if (ClientVersion.RemovedInVersion(ClientVersionBuild.V8_2_5_31921))
            {
                packet.ReadBit("RecruitAFriendSendingEnabled");
            }

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V8_2_5_31921))
            {
                packet.ReadBit("Enabled", "RAFSystem");
                packet.ReadBit("RecruitingEnabled", "RAFSystem");
            }

            packet.ReadBit("CharUndeleteEnabled");
            packet.ReadBit("RestrictedAccount");
            packet.ReadBit("CommerceSystemEnabled");
            packet.ReadBit("TutorialsEnabled");
            packet.ReadBit("NPETutorialsEnabled");
            packet.ReadBit("TwitterEnabled");
            packet.ReadBit("Unk67");
            packet.ReadBit("WillKickFromWorld");
            packet.ReadBit("KioskModeEnabled");
            packet.ReadBit("CompetitiveModeEnabled");

            var hasRaceClassExpansionLevels = false;

            if (ClientVersion.RemovedInVersion(ClientVersionBuild.V8_3_0_33062))
            {
                hasRaceClassExpansionLevels = packet.ReadBit("RaceClassExpansionLevels");
            }

            packet.ReadBit("TokenBalanceEnabled");
            packet.ReadBit("WarModeFeatureEnabled");
            packet.ReadBit("ClubsEnabled");
            packet.ReadBit("ClubsBattleNetClubTypeAllowed");
            packet.ReadBit("ClubsCharacterClubTypeAllowed");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V8_1_5_29683))
            {
                packet.ReadBit("ClubsPresenceUpdateEnabled");
            }

            packet.ReadBit("VoiceChatDisabledByParentalControl");
            packet.ReadBit("VoiceChatMutedByParentalControl");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V8_2_5_31921))
            {
                packet.ReadBit("QuestSessionEnabled");
                packet.ReadBit("Unused825");
                packet.ReadBit("ClubFinderEnabled");
            }

            {
                packet.ResetBitReader();
                packet.ReadBit("ToastsDisabled");
                packet.ReadSingle("ToastDuration");
                packet.ReadSingle("DelayDuration");
                packet.ReadSingle("QueueMultiplier");
                packet.ReadSingle("PlayerMultiplier");
                packet.ReadSingle("PlayerFriendValue");
                packet.ReadSingle("PlayerGuildValue");
                packet.ReadSingle("ThrottleInitialThreshold");
                packet.ReadSingle("ThrottleDecayTime");
                packet.ReadSingle("ThrottlePrioritySpike");
                packet.ReadSingle("ThrottleMinThreshold");
                packet.ReadSingle("ThrottlePvPPriorityNormal");
                packet.ReadSingle("ThrottlePvPPriorityLow");
                packet.ReadSingle("ThrottlePvPHonorThreshold");
                packet.ReadSingle("ThrottleLfgListPriorityDefault");
                packet.ReadSingle("ThrottleLfgListPriorityAbove");
                packet.ReadSingle("ThrottleLfgListPriorityBelow");
                packet.ReadSingle("ThrottleLfgListIlvlScalingAbove");
                packet.ReadSingle("ThrottleLfgListIlvlScalingBelow");
                packet.ReadSingle("ThrottleRfPriorityAbove");
                packet.ReadSingle("ThrottleRfIlvlScalingAbove");
                packet.ReadSingle("ThrottleDfMaxItemLevel");
                packet.ReadSingle("ThrottleDfBestPriority");
            }

            if (hasSessionAlert)
            {
                V6_0_2_19033.Parsers.MiscellaneousHandler.ReadClientSessionAlertConfig(packet, "SessionAlert");
            }

            if (hasRaceClassExpansionLevels)
            {
                var int88 = packet.ReadUInt32("RaceClassExpansionLevelsCount");
                for (int i = 0; i < int88; i++)
                {
                    packet.ReadByte("RaceClassExpansionLevels", i);
                }
            }

            packet.ResetBitReader();
            ReadVoiceChatManagerSettings(packet, "VoiceChatManagerSettings");

            if (hasEuropaTicketSystemStatus)
            {
                packet.ResetBitReader();
                V6_0_2_19033.Parsers.MiscellaneousHandler.ReadCliEuropaTicketConfig(packet, "EuropaTicketSystemStatus");
            }
        }
        public static void HandleGameObjectQueryResponse(Packet packet)
        {
            var entry = packet.ReadEntry("Entry");

            if (entry.Value) // entry is masked
            {
                return;
            }

            GameObjectTemplate gameObject = new GameObjectTemplate
            {
                Entry     = (uint)entry.Key,
                Type      = packet.ReadInt32E <GameObjectType>("Type"),
                DisplayID = packet.ReadUInt32("Display ID")
            };
            var query = packet.Holder.QueryGameObjectResponse = new() { Entry = (uint)entry.Key, HasData = true };

            var name = new string[4];

            for (int i = 0; i < 4; i++)
            {
                name[i] = packet.ReadCString("Name", i);
            }
            gameObject.Name = name[0];

            gameObject.IconName    = packet.ReadCString("Icon Name");
            gameObject.CastCaption = packet.ReadCString("Cast Caption");
            gameObject.UnkString   = packet.ReadCString("Unk String");

            gameObject.Data = new int?[ClientVersion.AddedInVersion(ClientVersionBuild.V4_0_6_13596) ? 32 : 24];
            for (int i = 0; i < gameObject.Data.Length; i++)
            {
                gameObject.Data[i] = packet.ReadInt32("Data", i);
            }

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_0_2_9056)) // not sure when it was added exactly - did not exist in 2.4.1 sniff
            {
                gameObject.Size = query.Size = packet.ReadSingle("Size");
            }

            gameObject.QuestItems = new uint?[ClientVersion.AddedInVersion(ClientVersionBuild.V3_2_0_10192) ? 6 : 4];
            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767))
            {
                for (int i = 0; i < gameObject.QuestItems.Length; i++)
                {
                    gameObject.QuestItems[i] = (uint)packet.ReadInt32 <ItemId>("Quest Item", i);
                    query.Items.Add(gameObject.QuestItems[i].Value);
                }
            }

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_0_6_13596))
            {
                gameObject.RequiredLevel = query.RequiredLevel = packet.ReadInt32("RequiredLevel");
            }

            packet.AddSniffData(StoreNameType.GameObject, entry.Key, "QUERY_RESPONSE");

            Storage.GameObjectTemplates.Add(gameObject, packet.TimeSpan);

            ObjectName objectName = new ObjectName
            {
                ObjectType = StoreNameType.GameObject,
                ID         = entry.Key,
                Name       = gameObject.Name
            };

            Storage.ObjectNames.Add(objectName, packet.TimeSpan);

            query.Type        = (uint)gameObject.Type.Value;
            query.Model       = gameObject.DisplayID.Value;
            query.Name        = gameObject.Name;
            query.IconName    = gameObject.IconName;
            query.CastCaption = gameObject.CastCaption;
            foreach (var data in gameObject.Data)
            {
                query.Data.Add(data.Value);
            }
        }
Exemplo n.º 17
0
        public static void HandleServerTrainerList(Packet packet)
        {
            uint entry = packet.ReadGuid("GUID").GetEntry();

            packet.ReadInt32E <TrainerType>("Type");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_0_6a_13623))
            {
                packet.ReadInt32("TrainerID");
            }

            int count = packet.ReadInt32("Count");

            for (int i = 0; i < count; ++i)
            {
                NpcTrainer trainer = new NpcTrainer
                {
                    ID      = entry,
                    SpellID = packet.ReadInt32 <SpellId>("Spell ID", i)
                };

                packet.ReadByteE <TrainerSpellState>("State", i);

                trainer.MoneyCost = packet.ReadUInt32("Cost", i);

                if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_0_6a_13623))
                {
                    trainer.ReqLevel     = packet.ReadByte("Required Level", i);
                    trainer.ReqSkillLine = packet.ReadUInt32("Required Skill", i);
                    trainer.ReqSkillRank = packet.ReadUInt32("Required Skill Level", i);
                    if (ClientVersion.RemovedInVersion(ClientVersionBuild.V5_1_0_16309))
                    {
                        packet.ReadInt32 <SpellId>("Chain Spell ID", i, 0);
                        packet.ReadInt32 <SpellId>("Chain Spell ID", i, 1);
                    }
                    else
                    {
                        packet.ReadInt32 <SpellId>("Required Spell ID", i);
                    }
                }

                packet.ReadInt32("Profession Dialog", i);
                packet.ReadInt32("Profession Button", i);

                if (ClientVersion.RemovedInVersion(ClientVersionBuild.V4_0_6a_13623))
                {
                    trainer.ReqLevel     = packet.ReadByte("Required Level", i);
                    trainer.ReqSkillLine = packet.ReadUInt32("Required Skill", i);
                    trainer.ReqSkillRank = packet.ReadUInt32("Required Skill Level", i);
                    packet.ReadInt32 <SpellId>("Chain Spell ID", i, 0);
                    packet.ReadInt32 <SpellId>("Chain Spell ID", i, 1);
                }

                if (ClientVersion.RemovedInVersion(ClientVersionBuild.V4_0_6a_13623))
                {
                    packet.ReadInt32("Unk Int32", i);
                }

                Storage.NpcTrainers.Add(trainer, packet.TimeSpan);
            }

            packet.ReadCString("Title");
        }
        public static void HandleLFGListSearch(Packet packet)
        {
            uint searchFilter = 0;

            packet.ResetBitReader();
            if (ClientVersion.AddedInVersion(ClientVersionBuild.V7_2_5_24330))
            {
                searchFilter = packet.ReadBits("SearchFilterNum", 5);
            }
            else
            {
                searchFilter = packet.ReadBits("SearchFilterNum", 6);
            }

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V7_2_5_24330))
            {
                uint[] length = new uint[4];
                for (int i = 0; i < searchFilter; i++)
                {
                    packet.ResetBitReader();
                    for (int z = 0; z < 3; z++)
                    {
                        length[z] = packet.ReadBits("SearchFilterLength", 5, i, z);
                    }
                    for (int z = 0; z < 3; z++)
                    {
                        packet.ReadWoWString("SearchFilter", length[z], i, z);
                    }
                }
            }
            packet.ReadInt32("GroupFinderCategoryId");
            packet.ReadInt32("SubActivityGroupID");
            packet.ReadInt32E <LfgListFilter>("LFGListFilter");
            packet.ReadUInt32E <LocaleConstantFlags>("LanguageFilter"); // 0x6b3 is default in enUS client (= enUS, koKR, ptBR, none, zhCN, zhTW, esMX)

            var entryCount = packet.ReadInt32();
            var guidCount  = packet.ReadInt32();

            if (ClientVersion.RemovedInVersion(ClientVersionBuild.V7_2_5_24330))
            {
                packet.ReadWoWString("SearchFilter", searchFilter);
            }

            for (int i = 0; i < entryCount; i++)
            {
                if (ClientVersion.RemovedInVersion(ClientVersionBuild.V7_2_5_24330))
                {
                    packet.ReadInt32("GroupFinderActivityId");
                    packet.ReadInt32E <LfgLockStatus>("LockStatus");
                }
                else
                {
                    packet.ReadInt32("Unk");
                }
            }

            for (int i = 0; i < guidCount; i++)
            {
                packet.ReadPackedGuid128("UnkGUID", i); // PartyMember?
            }
        }
Exemplo n.º 19
0
        public static void HandlePetSpells(Packet packet)
        {
            WowGuid guid = packet.ReadGuid("GUID");

            // Equal to "Clear spells" pre cataclysm
            if (guid.IsEmpty())
            {
                return;
            }

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767))
            {
                packet.ReadUInt16E <CreatureFamily>("Pet Family"); // vehicles -> 0
            }
            if (ClientVersion.AddedInVersion(ClientVersionBuild.V5_1_0_16309))
            {
                packet.ReadUInt16("Unk UInt16");
            }

            packet.ReadUInt32("Expiration Time");

            ReadPetFlags(packet);

            bool      isPet             = guid.GetHighType() == HighGuidType.Pet;
            bool      isVehicle         = guid.GetHighType() == HighGuidType.Vehicle;
            bool      isMinion          = guid.GetHighType() == HighGuidType.Creature;
            const int maxCreatureSpells = 10;
            var       spells            = new List <uint?>(maxCreatureSpells);

            for (int i = 0; i < maxCreatureSpells; i++) // Read pet/vehicle spell ids
            {
                ushort spell16 = packet.ReadUInt16();
                byte   spell8  = packet.ReadByte();
                int    spellId = spell16 + (spell8 << 16);
                byte   slot    = packet.ReadByte("Slot", i);

                if (spellId <= 4)
                {
                    packet.AddValue("Action", spellId, i);
                }
                else
                {
                    packet.AddValue("Spell", StoreGetters.GetName(StoreNameType.Spell, spellId), i);
                }

                // Spells for pets are on DBCs; also no entry in guid
                // We don't need the actions sent for minions (slots lower than 8)
                if (!isPet && (isVehicle || (isMinion && slot >= 8)))
                {
                    spells.Add((uint)spellId);
                }
            }

            if (spells.Count != 0)
            {
                if (!Storage.SpellsX.ContainsKey(guid.GetEntry()))
                {
                    Storage.SpellsX.Add(guid.GetEntry(), spells);
                }
            }

            byte spellCount = packet.ReadByte("Spell Count"); // vehicles -> 0, pets -> != 0. Could this be auras?

            for (int i = 0; i < spellCount; i++)
            {
                packet.ReadUInt16 <SpellId>("Spell", i);
                packet.ReadInt16("Active", i);
            }

            byte cdCount = packet.ReadByte("Cooldown count");

            for (int i = 0; i < cdCount; i++)
            {
                if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767))
                {
                    packet.ReadUInt32 <SpellId>("Spell", i);
                }
                else
                {
                    packet.ReadUInt16 <SpellId>("Spell", i);
                }

                packet.ReadUInt16("Category", i);
                packet.ReadUInt32("Cooldown", i);
                packet.ReadUInt32("Category Cooldown", i);
            }

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V5_1_0_16309))
            {
                byte unkLoopCounter = packet.ReadByte("Unk count");
                for (int i = 0; i < unkLoopCounter; i++)
                {
                    packet.ReadUInt32("Unk UInt32 1", i);
                    packet.ReadByte("Unk Byte", i);
                    packet.ReadUInt32("Unk UInt32 2", i);
                }
            }
        }
        public static void ReadLfgListSearchResultPartialUpdate(Packet packet, params object[] idx)
        {
            V6_0_2_19033.Parsers.LfgHandler.ReadCliRideTicket(packet, idx, "Ticket");
            packet.ReadUInt32("SequenceNum", idx);
            var memberCount = packet.ReadUInt32();

            for (int j = 0; j < memberCount; j++)
            {
                ReadLfgListSearchResultMemberInfo(packet, "Members", idx, j);
            }

            packet.ResetBitReader();
            var hasLeader = packet.ReadBit("ChangeLeader", idx);
            var hasVirtualRealmAddress     = packet.ReadBit("ChangeVirtualRealmAddress", idx);
            var hasCompletedEncountersMask = packet.ReadBit("ChangeCompletedEncountersMask", idx);

            packet.ReadBit("Delisted", idx);
            packet.ReadBit("ChangeTitle", idx);
            var hasAny     = packet.ReadBit();
            var hasName    = packet.ReadBit("ChangeName", idx);
            var hasComment = packet.ReadBit("ChangeComment", idx);
            var hasVoice   = false;

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V7_3_0_24920))
            {
                hasVoice = packet.ReadBit("ChangeVoice", idx);
            }
            var hasItemLevel = packet.ReadBit("ChangeItemLevel", idx);

            packet.ReadBit("ChangeAutoAccept", idx);
            packet.ReadBit("ChangeHonorLevel", idx);
            packet.ReadBit("ChangePrivate", idx);

            ReadLfgListJoinRequest(packet, idx, "LFGListJoinRequest");

            if (hasLeader)
            {
                packet.ReadPackedGuid128("Leader", idx);
            }

            if (hasVirtualRealmAddress)
            {
                packet.ReadUInt32("VirtualRealmAddress", idx);
            }

            if (hasCompletedEncountersMask)
            {
                packet.ReadUInt32("CompletedEncountersMask", idx);
            }

            if (hasAny)
            {
                packet.ReadPackedGuid128("LastTouchedAny");
            }

            if (hasName)
            {
                packet.ReadPackedGuid128("LastTouchedName", idx);
            }

            if (hasComment)
            {
                packet.ReadPackedGuid128("LastTouchedComment", idx);
            }

            if (hasVoice)
            {
                packet.ReadPackedGuid128("LastTouchedVoiceChat", idx);
            }
        }
Exemplo n.º 21
0
        public static void HandleQuestGiverQuestDetails(Packet packet)
        {
            var questgiverGUID = packet.ReadPackedGuid128("QuestGiverGUID");

            packet.ReadPackedGuid128("InformUnit");

            int          id           = packet.ReadInt32("QuestID");
            QuestDetails questDetails = new QuestDetails
            {
                ID = (uint)id
            };

            CoreParsers.QuestHandler.AddQuestStarter(questgiverGUID, (uint)id);

            packet.ReadInt32("QuestPackageID");
            packet.ReadInt32("PortraitGiver");
            packet.ReadInt32("PortraitGiverMount");
            packet.ReadInt32("PortraitTurnIn");

            for (int i = 0; i < 2; i++)
            {
                packet.ReadInt32("QuestFlags", i);
            }

            packet.ReadInt32("SuggestedPartyMembers");
            var learnSpellsCount = packet.ReadUInt32("LearnSpellsCount");

            var descEmotesCount = packet.ReadUInt32("DescEmotesCount");
            var objectivesCount = packet.ReadUInt32("ObjectivesCount");

            packet.ReadInt32("QuestStartItemID");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V8_2_5_31921))
            {
                packet.ReadInt32("QuestSessionBonus");
            }

            for (var i = 0; i < learnSpellsCount; i++)
            {
                packet.ReadInt32("LearnSpells", i);
            }

            questDetails.Emote      = new uint?[] { 0, 0, 0, 0 };
            questDetails.EmoteDelay = new uint?[] { 0, 0, 0, 0 };
            for (var i = 0; i < descEmotesCount; i++)
            {
                questDetails.Emote[i]      = (uint)packet.ReadInt32("Type", i);
                questDetails.EmoteDelay[i] = packet.ReadUInt32("Delay", i);
            }

            for (var i = 0; i < objectivesCount; i++)
            {
                packet.ReadInt32("ObjectiveID", i);
                packet.ReadInt32("ObjectID", i);
                packet.ReadInt32("Amount", i);
                packet.ReadByte("Type", i);
            }

            packet.ResetBitReader();

            uint questTitleLen         = packet.ReadBits(9);
            uint descriptionTextLen    = packet.ReadBits(12);
            uint logDescriptionLen     = packet.ReadBits(12);
            uint portraitGiverTextLen  = packet.ReadBits(10);
            uint portraitGiverNameLen  = packet.ReadBits(8);
            uint portraitTurnInTextLen = packet.ReadBits(10);
            uint portraitTurnInNameLen = packet.ReadBits(8);

            packet.ReadBit("DisplayPopup");
            packet.ReadBit("StartCheat");
            packet.ReadBit("AutoLaunched");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V8_2_5_31921))
            {
                packet.ReadBit(); // Unused by client
            }
            ReadQuestRewards(packet, "QuestRewards");

            packet.ReadWoWString("QuestTitle", questTitleLen);
            packet.ReadWoWString("DescriptionText", descriptionTextLen);
            packet.ReadWoWString("LogDescription", logDescriptionLen);
            packet.ReadWoWString("PortraitGiverText", portraitGiverTextLen);
            packet.ReadWoWString("PortraitGiverName", portraitGiverNameLen);
            packet.ReadWoWString("PortraitTurnInText", portraitTurnInTextLen);
            packet.ReadWoWString("PortraitTurnInName", portraitTurnInNameLen);

            Storage.QuestDetails.Add(questDetails, packet.TimeSpan);
        }
Exemplo n.º 22
0
        public static string CreatureTemplateAddon(Dictionary <WowGuid, Unit> units)
        {
            if (units.Count == 0)
            {
                return(string.Empty);
            }

            if (!Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.creature_template_addon))
            {
                return(string.Empty);
            }

            var addons = new DataBag <CreatureTemplateAddon>();

            foreach (var unit in units)
            {
                var npc = unit.Value;

                if (Settings.AreaFilters.Length > 0)
                {
                    if (!(npc.Area.ToString(CultureInfo.InvariantCulture).MatchesFilters(Settings.AreaFilters)))
                    {
                        continue;
                    }
                }

                if (Settings.MapFilters.Length > 0)
                {
                    if (!(npc.Map.ToString(CultureInfo.InvariantCulture).MatchesFilters(Settings.MapFilters)))
                    {
                        continue;
                    }
                }

                var auras        = string.Empty;
                var commentAuras = string.Empty;
                if (npc.Auras != null && npc.Auras.Count != 0)
                {
                    foreach (var aura in npc.Auras.Where(aura =>
                                                         aura != null &&
                                                         (ClientVersion.AddedInVersion(ClientType.MistsOfPandaria) ?
                                                          aura.AuraFlags.HasAnyFlag(AuraFlagMoP.NoCaster) :
                                                          aura.AuraFlags.HasAnyFlag(AuraFlag.NotCaster))))
                    {
                        auras        += aura.SpellId + " ";
                        commentAuras += StoreGetters.GetName(StoreNameType.Spell, (int)aura.SpellId, false) + ", ";
                    }
                    auras        = auras.TrimEnd(' ');
                    commentAuras = commentAuras.TrimEnd(',', ' ');
                }

                var addon = new CreatureTemplateAddon
                {
                    Entry           = unit.Key.GetEntry(),
                    PathID          = 0,
                    MountID         = npc.Mount.GetValueOrDefault(),
                    Bytes1          = npc.Bytes1.GetValueOrDefault(),
                    Bytes2          = npc.Bytes2.GetValueOrDefault(),
                    Emote           = 0,
                    AIAnimKit       = npc.AIAnimKit.GetValueOrDefault(0),
                    MovementAnimKit = npc.MovementAnimKit.GetValueOrDefault(0),
                    MeleeAnimKit    = npc.MeleeAnimKit.GetValueOrDefault(0),
                    Auras           = auras,
                    CommentAuras    = commentAuras
                };

                if (addons.ContainsKey(addon))
                {
                    continue;
                }

                addons.Add(addon);
            }

            var addonsDb = SQLDatabase.Get(addons);

            return(SQLUtil.Compare(addons, addonsDb,
                                   addon =>
            {
                var comment = StoreGetters.GetName(StoreNameType.Unit, (int)addon.Entry.GetValueOrDefault());
                if (!string.IsNullOrEmpty(addon.CommentAuras))
                {
                    comment += " - " + addon.CommentAuras;
                }
                return comment;
            }));
        }
Exemplo n.º 23
0
        public static void HandleFeatureSystemStatus(Packet packet)
        {
            packet.ReadByte("ComplaintStatus");

            packet.ReadUInt32("ScrollOfResurrectionRequestsRemaining");
            packet.ReadUInt32("ScrollOfResurrectionMaxRequestsPerDay");
            packet.ReadUInt32("CfgRealmID");
            packet.ReadInt32("CfgRealmRecID");
            packet.ReadUInt32("MaxRecruits", "RAFSystem");
            packet.ReadUInt32("MaxRecruitMonths", "RAFSystem");
            packet.ReadUInt32("MaxRecruitmentUses", "RAFSystem");
            packet.ReadUInt32("DaysInCycle", "RAFSystem");
            packet.ReadUInt32("TwitterPostThrottleLimit");
            packet.ReadUInt32("TwitterPostThrottleCooldown");
            packet.ReadUInt32("TokenPollTimeSeconds");
            packet.ReadUInt32("KioskSessionMinutes");
            packet.ReadInt64("TokenBalanceAmount");
            packet.ReadUInt32("BpayStoreProductDeliveryDelay");
            packet.ReadUInt32("ClubsPresenceUpdateTimer");
            packet.ReadUInt32("HiddenUIClubsPresenceUpdateTimer");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V9_2_0_42423))
            {
                packet.ReadInt32("GameRuleUnknown1");
                var gameRuleValuesCount = packet.ReadUInt32("GameRuleValuesCount");
                packet.ReadInt16("MaxPlayerNameQueriesPerPacket");

                for (var i = 0; i < gameRuleValuesCount; ++i)
                {
                    ReadGameRuleValuePair(packet, "GameRuleValues");
                }
            }

            packet.ResetBitReader();
            packet.ReadBit("VoiceEnabled");
            var hasEuropaTicketSystemStatus = packet.ReadBit("HasEuropaTicketSystemStatus");

            packet.ReadBit("ScrollOfResurrectionEnabled");
            packet.ReadBit("BpayStoreEnabled");
            packet.ReadBit("BpayStoreAvailable");
            packet.ReadBit("BpayStoreDisabledByParentalControls");
            packet.ReadBit("ItemRestorationButtonEnabled");
            packet.ReadBit("BrowserEnabled");
            var hasSessionAlert = packet.ReadBit("HasSessionAlert");

            packet.ReadBit("Enabled", "RAFSystem");
            packet.ReadBit("RecruitingEnabled", "RAFSystem");
            packet.ReadBit("CharUndeleteEnabled");
            packet.ReadBit("RestrictedAccount");
            packet.ReadBit("CommerceSystemEnabled");
            packet.ReadBit("TutorialsEnabled");
            packet.ReadBit("TwitterEnabled");
            packet.ReadBit("Unk67");
            packet.ReadBit("WillKickFromWorld");
            packet.ReadBit("KioskModeEnabled");
            packet.ReadBit("CompetitiveModeEnabled");
            packet.ReadBit("TokenBalanceEnabled");
            packet.ReadBit("WarModeFeatureEnabled");
            packet.ReadBit("ClubsEnabled");
            packet.ReadBit("ClubsBattleNetClubTypeAllowed");
            packet.ReadBit("ClubsCharacterClubTypeAllowed");
            packet.ReadBit("ClubsPresenceUpdateEnabled");
            packet.ReadBit("VoiceChatDisabledByParentalControl");
            packet.ReadBit("VoiceChatMutedByParentalControl");
            packet.ReadBit("QuestSessionEnabled");
            packet.ReadBit("IsMuted");
            packet.ReadBit("ClubFinderEnabled");
            packet.ReadBit("Unknown901CheckoutRelated");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V9_1_5_40772))
            {
                packet.ReadBit("TextToSpeechFeatureEnabled");
                packet.ReadBit("ChatDisabledByDefault");
                packet.ReadBit("ChatDisabledByPlayer");
                packet.ReadBit("LFGListCustomRequiresAuthenticator");
            }

            {
                packet.ResetBitReader();
                packet.ReadBit("ToastsDisabled");
                packet.ReadSingle("ToastDuration");
                packet.ReadSingle("DelayDuration");
                packet.ReadSingle("QueueMultiplier");
                packet.ReadSingle("PlayerMultiplier");
                packet.ReadSingle("PlayerFriendValue");
                packet.ReadSingle("PlayerGuildValue");
                packet.ReadSingle("ThrottleInitialThreshold");
                packet.ReadSingle("ThrottleDecayTime");
                packet.ReadSingle("ThrottlePrioritySpike");
                packet.ReadSingle("ThrottleMinThreshold");
                packet.ReadSingle("ThrottlePvPPriorityNormal");
                packet.ReadSingle("ThrottlePvPPriorityLow");
                packet.ReadSingle("ThrottlePvPHonorThreshold");
                packet.ReadSingle("ThrottleLfgListPriorityDefault");
                packet.ReadSingle("ThrottleLfgListPriorityAbove");
                packet.ReadSingle("ThrottleLfgListPriorityBelow");
                packet.ReadSingle("ThrottleLfgListIlvlScalingAbove");
                packet.ReadSingle("ThrottleLfgListIlvlScalingBelow");
                packet.ReadSingle("ThrottleRfPriorityAbove");
                packet.ReadSingle("ThrottleRfIlvlScalingAbove");
                packet.ReadSingle("ThrottleDfMaxItemLevel");
                packet.ReadSingle("ThrottleDfBestPriority");
            }

            if (hasSessionAlert)
            {
                V6_0_2_19033.Parsers.MiscellaneousHandler.ReadClientSessionAlertConfig(packet, "SessionAlert");
            }

            packet.ResetBitReader();
            V8_0_1_27101.Parsers.MiscellaneousHandler.ReadVoiceChatManagerSettings(packet, "VoiceChatManagerSettings");

            if (hasEuropaTicketSystemStatus)
            {
                packet.ResetBitReader();
                V6_0_2_19033.Parsers.MiscellaneousHandler.ReadCliEuropaTicketConfig(packet, "EuropaTicketSystemStatus");
            }
        }
Exemplo n.º 24
0
        public static string CreatureTemplateNonWDB(Dictionary <WowGuid, Unit> units)
        {
            if (units.Count == 0)
            {
                return(string.Empty);
            }

            if (!Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.creature_template))
            {
                return(string.Empty);
            }

            var levels = GetLevels(units);

            foreach (var unit in units)
            {
                if (Storage.CreatureTemplatesNonWDB.Any(creature => creature.Item1.Entry == unit.Key.GetEntry()))
                {
                    continue;
                }

                var npc = unit.Value;
                int minLevel, maxLevel;

                if (npc.ScalingMinLevel != null && npc.ScalingMaxLevel != null)
                {
                    minLevel = (int)npc.ScalingMinLevel;
                    maxLevel = (int)npc.ScalingMaxLevel;
                }
                else
                {
                    minLevel = (int)levels[unit.Key.GetEntry()].Item1;
                    maxLevel = (int)levels[unit.Key.GetEntry()].Item2;
                }

                var template = new CreatureTemplateNonWDB
                {
                    Entry            = unit.Key.GetEntry(),
                    GossipMenuId     = npc.GossipId,
                    MinLevel         = minLevel,
                    MaxLevel         = maxLevel,
                    Faction          = npc.Faction.GetValueOrDefault(35),
                    NpcFlag          = npc.NpcFlags.GetValueOrDefault(NPCFlags.None),
                    SpeedRun         = npc.Movement.RunSpeed,
                    SpeedWalk        = npc.Movement.WalkSpeed,
                    BaseAttackTime   = npc.MeleeTime.GetValueOrDefault(2000),
                    RangedAttackTime = npc.RangedTime.GetValueOrDefault(2000),
                    UnitClass        = (uint)npc.Class.GetValueOrDefault(Class.Warrior),
                    UnitFlags        = npc.UnitFlags.GetValueOrDefault(UnitFlags.None),
                    UnitFlags2       = npc.UnitFlags2.GetValueOrDefault(UnitFlags2.None),
                    DynamicFlags     = npc.DynamicFlags.GetValueOrDefault(UnitDynamicFlags.None),
                    VehicleID        = npc.Movement.VehicleId,
                    HoverHeight      = npc.HoverHeight.GetValueOrDefault(1.0f)
                };

                if (Settings.UseDBC)
                {
                    var creatureDiff = DBC.DBC.CreatureDifficulty.Where(diff => diff.Value.CreatureID == unit.Key.GetEntry());
                    if (creatureDiff.Any())
                    {
                        template.MinLevel = creatureDiff.Select(lv => lv.Value.MinLevel).First();
                        template.MaxLevel = creatureDiff.Select(lv => lv.Value.MaxLevel).First();
                        template.Faction  = creatureDiff.Select(lv => lv.Value.FactionTemplateID).First();
                    }
                }

                if (template.Faction == 1 || template.Faction == 2 || template.Faction == 3 ||
                    template.Faction == 4 || template.Faction == 5 || template.Faction == 6 ||
                    template.Faction == 115 || template.Faction == 116 || template.Faction == 1610 ||
                    template.Faction == 1629 || template.Faction == 2203 || template.Faction == 2204) // player factions
                {
                    template.Faction = 35;
                }

                template.UnitFlags &= ~UnitFlags.IsInCombat;
                template.UnitFlags &= ~UnitFlags.PetIsAttackingTarget;
                template.UnitFlags &= ~UnitFlags.PlayerControlled;
                template.UnitFlags &= ~UnitFlags.Silenced;
                template.UnitFlags &= ~UnitFlags.PossessedByPlayer;

                if (!ClientVersion.AddedInVersion(ClientType.WarlordsOfDraenor))
                {
                    template.DynamicFlags &= ~UnitDynamicFlags.Lootable;
                    template.DynamicFlags &= ~UnitDynamicFlags.Tapped;
                    template.DynamicFlags &= ~UnitDynamicFlags.TappedByPlayer;
                    template.DynamicFlags &= ~UnitDynamicFlags.TappedByAllThreatList;
                }
                else
                {
                    template.DynamicFlagsWod &= ~UnitDynamicFlagsWOD.Lootable;
                    template.DynamicFlagsWod &= ~UnitDynamicFlagsWOD.Tapped;
                    template.DynamicFlagsWod &= ~UnitDynamicFlagsWOD.TappedByPlayer;
                    template.DynamicFlagsWod &= ~UnitDynamicFlagsWOD.TappedByAllThreatList;
                }

                // has trainer flag but doesn't have prof nor class trainer flag
                if ((template.NpcFlag & NPCFlags.Trainer) != 0 &&
                    ((template.NpcFlag & NPCFlags.ProfessionTrainer) == 0 ||
                     (template.NpcFlag & NPCFlags.ClassTrainer) == 0))
                {
                    var subname = GetSubName((int)unit.Key.GetEntry(), false); // Fall back
                    var entry   = Storage.CreatureTemplates.Where(creature => creature.Item1.Entry == unit.Key.GetEntry());
                    if (entry.Any())
                    {
                        var sub = entry.Select(creature => creature.Item1.SubName).First();
                        if (sub.Length > 0)
                        {
                            template.NpcFlag |= ProcessNpcFlags(sub);
                            Trace.WriteLine($"Entry: { unit.Key.GetEntry() } NpcFlag: { template.NpcFlag }");
                        }
                        else // If the SubName doesn't exist or is cached, fall back to DB method
                        {
                            template.NpcFlag |= ProcessNpcFlags(subname);
                        }
                    }
                    else // In case we have NonWDB data which doesn't have an entry in CreatureTemplates
                    {
                        template.NpcFlag |= ProcessNpcFlags(subname);
                    }
                }

                Storage.CreatureTemplatesNonWDB.Add(template);
            }

            var templatesDb = SQLDatabase.Get(Storage.CreatureTemplatesNonWDB);

            return(SQLUtil.Compare(Storage.CreatureTemplatesNonWDB, templatesDb, StoreNameType.Unit));
        }
Exemplo n.º 25
0
        public static void HandleCreatureQueryResponse(Packet packet)
        {
            var entry = packet.ReadEntry("Entry");

            if (entry.Value)
            {
                return;
            }

            var creature = new UnitTemplate();

            var name = new string[4];

            for (var i = 0; i < name.Length; i++)
            {
                name[i] = packet.ReadCString("Name", i);
            }
            creature.Name = name[0];

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_1_0_13914))
            {
                var femaleName = new string[4];
                for (var i = 0; i < femaleName.Length; i++)
                {
                    femaleName[i] = packet.ReadCString("Female Name", i);
                }
                creature.femaleName = femaleName[0];
            }

            creature.SubName = packet.ReadCString("Sub Name");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V5_0_5_16048))
            {
                packet.ReadCString("Unk String");
            }

            creature.IconName = packet.ReadCString("Icon Name");

            creature.TypeFlags = packet.ReadEnum <CreatureTypeFlag>("Type Flags", TypeCode.UInt32);

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_1_0_13914))    // Might be earlier or later
            {
                creature.TypeFlags2 = packet.ReadUInt32("Creature Type Flags 2"); // Missing enum
            }
            creature.Type = packet.ReadEnum <CreatureType>("Type", TypeCode.Int32);

            creature.Family = packet.ReadEnum <CreatureFamily>("Family", TypeCode.Int32);

            creature.Rank = packet.ReadEnum <CreatureRank>("Rank", TypeCode.Int32);

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767))
            {
                creature.KillCredits = new uint[2];
                for (var i = 0; i < 2; ++i)
                {
                    creature.KillCredits[i] = packet.ReadUInt32("Kill Credit", i);
                }
            }
            else // Did they stop sending pet spell data after 3.1?
            {
                creature.UnkInt       = packet.ReadInt32("Unk Int");
                creature.PetSpellData = packet.ReadUInt32("Pet Spell Data Id");
            }

            creature.DisplayIds = new uint[4];
            for (var i = 0; i < 4; i++)
            {
                creature.DisplayIds[i] = packet.ReadUInt32("Display ID", i);
            }

            creature.Modifier1 = packet.ReadSingle("Modifier 1");
            creature.Modifier2 = packet.ReadSingle("Modifier 2");

            creature.RacialLeader = packet.ReadBoolean("Racial Leader");

            var qItemCount = ClientVersion.AddedInVersion(ClientVersionBuild.V3_2_0_10192) ? 6 : 4;

            creature.QuestItems = new uint[qItemCount];

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767))
            {
                for (var i = 0; i < qItemCount; i++)
                {
                    creature.QuestItems[i] = (uint)packet.ReadEntry <Int32>(StoreNameType.Item, "Quest Item", i);
                }

                creature.MovementId = packet.ReadUInt32("Movement ID");
            }

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_0_1_13164))
            {
                creature.Expansion = packet.ReadEnum <ClientType>("Expansion", TypeCode.UInt32);
            }

            packet.AddSniffData(StoreNameType.Unit, entry.Key, "QUERY_RESPONSE");

            Storage.UnitTemplates.Add((uint)entry.Key, creature, packet.TimeSpan);

            var objectName = new ObjectName
            {
                ObjectType = ObjectType.Unit,
                Name       = creature.Name,
            };

            Storage.ObjectNames.Add((uint)entry.Key, objectName, packet.TimeSpan);
        }
Exemplo n.º 26
0
        public static void HandleCreatureQueryResponse(Packet packet)
        {
            var entry = packet.ReadEntry("Entry");

            if (entry.Value)
            {
                return;
            }

            CreatureTemplate creature = new CreatureTemplate
            {
                Entry = (uint)entry.Key
            };

            var name = new string[4];

            for (int i = 0; i < name.Length; i++)
            {
                name[i] = packet.ReadCString("Name", i);
            }
            creature.Name = name[0];

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_1_0_13914))
            {
                var femaleName = new string[4];
                for (int i = 0; i < femaleName.Length; i++)
                {
                    femaleName[i] = packet.ReadCString("Female Name", i);
                }
                creature.FemaleName = femaleName[0];
            }

            creature.SubName = packet.ReadCString("Sub Name");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V5_0_5_16048))
            {
                creature.TitleAlt = packet.ReadCString("TitleAlt");
            }

            creature.IconName = packet.ReadCString("Icon Name");

            creature.TypeFlags = packet.ReadUInt32E <CreatureTypeFlag>("Type Flags");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_1_0_13914))    // Might be earlier or later
            {
                creature.TypeFlags2 = packet.ReadUInt32("Creature Type Flags 2"); // Missing enum
            }
            creature.Type = packet.ReadInt32E <CreatureType>("Type");

            creature.Family = packet.ReadInt32E <CreatureFamily>("Family");

            creature.Rank = packet.ReadInt32E <CreatureRank>("Rank");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767))
            {
                creature.KillCredits = new uint?[2];
                for (int i = 0; i < 2; ++i)
                {
                    creature.KillCredits[i] = packet.ReadUInt32("Kill Credit", i);
                }
            }
            else // Did they stop sending pet spell data after 3.1?
            {
                if (ClientVersion.RemovedInVersion(ClientType.WrathOfTheLichKing))
                {
                    packet.ReadInt32("Unk Int");
                }
                creature.PetSpellDataID = packet.ReadUInt32("Pet Spell Data Id");
            }

            creature.ModelIDs = new uint?[4];
            for (int i = 0; i < 4; i++)
            {
                creature.ModelIDs[i] = packet.ReadUInt32("Model ID", i);
            }

            creature.HealthModifier = packet.ReadSingle("Modifier 1");
            creature.ManaModifier   = packet.ReadSingle("Modifier 2");

            creature.RacialLeader = packet.ReadBool("Racial Leader");

            int qItemCount = ClientVersion.AddedInVersion(ClientVersionBuild.V3_2_0_10192) ? 6 : 4;

            //TODO: Move to creature_questitem
            //creature.QuestItems = new uint[qItemCount];

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767))
            {
                for (int i = 0; i < qItemCount; i++)
                {
                    /*creature.QuestItems[i] = (uint)*/ packet.ReadInt32 <ItemId>("Quest Item", i);
                }

                creature.MovementID = packet.ReadUInt32("Movement ID");
            }

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_0_1_13164))
            {
                creature.RequiredExpansion = packet.ReadUInt32E <ClientType>("Expansion");
            }

            packet.AddSniffData(StoreNameType.Unit, entry.Key, "QUERY_RESPONSE");

            Storage.CreatureTemplates.Add(creature.Entry.Value, creature, packet.TimeSpan);

            if (ClientLocale.PacketLocale != LocaleConstant.enUS)
            {
                CreatureTemplateLocale localesCreature = new CreatureTemplateLocale
                {
                    ID       = (uint)entry.Key,
                    Name     = creature.Name,
                    NameAlt  = creature.FemaleName,
                    Title    = creature.SubName,
                    TitleAlt = creature.TitleAlt
                };

                Storage.LocalesCreatures.Add(localesCreature, packet.TimeSpan);
            }

            ObjectName objectName = new ObjectName
            {
                ObjectType = StoreNameType.Unit,
                ID         = entry.Key,
                Name       = creature.Name
            };

            Storage.ObjectNames.Add(objectName, packet.TimeSpan);
        }
Exemplo n.º 27
0
        public static PacketSpellData ReadSpellCastData(Packet packet, params object[] idx)
        {
            var packetSpellData = new PacketSpellData();

            packet.ReadPackedGuid128("CasterGUID", idx);
            packetSpellData.Caster = packet.ReadPackedGuid128("CasterUnit", idx);

            packetSpellData.CastId = packet.ReadByte("CastID", idx);

            packetSpellData.Spell = (uint)packet.ReadInt32 <SpellId>("SpellID", idx);

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V6_2_0_20173))
            {
                packet.ReadUInt32("SpellXSpellVisualID", idx);
            }

            packetSpellData.Flags    = packet.ReadUInt32("CastFlags", idx);
            packetSpellData.CastTime = packet.ReadUInt32("CastTime", idx);

            var hitTargetsCount  = packet.ReadUInt32("HitTargetsCount", idx);
            var missTargetsCount = packet.ReadUInt32("MissTargetsCount", idx);
            var missStatusCount  = packet.ReadUInt32("MissStatusCount", idx);

            ReadSpellTargetData(packet, packetSpellData, idx, "Target");

            var remainingPowerCount = packet.ReadUInt32("RemainingPowerCount", idx);

            ReadMissileTrajectoryResult(packet, idx, "MissileTrajectory");

            ReadSpellAmmo(packet, idx, "Ammo");

            packet.ReadByte("DestLocSpellCastIndex", idx);

            var targetPointsCount = packet.ReadUInt32("TargetPointsCount", idx);

            ReadCreatureImmunities(packet, idx, "Immunities");

            ReadSpellHealPrediction(packet, idx, "Predict");

            for (var i = 0; i < hitTargetsCount; ++i)
            {
                packetSpellData.HitTargets.Add(packet.ReadPackedGuid128("HitTarget", idx, i));
            }

            for (var i = 0; i < missTargetsCount; ++i)
            {
                packetSpellData.MissedTargets.Add(packet.ReadPackedGuid128("MissTarget", idx, i));
            }

            for (var i = 0; i < missStatusCount; ++i)
            {
                ReadSpellMissStatus(packet, idx, "MissStatus", i);
            }

            for (var i = 0; i < remainingPowerCount; ++i)
            {
                ReadSpellPowerData(packet, idx, "RemainingPower", i);
            }

            for (var i = 0; i < targetPointsCount; ++i)
            {
                packetSpellData.TargetPoints.Add(ReadLocation(packet, idx, "TargetPoints", i));
            }

            packet.ResetBitReader();

            packetSpellData.Flags2 = packet.ReadBits("CastFlagsEx", ClientVersion.AddedInVersion(ClientVersionBuild.V6_2_0_20173) ? 20 : 18, idx);

            var hasRuneData         = packet.ReadBit("HasRuneData", idx);
            var hasProjectileVisual = ClientVersion.RemovedInVersion(ClientVersionBuild.V6_2_0_20173) && packet.ReadBit("HasProjectileVisual", idx);

            if (hasRuneData)
            {
                ReadRuneData(packet, idx, "RemainingRunes");
            }

            if (hasProjectileVisual)
            {
                ReadProjectileVisual(packet, idx, "ProjectileVisual");
            }

            return(packetSpellData);
        }
Exemplo n.º 28
0
        public static void HandleNameQueryResponse(Packet packet)
        {
            WowGuid guid;

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767))
            {
                guid = packet.ReadPackedGuid("GUID");
                var end = packet.ReadByte("Result");

                /*
                 * if (end == 1)
                 *  DenyItem(&WDB_CACHE_NAME, v11, v12);
                 * if (end == 2)
                 *  RetryItem(&WDB_CACHE_NAME, v11, v12);
                 * if (end == 3)
                 * {
                 *  AddItem(&WDB_CACHE_NAME, (int)&v8, v11, v12);
                 *  SetTemporary(&WDB_CACHE_NAME, v11, v12);
                 * }
                 */
                if (end != 0)
                {
                    return;
                }
            }
            else
            {
                guid = packet.ReadGuid("GUID");
            }

            var name = packet.ReadCString("Name");

            StoreGetters.AddName(guid, name);
            packet.ReadCString("Realm Name");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767))
            {
                packet.ReadByteE <Race>("Race");
                packet.ReadByteE <Gender>("Gender");
                packet.ReadByteE <Class>("Class");
            }
            else
            {
                packet.ReadInt32E <Race>("Race");
                packet.ReadInt32E <Gender>("Gender");
                packet.ReadInt32E <Class>("Class");
            }

            if (!packet.ReadBool("Name Declined"))
            {
                return;
            }

            for (var i = 0; i < 5; i++)
            {
                packet.ReadCString("Declined Name", i);
            }

            var objectName = new ObjectName
            {
                ObjectType = StoreNameType.Player,
                ID         = (int)guid.GetLow(),
                Name       = name
            };

            Storage.ObjectNames.Add(objectName, packet.TimeSpan);
        }
Exemplo n.º 29
0
        public static void QuestGiverOfferReward(Packet packet)
        {
            packet.ReadPackedGuid128("QuestGiverGUID");

            packet.ReadInt32("QuestGiverCreatureID");
            int id = packet.ReadInt32("QuestID");

            QuestOfferReward questOfferReward = new QuestOfferReward
            {
                ID = (uint)id
            };

            for (int i = 0; i < 2; i++)
            {
                packet.ReadInt32("QuestFlags", i);
            }

            packet.ReadInt32("SuggestedPartyMembers");

            var emotesCount = packet.ReadUInt32("EmotesCount");

            // QuestDescEmote
            questOfferReward.Emote      = new uint?[] { 0, 0, 0, 0 };
            questOfferReward.EmoteDelay = new uint?[] { 0, 0, 0, 0 };
            for (var i = 0; i < emotesCount; i++)
            {
                questOfferReward.Emote[i]      = (uint)packet.ReadInt32("Type");
                questOfferReward.EmoteDelay[i] = packet.ReadUInt32("Delay");
            }

            packet.ResetBitReader();

            packet.ReadBit("AutoLaunched");

            ReadQuestRewards(packet, "QuestRewards");

            packet.ReadInt32("QuestPackageID");
            packet.ReadInt32("PortraitGiver");
            packet.ReadInt32("PortraitGiverMount");
            packet.ReadInt32("PortraitTurnIn");

            packet.ResetBitReader();
            uint questTitleLen         = 0;
            uint rewardTextLen         = 0;
            uint portraitGiverTextLen  = 0;
            uint portraitGiverNameLen  = 0;
            uint portraitTurnInTextLen = 0;
            uint portraitTurnInNameLen = 0;

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V8_1_0_28724) && ClientVersion.RemovedInVersion(ClientVersionBuild.V8_1_5_29683))
            {
                questTitleLen         = packet.ReadBits(10);
                rewardTextLen         = packet.ReadBits(12);
                portraitGiverTextLen  = packet.ReadBits(11);
                portraitGiverNameLen  = packet.ReadBits(9);
                portraitTurnInTextLen = packet.ReadBits(11);
                portraitTurnInNameLen = packet.ReadBits(9);
            }
            else
            {
                questTitleLen         = packet.ReadBits(9);
                rewardTextLen         = packet.ReadBits(12);
                portraitGiverTextLen  = packet.ReadBits(10);
                portraitGiverNameLen  = packet.ReadBits(8);
                portraitTurnInTextLen = packet.ReadBits(10);
                portraitTurnInNameLen = packet.ReadBits(8);
            }

            packet.ReadWoWString("QuestTitle", questTitleLen);
            questOfferReward.RewardText = packet.ReadWoWString("RewardText", rewardTextLen);
            packet.ReadWoWString("PortraitGiverText", portraitGiverTextLen);
            packet.ReadWoWString("PortraitGiverName", portraitGiverNameLen);
            packet.ReadWoWString("PortraitTurnInText", portraitTurnInTextLen);
            packet.ReadWoWString("PortraitTurnInName", portraitTurnInNameLen);

            Storage.QuestOfferRewards.Add(questOfferReward, packet.TimeSpan);
        }
Exemplo n.º 30
0
        public static void ReadQuestRewards(Packet packet, params object[] idx)
        {
            packet.ReadInt32("ChoiceItemCount", idx);

            for (var i = 0; i < 6; ++i)
            {
                packet.ReadInt32("ItemID", idx, i);
                packet.ReadInt32("Quantity", idx, i);
            }

            packet.ReadInt32("ItemCount", idx);

            for (var i = 0; i < 4; ++i)
            {
                packet.ReadInt32("ItemID", idx, i);
                packet.ReadInt32("ItemQty", idx, i);
            }

            packet.ReadInt32("Money", idx);
            packet.ReadInt32("XP", idx);
            if (ClientVersion.AddedInVersion(ClientVersionBuild.V7_2_0_23826))
            {
                packet.ReadInt64("ArtifactXP", idx);
            }
            else
            {
                packet.ReadInt32("ArtifactXP", idx);
            }
            packet.ReadInt32("ArtifactCategoryID", idx);
            packet.ReadInt32("Honor", idx);
            packet.ReadInt32("Title", idx);
            packet.ReadInt32("FactionFlags", idx);

            for (var i = 0; i < 5; ++i)
            {
                packet.ReadInt32("FactionID", idx, i);
                packet.ReadInt32("FactionValue", idx, i);
                packet.ReadInt32("FactionOverride", idx, i);
                packet.ReadInt32("FactionCapIn", idx, i);
            }

            for (var i = 0; i < 3; ++i)
            {
                packet.ReadInt32("SpellCompletionDisplayID", idx, i);
            }

            packet.ReadInt32("SpellCompletionID", idx);

            for (var i = 0; i < 4; ++i)
            {
                packet.ReadInt32("CurrencyID", idx, i);
                packet.ReadInt32("CurrencyQty", idx, i);
            }

            packet.ReadInt32("SkillLineID", idx);
            packet.ReadInt32("NumSkillUps", idx);
            packet.ReadInt32("RewardID", idx);

            packet.ResetBitReader();

            packet.ReadBit("IsBoostSpell", idx);
        }