@@ -49,5 +49,185 @@ public static void HandleNameQueryResponse(Packet packet)
49
49
for ( var i = 0 ; i < count ; ++ i )
50
50
response . Responses . Add ( ReadNameCacheLookupResult ( packet , i ) ) ;
51
51
}
52
+
53
+ [ HasSniffData ]
54
+ [ Parser ( Opcode . SMSG_QUERY_CREATURE_RESPONSE ) ]
55
+ public static void HandleCreatureQueryResponse ( Packet packet )
56
+ {
57
+ PacketQueryCreatureResponse response = packet . Holder . QueryCreatureResponse = new PacketQueryCreatureResponse ( ) ;
58
+ var entry = packet . ReadEntry ( "Entry" ) ;
59
+
60
+ CreatureTemplate creature = new CreatureTemplate
61
+ {
62
+ Entry = ( uint ) entry . Key
63
+ } ;
64
+ response . Entry = ( uint ) entry . Key ;
65
+
66
+ Bit hasData = packet . ReadBit ( ) ;
67
+ response . HasData = hasData ;
68
+ if ( ! hasData )
69
+ return ; // nothing to do
70
+
71
+ packet . ResetBitReader ( ) ;
72
+ uint titleLen = packet . ReadBits ( 11 ) ;
73
+ uint titleAltLen = packet . ReadBits ( 11 ) ;
74
+ uint cursorNameLen = packet . ReadBits ( 6 ) ;
75
+ creature . Civilian = packet . ReadBit ( "Civilian" ) ;
76
+ creature . RacialLeader = response . Leader = packet . ReadBit ( "Leader" ) ;
77
+
78
+ var stringLens = new int [ 4 ] [ ] ;
79
+ for ( int i = 0 ; i < 4 ; i ++ )
80
+ {
81
+ stringLens [ i ] = new int [ 2 ] ;
82
+ stringLens [ i ] [ 0 ] = ( int ) packet . ReadBits ( 11 ) ;
83
+ stringLens [ i ] [ 1 ] = ( int ) packet . ReadBits ( 11 ) ;
84
+ }
85
+
86
+ for ( var i = 0 ; i < 4 ; ++ i )
87
+ {
88
+ if ( stringLens [ i ] [ 0 ] > 1 )
89
+ {
90
+ string name = packet . ReadDynamicString ( "Name" , stringLens [ i ] [ 0 ] , i ) ;
91
+ if ( i == 0 )
92
+ creature . Name = response . Name = name ;
93
+ }
94
+ if ( stringLens [ i ] [ 1 ] > 1 )
95
+ {
96
+ string nameAlt = packet . ReadDynamicString ( "NameAlt" , stringLens [ i ] [ 1 ] , i ) ;
97
+ if ( i == 0 )
98
+ creature . FemaleName = response . NameAlt = nameAlt ;
99
+ }
100
+ }
101
+
102
+ creature . TypeFlags = packet . ReadUInt32E < CreatureTypeFlag > ( "Type Flags" ) ;
103
+ response . TypeFlags = ( uint ? ) creature . TypeFlags ?? 0 ;
104
+ creature . TypeFlags2 = response . TypeFlags2 = packet . ReadUInt32 ( "Creature Type Flags 2" ) ;
105
+ packet . ReadUInt32 ( "Creature Type Flags 3" ) ;
106
+
107
+ creature . Type = packet . ReadByteE < CreatureType > ( "CreatureType" ) ;
108
+ creature . Family = packet . ReadInt32E < CreatureFamily > ( "CreatureFamily" ) ;
109
+ creature . Rank = packet . ReadSByteE < CreatureRank > ( "Classification" ) ;
110
+ creature . PetSpellDataID = packet . ReadUInt32 ( "PetSpellDataId" ) ;
111
+ response . Type = ( int ? ) creature . Type ?? 0 ;
112
+ response . Family = ( int ? ) creature . Family ?? 0 ;
113
+ response . Rank = ( int ? ) creature . Rank ?? 0 ;
114
+
115
+ creature . KillCredits = new uint ? [ 2 ] ;
116
+ for ( int i = 0 ; i < 2 ; ++ i )
117
+ {
118
+ creature . KillCredits [ i ] = ( uint ) packet . ReadInt32 ( "ProxyCreatureID" , i ) ;
119
+ response . KillCredits . Add ( creature . KillCredits [ i ] ?? 0 ) ;
120
+ }
121
+
122
+ var displayIdCount = packet . ReadUInt32 ( "DisplayIdCount" ) ;
123
+ packet . ReadSingle ( "TotalProbability" ) ;
124
+
125
+ for ( var i = 0 ; i < displayIdCount ; ++ i )
126
+ {
127
+ CreatureTemplateModel model = new CreatureTemplateModel
128
+ {
129
+ CreatureID = ( uint ) entry . Key ,
130
+ Idx = ( uint ) i
131
+ } ;
132
+
133
+ model . CreatureDisplayID = ( uint ) packet . ReadInt32 ( "CreatureDisplayID" , i ) ;
134
+ model . DisplayScale = packet . ReadSingle ( "DisplayScale" , i ) ;
135
+ model . Probability = packet . ReadSingle ( "Probability" , i ) ;
136
+
137
+ response . Models . Add ( model . CreatureDisplayID ?? 0 ) ;
138
+ Storage . CreatureTemplateModels . Add ( model , packet . TimeSpan ) ;
139
+ }
140
+
141
+ creature . HealthModifier = response . HpMod = packet . ReadSingle ( "HpMulti" ) ;
142
+ creature . ManaModifier = response . ManaMod = packet . ReadSingle ( "EnergyMulti" ) ;
143
+ uint questItems = packet . ReadUInt32 ( "QuestItems" ) ;
144
+ uint questCurrencies = packet . ReadUInt32 ( "QuestCurrencies" ) ;
145
+ creature . MovementID = response . MovementId = ( uint ) packet . ReadInt32 ( "CreatureMovementInfoID" ) ;
146
+ creature . HealthScalingExpansion = packet . ReadInt32E < ClientType > ( "HealthScalingExpansion" ) ;
147
+ response . HpScalingExp = ( uint ? ) creature . HealthScalingExpansion ?? 0 ;
148
+ creature . RequiredExpansion = packet . ReadInt32E < ClientType > ( "RequiredExpansion" ) ;
149
+ response . Expansion = ( uint ? ) creature . RequiredExpansion ?? 0 ;
150
+ creature . VignetteID = ( uint ) packet . ReadInt32 ( "VignetteID" ) ;
151
+ creature . UnitClass = ( uint ) packet . ReadInt32E < Class > ( "UnitClass" ) ;
152
+ creature . CreatureDifficultyID = packet . ReadInt32 ( "CreatureDifficultyID" ) ;
153
+ creature . WidgetSetID = packet . ReadInt32 ( "WidgetSetID" ) ;
154
+ creature . WidgetSetUnitConditionID = packet . ReadInt32 ( "WidgetSetUnitConditionID" ) ;
155
+
156
+ if ( titleLen > 1 )
157
+ creature . SubName = response . Title = packet . ReadCString ( "Title" ) ;
158
+
159
+ if ( titleAltLen > 1 )
160
+ creature . TitleAlt = response . TitleAlt = packet . ReadCString ( "TitleAlt" ) ;
161
+
162
+ if ( cursorNameLen > 1 )
163
+ creature . IconName = response . IconName = packet . ReadCString ( "CursorName" ) ;
164
+
165
+ for ( uint i = 0 ; i < questItems ; ++ i )
166
+ {
167
+ CreatureTemplateQuestItem questItem = new CreatureTemplateQuestItem
168
+ {
169
+ CreatureEntry = ( uint ) entry . Key ,
170
+ Idx = i ,
171
+ ItemId = ( uint ) packet . ReadInt32 < ItemId > ( "QuestItem" , i )
172
+ } ;
173
+
174
+ questItem . DifficultyID = WowPacketParser . Parsing . Parsers . MovementHandler . CurrentDifficultyID ;
175
+
176
+ Storage . CreatureTemplateQuestItems . Add ( questItem , packet . TimeSpan ) ;
177
+ response . QuestItems . Add ( questItem . ItemId ?? 0 ) ;
178
+ }
179
+
180
+ for ( uint i = 0 ; i < questCurrencies ; ++ i )
181
+ {
182
+ CreatureTemplateQuestCurrency questCurrency = new CreatureTemplateQuestCurrency
183
+ {
184
+ CreatureId = ( uint ) entry . Key ,
185
+ CurrencyId = packet . ReadInt32 < CurrencyId > ( "QuestCurrency" , i )
186
+ } ;
187
+
188
+ Storage . CreatureTemplateQuestCurrencies . Add ( questCurrency , packet . TimeSpan ) ;
189
+ response . QuestCurrencies . Add ( questCurrency . CurrencyId ?? 0 ) ;
190
+ }
191
+
192
+ packet . AddSniffData ( StoreNameType . Unit , entry . Key , "QUERY_RESPONSE" ) ;
193
+
194
+ if ( ClientLocale . PacketLocale != LocaleConstant . enUS )
195
+ {
196
+ CreatureTemplateLocale localesCreature = new CreatureTemplateLocale
197
+ {
198
+ ID = ( uint ) entry . Key ,
199
+ Name = creature . Name ,
200
+ NameAlt = creature . FemaleName ,
201
+ Title = creature . SubName ,
202
+ TitleAlt = creature . TitleAlt
203
+ } ;
204
+
205
+ Storage . LocalesCreatures . Add ( localesCreature , packet . TimeSpan ) ;
206
+ }
207
+
208
+ Storage . CreatureTemplates . Add ( creature . Entry . Value , creature , packet . TimeSpan ) ;
209
+
210
+ CreatureTemplateDifficultyWDB creatureTemplateDifficultyWDB = new CreatureTemplateDifficultyWDB
211
+ {
212
+ Entry = creature . Entry ,
213
+ DifficultyID = WowPacketParser . Parsing . Parsers . MovementHandler . CurrentDifficultyID ,
214
+ HealthScalingExpansion = creature . HealthScalingExpansion ,
215
+ HealthModifier = creature . HealthModifier ,
216
+ ManaModifier = creature . ManaModifier ,
217
+ CreatureDifficultyID = creature . CreatureDifficultyID ,
218
+ TypeFlags = creature . TypeFlags ,
219
+ TypeFlags2 = creature . TypeFlags2
220
+ } ;
221
+ creatureTemplateDifficultyWDB = WowPacketParser . SQL . SQLDatabase . CheckCreatureTemplateDifficultyWDBFallbacks ( creatureTemplateDifficultyWDB , creatureTemplateDifficultyWDB . DifficultyID ) ;
222
+ Storage . CreatureTemplateDifficultiesWDB . Add ( creatureTemplateDifficultyWDB ) ;
223
+
224
+ ObjectName objectName = new ObjectName
225
+ {
226
+ ObjectType = StoreNameType . Unit ,
227
+ ID = entry . Key ,
228
+ Name = creature . Name
229
+ } ;
230
+ Storage . ObjectNames . Add ( objectName , packet . TimeSpan ) ;
231
+ }
52
232
}
53
233
}
0 commit comments