Core/Spells: Implement using different difficulty data from all spell related db2s, not just SpellEffect and SpellPower

This commit is contained in:
Shauren
2020-06-12 01:29:18 +02:00
parent 1cdd1d0249
commit c7306439e7
101 changed files with 1631 additions and 1796 deletions
@@ -20,6 +20,7 @@
#include "DB2Stores.h"
#include "Cell.h"
#include "CellImpl.h"
#include "CreatureAIImpl.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
#include "InstanceScript.h"
@@ -30,13 +31,6 @@
#include "SpellMgr.h"
#include "TemporarySummon.h"
// Spell summary for ScriptedAI::SelectSpell
struct TSpellSummary
{
uint8 Targets; // set of enum SelectTarget
uint8 Effects; // set of enum SelectEffect
} extern* SpellSummary;
void SummonList::Summon(Creature const* summon)
{
storage_.push_back(summon->GetGUID());
@@ -231,23 +225,25 @@ SpellInfo const* ScriptedAI::SelectSpell(Unit* target, uint32 school, uint32 mec
uint32 spellCount = 0;
SpellInfo const* tempSpell = nullptr;
AISpellInfoType const* aiSpell = nullptr;
//Check if each spell is viable(set it to null if not)
for (uint32 i = 0; i < MAX_CREATURE_SPELLS; i++)
{
tempSpell = sSpellMgr->GetSpellInfo(me->m_spells[i]);
tempSpell = sSpellMgr->GetSpellInfo(me->m_spells[i], me->GetMap()->GetDifficultyID());
aiSpell = GetAISpellInfo(me->m_spells[i], me->GetMap()->GetDifficultyID());
//This spell doesn't exist
if (!tempSpell)
if (!tempSpell || !aiSpell)
continue;
// Targets and Effects checked first as most used restrictions
//Check the spell targets if specified
if (targets && !(SpellSummary[me->m_spells[i]].Targets & (1 << (targets-1))))
if (targets && !(aiSpell->Targets & (1 << (targets-1))))
continue;
//Check the type of spell if we are looking for a specific spell type
if (effect && !(SpellSummary[me->m_spells[i]].Effects & (1 << (effect-1))))
if (effect && !(aiSpell->Effects & (1 << (effect-1))))
continue;
//Check for school if specified