aboutsummaryrefslogtreecommitdiff
path: root/src/game/SpellMgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/SpellMgr.cpp')
-rw-r--r--src/game/SpellMgr.cpp114
1 files changed, 103 insertions, 11 deletions
diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp
index 98585fceaaf..8d842bd63a6 100644
--- a/src/game/SpellMgr.cpp
+++ b/src/game/SpellMgr.cpp
@@ -547,6 +547,17 @@ bool IsSingleTargetSpells(SpellEntry const *spellInfo1, SpellEntry const *spellI
return false;
}
+bool IsAuraAddedBySpell(uint32 auraType, uint32 spellId)
+{
+ SpellEntry const *spellproto = sSpellStore.LookupEntry(spellId);
+ if (!spellproto) return false;
+
+ for (int i = 0; i < 3; i++)
+ if (spellproto->EffectApplyAuraName[i] == auraType)
+ return true;
+ return false;
+}
+
uint8 GetErrorAtShapeshiftedCast (SpellEntry const *spellInfo, uint32 form)
{
// talents that learn spells can have stance requirements that need ignore
@@ -823,8 +834,8 @@ void SpellMgr::LoadSpellProcEvents()
uint32 count = 0;
- // 0 1 2 3 4 5 6 7 8
- QueryResult *result = WorldDatabase.Query("SELECT entry, SchoolMask, Category, SkillID, SpellFamilyName, SpellFamilyMask, procFlags, ppmRate, cooldown FROM spell_proc_event");
+ // 0 1 2 3 4 5 6 7 8
+ QueryResult *result = WorldDatabase.Query("SELECT entry, SchoolMask, SpellFamilyName, SpellFamilyMask, procFlags, procEx, ppmRate, CustomChance, Cooldown FROM spell_proc_event");
if( !result )
{
@@ -838,7 +849,7 @@ void SpellMgr::LoadSpellProcEvents()
}
barGoLink bar( result->GetRowCount() );
-
+ uint32 customProc = 0;
do
{
Field *fields = result->Fetch();
@@ -847,7 +858,8 @@ void SpellMgr::LoadSpellProcEvents()
uint16 entry = fields[0].GetUInt16();
- if (!sSpellStore.LookupEntry(entry))
+ const SpellEntry *spell = sSpellStore.LookupEntry(entry);
+ if (!spell)
{
sLog.outErrorDb("Spell %u listed in `spell_proc_event` does not exist", entry);
continue;
@@ -856,23 +868,35 @@ void SpellMgr::LoadSpellProcEvents()
SpellProcEventEntry spe;
spe.schoolMask = fields[1].GetUInt32();
- spe.category = fields[2].GetUInt32();
- spe.skillId = fields[3].GetUInt32();
- spe.spellFamilyName = fields[4].GetUInt32();
- spe.spellFamilyMask = fields[5].GetUInt64();
- spe.procFlags = fields[6].GetUInt32();
- spe.ppmRate = fields[7].GetFloat();
+ spe.spellFamilyName = fields[2].GetUInt32();
+ spe.spellFamilyMask = fields[3].GetUInt64();
+ spe.procFlags = fields[4].GetUInt32();
+ spe.procEx = fields[5].GetUInt32();
+ spe.ppmRate = fields[6].GetFloat();
+ spe.customChance = fields[7].GetFloat();
spe.cooldown = fields[8].GetUInt32();
mSpellProcEventMap[entry] = spe;
+ if (spell->procFlags==0)
+ {
+ if (spe.procFlags == 0)
+ {
+ sLog.outErrorDb("Spell %u listed in `spell_proc_event` probally not triggered spell", entry);
+ continue;
+ }
+ customProc++;
+ }
++count;
} while( result->NextRow() );
delete result;
sLog.outString();
- sLog.outString( ">> Loaded %u spell proc event conditions", count );
+ if (customProc)
+ sLog.outString( ">> Loaded %u custom spell proc event conditions +%u custom", count, customProc );
+ else
+ sLog.outString( ">> Loaded %u spell proc event conditions", count );
/*
// Commented for now, as it still produces many errors (still quite many spells miss spell_proc_event)
@@ -904,6 +928,7 @@ void SpellMgr::LoadSpellProcEvents()
*/
}
+/*
bool SpellMgr::IsSpellProcEventCanTriggeredBy( SpellProcEventEntry const * spellProcEvent, SpellEntry const * procSpell, uint32 procFlags )
{
if((procFlags & spellProcEvent->procFlags) == 0)
@@ -942,6 +967,73 @@ bool SpellMgr::IsSpellProcEventCanTriggeredBy( SpellProcEventEntry const * spell
return true;
}
+*/
+
+bool SpellMgr::IsSpellProcEventCanTriggeredBy(SpellProcEventEntry const * spellProcEvent, uint32 EventProcFlag, SpellEntry const * procSpell, uint32 procFlags, uint32 procExtra, bool active)
+{
+ // No extra req need
+ uint32 procEvent_procEx = PROC_EX_NONE;
+
+ // check prockFlags for condition
+ if((procFlags & EventProcFlag) == 0)
+ return false;
+
+ // Always trigger for this
+ if (EventProcFlag & (PROC_FLAG_KILLED | PROC_FLAG_KILL_AND_GET_XP))
+ return true;
+
+ if (spellProcEvent) // Exist event data
+ {
+ // Store extra req
+ procEvent_procEx = spellProcEvent->procEx;
+
+ // For melee triggers
+ if (procSpell == NULL)
+ {
+ // Check (if set) for school (melee attack have Normal school)
+ if(spellProcEvent->schoolMask && (spellProcEvent->schoolMask & SPELL_SCHOOL_MASK_NORMAL) == 0)
+ return false;
+ }
+ else // For spells need check school/spell family/family mask
+ {
+ // Check (if set) for school
+ if(spellProcEvent->schoolMask && (spellProcEvent->schoolMask & procSpell->SchoolMask) == 0)
+ return false;
+
+ // Check (if set) for spellFamilyName
+ if(spellProcEvent->spellFamilyName && (spellProcEvent->spellFamilyName != procSpell->SpellFamilyName))
+ return false;
+
+ // spellFamilyName is Ok need check for spellFamilyMask if present
+ if(spellProcEvent->spellFamilyMask)
+ {
+ if ((spellProcEvent->spellFamilyMask & procSpell->SpellFamilyFlags) == 0)
+ return false;
+ active = true; // Spell added manualy -> so its active spell
+ }
+ }
+ }
+ // Check for extra req (if none) and hit/crit
+ if (procEvent_procEx == PROC_EX_NONE)
+ {
+ // No extra req, so can trigger only for active (damage/healing present) and hit/crit
+ if((procExtra & (PROC_EX_NORMAL_HIT|PROC_EX_CRITICAL_HIT)) && active)
+ return true;
+ }
+ else // Passive spells hits here only if resist/reflect/immune/evade
+ {
+ // Exist req for PROC_EX_EX_TRIGGER_ALWAYS
+ if (procEvent_procEx & PROC_EX_EX_TRIGGER_ALWAYS)
+ return true;
+ // Passive spells can`t trigger if need hit
+ if ((procEvent_procEx & PROC_EX_NORMAL_HIT) && !active)
+ return false;
+ // Check Extra Requirement like (hit/crit/miss/resist/parry/dodge/block/immune/reflect/absorb and other)
+ if (procEvent_procEx & procExtra)
+ return true;
+ }
+ return false;
+}
void SpellMgr::LoadSpellElixirs()
{