feat(Core/Hooks): added collection of hooks to extends AC (#3047)

This collection of hooks comes from the Maelstrom project. It allows to release modules such as :
- 3v3-soloqueue
- 1v1 arena
- pvestats

and many others
This commit is contained in:
Kargatum
2021-04-13 18:26:39 +07:00
committed by GitHub
parent 911fbb377e
commit 2b3d46bd4f
46 changed files with 2053 additions and 278 deletions

View File

@@ -4726,7 +4726,7 @@ void AuraEffect::HandleModDamageDone(AuraApplication const* aurApp, uint8 mode,
// with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
// GetMiscValue() comparison with item generated damage types
if ((GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL) != 0)
if ((GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL) != 0 && sScriptMgr->CanModAuraEffectDamageDone(this, target, aurApp, mode, apply))
{
// apply generic physical damage bonuses including wand case
if (GetSpellInfo()->EquippedItemClass == -1 || target->GetTypeId() != TYPEID_PLAYER)
@@ -4796,6 +4796,9 @@ void AuraEffect::HandleModDamagePercentDone(AuraApplication const* aurApp, uint8
if (!target)
return;
if (!sScriptMgr->CanModAuraEffectModDamagePercentDone(this, target, aurApp, mode, apply))
return;
if (target->GetTypeId() == TYPEID_PLAYER)
{
for (int i = 0; i < MAX_ATTACK; ++i)

View File

@@ -836,19 +836,21 @@ void Spell::SelectSpellTargets()
else if (m_auraScaleMask)
{
bool checkLvl = !m_UniqueTargetInfo.empty();
for (std::list<TargetInfo>::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end();)
for (std::list<TargetInfo>::iterator itr = m_UniqueTargetInfo.begin(); itr != m_UniqueTargetInfo.end(); ++itr)
{
// remove targets which did not pass min level check
if (m_auraScaleMask && ihit->effectMask == m_auraScaleMask)
if (m_auraScaleMask && itr->effectMask == m_auraScaleMask)
{
// Do not check for selfcast
if (!ihit->scaleAura && ihit->targetGUID != m_caster->GetGUID())
{
m_UniqueTargetInfo.erase(ihit++);
continue;
}
bool needErase = false;
if (!itr->scaleAura && itr->targetGUID != m_caster->GetGUID())
needErase = true;
sScriptMgr->OnRemoveAuraScaleTargets(this, *itr, m_auraScaleMask, needErase);
if (needErase)
m_UniqueTargetInfo.erase(itr);
}
++ihit;
}
if (checkLvl && m_UniqueTargetInfo.empty())
{
@@ -2154,6 +2156,8 @@ void Spell::AddUnitTarget(Unit* target, uint32 effectMask, bool checkIfValid /*=
if (uint32(target->getLevel() + 10) >= auraSpell->SpellLevel)
ihit->scaleAura = true;
}
sScriptMgr->OnScaleAuraUnitAdd(this, target, effectMask, checkIfValid, implicit, m_auraScaleMask, *ihit);
return;
}
}
@@ -2176,6 +2180,8 @@ void Spell::AddUnitTarget(Unit* target, uint32 effectMask, bool checkIfValid /*=
targetInfo.scaleAura = true;
}
sScriptMgr->OnScaleAuraUnitAdd(this, target, effectMask, checkIfValid, implicit, m_auraScaleMask, targetInfo);
// Calculate hit result
if (m_originalCaster)
{
@@ -3163,8 +3169,14 @@ SpellCastResult Spell::prepare(SpellCastTargets const* targets, AuraEffect const
InitExplicitTargets(*targets);
if (!sScriptMgr->CanPrepare(this, targets, triggeredByAura))
{
finish(false);
return SPELL_FAILED_UNKNOWN;
}
// Fill aura scaling information
if (m_caster->IsTotem() || (m_caster->IsControlledByPlayer() && !m_spellInfo->IsPassive() && m_spellInfo->SpellLevel && !m_spellInfo->IsChanneled() && !(_triggeredCastFlags & TRIGGERED_IGNORE_AURA_SCALING)))
if (sScriptMgr->CanScalingEverything(this) || m_caster->IsTotem() || (m_caster->IsControlledByPlayer() && !m_spellInfo->IsPassive() && m_spellInfo->SpellLevel && !m_spellInfo->IsChanneled() && !(_triggeredCastFlags & TRIGGERED_IGNORE_AURA_SCALING)))
{
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
@@ -5140,6 +5152,13 @@ SpellCastResult Spell::CheckCast(bool strict)
if (((const Player*)m_caster)->IsSpectator() && m_spellInfo->Id != SPECTATOR_SPELL_BINDSIGHT)
return SPELL_FAILED_NOT_HERE;
SpellCastResult res = SPELL_CAST_OK;
sScriptMgr->OnSpellCheckCast(this, strict, res);
if (res != SPELL_CAST_OK)
return res;
// check cooldowns to prevent cheating
if (!m_spellInfo->HasAttribute(SPELL_ATTR0_PASSIVE))
{
@@ -5969,6 +5988,8 @@ SpellCastResult Spell::CheckCast(bool strict)
break;
}
case SPELL_EFFECT_TALENT_SPEC_SELECT:
if (!sScriptMgr->CanSelectSpecTalent(this))
return SPELL_FAILED_DONT_REPORT;
// can't change during already started arena/battleground
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (Battleground const* bg = m_caster->ToPlayer()->GetBattleground())

View File

@@ -234,6 +234,21 @@ struct ChannelTargetData
SpellDestination spellDst;
};
// Targets store structures and data
struct TargetInfo
{
uint64 targetGUID;
uint64 timeDelay;
SpellMissInfo missCondition:8;
SpellMissInfo reflectResult:8;
uint8 effectMask:8;
bool processed:1;
bool alive:1;
bool crit:1;
bool scaleAura:1;
int32 damage;
};
static const uint32 SPELL_INTERRUPT_NONPLAYER = 32747;
class Spell
@@ -241,6 +256,9 @@ class Spell
friend void Unit::SetCurrentCastedSpell(Spell* pSpell);
friend class SpellScript;
public:
Spell(Unit* caster, SpellInfo const* info, TriggerCastFlags triggerFlags, uint64 originalCasterGUID = 0, bool skipCheck = false);
~Spell();
void EffectNULL(SpellEffIndex effIndex);
void EffectUnused(SpellEffIndex effIndex);
void EffectDistract(SpellEffIndex effIndex);
@@ -369,9 +387,6 @@ public:
typedef std::set<Aura*> UsedSpellMods;
Spell(Unit* caster, SpellInfo const* info, TriggerCastFlags triggerFlags, uint64 originalCasterGUID = 0, bool skipCheck = false);
~Spell();
void InitExplicitTargets(SpellCastTargets const& targets);
void SelectExplicitTargets();
@@ -473,7 +488,7 @@ public:
void HandleEffects(Unit* pUnitTarget, Item* pItemTarget, GameObject* pGOTarget, uint32 i, SpellEffectHandleMode mode);
void HandleThreatSpells();
SpellInfo const* const m_spellInfo;
SpellInfo const* m_spellInfo;
Item* m_CastItem;
uint64 m_castItemGUID;
uint8 m_cast_count;
@@ -511,6 +526,7 @@ public:
Unit* GetCaster() const { return m_caster; }
Unit* GetOriginalCaster() const { return m_originalCaster; }
SpellInfo const* GetSpellInfo() const { return m_spellInfo; }
void SetSpellInfo(SpellInfo const* info) { m_spellInfo = info; }
int32 GetPowerCost() const { return m_powerCost; }
bool UpdatePointers(); // must be used at call Spell code after time delay (non triggered spell cast/update spell call/etc)
@@ -522,21 +538,6 @@ public:
// xinef: moved to public
void LoadScripts();
// Targets store structures and data
struct TargetInfo
{
uint64 targetGUID;
uint64 timeDelay;
SpellMissInfo missCondition: 8;
SpellMissInfo reflectResult: 8;
uint8 effectMask: 8;
bool processed: 1;
bool alive: 1;
bool crit: 1;
bool scaleAura: 1;
int32 damage;
};
std::list<TargetInfo>* GetUniqueTargetInfo() { return &m_UniqueTargetInfo; }
protected:
bool HasGlobalCooldown() const;

View File

@@ -9,6 +9,7 @@
#include "ConditionMgr.h"
#include "DBCStores.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "Spell.h"
#include "SpellAuraDefines.h"
#include "SpellAuraEffects.h"
@@ -2487,7 +2488,14 @@ SpellInfo const* SpellInfo::GetAuraRankForLevel(uint8 level) const
if (!needRankSelection)
return this;
for (SpellInfo const* nextSpellInfo = this; nextSpellInfo != nullptr; nextSpellInfo = nextSpellInfo->GetPrevRankSpell())
SpellInfo const* nextSpellInfo = nullptr;
sScriptMgr->OnBeforeAuraRankForLevel(this, nextSpellInfo, level);
if (nextSpellInfo != nullptr)
return nextSpellInfo;
for (nextSpellInfo = this; nextSpellInfo != nullptr; nextSpellInfo = nextSpellInfo->GetPrevRankSpell())
{
// if found appropriate level
if (uint32(level + 10) >= nextSpellInfo->SpellLevel)