Skip to content

Commit

Permalink
Implemented binary resistances and some more (#18933)
Browse files Browse the repository at this point in the history
- Fixed possible exploit with tamed pets having template immunities
- Implemented binary resistances
- Corrected resistances calculations
- Pets properly inherit players spell penetration
- Fixed doubled block calculation for damaging melee spells
- Auras removing snare effects will only remove the snaring component
- Shapeshifting will properly remove movement impairing auras only and not crowd control (dragon's breath)
- Immunities are properly checked versus all schools appearing in spell, unit is immune only if immune to all schools
- Spells with melee and magic school mask should compare armor reduction with resistances and select smaller reduction
- Demonic Circle: Teleport no longer removes root effects
  • Loading branch information
tomasz-szyszko authored and ariel- committed Feb 4, 2017
1 parent 86da1a1 commit 93746e8
Show file tree
Hide file tree
Showing 13 changed files with 381 additions and 84 deletions.
34 changes: 34 additions & 0 deletions sql/updates/world/3.3.5/2017_02_04_14_world.sql
@@ -0,0 +1,34 @@

DELETE FROM `spell_custom_attr` WHERE `entry` IN (63124) AND `attributes`= 131072;
INSERT INTO `spell_custom_attr` VALUES (63124, 131072); -- quest "There's Something About the Squire" (13654)

DELETE FROM `spell_custom_attr` WHERE `entry` IN (63293, 68873, 70324, 64619) AND `attributes`= 4;
INSERT INTO `spell_custom_attr` VALUES
(63293, 4), -- Mimiron - spinning damage
(68873, 4), -- Wailing Souls
(70324, 4), -- Wailing Souls
(64619, 4); -- Ulduar, Mimiron, Emergency Fire Bot, Water Spray

DELETE FROM `spell_custom_attr` WHERE `entry` IN (66809, 67331, 66765, 67333) AND `attributes`=8;
INSERT INTO `spell_custom_attr` VALUES
(66809, 8), -- Meteor Fists
(67331, 8), -- Meteor Fists
(66765, 8), -- Meteor Fists
(67333, 8); -- Meteor Fists

DELETE FROM `spell_custom_attr` WHERE `entry` IN (66378, 67097, 67098, 67099, 64125, 64126, 72409, 72447, 72448, 72449, 62775) AND `attributes`=32768;
INSERT INTO `spell_custom_attr` VALUES
(66378, 32768), -- Trial of the Crusader, Jaraxxus, Shivan Slash
(67097, 32768), -- Trial of the Crusader, Jaraxxus, Shivan Slash
(67098, 32768), -- Trial of the Crusader, Jaraxxus, Shivan Slash
(67099, 32768), -- Trial of the Crusader, Jaraxxus, Shivan Slash
(64125, 32768), -- Ulduar, Yogg-Saron, Squeeze
(64126, 32768), -- Ulduar, Yogg-Saron, Squeeze
(72409, 32768), -- Rune of Blood (Deathbringer Saurfang)
(72447, 32768), -- Rune of Blood (Deathbringer Saurfang)
(72448, 32768), -- Rune of Blood (Deathbringer Saurfang)
(72449, 32768), -- Rune of Blood (Deathbringer Saurfang)
(62775, 32768); -- Ulduar: XT-002 Tympanic Tamparum

DELETE FROM `spell_custom_attr` WHERE `entry` IN (45145) AND `attributes`= 1048576;
INSERT INTO `spell_custom_attr` VALUES (45145, 1048576); -- Snake Trap Effect
14 changes: 9 additions & 5 deletions src/server/game/Entities/Creature/Creature.cpp
Expand Up @@ -1823,28 +1823,32 @@ void Creature::DespawnOrUnsummon(uint32 msTimeToDespawn /*= 0*/, Seconds const&
ForcedDespawn(msTimeToDespawn, forceRespawnTimer);
}

bool Creature::HasMechanicTemplateImmunity(uint32 mask) const
{
return !GetOwnerGUID().IsPlayer() && (GetCreatureTemplate()->MechanicImmuneMask & mask);
}

bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo, Unit* caster) const
{
if (!spellInfo)
return false;

// Creature is immune to main mechanic of the spell
if (GetCreatureTemplate()->MechanicImmuneMask & (1 << (spellInfo->Mechanic - 1)))
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 (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
if (!spellInfo->Effects[i].IsEffect())
continue;
if (!IsImmunedToSpellEffect(spellInfo, i, caster))
if (spellInfo->Effects[i].IsEffect() && !IsImmunedToSpellEffect(spellInfo, i, caster))
{
immunedToAllEffects = false;
break;
}
}

if (immunedToAllEffects)
return true;

Expand All @@ -1853,7 +1857,7 @@ bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo, Unit* caster) const

bool Creature::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, Unit* caster) const
{
if (GetCreatureTemplate()->MechanicImmuneMask & (1 << (spellInfo->Effects[index].Mechanic - 1)))
if (spellInfo->Effects[index].Mechanic > MECHANIC_NONE && HasMechanicTemplateImmunity(1 << (spellInfo->Effects[index].Mechanic - 1)))
return true;

if (GetCreatureTemplate()->type == CREATURE_TYPE_MECHANICAL && spellInfo->Effects[index].Effect == SPELL_EFFECT_HEAL)
Expand Down
1 change: 1 addition & 0 deletions src/server/game/Entities/Creature/Creature.h
Expand Up @@ -470,6 +470,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;
bool HasMechanicTemplateImmunity(uint32 mask) const;
bool IsImmunedToSpell(SpellInfo const* spellInfo, Unit* caster) const override;
bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, Unit* caster) const override;
bool isElite() const;
Expand Down

0 comments on commit 93746e8

Please sign in to comment.