CPP 437
Lick Me By SkyFire on 30th January 2021 01:11:17 PM
  1. void Unit::SendAttackStateUpdate(CalcDamageInfo* damageInfo)
  2. {
  3.     TC_LOG_DEBUG("server", "WORLD: Sending SMSG_ATTACKERSTATEUPDATE");
  4.  
  5.     uint32 count = 1;
  6.     size_t maxsize = 4+5+5+4+4+1+4+4+4+4+4+1+4+4+4+4+4*12;
  7.     WorldPacket data(SMSG_ATTACKERSTATEUPDATE, maxsize);    // we guess size
  8.     data << uint32(damageInfo->HitInfo);
  9.     data.append(damageInfo->attacker->GetPackGUID());
  10.     data.append(damageInfo->target->GetPackGUID());
  11.     data << uint32(damageInfo->damage);                     // Full damage
  12.     int32 overkill = damageInfo->damage - damageInfo->target->GetHealth();
  13.     data << uint32(overkill < 0 ? 0 : overkill);            // Overkill
  14.     data << uint8(count);                                   // Sub damage count
  15.  
  16.     for (uint32 i = 0; i < count; ++i)
  17.     {
  18.         data << uint32(damageInfo->damageSchoolMask);       // School of sub damage
  19.         data << float(damageInfo->damage);                  // sub damage
  20.         data << uint32(damageInfo->damage);                 // Sub Damage
  21.     }
  22.  
  23.     if (damageInfo->HitInfo & (HITINFO_FULL_ABSORB | HITINFO_PARTIAL_ABSORB))
  24.     {
  25.         for (uint32 i = 0; i < count; ++i)
  26.             data << uint32(damageInfo->absorb);             // Absorb
  27.     }
  28.  
  29.     if (damageInfo->HitInfo & (HITINFO_FULL_RESIST | HITINFO_PARTIAL_RESIST))
  30.     {
  31.         for (uint32 i = 0; i < count; ++i)
  32.             data << uint32(damageInfo->resist);             // Resist
  33.     }
  34.  
  35.     data << uint8(damageInfo->TargetState);
  36.     data << uint32(0);  // Unknown attackerstate
  37.     data << uint32(0);  // Melee spellid
  38.  
  39.     if (damageInfo->HitInfo & HITINFO_BLOCK)
  40.         data << uint32(damageInfo->blocked_amount);
  41.  
  42.     if (damageInfo->HitInfo & HITINFO_RAGE_GAIN)
  43.         data << uint32(0);
  44.  
  45.     //! Probably used for debugging purposes, as it is not known to appear on retail servers
  46.     if (damageInfo->HitInfo & HITINFO_UNK1)
  47.     {
  48.         data << uint32(0);
  49.         data << float(0);
  50.         data << float(0);
  51.         data << float(0);
  52.         data << float(0);
  53.         data << float(0);
  54.         data << float(0);
  55.         data << float(0);
  56.         data << float(0);
  57.         for (uint8 i = 0; i < 2; ++i)
  58.         {
  59.             data << float(0);
  60.             data << float(0);
  61.         }
  62.         data << uint32(0);
  63.     }
  64.  
  65.     if (damageInfo->HitInfo & 0x3000)
  66.         data << float(0);
  67.  
  68.     SendMessageToSet(&data, true);
  69. }
  70.  
  71. void Unit::SendAttackStateUpdate(uint32 HitInfo, Unit* target, uint8 /*SwingType*/, SpellSchoolMask damageSchoolMask, uint32 Damage, uint32 AbsorbDamage, uint32 Resist, VictimState TargetState, uint32 BlockedAmount)
  72. {
  73.     CalcDamageInfo dmgInfo;
  74.     dmgInfo.HitInfo = HitInfo;
  75.     dmgInfo.attacker = this;
  76.     dmgInfo.target = target;
  77.     dmgInfo.damage = Damage - AbsorbDamage - Resist - BlockedAmount;
  78.     dmgInfo.damageSchoolMask = damageSchoolMask;
  79.     dmgInfo.absorb = AbsorbDamage;
  80.     dmgInfo.resist = Resist;
  81.     dmgInfo.TargetState = TargetState;
  82.     dmgInfo.blocked_amount = BlockedAmount;
  83.     SendAttackStateUpdate(&dmgInfo);
  84. }

Yourpaste is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.