TrinityCore
Loading...
Searching...
No Matches
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 "PacketOperators.h"
20#include "Spell.h"
21#include "UnitDefines.h"
22
24{
26{
27 data << worldTextViewer.ViewerGUID;
28 data << OptionalInit(worldTextViewer.ColorType);
29 data << OptionalInit(worldTextViewer.ScaleType);
30 data.FlushBits();
31
32 if (worldTextViewer.ColorType)
33 data << uint8(*worldTextViewer.ColorType);
34
35 if (worldTextViewer.ScaleType)
36 data << uint8(*worldTextViewer.ScaleType);
37
38 return data;
39}
40
42{
43 *this << Me;
44 *this << CasterGUID;
45 *this << CastID;
46 *this << int32(SpellID);
47 *this << Visual;
48 *this << int32(Damage);
49 *this << int32(OriginalDamage);
50 *this << int32(Overkill);
51 *this << uint8(SchoolMask);
52 *this << int32(Absorbed);
53 *this << int32(Resisted);
54 *this << int32(ShieldBlock);
55 *this << int32(ReflectingSpellID);
56 *this << int32(Flags);
57 *this << Size<uint32>(WorldTextViewers);
58 *this << Size<uint32>(Supporters);
59
60 for (Spells::SpellSupportInfo const& supportInfo : Supporters)
61 *this << supportInfo;
62
63 *this << Bits<1>(Periodic);
64 *this << Bits<1>(false); // Debug info
67 FlushBits();
68
69 for (CombatWorldTextViewerInfo const& worldTextViewer : WorldTextViewers)
70 *this << worldTextViewer;
71
73 if (ContentTuning)
74 *this << *ContentTuning;
75
76 return &_worldPacket;
77}
78
80{
81 *this << Victim;
82 *this << uint8(Type);
83 *this << int32(Amount);
84 *this << int32(Resisted);
85 *this << int32(Absorbed);
87 FlushBits();
89
90 return &_worldPacket;
91}
92
94{
95 *this << Caster;
96 *this << int32(SpellID);
97 *this << Size<uint32>(*Effects);
98
99 for (SpellLogEffect const& effect : *Effects)
100 {
101 *this << int32(effect.Effect);
102
103 *this << uint32(effect.PowerDrainTargets ? effect.PowerDrainTargets->size() : 0);
104 *this << uint32(effect.ExtraAttacksTargets ? effect.ExtraAttacksTargets->size() : 0);
105 *this << uint32(effect.DurabilityDamageTargets ? effect.DurabilityDamageTargets->size() : 0);
106 *this << uint32(effect.GenericVictimTargets ? effect.GenericVictimTargets->size() : 0);
107 *this << uint32(effect.TradeSkillTargets ? effect.TradeSkillTargets->size() : 0);
108 *this << uint32(effect.FeedPetTargets ? effect.FeedPetTargets->size() : 0);
109
110 if (effect.PowerDrainTargets)
111 {
112 for (SpellLogEffectPowerDrainParams const& powerDrainTarget : *effect.PowerDrainTargets)
113 {
114 *this << powerDrainTarget.Victim;
115 *this << uint32(powerDrainTarget.Points);
116 *this << int8(powerDrainTarget.PowerType);
117 *this << float(powerDrainTarget.Amplitude);
118 }
119 }
120
121 if (effect.ExtraAttacksTargets)
122 {
123 for (SpellLogEffectExtraAttacksParams const& extraAttacksTarget : *effect.ExtraAttacksTargets)
124 {
125 *this << extraAttacksTarget.Victim;
126 *this << uint32(extraAttacksTarget.NumAttacks);
127 }
128 }
129
130 if (effect.DurabilityDamageTargets)
131 {
132 for (SpellLogEffectDurabilityDamageParams const& durabilityDamageTarget : *effect.DurabilityDamageTargets)
133 {
134 *this << durabilityDamageTarget.Victim;
135 *this << int32(durabilityDamageTarget.ItemID);
136 *this << int32(durabilityDamageTarget.Amount);
137 }
138 }
139
140 if (effect.GenericVictimTargets)
141 for (SpellLogEffectGenericVictimParams const& genericVictimTarget : *effect.GenericVictimTargets)
142 *this << genericVictimTarget.Victim;
143
144 if (effect.TradeSkillTargets)
145 for (SpellLogEffectTradeSkillItemParams const& tradeSkillTarget : *effect.TradeSkillTargets)
146 *this << int32(tradeSkillTarget.ItemID);
147
148 if (effect.FeedPetTargets)
149 for (SpellLogEffectFeedPetParams const& feedPetTarget : *effect.FeedPetTargets)
150 *this << int32(feedPetTarget.ItemID);
151 }
152
154 FlushBits();
155 WriteLogData();
156
157 return &_worldPacket;
158}
159
161{
162 *this << TargetGUID;
163 *this << CasterGUID;
164 *this << int32(SpellID);
165 *this << int32(Health);
166 *this << int32(OriginalHeal);
167 *this << int32(OverHeal);
168 *this << int32(Absorbed);
169 *this << Size<uint32>(Supporters);
170
171 for (Spells::SpellSupportInfo const& supportInfo : Supporters)
172 *this << supportInfo;
173
174 *this << Bits<1>(Crit);
175 *this << OptionalInit(CritRollMade);
178 *this << OptionalInit(ContentTuning);
179 FlushBits();
180
181 WriteLogData();
182
183 if (CritRollMade)
184 *this << *CritRollMade;
185
186 if (CritRollNeeded)
187 *this << *CritRollNeeded;
188
189 if (ContentTuning)
190 *this << *ContentTuning;
191
192 return &_worldPacket;
193}
194
196{
197 data << float(debugInfo.CritRollMade);
198 data << float(debugInfo.CritRollNeeded);
199
200 return data;
201}
202
204{
205 data << int32(effect.Effect);
206 data << int32(effect.Amount);
207 data << int32(effect.OriginalDamage);
208 data << int32(effect.OverHealOrKill);
209 data << int32(effect.SchoolMaskOrPower);
210 data << int32(effect.AbsorbedOrAmplitude);
211 data << int32(effect.Resisted);
212 data << Size<uint32>(effect.Supporters);
213
214 for (Spells::SpellSupportInfo const& supportInfo : effect.Supporters)
215 data << supportInfo;
216
217 data << Bits<1>(effect.Crit);
218 data << OptionalInit(effect.DebugInfo);
219 data << OptionalInit(effect.ContentTuning);
220 data.FlushBits();
221
222 if (effect.ContentTuning)
223 data << *effect.ContentTuning;
224
225 if (effect.DebugInfo)
226 data << *effect.DebugInfo;
227
228 return data;
229}
230
232{
233 *this << TargetGUID;
234 *this << CasterGUID;
235 *this << int32(SpellID);
236 *this << Size<uint32>(Effects);
238 FlushBits();
239
240 for (PeriodicAuraLogEffect const& effect : Effects)
241 *this << effect;
242
243 WriteLogData();
244
245 return &_worldPacket;
246}
247
249{
254 _worldPacket << Bits<1>(HideFromCombatLog);
256
257 return &_worldPacket;
258}
259
261{
262 *this << TargetGUID;
263 *this << CasterGUID;
264
265 *this << int32(SpellID);
266 *this << int8(Type);
267 *this << int32(Amount);
268 *this << int32(OverEnergize);
269
271 FlushBits();
272 WriteLogData();
273
274 return &_worldPacket;
275}
276
285
287{
288 buffer << float(missDebug.HitRoll);
289 buffer << float(missDebug.HitRollNeeded);
290
291 return buffer;
292}
293
295{
296 buffer << missEntry.Victim;
297 buffer << uint8(missEntry.MissReason);
298 buffer << OptionalInit(missEntry.Debug);
299 if (missEntry.Debug)
300 buffer << *missEntry.Debug;
301
302 buffer.FlushBits();
303
304 return buffer;
305}
306
308{
311 _worldPacket << Size<uint32>(Entries);
312 _worldPacket << Bits<1>(HideFromCombatLog);
313 for (SpellLogMissEntry const& missEntry : Entries)
314 _worldPacket << missEntry;
315
316 return &_worldPacket;
317}
318
336
338{
342 _worldPacket << Bits<1>(IsPeriodic);
344
345 return &_worldPacket;
346}
347
349{
350 *this << Attacker;
351 *this << Defender;
352 *this << int32(SpellID);
353 *this << int32(TotalDamage);
354 *this << int32(OriginalDamage);
355 *this << int32(OverKill);
356 *this << int32(SchoolMask);
357 *this << int32(LogAbsorbed);
359 FlushBits();
360 WriteLogData();
361
362 return &_worldPacket;
363}
364
366{
367 ByteBuffer attackRoundInfo;
368 attackRoundInfo << uint32(Flags);
369 attackRoundInfo << AttackerGUID;
370 attackRoundInfo << VictimGUID;
371 attackRoundInfo << int32(Damage);
372 attackRoundInfo << int32(OriginalDamage);
373 attackRoundInfo << int32(OverDamage);
374 attackRoundInfo << uint8(SubDmg.has_value());
375 if (SubDmg)
376 {
377 attackRoundInfo << int32(SubDmg->SchoolMask);
378 attackRoundInfo << float(SubDmg->FDamage);
379 attackRoundInfo << int32(SubDmg->Damage);
381 attackRoundInfo << int32(SubDmg->Absorbed);
383 attackRoundInfo << int32(SubDmg->Resisted);
384 }
385
386 attackRoundInfo << uint8(VictimState);
387 attackRoundInfo << uint32(AttackerState);
388 attackRoundInfo << uint32(MeleeSpellID);
389 if (Flags & HITINFO_BLOCK)
390 attackRoundInfo << int32(BlockAmount);
391
393 attackRoundInfo << int32(RageGained);
394
395 if (Flags & HITINFO_UNK1)
396 {
397 attackRoundInfo << uint32(HitInfo.ArmorReduction);
398 attackRoundInfo << float(HitInfo.CritRollNeeded);
399 attackRoundInfo << float(HitInfo.CombatRoll);
400 attackRoundInfo << float(HitInfo.MissChance);
401 attackRoundInfo << float(HitInfo.DodgeChance);
402 attackRoundInfo << float(HitInfo.ParryChance);
403 attackRoundInfo << float(HitInfo.BlockChance);
404 attackRoundInfo << float(HitInfo.GlanceChance);
405 attackRoundInfo << float(HitInfo.CrushChance);
406 attackRoundInfo << float(HitInfo.MinDamage);
407 attackRoundInfo << float(HitInfo.MaxDamage);
408 attackRoundInfo << uint32(HitInfo.SinceLastSwing);
409 }
410
412 attackRoundInfo << float(BlockRoll);
413
414 attackRoundInfo << ContentTuning;
415
417 FlushBits();
418 WriteLogData();
419
420 *this << Size<uint32>(attackRoundInfo);
421 _worldPacket.append(attackRoundInfo);
422 _fullLogPacket.append(attackRoundInfo);
423
424 return &_worldPacket;
425}
426
428{
429 buffer << int32(dispellData.SpellID);
430 buffer << Bits<1>(dispellData.Harmful);
431 buffer << OptionalInit(dispellData.Rolled);
432 buffer << OptionalInit(dispellData.Needed);
433 buffer.FlushBits();
434
435 if (dispellData.Rolled)
436 buffer << int32(*dispellData.Rolled);
437
438 if (dispellData.Needed)
439 buffer << int32(*dispellData.Needed);
440
441 return buffer;
442}
443
445{
446 _worldPacket << Bits<1>(IsSteal);
447 _worldPacket << Bits<1>(IsBreak);
451
452 _worldPacket << Size<uint32>(DispellData);
453 for (SpellDispellData const& data : DispellData)
454 _worldPacket << data;
455
456 return &_worldPacket;
457}
458
460{
461 *this << Attacker;
462 *this << Victim;
463 *this << int32(AbsorbedSpellID);
464 *this << int32(AbsorbSpellID);
465 *this << Caster;
466 *this << int32(Absorbed);
467 *this << int32(OriginalDamage);
468 *this << Size<uint32>(Supporters);
469
470 for (Spells::SpellSupportInfo const& supportInfo : Supporters)
471 *this << supportInfo;
472
473 *this << Bits<1>(Crit);
475 FlushBits();
476 WriteLogData();
477
478 return &_worldPacket;
479}
480
482{
483 *this << Target;
484 *this << AbsorbCaster;
485 *this << Healer;
486 *this << int32(AbsorbSpellID);
487 *this << int32(AbsorbedSpellID);
488 *this << int32(Absorbed);
489 *this << int32(OriginalHeal);
490
492 *this << OptionalInit(ContentTuning);
493 FlushBits();
494
495 WriteLogData();
496
497 if (ContentTuning)
498 *this << *ContentTuning;
499
500 return &_worldPacket;
501}
502}
uint8_t uint8
Definition Define.h:156
int8_t int8
Definition Define.h:152
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
HitInfo
@ HITINFO_PARTIAL_ABSORB
@ HITINFO_FULL_RESIST
@ HITINFO_BLOCK
@ HITINFO_UNK12
@ HITINFO_RAGE_GAIN
@ HITINFO_FULL_ABSORB
@ HITINFO_UNK1
@ HITINFO_PARTIAL_RESIST
VictimState
Definition Unit.h:48
void append(T value)
Definition ByteBuffer.h:130
void FlushBits()
Definition ByteBuffer.h:141
WorldPacket const * Write() override
WorldPacket const * Write() override
std::vector< Spells::SpellSupportInfo > Supporters
std::vector< SpellDispellData > DispellData
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
std::vector< SpellLogMissEntry > Entries
WorldPacket const * Write() override
std::vector< CombatWorldTextViewerInfo > WorldTextViewers
Optional< Spells::ContentTuningParams > ContentTuning
std::vector< Spells::SpellSupportInfo > Supporters
std::vector< PeriodicAuraLogEffect > Effects
WorldPacket _worldPacket
Definition Packet.h:43
ByteBuffer & operator<<(ByteBuffer &data, CombatWorldTextViewerInfo const &worldTextViewer)
OptionalInitWriter< T > OptionalInit(Optional< T > const &value)
std::vector< Spells::SpellSupportInfo > Supporters
Optional< Spells::ContentTuningParams > ContentTuning
Optional< PeriodicalAuraLogEffectDebugInfo > DebugInfo