TrinityCore
CombatLogPackets.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "CombatLogPackets.h"
19#include "UnitDefines.h"
20
22{
24{
25 data << worldTextViewer.ViewerGUID;
26 data.WriteBit(worldTextViewer.ColorType.has_value());
27 data.WriteBit(worldTextViewer.ScaleType.has_value());
28 data.FlushBits();
29
30 if (worldTextViewer.ColorType)
31 data << uint8(*worldTextViewer.ColorType);
32
33 if (worldTextViewer.ScaleType)
34 data << uint8(*worldTextViewer.ScaleType);
35
36 return data;
37}
38
40{
41 *this << Me;
42 *this << CasterGUID;
43 *this << CastID;
44 *this << int32(SpellID);
45 *this << Visual;
46 *this << int32(Damage);
47 *this << int32(OriginalDamage);
48 *this << int32(Overkill);
49 *this << uint8(SchoolMask);
50 *this << int32(Absorbed);
51 *this << int32(Resisted);
52 *this << int32(ShieldBlock);
53 *this << uint32(WorldTextViewers.size());
54 *this << uint32(Supporters.size());
55
56 for (Spells::SpellSupportInfo const& supportInfo : Supporters)
57 *this << supportInfo;
58
60 WriteBits(Flags, 7);
61 WriteBit(false); // Debug info
63 WriteBit(ContentTuning.has_value());
64 FlushBits();
65
66 for (CombatWorldTextViewerInfo const& worldTextViewer : WorldTextViewers)
67 *this << worldTextViewer;
68
70 if (ContentTuning)
71 *this << *ContentTuning;
72
73 return &_worldPacket;
74}
75
77{
78 *this << Victim;
79 *this << uint8(Type);
80 *this << int32(Amount);
81 *this << int32(Resisted);
82 *this << int32(Absorbed);
84 FlushBits();
86
87 return &_worldPacket;
88}
89
91{
92 *this << Caster;
93 *this << int32(SpellID);
94 *this << uint32(Effects->size());
95
96 for (SpellLogEffect const& effect : *Effects)
97 {
98 *this << int32(effect.Effect);
99
100 *this << uint32(effect.PowerDrainTargets ? effect.PowerDrainTargets->size() : 0);
101 *this << uint32(effect.ExtraAttacksTargets ? effect.ExtraAttacksTargets->size() : 0);
102 *this << uint32(effect.DurabilityDamageTargets ? effect.DurabilityDamageTargets->size() : 0);
103 *this << uint32(effect.GenericVictimTargets ? effect.GenericVictimTargets->size() : 0);
104 *this << uint32(effect.TradeSkillTargets ? effect.TradeSkillTargets->size() : 0);
105 *this << uint32(effect.FeedPetTargets ? effect.FeedPetTargets->size() : 0);
106
107 if (effect.PowerDrainTargets)
108 {
109 for (SpellLogEffectPowerDrainParams const& powerDrainTarget : *effect.PowerDrainTargets)
110 {
111 *this << powerDrainTarget.Victim;
112 *this << uint32(powerDrainTarget.Points);
113 *this << int8(powerDrainTarget.PowerType);
114 *this << float(powerDrainTarget.Amplitude);
115 }
116 }
117
118 if (effect.ExtraAttacksTargets)
119 {
120 for (SpellLogEffectExtraAttacksParams const& extraAttacksTarget : *effect.ExtraAttacksTargets)
121 {
122 *this << extraAttacksTarget.Victim;
123 *this << uint32(extraAttacksTarget.NumAttacks);
124 }
125 }
126
127 if (effect.DurabilityDamageTargets)
128 {
129 for (SpellLogEffectDurabilityDamageParams const& durabilityDamageTarget : *effect.DurabilityDamageTargets)
130 {
131 *this << durabilityDamageTarget.Victim;
132 *this << int32(durabilityDamageTarget.ItemID);
133 *this << int32(durabilityDamageTarget.Amount);
134 }
135 }
136
137 if (effect.GenericVictimTargets)
138 for (SpellLogEffectGenericVictimParams const& genericVictimTarget : *effect.GenericVictimTargets)
139 *this << genericVictimTarget.Victim;
140
141 if (effect.TradeSkillTargets)
142 for (SpellLogEffectTradeSkillItemParams const& tradeSkillTarget : *effect.TradeSkillTargets)
143 *this << int32(tradeSkillTarget.ItemID);
144
145 if (effect.FeedPetTargets)
146 for (SpellLogEffectFeedPetParams const& feedPetTarget : *effect.FeedPetTargets)
147 *this << int32(feedPetTarget.ItemID);
148 }
149
151 FlushBits();
152 WriteLogData();
153
154 return &_worldPacket;
155}
156
158{
159 *this << TargetGUID;
160 *this << CasterGUID;
161 *this << int32(SpellID);
162 *this << int32(Health);
163 *this << int32(OriginalHeal);
164 *this << int32(OverHeal);
165 *this << int32(Absorbed);
166 *this << uint32(Supporters.size());
167
168 for (Spells::SpellSupportInfo const& supportInfo : Supporters)
169 *this << supportInfo;
170
171 WriteBit(Crit);
172 WriteBit(CritRollMade.has_value());
173 WriteBit(CritRollNeeded.has_value());
175 WriteBit(ContentTuning.has_value());
176 FlushBits();
177
178 WriteLogData();
179
180 if (CritRollMade)
181 *this << *CritRollMade;
182
183 if (CritRollNeeded)
184 *this << *CritRollNeeded;
185
186 if (ContentTuning)
187 *this << *ContentTuning;
188
189 return &_worldPacket;
190}
191
193{
194 *this << TargetGUID;
195 *this << CasterGUID;
196 *this << int32(SpellID);
197 *this << uint32(Effects.size());
199 FlushBits();
200
201 for (SpellLogEffect const& effect : Effects)
202 {
203 *this << int32(effect.Effect);
204 *this << int32(effect.Amount);
205 *this << int32(effect.OriginalDamage);
206 *this << int32(effect.OverHealOrKill);
207 *this << int32(effect.SchoolMaskOrPower);
208 *this << int32(effect.AbsorbedOrAmplitude);
209 *this << int32(effect.Resisted);
210 *this << uint32(effect.Supporters.size());
211
212 for (Spells::SpellSupportInfo const& supportInfo : effect.Supporters)
213 *this << supportInfo;
214
215 WriteBit(effect.Crit);
216 WriteBit(effect.DebugInfo.has_value());
217 WriteBit(effect.ContentTuning.has_value());
218 FlushBits();
219
220 if (effect.ContentTuning)
221 *this << *effect.ContentTuning;
222
223 if (effect.DebugInfo)
224 {
225 *this << float(effect.DebugInfo->CritRollMade);
226 *this << float(effect.DebugInfo->CritRollNeeded);
227 }
228 }
229
230 WriteLogData();
231
232 return &_worldPacket;
233}
234
236{
241
242 return &_worldPacket;
243}
244
246{
247 *this << TargetGUID;
248 *this << CasterGUID;
249
250 *this << int32(SpellID);
251 *this << int8(Type);
252 *this << int32(Amount);
253 *this << int32(OverEnergize);
254
256 FlushBits();
257 WriteLogData();
258
259 return &_worldPacket;
260}
261
263{
267
268 return &_worldPacket;
269}
270
272{
273 buffer << float(missDebug.HitRoll);
274 buffer << float(missDebug.HitRollNeeded);
275 return buffer;
276}
277
279{
280 buffer << missEntry.Victim;
281 buffer << uint8(missEntry.MissReason);
282 if (buffer.WriteBit(missEntry.Debug.has_value()))
283 buffer << *missEntry.Debug;
284
285 buffer.FlushBits();
286 return buffer;
287}
288
290{
293 _worldPacket << uint32(Entries.size());
294 for (SpellLogMissEntry const& missEntry : Entries)
295 _worldPacket << missEntry;
296
297 return &_worldPacket;
298}
299
301{
305 _worldPacket.WriteBit(Rolled.has_value());
306 _worldPacket.WriteBit(Needed.has_value());
308
309 if (Rolled)
311
312 if (Needed)
314
315 return &_worldPacket;
316}
317
319{
325
326 return &_worldPacket;
327}
328
330{
331 *this << Attacker;
332 *this << Defender;
333 *this << int32(SpellID);
334 *this << int32(TotalDamage);
335 *this << int32(OriginalDamage);
336 *this << int32(OverKill);
337 *this << int32(SchoolMask);
338 *this << int32(LogAbsorbed);
340 FlushBits();
341 WriteLogData();
342
343 return &_worldPacket;
344}
345
347{
348 ByteBuffer attackRoundInfo;
349 attackRoundInfo << uint32(HitInfo);
350 attackRoundInfo << AttackerGUID;
351 attackRoundInfo << VictimGUID;
352 attackRoundInfo << int32(Damage);
353 attackRoundInfo << int32(OriginalDamage);
354 attackRoundInfo << int32(OverDamage);
355 attackRoundInfo << uint8(SubDmg.has_value());
356 if (SubDmg)
357 {
358 attackRoundInfo << int32(SubDmg->SchoolMask);
359 attackRoundInfo << float(SubDmg->FDamage);
360 attackRoundInfo << int32(SubDmg->Damage);
362 attackRoundInfo << int32(SubDmg->Absorbed);
364 attackRoundInfo << int32(SubDmg->Resisted);
365 }
366
367 attackRoundInfo << uint8(VictimState);
368 attackRoundInfo << uint32(AttackerState);
369 attackRoundInfo << uint32(MeleeSpellID);
371 attackRoundInfo << int32(BlockAmount);
372
374 attackRoundInfo << int32(RageGained);
375
376 if (HitInfo & HITINFO_UNK1)
377 {
378 attackRoundInfo << uint32(UnkState.State1);
379 attackRoundInfo << float(UnkState.State2);
380 attackRoundInfo << float(UnkState.State3);
381 attackRoundInfo << float(UnkState.State4);
382 attackRoundInfo << float(UnkState.State5);
383 attackRoundInfo << float(UnkState.State6);
384 attackRoundInfo << float(UnkState.State7);
385 attackRoundInfo << float(UnkState.State8);
386 attackRoundInfo << float(UnkState.State9);
387 attackRoundInfo << float(UnkState.State10);
388 attackRoundInfo << float(UnkState.State11);
389 attackRoundInfo << uint32(UnkState.State12);
390 }
391
393 attackRoundInfo << float(Unk);
394
395 attackRoundInfo << ContentTuning;
396
398 FlushBits();
399 WriteLogData();
400
401 *this << uint32(attackRoundInfo.size());
402 _worldPacket.append(attackRoundInfo);
403 _fullLogPacket.append(attackRoundInfo);
404
405 return &_worldPacket;
406}
407
409{
410 buffer << int32(dispellData.SpellID);
411 buffer.WriteBit(dispellData.Harmful);
412 buffer.WriteBit(dispellData.Rolled.has_value());
413 buffer.WriteBit(dispellData.Needed.has_value());
414 if (dispellData.Rolled.has_value())
415 buffer << int32(*dispellData.Rolled);
416 if (dispellData.Needed.has_value())
417 buffer << int32(*dispellData.Needed);
418
419 buffer.FlushBits();
420
421 return buffer;
422}
423
425{
431
433 for (SpellDispellData const& data : DispellData)
434 _worldPacket << data;
435
436 return &_worldPacket;
437}
438
440{
441 *this << Attacker;
442 *this << Victim;
443 *this << int32(AbsorbedSpellID);
444 *this << int32(AbsorbSpellID);
445 *this << Caster;
446 *this << int32(Absorbed);
447 *this << int32(OriginalDamage);
448 *this << uint32(Supporters.size());
449
450 for (Spells::SpellSupportInfo const& supportInfo : Supporters)
451 *this << supportInfo;
452
453 WriteBit(Unk);
455 FlushBits();
456 WriteLogData();
457
458 return &_worldPacket;
459}
460
462{
472
473 if (ContentTuning)
475
476 return &_worldPacket;
477}
478}
uint8_t uint8
Definition: Define.h:144
int8_t int8
Definition: Define.h:140
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
HitInfo
Definition: UnitDefines.h:475
@ HITINFO_PARTIAL_ABSORB
Definition: UnitDefines.h:483
@ HITINFO_FULL_RESIST
Definition: UnitDefines.h:484
@ HITINFO_BLOCK
Definition: UnitDefines.h:490
@ HITINFO_UNK12
Definition: UnitDefines.h:489
@ HITINFO_RAGE_GAIN
Definition: UnitDefines.h:500
@ HITINFO_FULL_ABSORB
Definition: UnitDefines.h:482
@ HITINFO_UNK1
Definition: UnitDefines.h:477
@ HITINFO_PARTIAL_RESIST
Definition: UnitDefines.h:485
VictimState
Definition: Unit.h:47
void append(T value)
Definition: ByteBuffer.h:137
bool WriteBit(bool bit)
Definition: ByteBuffer.h:169
size_t size() const
Definition: ByteBuffer.h:530
void FlushBits()
Definition: ByteBuffer.h:149
void WriteBits(uint32 value, uint32 bitCount)
WorldPacket const * Write() override
WorldPacket const * Write() override
std::vector< Spells::SpellSupportInfo > Supporters
WorldPacket const * Write() override
std::vector< SpellDispellData > DispellData
WorldPacket const * Write() override
WorldPacket const * Write() override
std::vector< SpellLogEffect > const * Effects
Optional< Spells::ContentTuningParams > ContentTuning
std::vector< Spells::SpellSupportInfo > Supporters
WorldPacket const * Write() override
Optional< Spells::ContentTuningParams > ContentTuning
WorldPacket const * Write() override
std::vector< CombatWorldTextViewerInfo > WorldTextViewers
Optional< Spells::ContentTuningParams > ContentTuning
std::vector< Spells::SpellSupportInfo > Supporters
WorldPacket _worldPacket
Definition: Packet.h:43
ByteBuffer & operator<<(ByteBuffer &data, CombatWorldTextViewerInfo const &worldTextViewer)