Core/Creatures: fixed school immunity unapply when updating entry and unified code
Port From (https://github.com/TrinityCore/TrinityCore/commit/e4ca95983b1dc55e5b656d934d99b92cee30b444)
This commit is contained in:
@@ -419,8 +419,7 @@ namespace Game.Entities
|
||||
|
||||
UpdateMovementFlags();
|
||||
LoadCreaturesAddon();
|
||||
LoadMechanicTemplateImmunity();
|
||||
LoadSpellTemplateImmunity();
|
||||
LoadTemplateImmunities();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1868,16 +1867,19 @@ namespace Game.Entities
|
||||
ForcedDespawn(msTimeToDespawn, forceRespawnTimer);
|
||||
}
|
||||
|
||||
public void LoadMechanicTemplateImmunity()
|
||||
public void 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
|
||||
uint placeholderSpellId = uint.MaxValue;
|
||||
|
||||
// unapply template immunities (in case we're updating entry)
|
||||
for (uint i = 1; i < (int)Mechanics.Max; ++i)
|
||||
for (uint i = 0; i < (int)Mechanics.Max; ++i)
|
||||
ApplySpellImmune(placeholderSpellId, SpellImmunity.Mechanic, i, false);
|
||||
|
||||
for (var i = (int)SpellSchools.Normal; i < (int)SpellSchools.Max; ++i)
|
||||
ApplySpellImmune(placeholderSpellId, SpellImmunity.School, 1u << i, false);
|
||||
|
||||
// don't inherit immunities for hunter pets
|
||||
if (GetOwnerGUID().IsPlayer() && IsHunterPet())
|
||||
return;
|
||||
@@ -1891,25 +1893,10 @@ namespace Game.Entities
|
||||
ApplySpellImmune(placeholderSpellId, SpellImmunity.Mechanic, i, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void 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
|
||||
uint placeholderSpellId = uint.MaxValue;
|
||||
|
||||
// unapply template immunities (in case we're updating entry)
|
||||
for (var i = SpellSchoolMask.Normal; i <= SpellSchoolMask.Arcane; ++i)
|
||||
ApplySpellImmune(placeholderSpellId, SpellImmunity.School, i, false);
|
||||
|
||||
// don't inherit immunities for hunter pets
|
||||
if (GetOwnerGUID().IsPlayer() && IsHunterPet())
|
||||
return;
|
||||
|
||||
byte mask = GetCreatureTemplate().SpellSchoolImmuneMask;
|
||||
mask = GetCreatureTemplate().SpellSchoolImmuneMask;
|
||||
if (mask != 0)
|
||||
for (var i = (int)SpellSchoolMask.Normal; i <= (int)SpellSchoolMask.Arcane; ++i)
|
||||
for (var i = (int)SpellSchools.Normal; i <= (int)SpellSchools.Max; ++i)
|
||||
if ((mask & (1 << i)) != 0)
|
||||
ApplySpellImmune(placeholderSpellId, SpellImmunity.School, 1u << i, true);
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace Game.Entities
|
||||
public int WidgetSetUnitConditionID;
|
||||
public bool RegenHealth;
|
||||
public uint MechanicImmuneMask;
|
||||
public byte SpellSchoolImmuneMask;
|
||||
public uint SpellSchoolImmuneMask;
|
||||
public CreatureFlagsExtra FlagsExtra;
|
||||
public uint ScriptID;
|
||||
|
||||
|
||||
@@ -357,7 +357,7 @@ namespace Game.Entities
|
||||
owner.ToPlayer().SetLastPetNumber(petId);
|
||||
|
||||
// must be after SetMinion (owner guid check)
|
||||
LoadMechanicTemplateImmunity();
|
||||
LoadTemplateImmunities();
|
||||
m_loading = false;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -1870,7 +1870,7 @@ namespace Game
|
||||
creature.WidgetSetUnitConditionID = fields.Read<int>(72);
|
||||
creature.RegenHealth = fields.Read<bool>(73);
|
||||
creature.MechanicImmuneMask = fields.Read<uint>(74);
|
||||
creature.SpellSchoolImmuneMask = fields.Read<byte>(75);
|
||||
creature.SpellSchoolImmuneMask = fields.Read<uint>(75);
|
||||
creature.FlagsExtra = (CreatureFlagsExtra)fields.Read<uint>(76);
|
||||
creature.ScriptID = GetScriptId(fields.Read<string>(77));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user