*Allow damage shield hits to miss.

*Send overkill on damage shield hit.
*Correct data order for execute log of power take effects.

--HG--
branch : trunk
This commit is contained in:
QAston
2010-08-29 03:38:21 +02:00
parent f67441b863
commit 2d877bbbfd
5 changed files with 43 additions and 44 deletions
+37 -36
View File
@@ -1400,13 +1400,8 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da
void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss)
{
if (!damageInfo)
return;
Unit *pVictim = damageInfo->target;
if (!pVictim)
return;
if (!pVictim->isAlive() || pVictim->hasUnitState(UNIT_STAT_UNATTACKABLE) || (pVictim->GetTypeId() == TYPEID_UNIT && pVictim->ToCreature()->IsInEvadeMode()))
return;
@@ -1492,43 +1487,39 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss)
// Do effect if any damage done to target
if (damageInfo->damage)
{
// victim's damage shield
std::set<AuraEffect*> alreadyDone;
uint32 removedAuras = pVictim->m_removedAurasCount;
AuraEffectList const& vDamageShields = pVictim->GetAuraEffectsByType(SPELL_AURA_DAMAGE_SHIELD);
for (AuraEffectList::const_iterator i = vDamageShields.begin(), next = vDamageShields.begin(); i != vDamageShields.end(); i = next)
for (AuraEffectList::const_iterator dmgShieldItr = vDamageShields.begin(); dmgShieldItr != vDamageShields.end(); ++dmgShieldItr)
{
++next;
if (alreadyDone.find(*i) == alreadyDone.end())
{
alreadyDone.insert(*i);
uint32 damage=(*i)->GetAmount();
SpellEntry const *i_spellProto = (*i)->GetSpellProto();
//Calculate absorb resist ??? no data in opcode for this possibly unable to absorb or resist?
//uint32 absorb;
//uint32 resist;
//CalcAbsorbResist(pVictim, SpellSchools(spellProto->School), SPELL_DIRECT_DAMAGE, damage, &absorb, &resist);
//damage-=absorb + resist;
SpellEntry const *i_spellProto = (*dmgShieldItr)->GetSpellProto();
// Damage shield can be resisted...
if (SpellMissInfo missInfo = pVictim->SpellHitResult(this, i_spellProto ,false))
{
pVictim->SendSpellMiss(this, i_spellProto->Id, missInfo);
continue;
}
// ...or immuned
if (IsImmunedToDamage(i_spellProto))
{
pVictim->SendSpellDamageImmune(this, i_spellProto->Id);
continue;
}
pVictim->DealDamageMods(this,damage,NULL);
uint32 damage = (*dmgShieldItr)->GetAmount();
WorldPacket data(SMSG_SPELLDAMAGESHIELD,(8+8+4+4+4+4));
data << uint64(pVictim->GetGUID());
data << uint64(GetGUID());
data << uint32(i_spellProto->Id);
data << uint32(damage); // Damage
data << uint32(0); // Overkill
data << uint32(i_spellProto->SchoolMask);
pVictim->SendMessageToSet(&data, true);
// No Unit::CalcAbsorbResist here - opcode doesn't send that data - this damage is probably not affected by that
pVictim->DealDamageMods(this,damage,NULL);
pVictim->DealDamage(this, damage, 0, SPELL_DIRECT_DAMAGE, GetSpellSchoolMask(i_spellProto), i_spellProto, true);
WorldPacket data(SMSG_SPELLDAMAGESHIELD,(8+8+4+4+4+4));
data << uint64(pVictim->GetGUID());
data << uint64(GetGUID());
data << uint32(i_spellProto->Id);
data << uint32(damage); // Damage
int32 overkill = damage - GetHealth();
data << uint32(overkill > 0 ? overkill : 0); // Overkill
data << uint32(i_spellProto->SchoolMask);
pVictim->SendMessageToSet(&data, true);
if (pVictim->m_removedAurasCount > removedAuras)
{
removedAuras = pVictim->m_removedAurasCount;
next = vDamageShields.begin();
}
}
pVictim->DealDamage(this, damage, 0, SPELL_DIRECT_DAMAGE, GetSpellSchoolMask(i_spellProto), i_spellProto, true);
}
}
}
@@ -5223,6 +5214,16 @@ void Unit::SendSpellMiss(Unit *target, uint32 spellID, SpellMissInfo missInfo)
SendMessageToSet(&data, true);
}
void Unit::SendSpellDamageImmune(Unit * target, uint32 spellId)
{
WorldPacket data(SMSG_SPELLORDAMAGE_IMMUNE, 8+8+4+1);
data << uint64(GetGUID());
data << uint64(target->GetGUID());
data << uint32(spellId);
data << uint8(0); // bool - log format: 0-default, 1-debug
SendMessageToSet(&data,true);
}
void Unit::SendAttackStateUpdate(CalcDamageInfo *damageInfo)
{
sLog.outDebug("WORLD: Sending SMSG_ATTACKERSTATEUPDATE");
+1
View File
@@ -1443,6 +1443,7 @@ class Unit : public WorldObject
void SendSpellNonMeleeDamageLog(Unit *target,uint32 SpellID, uint32 Damage, SpellSchoolMask damageSchoolMask, uint32 AbsorbedDamage, uint32 Resist, bool PhysicalDamage, uint32 Blocked, bool CriticalHit = false);
void SendPeriodicAuraLog(SpellPeriodicAuraLogInfo *pInfo);
void SendSpellMiss(Unit *target, uint32 spellID, SpellMissInfo missInfo);
void SendSpellDamageImmune(Unit *target, uint32 spellId);
void NearTeleportTo(float x, float y, float z, float orientation, bool casting = false);
virtual bool SetPosition(float x, float y, float z, float ang, bool teleport = false);
@@ -1238,12 +1238,8 @@ bool AuraEffect::IsPeriodicTickCrit(Unit * target, Unit const * caster) const
void AuraEffect::SendTickImmune(Unit * target, Unit *caster) const
{
WorldPacket data(SMSG_SPELLORDAMAGE_IMMUNE, 8+8+4+1);
data << uint64(caster ? caster->GetGUID() : target->GetGUID());
data << uint64(target->GetGUID());
data << uint32(m_spellProto->Id);
data << uint8(1);
target->SendMessageToSet(&data,true);
if (caster)
caster->SendSpellDamageImmune(target, m_spellProto->Id);
}
void AuraEffect::PeriodicTick(Unit * target, Unit * caster) const
+2 -2
View File
@@ -4153,8 +4153,8 @@ void Spell::ExecuteLogEffectTakeTargetPower(uint8 effIndex, Unit * target, uint3
{
InitEffectExecuteData(effIndex);
m_effectExecuteData[effIndex]->append(target->GetPackGUID());
*m_effectExecuteData[effIndex] << uint32(powerType);
*m_effectExecuteData[effIndex] << uint32(powerTaken);
*m_effectExecuteData[effIndex] << uint32(powerType);
*m_effectExecuteData[effIndex] << float(gainMultiplier);
}
@@ -4176,7 +4176,7 @@ void Spell::ExecuteLogEffectDurabilityDamage(uint8 effIndex, Unit * victim, uint
{
InitEffectExecuteData(effIndex);
m_effectExecuteData[effIndex]->append(victim->GetPackGUID());
*m_effectExecuteData[effIndex] << uint32(itemslot);
*m_effectExecuteData[effIndex] << uint32(m_spellInfo->Id);
*m_effectExecuteData[effIndex] << uint32(damage);
}
+1
View File
@@ -2585,6 +2585,7 @@ void Spell::EffectHealthLeech(SpellEffIndex effIndex)
float healMultiplier = SpellMgr::CalculateSpellEffectValueMultiplier(m_spellInfo, effIndex, m_originalCaster, this);
int32 newDamage = int32(damage * healMultiplier);
newDamage = std::min(int32(unitTarget->GetHealth()), newDamage);
m_damage += newDamage;
if (m_caster->isAlive())