Skip to content

Commit

Permalink
Core/Spells: check aura dummy cooldown instead of trigger cooldown
Browse files Browse the repository at this point in the history
  • Loading branch information
ariel- committed Feb 18, 2016
1 parent b8bd005 commit 8214d6f
Showing 1 changed file with 34 additions and 30 deletions.
64 changes: 34 additions & 30 deletions src/server/game/Entities/Unit/Unit.cpp
Expand Up @@ -5215,8 +5215,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
? ToPlayer()->GetItemByGuid(triggeredByAura->GetBase()->GetCastItemGUID()) : NULL;

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 = victim;
int32 basepoints0 = 0;
ObjectGuid originalCaster;
Expand Down Expand Up @@ -5292,24 +5291,20 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
case CLASS_PALADIN: // 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);
cooldown_spell_id = 39511;
break;
case CLASS_ROGUE: // 39511, 40997, 40998, 41002, 41005, 41011
case CLASS_WARRIOR: // 39511, 40997, 40998, 41002, 41005, 41011
case CLASS_DEATH_KNIGHT:
triggered_spell_id = RAND(39511, 40997, 40998, 41002, 41005, 41011);
cooldown_spell_id = 39511;
break;
case CLASS_PRIEST: // 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_WARLOCK: // 40999, 41002, 41005, 41009, 41011, 41406, 41409
triggered_spell_id = RAND(40999, 41002, 41005, 41009, 41011, 41406, 41409);
cooldown_spell_id = 40999;
break;
case CLASS_HUNTER: // 40997, 40999, 41002, 41005, 41009, 41011, 41406, 41409
triggered_spell_id = RAND(40997, 40999, 41002, 41005, 41009, 41011, 41406, 41409);
cooldown_spell_id = 40997;
break;
default:
return false;
Expand Down Expand Up @@ -5505,7 +5500,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
if (GetTypeId() != TYPEID_PLAYER)
return false;

