Core/Scripts: Expose IsCrit to hit hooks for spell scripts

This commit is contained in:
Shauren
2022-01-30 12:36:29 +01:00
parent ea82454932
commit 2cc652b305
2 changed files with 21 additions and 0 deletions

View File

@@ -686,6 +686,25 @@ void SpellScript::SetHitHeal(int32 heal)
m_spell->m_healing = heal;
}
bool SpellScript::IsHitCrit() const
{
if (!IsInTargetHook())
{
TC_LOG_ERROR("scripts", "Script: `%s` Spell: `%u`: function SpellScript::IsHitCrit was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
return false;
}
if (Unit* hitUnit = GetHitUnit())
{
auto itr = std::find_if(m_spell->m_UniqueTargetInfo.begin(), m_spell->m_UniqueTargetInfo.end(), [hitUnit](Spell::TargetInfo const& targetInfo)
{
return targetInfo.TargetGUID == hitUnit->GetGUID();
});
ASSERT(itr != m_spell->m_UniqueTargetInfo.end());
return itr->IsCrit;
}
return false;
}
Aura* SpellScript::GetHitAura(bool dynObjAura /*= false*/) const
{
if (!IsInTargetHook())