mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-21 20:56:23 +00:00
feat(Core/Creature): implement c_t->spell_school_immune_mask (#4358)
* feat(Core/Creature): implement spell_school_immune_mask
* ae878e18ef
Co-Authored-By: Wyreth <32145860+Wyreth@users.noreply.github.com>
* Import from TC
* just capitalize sql keywords
* Update rev_1611769264588956600.sql
Co-authored-by: Wyreth <32145860+Wyreth@users.noreply.github.com>
This commit is contained in:
@@ -488,6 +488,7 @@ bool Creature::UpdateEntry(uint32 Entry, const CreatureData* data, bool changele
|
||||
|
||||
UpdateEnvironmentIfNeeded(3);
|
||||
|
||||
LoadSpellTemplateImmunity();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1804,6 +1805,37 @@ bool Creature::HasMechanicTemplateImmunity(uint32 mask) const
|
||||
return !IS_PLAYER_GUID(GetOwnerGUID()) && (GetCreatureTemplate()->MechanicImmuneMask & mask);
|
||||
}
|
||||
|
||||
void Creature::LoadSpellTemplateImmunity()
|
||||
{
|
||||
// uint32 max used for "spell id", the immunity system will not perform SpellInfo checks against invalid spells
|
||||
// used so we know which immunities were loaded from template
|
||||
static uint32 const placeholderSpellId = std::numeric_limits<uint32>::max();
|
||||
|
||||
// unapply template immunities (in case we're updating entry)
|
||||
for (uint8 i = SPELL_SCHOOL_NORMAL; i <= SPELL_SCHOOL_ARCANE; ++i)
|
||||
{
|
||||
ApplySpellImmune(placeholderSpellId, IMMUNITY_SCHOOL, i, false);
|
||||
}
|
||||
|
||||
// don't inherit immunities for hunter pets
|
||||
if (IS_PLAYER_GUID(GetOwnerGUID()) && IsHunterPet())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (uint8 mask = GetCreatureTemplate()->SpellSchoolImmuneMask)
|
||||
{
|
||||
for (uint8 i = SPELL_SCHOOL_NORMAL; i <= SPELL_SCHOOL_ARCANE; ++i)
|
||||
{
|
||||
if (mask & (1 << i))
|
||||
{
|
||||
ApplySpellImmune(placeholderSpellId, IMMUNITY_SCHOOL, 1 << i, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo)
|
||||
{
|
||||
if (!spellInfo)
|
||||
|
||||
Reference in New Issue
Block a user