Fixed wand damage immunity

This commit is contained in:
Sidsukana 2020-01-23 14:42:08 +00:00 committed by Antz
parent 2590413559
commit f36301c474
3 changed files with 43 additions and 13 deletions

View File

@ -3107,6 +3107,15 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit* pVictim, SpellEntry const* spell)
// Resist
SpellMissInfo Unit::SpellHitResult(Unit* pVictim, SpellEntry const* spell, bool CanReflect)
{
SpellSchoolMask schoolMask = GetSpellSchoolMask(spell);
// wand case
bool wand = spell->Id == 5019;
if (wand && !!(getClassMask() & CLASSMASK_WAND_USERS) && GetTypeId() == TYPEID_PLAYER)
{
schoolMask = GetSchoolMask(GetWeaponDamageSchool(RANGED_ATTACK));
}
// Return evade for units in evade mode
if (pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode())
{
@ -3114,7 +3123,7 @@ SpellMissInfo Unit::SpellHitResult(Unit* pVictim, SpellEntry const* spell, bool
}
// Check for immune
if (pVictim->IsImmuneToSpell(spell, this == pVictim) && !spell->HasAttribute(SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY))
if (!wand && pVictim->IsImmuneToSpell(spell, this == pVictim) && !spell->HasAttribute(SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY))
{
return SPELL_MISS_IMMUNE;
}
@ -3127,7 +3136,7 @@ SpellMissInfo Unit::SpellHitResult(Unit* pVictim, SpellEntry const* spell, bool
}
// Check for immune (use charges)
if (pVictim->IsImmuneToDamage(GetSpellSchoolMask(spell)) && !spell->HasAttribute(SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY))
if (pVictim->IsImmuneToDamage(schoolMask) && !spell->HasAttribute(SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY))
{
return SPELL_MISS_IMMUNE;
}
@ -3138,7 +3147,7 @@ SpellMissInfo Unit::SpellHitResult(Unit* pVictim, SpellEntry const* spell, bool
int32 reflectchance = pVictim->GetTotalAuraModifier(SPELL_AURA_REFLECT_SPELLS);
Unit::AuraList const& mReflectSpellsSchool = pVictim->GetAurasByType(SPELL_AURA_REFLECT_SPELLS_SCHOOL);
for (Unit::AuraList::const_iterator i = mReflectSpellsSchool.begin(); i != mReflectSpellsSchool.end(); ++i)
if ((*i)->GetModifier()->m_miscvalue & GetSpellSchoolMask(spell))
if ((*i)->GetModifier()->m_miscvalue & schoolMask)
{
reflectchance += (*i)->GetModifier()->m_amount;
}

View File

@ -3453,6 +3453,10 @@ class Unit : public WorldObject
float GetWeaponDamageRange(WeaponAttackType attType , WeaponDamageRange type) const;
void SetBaseWeaponDamage(WeaponAttackType attType , WeaponDamageRange damageRange, float value) { m_weaponDamage[attType][damageRange] = value; }
SpellSchools GetWeaponDamageSchool(WeaponAttackType attType, uint8 index = 0) const { return m_weaponDamageInfo.weapon[attType].damage[index].school; }
void SetWeaponDamageSchool(WeaponAttackType attType, SpellSchools school, uint8 index = 0) { m_weaponDamageInfo.weapon[attType].damage[index].school = school; }
// Visibility system
UnitVisibility GetVisibility() const { return m_Visibility; }
void SetVisibility(UnitVisibility x);
@ -3700,7 +3704,24 @@ class Unit : public WorldObject
virtual bool CanSwim() const = 0;
virtual bool CanFly() const = 0;
protected:
protected:
struct WeaponDamageInfo
{
struct Weapon
{
struct Damage
{
SpellSchools school = SPELL_SCHOOL_NORMAL;
float value[2] = { BASE_MINDAMAGE, BASE_MAXDAMAGE };
};
uint32 lines = 1;
Damage damage[MAX_ITEM_PROTO_DAMAGES];
};
Weapon weapon[MAX_ATTACK];
};
explicit Unit();
void _UpdateSpells(uint32 time);
@ -3736,6 +3757,8 @@ class Unit : public WorldObject
AuraList m_modAuras[TOTAL_AURAS];
float m_auraModifiersGroup[UNIT_MOD_END][MODIFIER_TYPE_END];
float m_weaponDamage[MAX_ATTACK][2];
WeaponDamageInfo m_weaponDamageInfo;
bool m_canModifyStats;
// std::list< spellEffectPair > AuraSpells[TOTAL_AURAS]; // TODO: use this if ok for mem
@ -3756,7 +3779,8 @@ class Unit : public WorldObject
bool m_isSpawningLinked;
private:
void CleanupDeletedAuras();
void CleanupDeletedAuras();
void UpdateSplineMovement(uint32 t_diff);
Unit* _GetTotem(TotemSlot slot) const; // for templated function without include need

View File

@ -333,16 +333,13 @@ Spell::Spell(Unit* caster, SpellEntry const* info, bool triggered, ObjectGuid or
m_spellSchoolMask = GetSpellSchoolMask(info); // Can be override for some spell (wand shoot for example)
// wand case
if (m_attackType == RANGED_ATTACK)
{
// wand case
if ((m_caster->getClassMask() & CLASSMASK_WAND_USERS) != 0 && m_caster->GetTypeId() == TYPEID_PLAYER)
{
if (Item* pItem = ((Player*)m_caster)->GetWeaponForAttack(RANGED_ATTACK))
{
m_spellSchoolMask = GetSchoolMask(pItem->GetProto()->Damage[0].DamageType);
}
}
if (!(m_caster->getClassMask() & CLASSMASK_WAND_USERS) && m_caster->GetTypeId() == TYPEID_PLAYER)
m_spellSchoolMask = GetSchoolMask(m_caster->GetWeaponDamageSchool(RANGED_ATTACK));
}
// Set health leech amount to zero
m_healthLeech = 0;