Skip to content
Permalink
Browse files

[mr169] Implement CustomProcEvent system for handle proc-type spells,…

… not handled in clean core by normal way. Implement custom HandleDamageShieldAuraProc for example, handle all SPELL_AURA_DAMAGE_SHIELD auras, repair procs and make SpellDamageBonus for his. Repair damage from druid thorns and paladin Retr aura at least.
  • Loading branch information
rsa committed Jun 9, 2011
1 parent 4daa8d6 commit 7575e4344fafb81948dd50f7b11ea463df066198
Showing with 91 additions and 58 deletions.
  1. +0 −55 src/game/Unit.cpp
  2. +2 −0 src/game/Unit.h
  3. +88 −2 src/game/UnitAuraProcHandler.cpp
  4. +1 −1 src/shared/revision_R2.h
@@ -1978,61 +1978,6 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss)
// on weapon hit casts
if(GetTypeId() == TYPEID_PLAYER && pVictim->isAlive())
((Player*)this)->CastItemCombatSpell(pVictim, damageInfo->attackType);

// victim's damage shield
std::set<Aura*> alreadyDone;
AuraList const& vDamageShields = pVictim->GetAurasByType(SPELL_AURA_DAMAGE_SHIELD);
for(AuraList::const_iterator i = vDamageShields.begin(); i != vDamageShields.end();)
{
if (alreadyDone.find(*i) == alreadyDone.end())
{
alreadyDone.insert(*i);
uint32 damage=(*i)->GetModifier()->m_amount;
SpellEntry const *i_spellProto = (*i)->GetSpellProto();

// Thorns
if (i_spellProto && i_spellProto->SpellFamilyName == SPELLFAMILY_DRUID && i_spellProto->SpellFamilyFlags & UI64LIT(0x00000100))
{
Unit::AuraList const& dummyList = pVictim->GetAurasByType(SPELL_AURA_DUMMY);
for(Unit::AuraList::const_iterator iter = dummyList.begin(); iter != dummyList.end(); ++iter)
{
// Brambles
if((*iter)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_DRUID &&
(*iter)->GetSpellProto()->SpellIconID == 53)
{
damage += uint32(damage * (*iter)->GetModifier()->m_amount / 100);
break;
}
}
}

//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;

pVictim->DealDamageMods(this,damage,NULL);

uint32 targetHealth = GetHealth();
uint32 overkill = damage > targetHealth ? damage - targetHealth : 0;

WorldPacket data(SMSG_SPELLDAMAGESHIELD,(8+8+4+4+4+4));
data << pVictim->GetObjectGuid();
data << GetObjectGuid();
data << uint32(i_spellProto->Id);
data << uint32(damage); // Damage
data << uint32(overkill); // Overkill
data << uint32(i_spellProto->SchoolMask);
pVictim->SendMessageToSet(&data, true );

pVictim->DealDamage(this, damage, 0, SPELL_DIRECT_DAMAGE, GetSpellSchoolMask(i_spellProto), i_spellProto, true);

i = vDamageShields.begin();
}
else
++i;
}
}
}

@@ -1869,6 +1869,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
uint32 SpellCriticalHealingBonus(SpellEntry const *spellProto, uint32 damage, Unit *pVictim);

bool IsTriggeredAtSpellProcEvent(Unit *pVictim, SpellAuraHolder* holder, SpellEntry const* procSpell, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, bool isVictim, SpellProcEventEntry const*& spellProcEvent );
bool IsTriggeredAtCustomProcEvent(Unit *pVictim, SpellAuraHolder* holder, SpellEntry const* procSpell, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, bool isVictim, SpellProcEventEntry const*& spellProcEvent );
// Aura proc handlers
SpellAuraProcResult HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown);
SpellAuraProcResult HandleHasteAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown);
@@ -1901,6 +1902,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
// this aura type can't proc
return SPELL_AURA_PROC_CANT_TRIGGER;
}
SpellAuraProcResult HandleDamageShieldAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown);

