fix(Core/Spells): show Execute/Slam misses/dodges/parries in combat log (#7494)

- Closes #7428.
This commit is contained in:
UltraNix
2021-08-26 11:45:22 +02:00
committed by GitHub
parent 5c97632cc3
commit 45218224b4
13 changed files with 118 additions and 26 deletions

View File

@@ -2411,6 +2411,9 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target)
m_spellAura = nullptr; // Set aura to null for every target-make sure that pointer is not used for unit without aura applied
PrepareScriptHitHandlers();
CallScriptBeforeHitHandlers(missInfo);
//Spells with this flag cannot trigger if effect is casted on self
bool canEffectTrigger = !m_spellInfo->HasAttribute(SPELL_ATTR3_SUPRESS_CASTER_PROCS) && unitTarget->CanProc() && (CanExecuteTriggersOnHit(mask) || missInfo == SPELL_MISS_IMMUNE2);
bool reflectedSpell = missInfo == SPELL_MISS_REFLECT;
@@ -2738,9 +2741,6 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA
if (!effectMask)
return returnVal;
PrepareScriptHitHandlers();
CallScriptBeforeHitHandlers();
if (unit->GetTypeId() == TYPEID_PLAYER)
{
unit->ToPlayer()->StartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_SPELL_TARGET, m_spellInfo->Id);
@@ -3034,7 +3034,7 @@ void Spell::DoAllEffectOnTarget(GOTargetInfo* target)
return;
PrepareScriptHitHandlers();
CallScriptBeforeHitHandlers();
CallScriptBeforeHitHandlers(SPELL_MISS_NONE);
for (uint32 effectNumber = 0; effectNumber < MAX_SPELL_EFFECTS; ++effectNumber)
if (effectMask & (1 << effectNumber))
@@ -3055,7 +3055,7 @@ void Spell::DoAllEffectOnTarget(ItemTargetInfo* target)
return;
PrepareScriptHitHandlers();
CallScriptBeforeHitHandlers();
CallScriptBeforeHitHandlers(SPELL_MISS_NONE);
for (uint32 effectNumber = 0; effectNumber < MAX_SPELL_EFFECTS; ++effectNumber)
if (effectMask & (1 << effectNumber))
@@ -7968,14 +7968,14 @@ bool Spell::CallScriptEffectHandlers(SpellEffIndex effIndex, SpellEffectHandleMo
return preventDefault;
}
void Spell::CallScriptBeforeHitHandlers()
void Spell::CallScriptBeforeHitHandlers(SpellMissInfo missInfo)
{
for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_BEFORE_HIT);
std::list<SpellScript::HitHandler>::iterator hookItrEnd = (*scritr)->BeforeHit.end(), hookItr = (*scritr)->BeforeHit.begin();
std::list<SpellScript::BeforeHitHandler>::iterator hookItrEnd = (*scritr)->BeforeHit.end(), hookItr = (*scritr)->BeforeHit.begin();
for (; hookItr != hookItrEnd; ++hookItr)
(*hookItr).Call(*scritr);
(*hookItr).Call(*scritr, missInfo);
(*scritr)->_FinishScriptCall();
}

View File

@@ -678,7 +678,7 @@ protected:
SpellCastResult CallScriptCheckCastHandlers();
void PrepareScriptHitHandlers();
bool CallScriptEffectHandlers(SpellEffIndex effIndex, SpellEffectHandleMode mode);
void CallScriptBeforeHitHandlers();
void CallScriptBeforeHitHandlers(SpellMissInfo missInfo);
void CallScriptOnHitHandlers();
void CallScriptAfterHitHandlers();
void CallScriptObjectAreaTargetSelectHandlers(std::list<WorldObject*>& targets, SpellEffIndex effIndex, SpellImplicitTargetInfo const& targetType);

View File

