* Author of CastItemCombatSpell part was freeganja. Sorry for typo.

* Some cleanup

--HG--
branch : trunk
This commit is contained in:
krz
2009-06-23 04:59:28 +02:00
parent 738f3567ca
commit 97e4a59a75

View File

@@ -6186,668 +6186,6 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAu
return true;
}
/*
bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlags,WeaponAttackType attackType, uint32 cooldown)
{
SpellEntry const* auraSpellInfo = triggeredByAura->GetSpellProto();
Item* castItem = triggeredByAura->GetCastItemGUID() && GetTypeId()==TYPEID_PLAYER
? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGUID()) : NULL;
uint32 triggered_spell_id = auraSpellInfo->EffectTriggerSpell[triggeredByAura->GetEffIndex()];
Unit* target = !(procFlags & PROC_FLAG_HEAL) && IsPositiveSpell(triggered_spell_id) ? this : pVictim;
int32 basepoints0 = 0;
switch(auraSpellInfo->SpellFamilyName)
{
case SPELLFAMILY_GENERIC:
{
switch(auraSpellInfo->Id)
{
// Aegis of Preservation
case 23780:
//Aegis Heal (instead non-existed triggered spell)
triggered_spell_id = 23781;
target = this;
break;
// Elune's Touch (moonkin mana restore)
case 24905:
{
// Elune's Touch (instead non-existed triggered spell)
triggered_spell_id = 33926;
basepoints0 = int32(0.3f * GetTotalAttackPowerValue(BASE_ATTACK));
target = this;
break;
}
// Enlightenment
case 29601:
{
// only for cast with mana price
if(!procSpell || procSpell->powerType!=POWER_MANA || procSpell->manaCost==0 && procSpell->ManaCostPercentage==0 && procSpell->manaCostPerlevel==0)
return false;
break; // fall through to normal cast
}
// Health Restore
case 33510:
{
// at melee hit call std triggered spell
if(procFlags & PROC_FLAG_HIT_MELEE)
break; // fall through to normal cast
// Mark of Conquest - else (at range hit) called custom case
triggered_spell_id = 39557;
target = this;
break;
}
// Shaleskin
case 36576:
return true; // nothing to do
// Forgotten Knowledge (Blade of Wizardry)
case 38319:
// only for harmful enemy targeted spell
if(!pVictim || pVictim==this || !procSpell || IsPositiveSpell(procSpell->Id))
return false;
break; // fall through to normal cast
// Aura of Wrath (Darkmoon Card: Wrath trinket bonus)
case 39442:
{
// proc only at non-crit hits
if(procFlags & (PROC_FLAG_CRIT_MELEE|PROC_FLAG_CRIT_RANGED|PROC_FLAG_CRIT_SPELL))
return false;
break; // fall through to normal cast
}
// Augment Pain (Timbal's Focusing Crystal trinket bonus)
case 45054:
{
if(!procSpell)
return false;
//only periodic damage can trigger spell
bool found = false;
for(int j = 0; j < 3; ++j)
{
if( procSpell->EffectApplyAuraName[j]==SPELL_AURA_PERIODIC_DAMAGE ||
procSpell->EffectApplyAuraName[j]==SPELL_AURA_PERIODIC_DAMAGE_PERCENT ||
procSpell->EffectApplyAuraName[j]==SPELL_AURA_PERIODIC_LEECH )
{
found = true;
break;
}
}
if(!found)
return false;
break; // fall through to normal cast
}
// Evasive Maneuvers (Commendation of Kael'thas)
case 45057:
{
// damage taken that reduces below 35% health
// does NOT mean you must have been >= 35% before
if (int32(GetHealth())-int32(damage) >= int32(GetMaxHealth()*0.35f))
return false;
break; // fall through to normal cast
}
}
switch(triggered_spell_id)
{
// Setup
case 15250:
{
// applied only for main target
if(!pVictim || pVictim != getVictim())
return false;
// continue normal case
break;
}
// Shamanistic Rage triggered spell
case 30824:
basepoints0 = int32(GetTotalAttackPowerValue(BASE_ATTACK)*triggeredByAura->GetModifier()->m_amount/100);
break;
}
break;
}
case SPELLFAMILY_MAGE:
{
switch(auraSpellInfo->SpellIconID)
{
// Blazing Speed
case 2127:
//Blazing Speed (instead non-existed triggered spell)
triggered_spell_id = 31643;
target = this;
break;
}
switch(auraSpellInfo->Id)
{
// Persistent Shield (Scarab Brooch)
case 26467:
basepoints0 = int32(damage * 0.15f);
break;
}
break;
}
case SPELLFAMILY_WARRIOR:
{
//Rampage
if((auraSpellInfo->SpellFamilyFlags & 0x100000) && auraSpellInfo->SpellIconID==2006)
{
//all ranks have effect[0]==AURA (Proc Trigger Spell, non-existed)
//and effect[1]==TriggerSpell
if(auraSpellInfo->Effect[1]!=SPELL_EFFECT_TRIGGER_SPELL)
{
sLog.outError("Unit::HandleProcTriggerSpell: Spell %u have wrong effect in RM",triggeredByAura->GetSpellProto()->Id);
return false;
}
triggered_spell_id = auraSpellInfo->EffectTriggerSpell[1];
break; // fall through to normal cast
}
break;
}
case SPELLFAMILY_WARLOCK:
{
// Pyroclasm
if(auraSpellInfo->SpellFamilyFlags == 0x0000000000000000 && auraSpellInfo->SpellIconID==1137)
{
// last case for Hellfire that damage caster also but don't must stun caster
if( pVictim == this )
return false;
// custom chance
float chance = 0;
switch (triggeredByAura->GetId())
{
case 18096: chance = 13.0f; break;
case 18073: chance = 26.0f; break;
}
if (!roll_chance_f(chance))
return false;
// Pyroclasm (instead non-existed triggered spell)
triggered_spell_id = 18093;
target = pVictim;
break;
}
// Drain Soul
if(auraSpellInfo->SpellFamilyFlags & 0x0000000000004000)
{
bool found = false;
Unit::AuraList const& mAddFlatModifier = GetAurasByType(SPELL_AURA_ADD_FLAT_MODIFIER);
for(Unit::AuraList::const_iterator i = mAddFlatModifier.begin(); i != mAddFlatModifier.end(); ++i)
{
//Improved Drain Soul
if ((*i)->GetModifier()->m_miscvalue == SPELLMOD_CHANCE_OF_SUCCESS && (*i)->GetSpellProto()->SpellIconID == 113)
{
int32 value2 = CalculateSpellDamage((*i)->GetSpellProto(),2,(*i)->GetSpellProto()->EffectBasePoints[2],this);
basepoints0 = value2 * GetMaxPower(POWER_MANA) / 100;
// Drain Soul
CastCustomSpell(this, 18371, &basepoints0, NULL, NULL, true, castItem, triggeredByAura);
break;
}
}
// Not remove charge (aura removed on death in any cases)
// Need for correct work Drain Soul SPELL_AURA_CHANNEL_DEATH_ITEM aura
return false;
}
break;
}
case SPELLFAMILY_PRIEST:
{
//Blessed Recovery
if(auraSpellInfo->SpellFamilyFlags == 0x00000000LL && auraSpellInfo->SpellIconID==1875)
{
switch (triggeredByAura->GetSpellProto()->Id)
{
case 27811: triggered_spell_id = 27813; break;
case 27815: triggered_spell_id = 27817; break;
case 27816: triggered_spell_id = 27818; break;
default:
sLog.outError("Unit::HandleProcTriggerSpell: Spell %u not handled in BR",triggeredByAura->GetSpellProto()->Id);
return false;
}
int32 heal_amount = damage * triggeredByAura->GetModifier()->m_amount / 100;
basepoints0 = heal_amount/3;
target = this;
break;
}
// Shadowguard
if((auraSpellInfo->SpellFamilyFlags & 0x80000000LL) && auraSpellInfo->SpellVisual==7958)
{
switch(triggeredByAura->GetSpellProto()->Id)
{
case 18137:
triggered_spell_id = 28377; break; // Rank 1
case 19308:
triggered_spell_id = 28378; break; // Rank 2
case 19309:
triggered_spell_id = 28379; break; // Rank 3
case 19310:
triggered_spell_id = 28380; break; // Rank 4
case 19311:
triggered_spell_id = 28381; break; // Rank 5
case 19312:
triggered_spell_id = 28382; break; // Rank 6
case 25477:
triggered_spell_id = 28385; break; // Rank 7
default:
sLog.outError("Unit::HandleProcTriggerSpell: Spell %u not handled in SG",triggeredByAura->GetSpellProto()->Id);
return false;
}
target = pVictim;
break;
}
break;
}
case SPELLFAMILY_DRUID:
{
switch(auraSpellInfo->Id)
{
// Leader of the Pack (triggering Improved Leader of the Pack heal)
case 24932:
{
if (triggeredByAura->GetModifier()->m_amount == 0)
return false;
basepoints0 = triggeredByAura->GetModifier()->m_amount * GetMaxHealth() / 100;
triggered_spell_id = 34299;
break;
};
// Druid Forms Trinket (Druid Tier5 Trinket, triggers different spells per Form)
case 37336:
{
switch(m_form)
{
case FORM_BEAR:
case FORM_DIREBEAR:
triggered_spell_id=37340; break;// Ursine Blessing
case FORM_CAT:
triggered_spell_id=37341; break;// Feline Blessing
case FORM_TREE:
triggered_spell_id=37342; break;// Slyvan Blessing
case FORM_MOONKIN:
triggered_spell_id=37343; break;// Lunar Blessing
case FORM_NONE:
triggered_spell_id=37344; break;// Cenarion Blessing (for caster form, except FORM_MOONKIN)
default:
return false;
}
target = this;
break;
}
}
break;
}
case SPELLFAMILY_ROGUE:
{
if(auraSpellInfo->SpellFamilyFlags == 0x0000000000000000LL)
{
switch(auraSpellInfo->SpellIconID)
{
// Combat Potency
case 2260:
{
// skip non offhand attacks
if(attackType!=OFF_ATTACK)
return false;
break; // fall through to normal cast
}
}
}
break;
}
case SPELLFAMILY_PALADIN:
{
if(auraSpellInfo->SpellFamilyFlags == 0x00000000LL)
{
switch(auraSpellInfo->Id)
{
// Lightning Capacitor
case 37657:
{
// trinket ProcTriggerSpell but for safe checks for player
if(!castItem || !pVictim || !pVictim->isAlive() || GetTypeId()!=TYPEID_PLAYER)
return false;
if(((Player*)this)->HasSpellCooldown(37657))
return false;
// stacking
CastSpell(this, 37658, true, castItem, triggeredByAura);
// 2.5s cooldown before it can stack again, current system allow 1 sec step in cooldown
((Player*)this)->AddSpellCooldown(37657,0,time(NULL)+(roll_chance_i(50) ? 2 : 3));
// counting
Aura * dummy = GetDummyAura(37658);
if (!dummy)
return false;
// release at 3 aura in stack
if(dummy->GetStackAmount() <= 2)
return true; // main triggered spell casted anyway
RemoveAurasDueToSpell(37658);
CastSpell(pVictim, 37661, true, castItem, triggeredByAura);
return true;
}
// Healing Discount
case 37705:
// Healing Trance (instead non-existed triggered spell)
triggered_spell_id = 37706;
target = this;
break;
// HoTs on Heals (Fel Reaver's Piston trinket)
case 38299:
{
// at direct heal effect
if(!procSpell || !IsSpellHaveEffect(procSpell,SPELL_EFFECT_HEAL))
return false;
// single proc at time
AuraList const& scAuras = GetSingleCastAuras();
for(AuraList::const_iterator itr = scAuras.begin(); itr != scAuras.end(); ++itr)
if((*itr)->GetId()==triggered_spell_id)
return false;
// positive cast at victim instead self
target = pVictim;
break;
}
}
switch(auraSpellInfo->SpellIconID)
{
case 241:
{
switch(auraSpellInfo->EffectTriggerSpell[0])
{
//Illumination
case 18350:
{
if(!procSpell)
return false;
// procspell is triggered spell but we need mana cost of original casted spell
uint32 originalSpellId = procSpell->Id;
// Holy Shock
if(procSpell->SpellFamilyName == SPELLFAMILY_PALADIN)
{
if(procSpell->SpellFamilyFlags & 0x0001000000000000LL)
{
switch(procSpell->Id)
{
case 25914: originalSpellId = 20473; break;
case 25913: originalSpellId = 20929; break;
case 25903: originalSpellId = 20930; break;
case 27175: originalSpellId = 27174; break;
case 33074: originalSpellId = 33072; break;
default:
sLog.outError("Unit::HandleProcTriggerSpell: Spell %u not handled in HShock",procSpell->Id);
return false;
}
}
}
SpellEntry const *originalSpell = sSpellStore.LookupEntry(originalSpellId);
if(!originalSpell)
{
sLog.outError("Unit::HandleProcTriggerSpell: Spell %u unknown but selected as original in Illu",originalSpellId);
return false;
}
// percent stored in effect 1 (class scripts) base points
int32 percent = auraSpellInfo->EffectBasePoints[1]+1;
basepoints0 = originalSpell->manaCost*percent/100;
triggered_spell_id = 20272;
target = this;
break;
}
}
break;
}
}
}
if(auraSpellInfo->SpellFamilyFlags & 0x00080000)
{
switch(auraSpellInfo->SpellIconID)
{
//Judgement of Wisdom (overwrite non existing triggered spell call in spell.dbc
case 206:
{
if(!pVictim || !pVictim->isAlive())
return false;
switch(triggeredByAura->GetSpellProto()->Id)
{
case 20186:
triggered_spell_id = 20268; // Rank 1
break;
case 20354:
triggered_spell_id = 20352; // Rank 2
break;
case 20355:
triggered_spell_id = 20353; // Rank 3
break;
case 27164:
triggered_spell_id = 27165; // Rank 4
break;
default:
sLog.outError("Unit::HandleProcTriggerSpell: Spell %u not handled in JoW",triggeredByAura->GetSpellProto()->Id);
return false;
}
pVictim->CastSpell(pVictim,triggered_spell_id,true,castItem,triggeredByAura,GetGUID());
return true; // no hidden cooldown
}
//Judgement of Light
case 299:
{
if(!pVictim || !pVictim->isAlive())
return false;
// overwrite non existing triggered spell call in spell.dbc
switch(triggeredByAura->GetSpellProto()->Id)
{
case 20185:
triggered_spell_id = 20267; // Rank 1
break;
case 20344:
triggered_spell_id = 20341; // Rank 2
break;
case 20345:
triggered_spell_id = 20342; // Rank 3
break;
case 20346:
triggered_spell_id = 20343; // Rank 4
break;
case 27162:
triggered_spell_id = 27163; // Rank 5
break;
default:
sLog.outError("Unit::HandleProcTriggerSpell: Spell %u not handled in JoL",triggeredByAura->GetSpellProto()->Id);
return false;
}
pVictim->CastSpell(pVictim,triggered_spell_id,true,castItem,triggeredByAura,GetGUID());
return true; // no hidden cooldown
}
}
}
// custom check for proc spell
switch(auraSpellInfo->Id)
{
// Bonus Healing (item spell)
case 40971:
{
if(!pVictim || !pVictim->isAlive())
return false;
// bonus if health < 50%
if(pVictim->GetHealth() >= pVictim->GetMaxHealth()*triggeredByAura->GetModifier()->m_amount/100)
return false;
// cast at target positive spell
target = pVictim;
break;
}
}
switch(triggered_spell_id)
{
// Seal of Command
case 20424:
// prevent chain of triggered spell from same triggered spell
if(procSpell && procSpell->Id==20424)
return false;
break;
}
break;
}
case SPELLFAMILY_SHAMAN:
{
if(auraSpellInfo->SpellFamilyFlags == 0x0000000000000000)
{
switch(auraSpellInfo->SpellIconID)
{
case 19:
{
switch(auraSpellInfo->Id)
{
case 23551: // Lightning Shield - Tier2: 8 pieces proc shield
{
// Lightning Shield (overwrite non existing triggered spell call in spell.dbc)
triggered_spell_id = 23552;
target = pVictim;
break;
}
case 23552: // Lightning Shield - trigger shield damage
{
// Lightning Shield (overwrite non existing triggered spell call in spell.dbc)
triggered_spell_id = 27635;
target = pVictim;
break;
}
}
break;
}
// Mana Surge (Shaman T1 bonus)
case 87:
{
if(!procSpell)
return false;
basepoints0 = procSpell->manaCost * 35/100;
triggered_spell_id = 23571;
target = this;
break;
}
//Nature's Guardian
case 2013:
{
if(GetTypeId()!=TYPEID_PLAYER)
return false;
// damage taken that reduces below 30% health
// does NOT mean you must have been >= 30% before
if (10*(int32(GetHealth())-int32(damage)) >= 3*GetMaxHealth())
return false;
triggered_spell_id = 31616;
// need check cooldown now
if( cooldown && ((Player*)this)->HasSpellCooldown(triggered_spell_id))
return false;
basepoints0 = triggeredByAura->GetModifier()->m_amount * GetMaxHealth() / 100;
target = this;
if(pVictim && pVictim->isAlive())
pVictim->getThreatManager().modifyThreatPercent(this,-10);
break;
}
}
}
// Water Shield (we can't set cooldown for main spell - it's player casted spell
if((auraSpellInfo->SpellFamilyFlags & 0x0000002000000000LL) && auraSpellInfo->SpellVisual==7358)
{
target = this;
break;
}
// Lightning Shield
if((auraSpellInfo->SpellFamilyFlags & 0x00000400) && auraSpellInfo->SpellVisual==37)
{
// overwrite non existing triggered spell call in spell.dbc
switch(triggeredByAura->GetSpellProto()->Id)
{
case 324:
triggered_spell_id = 26364; break; // Rank 1
case 325:
triggered_spell_id = 26365; break; // Rank 2
case 905:
triggered_spell_id = 26366; break; // Rank 3
case 945:
triggered_spell_id = 26367; break; // Rank 4
case 8134:
triggered_spell_id = 26369; break; // Rank 5
case 10431:
triggered_spell_id = 26370; break; // Rank 6
case 10432:
triggered_spell_id = 26363; break; // Rank 7
case 25469:
triggered_spell_id = 26371; break; // Rank 8
case 25472:
triggered_spell_id = 26372; break; // Rank 9
default:
sLog.outError("Unit::HandleProcTriggerSpell: Spell %u not handled in LShield",triggeredByAura->GetSpellProto()->Id);
return false;
}
target = pVictim;
break;
}
break;
}
}
// standard non-dummy case
if(!triggered_spell_id)
{
sLog.outError("Unit::HandleProcTriggerSpell: Spell %u have 0 in EffectTriggered[%d], not handled custom case?",auraSpellInfo->Id,triggeredByAura->GetEffIndex());
return false;
}
SpellEntry const* triggerEntry = sSpellStore.LookupEntry(triggered_spell_id);
if(!triggerEntry)
{
sLog.outError("Unit::HandleProcTriggerSpell: Spell %u have not existed EffectTriggered[%d]=%u, not handled custom case?",auraSpellInfo->Id,triggeredByAura->GetEffIndex(),triggered_spell_id);
return false;
}
// not allow proc extra attack spell at extra attack
if( m_extraAttacks && IsSpellHaveEffect(triggerEntry,SPELL_EFFECT_ADD_EXTRA_ATTACKS) )
return false;
if( cooldown && GetTypeId()==TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(triggered_spell_id))
return false;
// default case
if(!target || target!=this && !target->isAlive())
return false;
if(basepoints0)
CastCustomSpell(target,triggered_spell_id,&basepoints0,NULL,NULL,true,castItem,triggeredByAura);
else
CastSpell(target,triggered_spell_id,true,castItem,triggeredByAura);
if( cooldown && GetTypeId()==TYPEID_PLAYER )
((Player*)this)->AddSpellCooldown(triggered_spell_id,0,time(NULL) + cooldown);
return true;
}
*/
bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlags, uint32 procEx, uint32 cooldown)
{