std::vector<uint32> RandomSpells;
std::vector<uint32> RandomSpells(3);
switch (getClass())
{
case CLASS_WARRIOR:
Expand Down Expand Up @@ -5538,20 +5533,15 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
return false;

uint8 rand_spell = urand(0, (RandomSpells.size() - 1));
CastSpell(target, RandomSpells[rand_spell], true, castItem, triggeredByAura, originalCaster);
for (std::vector<uint32>::iterator itr = RandomSpells.begin(); itr != RandomSpells.end(); ++itr)
{
if (!GetSpellHistory()->HasCooldown(*itr))
GetSpellHistory()->AddCooldown(*itr, 0, std::chrono::seconds(cooldown));
}
triggered_spell_id = RandomSpells[rand_spell];
break;
}
case 71562: // Deathbringer's Will Heroic
{
if (GetTypeId() != TYPEID_PLAYER)
return false;

std::vector<uint32> RandomSpells;
std::vector<uint32> RandomSpells(3);
switch (getClass())
{
case CLASS_WARRIOR:
Expand Down Expand Up @@ -5584,12 +5574,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
return false;

uint8 rand_spell = urand(0, (RandomSpells.size() - 1));
CastSpell(target, RandomSpells[rand_spell], true, castItem, triggeredByAura, originalCaster);
for (std::vector<uint32>::iterator itr = RandomSpells.begin(); itr != RandomSpells.end(); ++itr)
{
if (!GetSpellHistory()->HasCooldown(*itr))
GetSpellHistory()->AddCooldown(*itr, 0, std::chrono::seconds(cooldown));
}
triggered_spell_id = RandomSpells[rand_spell];
break;
}
case 65032: // Boom aura (321 Boombot)
Expand Down Expand Up @@ -6115,6 +6100,9 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
// Check cooldown of heal spell cooldown
if (!GetSpellHistory()->HasCooldown(34299))
CastCustomSpell(this, 68285, &basepoints1, 0, 0, true, 0, triggeredByAura);

if (cooldown && GetTypeId() == TYPEID_PLAYER)
GetSpellHistory()->AddCooldown(34299, 0, std::chrono::seconds(cooldown));
break;
}
// Healing Touch (Dreamwalker Raiment set)
Expand Down Expand Up @@ -6416,19 +6404,27 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
// Sacred Shield
case 53601:
{
if (procFlag & PROC_FLAG_TAKEN_SPELL_MAGIC_DMG_CLASS_POS)
if (!damage || (procFlag & PROC_FLAG_TAKEN_SPELL_MAGIC_DMG_CLASS_POS) != 0)
return false;

if (damage > 0)
triggered_spell_id = 58597;
triggered_spell_id = 58597;

// Item - Paladin T8 Holy 4P Bonus
if (Unit* caster = triggeredByAura->GetCaster())
if (AuraEffect const* aurEff = caster->GetAuraEffect(64895, 0))
cooldown = aurEff->GetAmount();

target = this;
break;
// Normally we would check cooldown on the dummy aura, but in this case the dummy is casted by player
// and adding a bogus cd on a player spell is no-no, so we instead check cooldown on the triggered spell
// like on the previous system
if (cooldown && GetSpellHistory()->HasCooldown(triggered_spell_id))
return false;

CastSpell(this, triggered_spell_id, true, castItem, triggeredByAura, originalCaster);

if (cooldown)
GetSpellHistory()->AddCooldown(triggered_spell_id, 0, std::chrono::seconds(cooldown));
return true;
}
// Heart of the Crusader
case 20335: // rank 1
Expand Down Expand Up @@ -7039,7 +7035,13 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
if (AuraEffect const* aurEff = GetAuraEffect(SPELL_AURA_PROC_TRIGGER_SPELL, SPELLFAMILY_SHAMAN, 0, 0x00000020, 0))
{
uint32 spell = aurEff->GetSpellInfo()->Effects[aurEff->GetEffIndex()].TriggerSpell;
if (GetSpellHistory()->HasCooldown(spell))
return false;

CastSpell(this, spell, true, castItem, triggeredByAura);

if (cooldown && GetTypeId() == TYPEID_PLAYER)
GetSpellHistory()->AddCooldown(spell, 0, std::chrono::seconds(cooldown));
return true;
}
return false;
Expand Down Expand Up @@ -7404,10 +7406,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
return false;
}

if (cooldown_spell_id == 0)
cooldown_spell_id = triggered_spell_id;

if (cooldown && GetTypeId() == TYPEID_PLAYER && GetSpellHistory()->HasCooldown(cooldown_spell_id))
if (cooldown && GetTypeId() == TYPEID_PLAYER && GetSpellHistory()->HasCooldown(dummySpell->Id))
return false;

if (basepoints0)
Expand All @@ -7416,7 +7415,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
CastSpell(target, triggered_spell_id, true, castItem, triggeredByAura, originalCaster);

if (cooldown && GetTypeId() == TYPEID_PLAYER)
GetSpellHistory()->AddCooldown(cooldown_spell_id, 0, std::chrono::seconds(cooldown));
GetSpellHistory()->AddCooldown(dummySpell->Id, 0, std::chrono::seconds(cooldown));

return true;
}
Expand Down Expand Up @@ -15090,6 +15089,11 @@ bool Unit::IsTriggeredAtSpellProcEvent(Unit* victim, Aura* aura, SpellInfo const
{
SpellInfo const* spellProto = aura->GetSpellInfo();

// Check cooldown for passive aura dummy, if the trigger aura has cooldown
// it means it has recently procced, and now we must wait ICD
if (spellProto->IsPassive() && GetSpellHistory()->HasCooldown(spellProto))
return false;

// let the aura be handled by new proc system if it has new entry
if (sSpellMgr->GetSpellProcEntry(spellProto->Id))
return false;
Expand Down

0 comments on commit 8214d6f

Please sign in to comment.