mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-17 05:29:43 -04:00
Core/Spells: Fixed resist calculations for spells with multiple schools. Thx to Shauren for tips
Closes #3875
This commit is contained in:
@@ -1584,7 +1584,7 @@ void Unit::CalcAbsorbResist(Unit* victim, SpellSchoolMask schoolMask, DamageEffe
|
||||
// Magic damage, check for resists
|
||||
if ((schoolMask & SPELL_SCHOOL_MASK_NORMAL) == 0)
|
||||
{
|
||||
float victimResistance = float(victim->GetResistance(GetFirstSchoolInMask(schoolMask)));
|
||||
float victimResistance = float(victim->GetResistance(schoolMask));
|
||||
victimResistance += float(GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_RESISTANCE, schoolMask));
|
||||
|
||||
if (Player* player = ToPlayer())
|
||||
@@ -17386,7 +17386,7 @@ uint32 Unit::GetRemainingPeriodicAmount(uint64 caster, uint32 spellId, AuraType
|
||||
AuraEffectList const& periodicAuras = GetAuraEffectsByType(auraType);
|
||||
for (AuraEffectList::const_iterator i = periodicAuras.begin(); i != periodicAuras.end(); ++i)
|
||||
{
|
||||
if ((*i)->GetCasterGUID() != caster || (*i)->GetId() != spellId || (*i)->GetEffIndex() != effectIndex || (*i)->GetTotalTicks() == 0)
|
||||
if ((*i)->GetCasterGUID() != caster || (*i)->GetId() != spellId || (*i)->GetEffIndex() != effectIndex || !(*i)->GetTotalTicks())
|
||||
continue;
|
||||
amount += uint32(((*i)->GetAmount() * std::max<int32>((*i)->GetTotalTicks() - int32((*i)->GetTickNumber()), 0)) / (*i)->GetTotalTicks());
|
||||
break;
|
||||
@@ -17402,6 +17402,17 @@ void Unit::SendClearTarget()
|
||||
SendMessageToSet(&data, false);
|
||||
}
|
||||
|
||||
uint32 Unit::GetResistance(SpellSchoolMask mask) const
|
||||
{
|
||||
int32 resist = -1;
|
||||
for (int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i)
|
||||
if (mask & (1 << i) && (resist < 0 || resist > int32(GetResistance(SpellSchools(i)))))
|
||||
resist = int32(GetResistance(SpellSchools(i)));
|
||||
|
||||
// resist value will never be negative here
|
||||
return uint32(resist);
|
||||
}
|
||||
|
||||
void CharmInfo::SetIsCommandAttack(bool val)
|
||||
{
|
||||
m_isCommandAttack = val;
|
||||
|
||||
@@ -1346,6 +1346,7 @@ class Unit : public WorldObject
|
||||
void SetArmor(int32 val) { SetResistance(SPELL_SCHOOL_NORMAL, val); }
|
||||
|
||||
uint32 GetResistance(SpellSchools school) const { return GetUInt32Value(UNIT_FIELD_RESISTANCES+school); }
|
||||
uint32 GetResistance(SpellSchoolMask mask) const;
|
||||
void SetResistance(SpellSchools school, int32 val) { SetStatInt32Value(UNIT_FIELD_RESISTANCES+school, val); }
|
||||
|
||||
uint32 GetHealth() const { return GetUInt32Value(UNIT_FIELD_HEALTH); }
|
||||
@@ -1517,7 +1518,7 @@ class Unit : public WorldObject
|
||||
{
|
||||
value = soft_cap + ((value - soft_cap) / 2);
|
||||
}
|
||||
|
||||
|
||||
return value;
|
||||
}
|
||||
uint32 GetUnitMeleeSkill(Unit const* target = NULL) const { return (target ? getLevelForTarget(target) : getLevel()) * 5; }
|
||||
|
||||
@@ -177,7 +177,7 @@ void Vehicle::ApplyAllImmunities()
|
||||
case 244: // Wintergrasp
|
||||
case 510: // Isle of Conquest
|
||||
_me->SetControlled(true, UNIT_STAT_ROOT);
|
||||
// why we need to apply this? we can simple add immunities to slow mechamic in DB
|
||||
// why we need to apply this? we can simple add immunities to slow mechanic in DB
|
||||
_me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_DECREASE_SPEED, true);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -971,7 +971,7 @@ class spell_sindragosa_s_fury : public SpellScriptLoader
|
||||
if (!GetHitUnit()->isAlive() || !_targetCount)
|
||||
return;
|
||||
|
||||
float resistance = float(GetHitUnit()->GetResistance(GetFirstSchoolInMask(SpellSchoolMask(GetSpellInfo()->SchoolMask))));
|
||||
float resistance = float(GetHitUnit()->GetResistance(SpellSchoolMask(GetSpellInfo()->SchoolMask)));
|
||||
uint32 minResistFactor = uint32((resistance / (resistance + 510.0f))* 10.0f) * 2;
|
||||
uint32 randomResist = urand(0, (9 - minResistFactor) * 100)/100 + minResistFactor;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user