Core/Creatures: fixed school immunity unapply when updating entry and unified code
- Also use correct data type for SQL (INT <-> uint32) (cherry picked from commit 00c0ec3f2784e67f4ccc7616bf65aa7e5496687a)
This commit is contained in:
@@ -667,8 +667,7 @@ bool Creature::UpdateEntry(uint32 entry, CreatureData const* data /*= nullptr*/,
|
||||
|
||||
UpdateMovementFlags();
|
||||
LoadCreaturesAddon();
|
||||
LoadMechanicTemplateImmunity();
|
||||
LoadSpellTemplateImmunity();
|
||||
LoadTemplateImmunities();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2201,7 +2200,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
|
||||
@@ -2211,6 +2210,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;
|
||||
@@ -2223,26 +2225,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
|
||||
|
||||
@@ -111,8 +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;
|
||||
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;
|
||||
|
||||
@@ -399,7 +399,7 @@ struct TC_GAME_API CreatureTemplate
|
||||
int32 WidgetSetUnitConditionID;
|
||||
bool RegenHealth;
|
||||
uint32 MechanicImmuneMask;
|
||||
uint8 SpellSchoolImmuneMask;
|
||||
uint32 SpellSchoolImmuneMask;
|
||||
uint32 flags_extra;
|
||||
uint32 ScriptID;
|
||||
WorldPacket QueryData[TOTAL_LOCALES];
|
||||
|
||||
@@ -376,7 +376,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;
|
||||
|
||||
@@ -540,7 +540,7 @@ void ObjectMgr::LoadCreatureTemplate(Field* fields)
|
||||
creatureTemplate.WidgetSetUnitConditionID = fields[72].GetInt32();
|
||||
creatureTemplate.RegenHealth = fields[73].GetBool();
|
||||
creatureTemplate.MechanicImmuneMask = fields[74].GetUInt32();
|
||||
creatureTemplate.SpellSchoolImmuneMask = fields[75].GetUInt8();
|
||||
creatureTemplate.SpellSchoolImmuneMask = fields[75].GetUInt32();
|
||||
creatureTemplate.flags_extra = fields[76].GetUInt32();
|
||||
creatureTemplate.ScriptID = GetScriptId(fields[77].GetString());
|
||||
}
|
||||
|
||||
@@ -294,11 +294,10 @@ enum SpellSchools : uint16
|
||||
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
|
||||
@@ -2363,7 +2362,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