aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortobmaps <spambot42@yandex.ru>2011-11-12 04:40:44 +0700
committertobmaps <spambot42@yandex.ru>2011-11-12 04:40:44 +0700
commit3569f01adcbb9badc2a4211fd472bf5110239267 (patch)
treefccbd2b32110827c04ab018f3f459a41b55c074a /src
parentc5e316164fa4cbb3dcdac1ef3d06554ca0d41e47 (diff)
Core/Spells: Fixed resist calculations for spells with multiple schools. Thx to Shauren for tips
Closes #3875
Diffstat (limited to 'src')
-rwxr-xr-xsrc/server/game/Entities/Unit/Unit.cpp15
-rwxr-xr-xsrc/server/game/Entities/Unit/Unit.h3
-rwxr-xr-xsrc/server/game/Entities/Vehicle/Vehicle.cpp2
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp2
4 files changed, 17 insertions, 5 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index f9d049a51b8..f6798d08708 100755
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -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;
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index 36844d97b67..02e78276782 100755
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -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; }
diff --git a/src/server/game/Entities/Vehicle/Vehicle.cpp b/src/server/game/Entities/Vehicle/Vehicle.cpp
index edd8745d246..fe018ec78ce 100755
--- a/src/server/game/Entities/Vehicle/Vehicle.cpp
+++ b/src/server/game/Entities/Vehicle/Vehicle.cpp
@@ -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:
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp
index 5b612942435..7ef2e887a1d 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp
@@ -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;