@@ -3326,7 +3326,9 @@ void SpellMgr::LoadDbcDataCorrections()
9910, // Thorns (Rank 6)
26992, // Thorns (Rank 7)
53307, // Thorns (Rank 8)
53352 // Explosive Shot (trigger)
53352, // Explosive Shot (trigger)
50783, // Slam (Triggered spell)
20647 // Execute (Triggered spell)
}, [](SpellEntry* spellInfo)
{
spellInfo->AttributesEx3 |= SPELL_ATTR3_ALWAYS_HIT;

View File

@@ -193,6 +193,16 @@ void SpellScript::EffectHandler::Call(SpellScript* spellScript, SpellEffIndex ef
(spellScript->*pEffectHandlerScript)(effIndex);
}
SpellScript::BeforeHitHandler::BeforeHitHandler(SpellBeforeHitFnType pBeforeHitHandlerScript)
{
_pBeforeHitHandlerScript = pBeforeHitHandlerScript;
}
void SpellScript::BeforeHitHandler::Call(SpellScript* spellScript, SpellMissInfo missInfo)
{
(spellScript->*_pBeforeHitHandlerScript)(missInfo);
}
SpellScript::HitHandler::HitHandler(SpellHitFnType _pHitHandlerScript)
{
pHitHandlerScript = _pHitHandlerScript;

View File

@@ -175,6 +175,7 @@ public:
#define SPELLSCRIPT_FUNCTION_TYPE_DEFINES(CLASSNAME) \
typedef SpellCastResult(CLASSNAME::*SpellCheckCastFnType)(); \
typedef void(CLASSNAME::*SpellEffectFnType)(SpellEffIndex); \
typedef void(CLASSNAME::*SpellBeforeHitFnType)(SpellMissInfo missInfo); \
typedef void(CLASSNAME::*SpellHitFnType)(); \
typedef void(CLASSNAME::*SpellCastFnType)(); \
typedef void(CLASSNAME::*SpellObjectAreaTargetSelectFnType)(std::list<WorldObject*>&); \
@@ -212,6 +213,16 @@ public:
SpellEffectFnType pEffectHandlerScript;
};
class BeforeHitHandler
{
public:
BeforeHitHandler(SpellBeforeHitFnType pBeforeHitHandlerScript);
void Call(SpellScript* spellScript, SpellMissInfo missInfo);
private:
SpellBeforeHitFnType _pBeforeHitHandlerScript;
};
class HitHandler
{
public:
@@ -265,6 +276,7 @@ public:
class CastHandlerFunction : public SpellScript::CastHandler { public: CastHandlerFunction(SpellCastFnType _pCastHandlerScript) : SpellScript::CastHandler((SpellScript::SpellCastFnType)_pCastHandlerScript) {} }; \
class CheckCastHandlerFunction : public SpellScript::CheckCastHandler { public: CheckCastHandlerFunction(SpellCheckCastFnType _checkCastHandlerScript) : SpellScript::CheckCastHandler((SpellScript::SpellCheckCastFnType)_checkCastHandlerScript) {} }; \
class EffectHandlerFunction : public SpellScript::EffectHandler { public: EffectHandlerFunction(SpellEffectFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName) : SpellScript::EffectHandler((SpellScript::SpellEffectFnType)_pEffectHandlerScript, _effIndex, _effName) {} }; \
class BeforeHitHandlerFunction : public SpellScript::BeforeHitHandler { public: explicit BeforeHitHandlerFunction(SpellBeforeHitFnType pBeforeHitHandlerScript) : SpellScript::BeforeHitHandler((SpellScript::SpellBeforeHitFnType)pBeforeHitHandlerScript) {} }; \
class HitHandlerFunction : public SpellScript::HitHandler { public: HitHandlerFunction(SpellHitFnType _pHitHandlerScript) : SpellScript::HitHandler((SpellScript::SpellHitFnType)_pHitHandlerScript) {} }; \
class ObjectAreaTargetSelectHandlerFunction : public SpellScript::ObjectAreaTargetSelectHandler { public: ObjectAreaTargetSelectHandlerFunction(SpellObjectAreaTargetSelectFnType _pObjectAreaTargetSelectHandlerScript, uint8 _effIndex, uint16 _targetType) : SpellScript::ObjectAreaTargetSelectHandler((SpellScript::SpellObjectAreaTargetSelectFnType)_pObjectAreaTargetSelectHandlerScript, _effIndex, _targetType) {} }; \
class ObjectTargetSelectHandlerFunction : public SpellScript::ObjectTargetSelectHandler { public: ObjectTargetSelectHandlerFunction(SpellObjectTargetSelectFnType _pObjectTargetSelectHandlerScript, uint8 _effIndex, uint16 _targetType) : SpellScript::ObjectTargetSelectHandler((SpellScript::SpellObjectTargetSelectFnType)_pObjectTargetSelectHandlerScript, _effIndex, _targetType) { } }; \
@@ -313,8 +325,11 @@ public:
HookList<EffectHandler> OnEffectHitTarget;
#define SpellEffectFn(F, I, N) EffectHandlerFunction(&F, I, N)
// example: BeforeHit += SpellHitFn(class::function);
HookList<HitHandler> BeforeHit;
// example: BeforeHit += BeforeSpellHitFn(class::function);
// where function is void function(SpellMissInfo missInfo)
HookList<BeforeHitHandler> BeforeHit;
#define BeforeSpellHitFn(F) BeforeHitHandlerFunction(&F)
// example: OnHit += SpellHitFn(class::function);
HookList<HitHandler> OnHit;
// example: AfterHit += SpellHitFn(class::function);

View File

@@ -1594,8 +1594,13 @@ public:
targets.push_back(caster);
}
void HandleBeforeHit()
void HandleBeforeHit(SpellMissInfo missInfo)
{
if (missInfo != SPELL_MISS_NONE)
{
return;
}
if (Unit* target = GetHitUnit())
{
if (!GetCaster() || target->GetGUID() == GetCaster()->GetGUID())
@@ -1640,7 +1645,7 @@ public:
{
OnCheckCast += SpellCheckCastFn(spell_brewfest_toss_mug_SpellScript::CheckCast);
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_brewfest_toss_mug_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY);
BeforeHit += SpellHitFn(spell_brewfest_toss_mug_SpellScript::HandleBeforeHit);
BeforeHit += BeforeSpellHitFn(spell_brewfest_toss_mug_SpellScript::HandleBeforeHit);
OnEffectHitTarget += SpellEffectFn(spell_brewfest_toss_mug_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};

View File

@@ -1672,15 +1672,20 @@ public:
{
PrepareSpellScript(spell_valanar_kinetic_bomb_knockback_SpellScript);
void KnockIntoAir()
void KnockIntoAir(SpellMissInfo missInfo)
{
if (missInfo != SPELL_MISS_NONE)
{
return;
}
if (Creature* target = GetHitCreature())
target->AI()->DoAction(ACTION_KINETIC_BOMB_JUMP);
}
void Register() override
{
BeforeHit += SpellHitFn(spell_valanar_kinetic_bomb_knockback_SpellScript::KnockIntoAir);
BeforeHit += BeforeSpellHitFn(spell_valanar_kinetic_bomb_knockback_SpellScript::KnockIntoAir);
}
};

View File

@@ -862,8 +862,13 @@ public:
return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW;
}
void OnCast()
void OnCast(SpellMissInfo missInfo)
{
if (missInfo != SPELL_MISS_NONE)
{
return;
}
if (GetCaster()->GetTypeId() != TYPEID_PLAYER || GetCaster()->GetMapId() != 631)
return;
InstanceScript* instance = GetCaster()->GetInstanceScript();
@@ -899,7 +904,7 @@ public:
void Register() override
{
OnCheckCast += SpellCheckCastFn(spell_blood_queen_vampiric_bite_SpellScript::CheckTarget);
BeforeHit += SpellHitFn(spell_blood_queen_vampiric_bite_SpellScript::OnCast);
BeforeHit += BeforeSpellHitFn(spell_blood_queen_vampiric_bite_SpellScript::OnCast);
OnEffectHitTarget += SpellEffectFn(spell_blood_queen_vampiric_bite_SpellScript::HandlePresence, EFFECT_1, SPELL_EFFECT_TRIGGER_SPELL);
}
};

View File

@@ -2626,15 +2626,20 @@ public:
{
PrepareSpellScript(spell_igb_below_zero_SpellScript);
void RemovePassengers()
void RemovePassengers(SpellMissInfo missInfo)
{
if (missInfo != SPELL_MISS_NONE)
{
return;
}
GetHitUnit()->SetPower(POWER_ENERGY, 0);
GetHitUnit()->CastSpell(GetHitUnit(), SPELL_EJECT_ALL_PASSENGERS, TRIGGERED_FULL_MASK);
}
void Register() override
{
BeforeHit += SpellHitFn(spell_igb_below_zero_SpellScript::RemovePassengers);
BeforeHit += BeforeSpellHitFn(spell_igb_below_zero_SpellScript::RemovePassengers);
}
};

View File

@@ -1973,8 +1973,13 @@ public:
targets.resize(1);
}
void CheckAura()
void CheckAura(SpellMissInfo missInfo)
{
if (missInfo != SPELL_MISS_NONE)
{
return;
}
if (GetHitUnit()->HasAura(GetSpellInfo()->Id))
_hadJumpingAura = true;
else if (uint32 spellId = sSpellMgr->GetSpellIdForDifficulty(SPELL_NECROTIC_PLAGUE, GetHitUnit()))
@@ -1998,7 +2003,7 @@ public:
void Register() override
{
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_the_lich_king_necrotic_plague_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY);
BeforeHit += SpellHitFn(spell_the_lich_king_necrotic_plague_SpellScript::CheckAura);
BeforeHit += BeforeSpellHitFn(spell_the_lich_king_necrotic_plague_SpellScript::CheckAura);
OnHit += SpellHitFn(spell_the_lich_king_necrotic_plague_SpellScript::AddMissingStack);
}

View File

@@ -241,8 +241,13 @@ public:
return GetCaster()->GetTypeId() == TYPEID_PLAYER && GetCastItem();
}
void HandleBeforeHit()
void HandleBeforeHit(SpellMissInfo missInfo)
{
if (missInfo != SPELL_MISS_NONE)
{
return;
}
if (Unit* target = GetHitUnit())
// Deadly Poison
if (AuraEffect const* aurEff = target->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_ROGUE, 0x10000, 0x80000, 0, GetCaster()->GetGUID()))
@@ -305,7 +310,7 @@ public:
void Register() override
{
BeforeHit += SpellHitFn(spell_rog_deadly_poison_SpellScript::HandleBeforeHit);
BeforeHit += BeforeSpellHitFn(spell_rog_deadly_poison_SpellScript::HandleBeforeHit);
AfterHit += SpellHitFn(spell_rog_deadly_poison_SpellScript::HandleAfterHit);
}

