diff options
author | Robingad <robingad@rambler.ru> | 2021-03-25 22:28:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-25 21:28:22 +0100 |
commit | f8255b15419cd1efdd2ccaf77298c8598322288f (patch) | |
tree | b742e3d49d152763f5d682365dabc52d98c4f3a5 /src/server/game/Spells/SpellScript.cpp | |
parent | 834cd1554064785d87d36892dc92cc6b48291b27 (diff) |
Core/Script: Implement CalcCritChance hooks for spell and aura scripts (#26116)
(cherry picked from commit AshamaneProject/AshamaneCore@4e0a3f43430342ffe94afa90d2275515d1bf3924)
Diffstat (limited to 'src/server/game/Spells/SpellScript.cpp')
-rw-r--r-- | src/server/game/Spells/SpellScript.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/server/game/Spells/SpellScript.cpp b/src/server/game/Spells/SpellScript.cpp index 97b93e74766..62b57b3a36a 100644 --- a/src/server/game/Spells/SpellScript.cpp +++ b/src/server/game/Spells/SpellScript.cpp @@ -244,6 +244,16 @@ void SpellScript::HitHandler::Call(SpellScript* spellScript) (spellScript->*pHitHandlerScript)(); } +SpellScript::OnCalcCritChanceHandler::OnCalcCritChanceHandler(SpellOnCalcCritChanceFnType onCalcCritChanceHandlerScript) +{ + _onCalcCritChanceHandlerScript = onCalcCritChanceHandlerScript; +} + +void SpellScript::OnCalcCritChanceHandler::Call(SpellScript* spellScript, Unit* victim, float& critChance) const +{ + (spellScript->*_onCalcCritChanceHandlerScript)(victim, critChance); +} + SpellScript::TargetHook::TargetHook(uint8 _effectIndex, uint16 _targetType, bool _area, bool _dest) : _SpellScript::EffectHook(_effectIndex), targetType(_targetType), area(_area), dest(_dest) { } @@ -751,6 +761,10 @@ bool AuraScript::_Validate(SpellInfo const* entry) if (!itr->GetAffectedEffectsMask(entry)) TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `DoEffectCalcSpellMod` of AuraScript won't be executed", entry->Id, itr->ToString().c_str(), m_scriptName->c_str()); + for (auto itr = DoEffectCalcCritChance.begin(); itr != DoEffectCalcCritChance.end(); ++itr) + if (!itr->GetAffectedEffectsMask(entry)) + TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `DoEffectCalcCritChance` of AuraScript won't be executed", entry->Id, itr->ToString().c_str(), m_scriptName->c_str()); + for (auto itr = OnEffectAbsorb.begin(); itr != OnEffectAbsorb.end(); ++itr) if (!itr->GetAffectedEffectsMask(entry)) TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectAbsorb` of AuraScript won't be executed", entry->Id, itr->ToString().c_str(), m_scriptName->c_str()); @@ -890,6 +904,17 @@ void AuraScript::EffectCalcSpellModHandler::Call(AuraScript* auraScript, AuraEff (auraScript->*pEffectHandlerScript)(aurEff, spellMod); } +AuraScript::EffectCalcCritChanceHandler::EffectCalcCritChanceHandler(AuraEffectCalcCritChanceFnType effectHandlerScript, uint8 effIndex, uint16 effName) + : AuraScript::EffectBase(effIndex, effName) +{ + _effectHandlerScript = effectHandlerScript; +} + +void AuraScript::EffectCalcCritChanceHandler::Call(AuraScript* auraScript, AuraEffect const* aurEff, Unit* victim, float& critChance) const +{ + (auraScript->*_effectHandlerScript)(aurEff, victim, critChance); +} + AuraScript::EffectApplyHandler::EffectApplyHandler(AuraEffectApplicationModeFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName, AuraEffectHandleModes _mode) : AuraScript::EffectBase(_effIndex, _effName) { |