void SetLastManaUse()
{
@@ -47,7 +47,7 @@ pAuraProcHandler AuraProcHandler[TOTAL_AURAS]=
&Unit::HandleNULLProc, // 12 SPELL_AURA_MOD_STUN
&Unit::HandleNULLProc, // 13 SPELL_AURA_MOD_DAMAGE_DONE
&Unit::HandleNULLProc, // 14 SPELL_AURA_MOD_DAMAGE_TAKEN
&Unit::HandleNULLProc, // 15 SPELL_AURA_DAMAGE_SHIELD
&Unit::HandleDamageShieldAuraProc, // 15 SPELL_AURA_DAMAGE_SHIELD
&Unit::HandleRemoveByDamageProc, // 16 SPELL_AURA_MOD_STEALTH
&Unit::HandleNULLProc, // 17 SPELL_AURA_MOD_STEALTH_DETECT
&Unit::HandleRemoveByDamageProc, // 18 SPELL_AURA_MOD_INVISIBILITY
@@ -353,7 +353,11 @@ pAuraProcHandler AuraProcHandler[TOTAL_AURAS]=

bool Unit::IsTriggeredAtSpellProcEvent(Unit *pVictim, SpellAuraHolder* holder, SpellEntry const* procSpell, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, bool isVictim, SpellProcEventEntry const*& spellProcEvent )
{
SpellEntry const* spellProto = holder->GetSpellProto ();

if (IsTriggeredAtCustomProcEvent(pVictim, holder, procSpell, procFlag, procExtra, attType, isVictim, spellProcEvent))
return true;

SpellEntry const* spellProto = holder->GetSpellProto();

// Get proc Event Entry
spellProcEvent = sSpellMgr.GetSpellProcEvent(spellProto->Id);
@@ -4753,3 +4757,85 @@ SpellAuraProcResult Unit::HandleModResistanceAuraProc(Unit* /*pVictim*/, uint32

return SPELL_AURA_PROC_OK;
}

bool Unit::IsTriggeredAtCustomProcEvent(Unit *pVictim, SpellAuraHolder* holder, SpellEntry const* procSpell, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, bool isVictim, SpellProcEventEntry const*& spellProcEvent )
{
if (!holder || holder->IsDeleted())
return false;

SpellEntry const* spellProto = holder->GetSpellProto();

// if (procSpell == spellProto)
// return false;

for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i)
{
if (Aura* aura = holder->GetAuraByEffectIndex(SpellEffectIndex(i)))
{
AuraType auraName = AuraType(spellProto->EffectApplyAuraName[i]);

switch (auraName)
{
case SPELL_AURA_DAMAGE_SHIELD:
if (procFlag & PROC_FLAG_TAKEN_MELEE_HIT)
return true;
break;
default:
break;
}

}
}
return false;
}

SpellAuraProcResult Unit::HandleDamageShieldAuraProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown)
{
if (!triggeredByAura)
return SPELL_AURA_PROC_FAILED;

SpellEntry const *spellProto = triggeredByAura->GetSpellProto();

if (!spellProto)
return SPELL_AURA_PROC_FAILED;

uint32 retdamage = triggeredByAura->GetModifier()->m_amount;

// Thorns
if (spellProto && spellProto->SpellFamilyName == SPELLFAMILY_DRUID && spellProto->SpellFamilyFlags & UI64LIT(0x00000100))
{
Unit::AuraList const& dummyList = pVictim->GetAurasByType(SPELL_AURA_DUMMY);
for(Unit::AuraList::const_iterator iter = dummyList.begin(); iter != dummyList.end(); ++iter)
{
// Brambles
if((*iter)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_DRUID &&
(*iter)->GetSpellProto()->SpellIconID == 53)
{
damage += uint32(damage * (*iter)->GetModifier()->m_amount / 100);
break;
}
}
}

int32 DoneAdvertisedBenefit = SpellBaseDamageBonusDone(GetSpellSchoolMask(spellProto));
int32 realBenefit = int32(float(DoneAdvertisedBenefit)*3.3f/100.0f);
retdamage += realBenefit;

DealDamageMods(pVictim,retdamage,NULL);

uint32 targetHealth = pVictim->GetHealth();
uint32 overkill = retdamage > targetHealth ? retdamage - targetHealth : 0;

WorldPacket data(SMSG_SPELLDAMAGESHIELD,(8+8+4+4+4+4));
data << GetObjectGuid();
data << pVictim->GetObjectGuid();
data << uint32(spellProto->Id);
data << uint32(retdamage); // Damage
data << uint32(overkill); // Overkill
data << uint32(spellProto->SchoolMask);
SendMessageToSet(&data, true );

DealDamage(pVictim, retdamage, 0, SPELL_DIRECT_DAMAGE, GetSpellSchoolMask(spellProto), spellProto, true);

return SPELL_AURA_PROC_OK;
}
@@ -1,4 +1,4 @@
#ifndef __REVISION_R2_H__
#define __REVISION_R2_H__
#define REVISION_R2 "168"
#define REVISION_R2 "169"
#endif // __REVISION_R2_H__

0 comments on commit 7575e43

Please sign in to comment.
You can’t perform that action at this time.