mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Scripts: Expose IsCrit to hit hooks for spell scripts
This commit is contained in:
@@ -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())
|
||||
|
||||
@@ -514,6 +514,8 @@ class TC_GAME_API SpellScript : public _SpellScript
|
||||
int32 GetHitHeal() const;
|
||||
void SetHitHeal(int32 heal);
|
||||
void PreventHitHeal() { SetHitHeal(0); }
|
||||
// returns: true if spell critically hits current HitUnit
|
||||
bool IsHitCrit() const;
|
||||
Spell* GetSpell() const { return m_spell; }
|
||||
// returns current spell hit target aura
|
||||
Aura* GetHitAura(bool dynObjAura = false) const;
|
||||
|
||||
Reference in New Issue
Block a user