Fix hidden CD for HandleDummyAuraProc for random proc spell (put the hidden CD on one of the random spell to avoid multiple proc of different random spell).

Take trigger_spell from dbc in case there is one and not yet handled by custom case.

--HG--
branch : trunk
This commit is contained in:
Trazom62
2010-05-31 20:14:21 +02:00
parent 427e8be656
commit 248782448c
+31 -31
View File
@@ -5241,7 +5241,7 @@ bool Unit::HandleSpellCritChanceAuraProc(Unit *pVictim, uint32 /*damage*/, AuraE
bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* triggeredByAura, SpellEntry const * procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown) bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* triggeredByAura, SpellEntry const * procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown)
{ {
SpellEntry const *dummySpell = triggeredByAura->GetSpellProto (); SpellEntry const *dummySpell = triggeredByAura->GetSpellProto();
uint32 effIndex = triggeredByAura->GetEffIndex(); uint32 effIndex = triggeredByAura->GetEffIndex();
int32 triggerAmount = triggeredByAura->GetAmount(); int32 triggerAmount = triggeredByAura->GetAmount();
@@ -5249,6 +5249,8 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
? this->ToPlayer()->GetItemByGuid(triggeredByAura->GetBase()->GetCastItemGUID()) : NULL; ? this->ToPlayer()->GetItemByGuid(triggeredByAura->GetBase()->GetCastItemGUID()) : NULL;
uint32 triggered_spell_id = 0; uint32 triggered_spell_id = 0;
uint32 cooldown_spell_id = 0; // for random trigger, will be one of the triggered spell to avoid repeatable triggers
// otherwise, it's the triggered_spell_id by default
Unit* target = pVictim; Unit* target = pVictim;
int32 basepoints0 = 0; int32 basepoints0 = 0;
uint64 originalCaster = 0; uint64 originalCaster = 0;
@@ -5434,33 +5436,25 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
{ {
case CLASS_PALADIN: // 39511,40997,40998,40999,41002,41005,41009,41011,41409 case CLASS_PALADIN: // 39511,40997,40998,40999,41002,41005,41009,41011,41409
case CLASS_DRUID: // 39511,40997,40998,40999,41002,41005,41009,41011,41409 case CLASS_DRUID: // 39511,40997,40998,40999,41002,41005,41009,41011,41409
{ triggered_spell_id = RAND(39511,40997,40998,40999,41002,41005,41009,41011,41409);
uint32 RandomSpell[]={39511,40997,40998,40999,41002,41005,41009,41011,41409}; cooldown_spell_id = 39511;
triggered_spell_id = RandomSpell[ irand(0, sizeof(RandomSpell)/sizeof(uint32) - 1) ];
break; break;
}
case CLASS_ROGUE: // 39511,40997,40998,41002,41005,41011 case CLASS_ROGUE: // 39511,40997,40998,41002,41005,41011
case CLASS_WARRIOR: // 39511,40997,40998,41002,41005,41011 case CLASS_WARRIOR: // 39511,40997,40998,41002,41005,41011
{ triggered_spell_id = RAND(39511,40997,40998,41002,41005,41011);
uint32 RandomSpell[]={39511,40997,40998,41002,41005,41011}; cooldown_spell_id = 39511;
triggered_spell_id = RandomSpell[ irand(0, sizeof(RandomSpell)/sizeof(uint32) - 1) ];
break; break;
}
case CLASS_PRIEST: // 40999,41002,41005,41009,41011,41406,41409 case CLASS_PRIEST: // 40999,41002,41005,41009,41011,41406,41409
case CLASS_SHAMAN: // 40999,41002,41005,41009,41011,41406,41409 case CLASS_SHAMAN: // 40999,41002,41005,41009,41011,41406,41409
case CLASS_MAGE: // 40999,41002,41005,41009,41011,41406,41409 case CLASS_MAGE: // 40999,41002,41005,41009,41011,41406,41409
case CLASS_WARLOCK: // 40999,41002,41005,41009,41011,41406,41409 case CLASS_WARLOCK: // 40999,41002,41005,41009,41011,41406,41409
{ triggered_spell_id = RAND(40999,41002,41005,41009,41011,41406,41409);
uint32 RandomSpell[]={40999,41002,41005,41009,41011,41406,41409}; cooldown_spell_id = 40999;
triggered_spell_id = RandomSpell[ irand(0, sizeof(RandomSpell)/sizeof(uint32) - 1) ];
break; break;
}
case CLASS_HUNTER: // 40997,40999,41002,41005,41009,41011,41406,41409 case CLASS_HUNTER: // 40997,40999,41002,41005,41009,41011,41406,41409
{ triggered_spell_id = RAND(40997,40999,41002,41005,41009,41011,41406,41409);
uint32 RandomSpell[]={40997,40999,41002,41005,41009,41011,41406,41409}; cooldown_spell_id = 40997;
triggered_spell_id = RandomSpell[ irand(0, sizeof(RandomSpell)/sizeof(uint32) - 1) ];
break; break;
}
default: default:
return false; return false;
} }
@@ -6986,7 +6980,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
return false; return false;
// custom cooldown processing case // custom cooldown processing case
if (cooldown && this->ToPlayer()->HasSpellCooldown(dummySpell->Id)) if (cooldown && ToPlayer()->HasSpellCooldown(dummySpell->Id))
return false; return false;
if (triggeredByAura->GetBase() && castItem->GetGUID() != triggeredByAura->GetBase()->GetCastItemGUID()) if (triggeredByAura->GetBase() && castItem->GetGUID() != triggeredByAura->GetBase()->GetCastItemGUID())
@@ -7045,7 +7039,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
// apply cooldown before cast to prevent processing itself // apply cooldown before cast to prevent processing itself
if (cooldown) if (cooldown)
this->ToPlayer()->AddSpellCooldown(dummySpell->Id,0,time(NULL) + cooldown); ToPlayer()->AddSpellCooldown(dummySpell->Id,0,time(NULL) + cooldown);
// Attack Twice // Attack Twice
for (uint32 i = 0; i<2; ++i) for (uint32 i = 0; i<2; ++i)
@@ -7239,7 +7233,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
return false; return false;
// custom cooldown processing case // custom cooldown processing case
if (cooldown && GetTypeId() == TYPEID_PLAYER && this->ToPlayer()->HasSpellCooldown(dummySpell->Id)) if (cooldown && GetTypeId() == TYPEID_PLAYER && ToPlayer()->HasSpellCooldown(dummySpell->Id))
return false; return false;
uint32 spellId = 0; uint32 spellId = 0;
@@ -7287,14 +7281,14 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
// Remove cooldown (Chain Lightning - have Category Recovery time) // Remove cooldown (Chain Lightning - have Category Recovery time)
if (procSpell->SpellFamilyFlags[0] & 0x2) if (procSpell->SpellFamilyFlags[0] & 0x2)
this->ToPlayer()->RemoveSpellCooldown(spellId); ToPlayer()->RemoveSpellCooldown(spellId);
CastSpell(pVictim, spellId, true, castItem, triggeredByAura); CastSpell(pVictim, spellId, true, castItem, triggeredByAura);
this->ToPlayer()->AddSpellMod(mod, false); this->ToPlayer()->AddSpellMod(mod, false);
if (cooldown && GetTypeId() == TYPEID_PLAYER) if (cooldown && GetTypeId() == TYPEID_PLAYER)
this->ToPlayer()->AddSpellCooldown(dummySpell->Id,0,time(NULL) + cooldown); ToPlayer()->AddSpellCooldown(dummySpell->Id,0,time(NULL) + cooldown);
return true; return true;
} }
@@ -7307,8 +7301,8 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
uint32 spell = spellmgr.GetSpellWithRank(26364, spellmgr.GetSpellRank(aurEff->GetId())); uint32 spell = spellmgr.GetSpellWithRank(26364, spellmgr.GetSpellRank(aurEff->GetId()));
// custom cooldown processing case // custom cooldown processing case
if (GetTypeId() == TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(spell)) if (GetTypeId() == TYPEID_PLAYER && ToPlayer()->HasSpellCooldown(spell))
((Player*)this)->RemoveSpellCooldown(spell); ToPlayer()->RemoveSpellCooldown(spell);
CastSpell(target, spell, true, castItem, triggeredByAura); CastSpell(target, spell, true, castItem, triggeredByAura);
aurEff->GetBase()->DropCharge(); aurEff->GetBase()->DropCharge();
@@ -7577,14 +7571,17 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
} }
default: default:
break; break;
} }
// if not handled by custom case, get triggered spell from dummySpell proto
if (!triggered_spell_id)
triggered_spell_id = dummySpell->EffectTriggerSpell[triggeredByAura->GetEffIndex()];
// processed charge only counting case // processed charge only counting case
if (!triggered_spell_id) if (!triggered_spell_id)
return true; return true;
SpellEntry const* triggerEntry = sSpellStore.LookupEntry(triggered_spell_id); SpellEntry const* triggerEntry = sSpellStore.LookupEntry(triggered_spell_id);
if (!triggerEntry) if (!triggerEntry)
{ {
sLog.outError("Unit::HandleDummyAuraProc: Spell %u have not existed triggered spell %u",dummySpell->Id,triggered_spell_id); sLog.outError("Unit::HandleDummyAuraProc: Spell %u have not existed triggered spell %u",dummySpell->Id,triggered_spell_id);
@@ -7595,7 +7592,10 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
if ((!target && !spellmgr.IsSrcTargetSpell(triggerEntry)) || (target && target != this && !target->isAlive())) if ((!target && !spellmgr.IsSrcTargetSpell(triggerEntry)) || (target && target != this && !target->isAlive()))
return false; return false;
if (cooldown && GetTypeId() == TYPEID_PLAYER && this->ToPlayer()->HasSpellCooldown(triggered_spell_id)) if (cooldown_spell_id == 0)
cooldown_spell_id = triggered_spell_id;
if (cooldown && GetTypeId() == TYPEID_PLAYER && ToPlayer()->HasSpellCooldown(cooldown_spell_id))
return false; return false;
if (basepoints0) if (basepoints0)
@@ -7604,7 +7604,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
CastSpell(target,triggered_spell_id,true,castItem,triggeredByAura, originalCaster); CastSpell(target,triggered_spell_id,true,castItem,triggeredByAura, originalCaster);
if (cooldown && GetTypeId() == TYPEID_PLAYER) if (cooldown && GetTypeId() == TYPEID_PLAYER)
this->ToPlayer()->AddSpellCooldown(triggered_spell_id,0,time(NULL) + cooldown); ToPlayer()->AddSpellCooldown(cooldown_spell_id,0,time(NULL) + cooldown);
return true; return true;
} }
@@ -8402,7 +8402,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig
if (!target) if (!target)
return false; return false;
if (cooldown && GetTypeId() == TYPEID_PLAYER && target->ToPlayer()->HasSpellCooldown(trigger_spell_id)) if (cooldown && target->GetTypeId() == TYPEID_PLAYER && target->ToPlayer()->HasSpellCooldown(trigger_spell_id))
return false; return false;
target->CastSpell(target,trigger_spell_id,true,castItem,triggeredByAura); target->CastSpell(target,trigger_spell_id,true,castItem,triggeredByAura);
@@ -8552,7 +8552,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig
} }
} }
if (cooldown && GetTypeId() == TYPEID_PLAYER && this->ToPlayer()->HasSpellCooldown(trigger_spell_id)) if (cooldown && GetTypeId() == TYPEID_PLAYER && ToPlayer()->HasSpellCooldown(trigger_spell_id))
return false; return false;
// try detect target manually if not set // try detect target manually if not set
@@ -8569,7 +8569,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig
CastSpell(target,trigger_spell_id,true,castItem,triggeredByAura); CastSpell(target,trigger_spell_id,true,castItem,triggeredByAura);
if (cooldown && GetTypeId() == TYPEID_PLAYER) if (cooldown && GetTypeId() == TYPEID_PLAYER)
this->ToPlayer()->AddSpellCooldown(trigger_spell_id,0,time(NULL) + cooldown); ToPlayer()->AddSpellCooldown(trigger_spell_id,0,time(NULL) + cooldown);
return true; return true;
} }