View File

@@ -557,8 +557,13 @@ public:
return true;
}
void HandleBanish()
void HandleBanish(SpellMissInfo missInfo)
{
if (missInfo != SPELL_MISS_NONE)
{
return;
}
if (Unit* target = GetHitUnit())
{
if (target->GetAuraEffect(SPELL_AURA_SCHOOL_IMMUNITY, SPELLFAMILY_WARLOCK, 0, 0x08000000, 0))
@@ -580,7 +585,7 @@ public:
void Register() override
{
BeforeHit += SpellHitFn(spell_warl_banish_SpellScript::HandleBanish);
BeforeHit += BeforeSpellHitFn(spell_warl_banish_SpellScript::HandleBanish);
AfterHit += SpellHitFn(spell_warl_banish_SpellScript::RemoveAura);
}

View File

@@ -396,6 +396,20 @@ public:
return ValidateSpellInfo({ SPELL_WARRIOR_SLAM });
}
void SendMiss(SpellMissInfo missInfo)
{
if (missInfo != SPELL_MISS_NONE)
{
if (Unit* caster = GetCaster())
{
if (Unit* target = GetHitUnit())
{
caster->SendSpellMiss(target, SPELL_WARRIOR_SLAM, missInfo);
}
}
}
}
void HandleDummy(SpellEffIndex /*effIndex*/)
{
if (GetHitUnit())
@@ -404,6 +418,7 @@ public:
void Register() override
{
BeforeHit += BeforeSpellHitFn(spell_warr_slam_SpellScript::SendMiss);
OnEffectHitTarget += SpellEffectFn(spell_warr_slam_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
@@ -465,6 +480,20 @@ public:
return ValidateSpellInfo({ SPELL_WARRIOR_EXECUTE, SPELL_WARRIOR_GLYPH_OF_EXECUTION });
}
void SendMiss(SpellMissInfo missInfo)
{
if (missInfo != SPELL_MISS_NONE)
{
if (Unit* caster = GetCaster())
{
if (Unit* target = GetHitUnit())
{
caster->SendSpellMiss(target, SPELL_WARRIOR_EXECUTE, missInfo);
}
}
}
}
void HandleEffect(SpellEffIndex effIndex)
{
Unit* caster = GetCaster();
@@ -493,6 +522,7 @@ public:
void Register() override
{
BeforeHit += BeforeSpellHitFn(spell_warr_execute_SpellScript::SendMiss);
OnEffectHitTarget += SpellEffectFn(spell_warr_execute_SpellScript::HandleEffect, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};