Core/Creatures: fixed school immunity unapply when updating entry and unified code
This commit is contained in:
1 parent
1636e36411
commit
19ddf3e8a5
6 files changed
+18
-29
No files matched your search
@@ -491,8 +491,7 @@ bool Creature::UpdateEntry(uint32 entry, CreatureData const* data /*= nullptr*/,
|
||||
|
||||
UpdateMovementFlags();
|
||||
LoadCreaturesAddon();
|
||||
LoadMechanicTemplateImmunity();
|
||||
LoadSpellTemplateImmunity();
|
||||
LoadTemplateImmunities();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1852,7 +1851,7 @@ void Creature::DespawnOrUnsummon(uint32 msTimeToDespawn /*= 0*/, Seconds const&
|
||||
ForcedDespawn(msTimeToDespawn, forceRespawnTimer);
|
||||
}
|
||||
|
||||
void Creature::LoadMechanicTemplateImmunity()
|
||||
void Creature::LoadTemplateImmunities()
|
||||
{
|
||||
// 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
|
||||
@@ -1862,6 +1861,9 @@ void Creature::LoadMechanicTemplateImmunity()
|
||||
for (uint32 i = MECHANIC_NONE + 1; i < MAX_MECHANIC; ++i)
|
||||
ApplySpellImmune(placeholderSpellId, IMMUNITY_MECHANIC, i, false);
|
||||
|
||||
for (uint32 i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i)
|
||||
ApplySpellImmune(placeholderSpellId, IMMUNITY_SCHOOL, 1 << i, false);
|
||||
|
||||
// don't inherit immunities for hunter pets
|
||||
if (GetOwnerGUID().IsPlayer() && IsHunterPet())
|
||||
return;
|
||||
@@ -1874,26 +1876,15 @@ void Creature::LoadMechanicTemplateImmunity()
|
||||
ApplySpellImmune(placeholderSpellId, IMMUNITY_MECHANIC, i, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 (GetOwnerGUID().IsPlayer() && IsHunterPet())
|
||||
return;
|
||||
|
||||
if (uint8 mask = GetCreatureTemplate()->SpellSchoolImmuneMask)
|
||||
for (uint8 i = SPELL_SCHOOL_NORMAL; i <= SPELL_SCHOOL_ARCANE; ++i)
|
||||
if (uint32 mask = GetCreatureTemplate()->SpellSchoolImmuneMask)
|
||||
{
|
||||
for (uint8 i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i)
|
||||
{
|
||||
if (mask & (1 << i))
|
||||
ApplySpellImmune(placeholderSpellId, IMMUNITY_SCHOOL, 1 << i, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo, Unit* caster) const
|
||||
|
||||
@@ -154,7 +154,7 @@ struct TC_GAME_API CreatureTemplate
|
||||
uint32 movementId;
|
||||
bool RegenHealth;
|
||||
uint32 MechanicImmuneMask;
|
||||
uint8 SpellSchoolImmuneMask;
|
||||
uint32 SpellSchoolImmuneMask;
|
||||
uint32 flags_extra;
|
||||
uint32 ScriptID;
|
||||
uint32 GetRandomValidModelId() const;
|
||||
@@ -497,8 +497,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
|
||||
bool isCanInteractWithBattleMaster(Player* player, bool msg) const;
|
||||
bool isCanTrainingAndResetTalentsOf(Player* player) const;
|
||||
bool CanCreatureAttack(Unit const* victim, bool force = true) const;
|
||||
void LoadMechanicTemplateImmunity();
|
||||
void LoadSpellTemplateImmunity();
|
||||
void LoadTemplateImmunities();
|
||||
bool IsImmunedToSpell(SpellInfo const* spellInfo, Unit* caster) const override;
|
||||
bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, Unit* caster) const override;
|
||||
bool isElite() const;
|
||||
|
||||
@@ -371,7 +371,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c
|
||||
owner->ToPlayer()->SetLastPetNumber(petId);
|
||||
|
||||
// must be after SetMinion (owner guid check)
|
||||
LoadMechanicTemplateImmunity();
|
||||
LoadTemplateImmunities();
|
||||
m_loading = false;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -537,7 +537,7 @@ void ObjectMgr::LoadCreatureTemplate(Field* fields)
|
||||
creatureTemplate.movementId = fields[74].GetUInt32();
|
||||
creatureTemplate.RegenHealth = fields[75].GetBool();
|
||||
creatureTemplate.MechanicImmuneMask = fields[76].GetUInt32();
|
||||
creatureTemplate.SpellSchoolImmuneMask = fields[77].GetUInt8();
|
||||
creatureTemplate.SpellSchoolImmuneMask = fields[77].GetUInt32();
|
||||
creatureTemplate.flags_extra = fields[78].GetUInt32();
|
||||
creatureTemplate.ScriptID = GetScriptId(fields[79].GetCString());
|
||||
}
|
||||
|
||||
@@ -254,11 +254,10 @@ enum SpellSchools
|
||||
SPELL_SCHOOL_NATURE = 3,
|
||||
SPELL_SCHOOL_FROST = 4,
|
||||
SPELL_SCHOOL_SHADOW = 5,
|
||||
SPELL_SCHOOL_ARCANE = 6
|
||||
SPELL_SCHOOL_ARCANE = 6,
|
||||
MAX_SPELL_SCHOOL = 7
|
||||
};
|
||||
|
||||
#define MAX_SPELL_SCHOOL 7
|
||||
|
||||
enum SpellSchoolMask
|
||||
{
|
||||
SPELL_SCHOOL_MASK_NONE = 0x00, // not exist
|
||||
@@ -1510,7 +1509,7 @@ enum Mechanics
|
||||
MECHANIC_SAPPED = 30,
|
||||
MECHANIC_ENRAGED = 31,
|
||||
MECHANIC_WOUNDED = 32,
|
||||
MAX_MECHANIC = 33
|
||||
MAX_MECHANIC = 33
|
||||
};
|
||||
|
||||
// Used for spell 42292 Immune Movement Impairment and Loss of Control (0x49967ca6)
|
||||
|
||||
Reference in new issue
Block a user