mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-22 02:04:52 +01:00
Core/Creature: Load template immunities into m_spellImmune container.
- Fixes sending SMSG_SPELL_START data
Closes #19212
(cherrypicked from 7cb6915e2b)
This commit is contained in:
@@ -577,6 +577,7 @@ bool Creature::UpdateEntry(uint32 entry, CreatureData const* data /*= nullptr*/,
|
||||
|
||||
UpdateMovementFlags();
|
||||
LoadCreaturesAddon();
|
||||
LoadMechanicTemplateImmunity();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2015,9 +2016,28 @@ void Creature::DespawnOrUnsummon(uint32 msTimeToDespawn /*= 0*/, Seconds const&
|
||||
ForcedDespawn(msTimeToDespawn, forceRespawnTimer);
|
||||
}
|
||||
|
||||
bool Creature::HasMechanicTemplateImmunity(uint32 mask) const
|
||||
void Creature::LoadMechanicTemplateImmunity()
|
||||
{
|
||||
return (!GetOwnerGUID().IsPlayer() || !IsHunterPet()) && (GetCreatureTemplate()->MechanicImmuneMask & mask);
|
||||
// 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 (uint32 i = MECHANIC_NONE + 1; i < MAX_MECHANIC; ++i)
|
||||
ApplySpellImmune(placeholderSpellId, IMMUNITY_MECHANIC, i, false);
|
||||
|
||||
// don't inherit immunities for hunter pets
|
||||
if (GetOwnerGUID().IsPlayer() && IsHunterPet())
|
||||
return;
|
||||
|
||||
if (uint32 mask = GetCreatureTemplate()->MechanicImmuneMask)
|
||||
{
|
||||
for (uint32 i = MECHANIC_NONE + 1; i < MAX_MECHANIC; ++i)
|
||||
{
|
||||
if (mask & (1 << (i - 1)))
|
||||
ApplySpellImmune(placeholderSpellId, IMMUNITY_MECHANIC, i, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo, Unit* caster) const
|
||||
@@ -2025,12 +2045,6 @@ bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo, Unit* caster) const
|
||||
if (!spellInfo)
|
||||
return false;
|
||||
|
||||
// Creature is immune to main mechanic of the spell
|
||||
if (spellInfo->Mechanic > MECHANIC_NONE && HasMechanicTemplateImmunity(1 << (spellInfo->Mechanic - 1)))
|
||||
return true;
|
||||
|
||||
// This check must be done instead of 'if (GetCreatureTemplate()->MechanicImmuneMask & (1 << (spellInfo->Mechanic - 1)))' for not break
|
||||
// the check of mechanic immunity on DB (tested) because GetCreatureTemplate()->MechanicImmuneMask and m_spellImmune[IMMUNITY_MECHANIC] don't have same data.
|
||||
bool immunedToAllEffects = true;
|
||||
for (SpellEffectInfo const* effect : spellInfo->GetEffectsForDifficulty(GetMap()->GetDifficultyID()))
|
||||
{
|
||||
@@ -2056,9 +2070,6 @@ bool Creature::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index,
|
||||
if (!effect)
|
||||
return true;
|
||||
|
||||
if (effect->Mechanic > MECHANIC_NONE && HasMechanicTemplateImmunity(1 << (effect->Mechanic - 1)))
|
||||
return true;
|
||||
|
||||
if (GetCreatureTemplate()->type == CREATURE_TYPE_MECHANICAL && effect->Effect == SPELL_EFFECT_HEAL)
|
||||
return true;
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
|
||||
bool isCanInteractWithBattleMaster(Player* player, bool msg) const;
|
||||
bool CanResetTalents(Player* player) const;
|
||||
bool CanCreatureAttack(Unit const* victim, bool force = true) const;
|
||||
bool HasMechanicTemplateImmunity(uint32 mask) const;
|
||||
void LoadMechanicTemplateImmunity();
|
||||
bool IsImmunedToSpell(SpellInfo const* spellInfo, Unit* caster) const override;
|
||||
bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, Unit* caster) const override;
|
||||
bool isElite() const;
|
||||
|
||||
Reference in New Issue
Block a user