Core/Spells: Separation caster/target part damage/heal bonus calculations.
*Implement HoT/DoT save caster side bonuses and apply target mods on each tick
This commit is contained in:
1 parent
bc4303d8f9
commit
879070bc80
13 files changed
+472
-368
No files matched your search
@@ -953,7 +953,9 @@ uint32 Unit::SpellNonMeleeDamageLog(Unit* victim, uint32 spellID, uint32 damage)
|
||||
{
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellID);
|
||||
SpellNonMeleeDamage damageInfo(this, victim, spellInfo->Id, spellInfo->SchoolMask);
|
||||
damage = SpellDamageBonus(victim, spellInfo, damage, SPELL_DIRECT_DAMAGE);
|
||||
damage = SpellDamageBonusDone(victim, spellInfo, damage, SPELL_DIRECT_DAMAGE);
|
||||
damage = victim->SpellDamageBonusTaken(spellInfo, damage, SPELL_DIRECT_DAMAGE);
|
||||
|
||||
CalculateSpellDamageTaken(&damageInfo, damage, spellInfo);
|
||||
DealDamageMods(damageInfo.target, damageInfo.damage, &damageInfo.absorb);
|
||||
SendSpellNonMeleeDamageLog(&damageInfo);
|
||||
@@ -1148,7 +1150,8 @@ void Unit::CalculateMeleeDamage(Unit* victim, uint32 damage, CalcDamageInfo* dam
|
||||
|
||||
damage += CalculateDamage(damageInfo->attackType, false, true);
|
||||
// Add melee damage bonus
|
||||
MeleeDamageBonus(damageInfo->target, &damage, damageInfo->attackType);
|
||||
damage = MeleeDamageBonusDone(damageInfo->target, damage, damageInfo->attackType);
|
||||
damage = MeleeDamageBonusTaken(damage, damageInfo->attackType);
|
||||
|
||||
// Calculate armor reduction
|
||||
if (IsDamageReducedByArmor((SpellSchoolMask)(damageInfo->damageSchoolMask)))
|
||||
@@ -1400,7 +1403,10 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss)
|
||||
uint32 damage = (*dmgShieldItr)->GetAmount();
|
||||
|
||||
if (Unit* caster = (*dmgShieldItr)->GetCaster())
|
||||
damage = caster->SpellDamageBonus(this, i_spellProto, damage, SPELL_DIRECT_DAMAGE);
|
||||
{
|
||||
damage = caster->SpellDamageBonusDone(this, i_spellProto, damage, SPELL_DIRECT_DAMAGE);
|
||||
damage = this->SpellDamageBonusTaken(i_spellProto, damage, SPELL_DIRECT_DAMAGE);
|
||||
}
|
||||
|
||||
// No Unit::CalcAbsorbResist here - opcode doesn't send that data - this damage is probably not affected by that
|
||||
victim->DealDamageMods(this, damage, NULL);
|
||||
@@ -3652,7 +3658,10 @@ void Unit::RemoveAurasDueToSpellByDispel(uint32 spellId, uint32 dispellerSpellId
|
||||
// final heal
|
||||
int32 healAmount = aurEff->GetAmount();
|
||||
if (Unit* caster = aura->GetCaster())
|
||||
healAmount = caster->SpellHealingBonus(this, aura->GetSpellInfo(), healAmount, HEAL, dispelInfo.GetRemovedCharges());
|
||||
{
|
||||
healAmount = caster->SpellHealingBonusDone(this, aura->GetSpellInfo(), healAmount, HEAL, dispelInfo.GetRemovedCharges());
|
||||
healAmount = this->SpellHealingBonusTaken(aura->GetSpellInfo(), healAmount, HEAL, dispelInfo.GetRemovedCharges());
|
||||
}
|
||||
CastCustomSpell(this, 33778, &healAmount, NULL, NULL, true, NULL, NULL, aura->GetCasterGUID());
|
||||
|
||||
// mana
|
||||
@@ -6724,8 +6733,8 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
|
||||
return false;
|
||||
triggered_spell_id = 25742;
|
||||
float ap = GetTotalAttackPowerValue(BASE_ATTACK);
|
||||
int32 holy = SpellBaseDamageBonus(SPELL_SCHOOL_MASK_HOLY) +
|
||||
SpellBaseDamageBonusForVictim(SPELL_SCHOOL_MASK_HOLY, victim);
|
||||
int32 holy = SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_HOLY) +
|
||||
victim->SpellBaseDamageBonusTaken(SPELL_SCHOOL_MASK_HOLY);
|
||||
basepoints0 = (int32)GetAttackTime(BASE_ATTACK) * int32(ap * 0.022f + 0.044f * holy) / 1000;
|
||||
break;
|
||||
}
|
||||
@@ -7435,8 +7444,8 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
|
||||
|
||||
float fire_onhit = float(CalculatePctF(dummySpell->Effects[EFFECT_0]. CalcValue(), 1.0f));
|
||||
|
||||
float add_spellpower = (float)(SpellBaseDamageBonus(SPELL_SCHOOL_MASK_FIRE)
|
||||
+ SpellBaseDamageBonusForVictim(SPELL_SCHOOL_MASK_FIRE, victim));
|
||||
float add_spellpower = (float)(SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_FIRE)
|
||||
+ victim->SpellBaseDamageBonusTaken(SPELL_SCHOOL_MASK_FIRE));
|
||||
|
||||
// 1.3speed = 5%, 2.6speed = 10%, 4.0 speed = 15%, so, 1.0speed = 3.84%
|
||||
ApplyPctF(add_spellpower, 3.84f);
|
||||
@@ -9007,7 +9016,7 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg
|
||||
{
|
||||
if (AuraEffect* aurEff = owner->GetDummyAuraEffect(SPELLFAMILY_WARLOCK, 3220, 0))
|
||||
{
|
||||
basepoints0 = int32((aurEff->GetAmount() * owner->SpellBaseDamageBonus(SpellSchoolMask(SPELL_SCHOOL_MASK_MAGIC)) + 100.0f) / 100.0f); // TODO: Is it right?
|
||||
basepoints0 = int32((aurEff->GetAmount() * owner->SpellBaseDamageBonusDone(SpellSchoolMask(SPELL_SCHOOL_MASK_MAGIC)) + 100.0f) / 100.0f); // TODO: Is it right?
|
||||
CastCustomSpell(this, trigger_spell_id, &basepoints0, &basepoints0, NULL, true, castItem, triggeredByAura);
|
||||
return true;
|
||||
}
|
||||
@@ -10374,7 +10383,7 @@ void Unit::EnergizeBySpell(Unit* victim, uint32 spellID, uint32 damage, Powers p
|
||||
victim->getHostileRefManager().threatAssist(this, float(damage) * 0.5f, spellInfo);
|
||||
}
|
||||
|
||||
uint32 Unit::SpellDamageBonus(Unit* victim, SpellInfo const* spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack)
|
||||
uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack)
|
||||
{
|
||||
if (!spellProto || !victim || damagetype == DIRECT_DAMAGE)
|
||||
return pdamage;
|
||||
@@ -10387,15 +10396,13 @@ uint32 Unit::SpellDamageBonus(Unit* victim, SpellInfo const* spellProto, uint32
|
||||
// For totems get damage bonus from owner
|
||||
if (GetTypeId() == TYPEID_UNIT && ToCreature()->isTotem())
|
||||
if (Unit* owner = GetOwner())
|
||||
return owner->SpellDamageBonus(victim, spellProto, pdamage, damagetype);
|
||||
return owner->SpellDamageBonusDone(victim, spellProto, pdamage, damagetype);
|
||||
|
||||
// Taken/Done total percent damage auras
|
||||
// Done total percent damage auras
|
||||
float DoneTotalMod = 1.0f;
|
||||
float ApCoeffMod = 1.0f;
|
||||
int32 DoneTotal = 0;
|
||||
int32 TakenTotal = 0;
|
||||
|
||||
// ..done
|
||||
// Pet damage?
|
||||
if (GetTypeId() == TYPEID_UNIT && !ToCreature()->isPet())
|
||||
DoneTotalMod *= ToCreature()->GetSpellDamageMod(ToCreature()->GetCreatureTemplate()->rank);
|
||||
@@ -10726,50 +10733,8 @@ uint32 Unit::SpellDamageBonus(Unit* victim, SpellInfo const* spellProto, uint32
|
||||
break;
|
||||
}
|
||||
|
||||
// ..taken
|
||||
float TakenTotalMod = 1.0f;
|
||||
|
||||
// from positive and negative SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN
|
||||
// multiplicative bonus, for example Dispersion + Shadowform (0.10*0.85=0.085)
|
||||
TakenTotalMod *= victim->GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, spellProto->GetSchoolMask());
|
||||
|
||||
// .. taken pct: dummy auras
|
||||
AuraEffectList const& mDummyAuras = victim->GetAuraEffectsByType(SPELL_AURA_DUMMY);
|
||||
for (AuraEffectList::const_iterator i = mDummyAuras.begin(); i != mDummyAuras.end(); ++i)
|
||||
{
|
||||
switch ((*i)->GetSpellInfo()->SpellIconID)
|
||||
{
|
||||
// Cheat Death
|
||||
case 2109:
|
||||
if ((*i)->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL)
|
||||
{
|
||||
if (victim->GetTypeId() != TYPEID_PLAYER)
|
||||
continue;
|
||||
float mod = victim->ToPlayer()->GetRatingBonusValue(CR_CRIT_TAKEN_MELEE) * (-8.0f);
|
||||
AddPctF(TakenTotalMod, std::max(mod, float((*i)->GetAmount())));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// From caster spells
|
||||
AuraEffectList const& mOwnerTaken = victim->GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_FROM_CASTER);
|
||||
for (AuraEffectList::const_iterator i = mOwnerTaken.begin(); i != mOwnerTaken.end(); ++i)
|
||||
if ((*i)->GetCasterGUID() == GetGUID() && (*i)->IsAffectedOnSpell(spellProto))
|
||||
AddPctN(TakenTotalMod, (*i)->GetAmount());
|
||||
|
||||
// Mod damage from spell mechanic
|
||||
if (uint32 mechanicMask = spellProto->GetAllEffectsMechanicMask())
|
||||
{
|
||||
AuraEffectList const& mDamageDoneMechanic = victim->GetAuraEffectsByType(SPELL_AURA_MOD_MECHANIC_DAMAGE_TAKEN_PERCENT);
|
||||
for (AuraEffectList::const_iterator i = mDamageDoneMechanic.begin(); i != mDamageDoneMechanic.end(); ++i)
|
||||
if (mechanicMask & uint32(1<<((*i)->GetMiscValue())))
|
||||
AddPctN(TakenTotalMod, (*i)->GetAmount());
|
||||
}
|
||||
|
||||
// Taken/Done fixed damage bonus auras
|
||||
int32 DoneAdvertisedBenefit = SpellBaseDamageBonus(spellProto->GetSchoolMask());
|
||||
int32 TakenAdvertisedBenefit = SpellBaseDamageBonusForVictim(spellProto->GetSchoolMask(), victim);
|
||||
// Done fixed damage bonus auras
|
||||
int32 DoneAdvertisedBenefit = SpellBaseDamageBonusDone(spellProto->GetSchoolMask());
|
||||
// Pets just add their bonus damage to their spell damage
|
||||
// note that their spell damage is just gain of their own auras
|
||||
if (HasUnitTypeMask(UNIT_MASK_GUARDIAN))
|
||||
@@ -10804,67 +10769,13 @@ uint32 Unit::SpellDamageBonus(Unit* victim, SpellInfo const* spellProto, uint32
|
||||
}
|
||||
}
|
||||
// Default calculation
|
||||
if (DoneAdvertisedBenefit || TakenAdvertisedBenefit)
|
||||
if (DoneAdvertisedBenefit)
|
||||
{
|
||||
if (!bonus || coeff < 0)
|
||||
{
|
||||
// Damage Done from spell damage bonus
|
||||
int32 CastingTime = spellProto->IsChanneled() ? spellProto->GetDuration() : spellProto->CalcCastTime();
|
||||
// Damage over Time spells bonus calculation
|
||||
float DotFactor = 1.0f;
|
||||
if (damagetype == DOT)
|
||||
{
|
||||
int32 DotDuration = spellProto->GetDuration();
|
||||
// 200% limit
|
||||
if (DotDuration > 0)
|
||||
{
|
||||
if (DotDuration > 30000)
|
||||
DotDuration = 30000;
|
||||
if (!spellProto->IsChanneled())
|
||||
DotFactor = DotDuration / 15000.0f;
|
||||
uint8 x = 0;
|
||||
for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j)
|
||||
{
|
||||
if (spellProto->Effects[j].Effect == SPELL_EFFECT_APPLY_AURA && (
|
||||
spellProto->Effects[j].ApplyAuraName == SPELL_AURA_PERIODIC_DAMAGE ||
|
||||
spellProto->Effects[j].ApplyAuraName == SPELL_AURA_PERIODIC_LEECH))
|
||||
{
|
||||
x = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int32 DotTicks = 6;
|
||||
if (spellProto->Effects[x].Amplitude != 0)
|
||||
DotTicks = DotDuration / spellProto->Effects[x].Amplitude;
|
||||
if (DotTicks)
|
||||
{
|
||||
DoneAdvertisedBenefit /= DotTicks;
|
||||
TakenAdvertisedBenefit /= DotTicks;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Distribute Damage over multiple effects, reduce by AoE
|
||||
CastingTime = GetCastingTimeForBonus(spellProto, damagetype, CastingTime);
|
||||
|
||||
// 50% for damage and healing spells for leech spells from damage bonus and 0% from healing
|
||||
for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j)
|
||||
{
|
||||
if (spellProto->Effects[j].Effect == SPELL_EFFECT_HEALTH_LEECH ||
|
||||
(spellProto->Effects[j].Effect == SPELL_EFFECT_APPLY_AURA && spellProto->Effects[j].ApplyAuraName == SPELL_AURA_PERIODIC_LEECH))
|
||||
{
|
||||
CastingTime /= 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (spellProto->SchoolMask != SPELL_SCHOOL_MASK_NORMAL)
|
||||
coeff = (CastingTime / 3500.0f) * DotFactor;
|
||||
else
|
||||
coeff = DotFactor;
|
||||
}
|
||||
coeff = CalculateDefaultCoefficient(spellProto, damagetype) * int32(stack);
|
||||
|
||||
float factorMod = CalculateLevelPenalty(spellProto) * stack;
|
||||
// level penalty still applied on Taken bonus - is it blizzlike?
|
||||
TakenTotal+= int32(TakenAdvertisedBenefit * factorMod);
|
||||
|
||||
if (Player* modOwner = GetSpellModOwner())
|
||||
{
|
||||
coeff *= 100.0f;
|
||||
@@ -10892,16 +10803,89 @@ uint32 Unit::SpellDamageBonus(Unit* victim, SpellInfo const* spellProto, uint32
|
||||
if (Player* modOwner = GetSpellModOwner())
|
||||
modOwner->ApplySpellMod(spellProto->Id, damagetype == DOT ? SPELLMOD_DOT : SPELLMOD_DAMAGE, tmpDamage);
|
||||
|
||||
tmpDamage = (tmpDamage + TakenTotal) * TakenTotalMod;
|
||||
return uint32(std::max(tmpDamage, 0.0f));
|
||||
}
|
||||
|
||||
uint32 Unit::SpellDamageBonusTaken(SpellInfo const* spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack)
|
||||
{
|
||||
if (!spellProto || damagetype == DIRECT_DAMAGE)
|
||||
return pdamage;
|
||||
|
||||
int32 TakenTotal = 0;
|
||||
float TakenTotalMod = 1.0f;
|
||||
|
||||
//from positive and negative SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN
|
||||
//multiplicative bonus, for example Dispersion + Shadowform (0.10*0.85=0.085)
|
||||
TakenTotalMod *= GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, spellProto->GetSchoolMask());
|
||||
|
||||
//.. taken pct: dummy auras
|
||||
AuraEffectList const& mDummyAuras = GetAuraEffectsByType(SPELL_AURA_DUMMY);
|
||||
for (AuraEffectList::const_iterator i = mDummyAuras.begin(); i != mDummyAuras.end(); ++i)
|
||||
{
|
||||
switch ((*i)->GetSpellInfo()->SpellIconID)
|
||||
{
|
||||
// Cheat Death
|
||||
case 2109:
|
||||
if ((*i)->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL)
|
||||
{
|
||||
if (GetTypeId() != TYPEID_PLAYER)
|
||||
continue;
|
||||
float mod = ToPlayer()->GetRatingBonusValue(CR_CRIT_TAKEN_MELEE) * (-8.0f);
|
||||
AddPctF(TakenTotalMod, std::max(mod, float((*i)->GetAmount())));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// From caster spells
|
||||
AuraEffectList const& mOwnerTaken = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_FROM_CASTER);
|
||||
for (AuraEffectList::const_iterator i = mOwnerTaken.begin(); i != mOwnerTaken.end(); ++i)
|
||||
if ((*i)->GetCasterGUID() == GetGUID() && (*i)->IsAffectedOnSpell(spellProto))
|
||||
AddPctN(TakenTotalMod, (*i)->GetAmount());
|
||||
|
||||
// Mod damage from spell mechanic
|
||||
if (uint32 mechanicMask = spellProto->GetAllEffectsMechanicMask())
|
||||
{
|
||||
AuraEffectList const& mDamageDoneMechanic = GetAuraEffectsByType(SPELL_AURA_MOD_MECHANIC_DAMAGE_TAKEN_PERCENT);
|
||||
for (AuraEffectList::const_iterator i = mDamageDoneMechanic.begin(); i != mDamageDoneMechanic.end(); ++i)
|
||||
if (mechanicMask & uint32(1<<((*i)->GetMiscValue())))
|
||||
AddPctN(TakenTotalMod, (*i)->GetAmount());
|
||||
}
|
||||
|
||||
int32 TakenAdvertisedBenefit = SpellBaseDamageBonusTaken(spellProto->GetSchoolMask());
|
||||
|
||||
// Check for table values
|
||||
float coeff = 0;
|
||||
SpellBonusEntry const* bonus = sSpellMgr->GetSpellBonusData(spellProto->Id);
|
||||
if (bonus)
|
||||
coeff = (damagetype == DOT) ? bonus->dot_damage : bonus->direct_damage;
|
||||
|
||||
// Default calculation
|
||||
if (TakenAdvertisedBenefit)
|
||||
{
|
||||
if (!bonus || coeff < 0)
|
||||
coeff = CalculateDefaultCoefficient(spellProto, damagetype) * int32(stack);
|
||||
|
||||
float factorMod = CalculateLevelPenalty(spellProto) * stack;
|
||||
// level penalty still applied on Taken bonus - is it blizzlike?
|
||||
if (Player* modOwner = GetSpellModOwner())
|
||||
{
|
||||
coeff *= 100.0f;
|
||||
modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_BONUS_MULTIPLIER, coeff);
|
||||
coeff /= 100.0f;
|
||||
}
|
||||
TakenTotal+= int32(TakenAdvertisedBenefit * coeff * factorMod);
|
||||
}
|
||||
|
||||
float tmpDamage = (pdamage + TakenTotal) * TakenTotalMod;
|
||||
|
||||
return uint32(std::max(tmpDamage, 0.0f));
|
||||
}
|
||||
|
||||
int32 Unit::SpellBaseDamageBonus(SpellSchoolMask schoolMask)
|
||||
int32 Unit::SpellBaseDamageBonusDone(SpellSchoolMask schoolMask)
|
||||
{
|
||||
int32 DoneAdvertisedBenefit = 0;
|
||||
|
||||
// ..done
|
||||
AuraEffectList const& mDamageDone = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_DONE);
|
||||
for (AuraEffectList::const_iterator i = mDamageDone.begin(); i != mDamageDone.end(); ++i)
|
||||
if (((*i)->GetMiscValue() & schoolMask) != 0 &&
|
||||
@@ -10937,19 +10921,11 @@ int32 Unit::SpellBaseDamageBonus(SpellSchoolMask schoolMask)
|
||||
return DoneAdvertisedBenefit > 0 ? DoneAdvertisedBenefit : 0;
|
||||
}
|
||||
|
||||
int32 Unit::SpellBaseDamageBonusForVictim(SpellSchoolMask schoolMask, Unit* victim)
|
||||
int32 Unit::SpellBaseDamageBonusTaken(SpellSchoolMask schoolMask)
|
||||
{
|
||||
uint32 creatureTypeMask = victim->GetCreatureTypeMask();
|
||||
|
||||
int32 TakenAdvertisedBenefit = 0;
|
||||
// ..done (for creature type by mask) in taken
|
||||
AuraEffectList const& mDamageDoneCreature = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_DONE_CREATURE);
|
||||
for (AuraEffectList::const_iterator i = mDamageDoneCreature.begin(); i != mDamageDoneCreature.end(); ++i)
|
||||
if (creatureTypeMask & uint32((*i)->GetMiscValue()))
|
||||
TakenAdvertisedBenefit += (*i)->GetAmount();
|
||||
|
||||
// ..taken
|
||||
AuraEffectList const& mDamageTaken = victim->GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_TAKEN);
|
||||
AuraEffectList const& mDamageTaken = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_TAKEN);
|
||||
for (AuraEffectList::const_iterator i = mDamageTaken.begin(); i != mDamageTaken.end(); ++i)
|
||||
if (((*i)->GetMiscValue() & schoolMask) != 0)
|
||||
TakenAdvertisedBenefit += (*i)->GetAmount();
|
||||
@@ -11218,23 +11194,19 @@ uint32 Unit::SpellCriticalHealingBonus(SpellInfo const* spellProto, uint32 damag
|
||||
return damage;
|
||||
}
|
||||
|
||||
uint32 Unit::SpellHealingBonus(Unit* victim, SpellInfo const* spellProto, uint32 healamount, DamageEffectType damagetype, uint32 stack)
|
||||
uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 healamount, DamageEffectType damagetype, uint32 stack)
|
||||
{
|
||||
// For totems get healing bonus from owner (statue isn't totem in fact)
|
||||
if (GetTypeId() == TYPEID_UNIT && ToCreature()->isTotem())
|
||||
if (Unit* owner = GetOwner())
|
||||
return owner->SpellHealingBonus(victim, spellProto, healamount, damagetype, stack);
|
||||
return owner->SpellHealingBonusDone(victim, spellProto, healamount, damagetype, stack);
|
||||
|
||||
// no bonus for heal potions/bandages
|
||||
if (spellProto->SpellFamilyName == SPELLFAMILY_POTION)
|
||||
return healamount;
|
||||
|
||||
// Healing Done
|
||||
// Taken/Done total percent damage auras
|
||||
float DoneTotalMod = 1.0f;
|
||||
float TakenTotalMod = 1.0f;
|
||||
int32 DoneTotal = 0;
|
||||
int32 TakenTotal = 0;
|
||||
|
||||
// Healing done percent
|
||||
AuraEffectList const& mHealingDonePct = GetAuraEffectsByType(SPELL_AURA_MOD_HEALING_DONE_PERCENT);
|
||||
@@ -11297,28 +11269,11 @@ uint32 Unit::SpellHealingBonus(Unit* victim, SpellInfo const* spellProto, uint32
|
||||
}
|
||||
}
|
||||
|
||||
// Taken/Done fixed damage bonus auras
|
||||
int32 DoneAdvertisedBenefit = SpellBaseHealingBonus(spellProto->GetSchoolMask());
|
||||
int32 TakenAdvertisedBenefit = SpellBaseHealingBonusForVictim(spellProto->GetSchoolMask(), victim);
|
||||
|
||||
bool scripted = false;
|
||||
|
||||
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
|
||||
{
|
||||
switch (spellProto->Effects[i].ApplyAuraName)
|
||||
{
|
||||
// These auras do not use healing coeff
|
||||
case SPELL_AURA_PERIODIC_LEECH:
|
||||
case SPELL_AURA_PERIODIC_HEALTH_FUNNEL:
|
||||
scripted = true;
|
||||
break;
|
||||
}
|
||||
if (spellProto->Effects[i].Effect == SPELL_EFFECT_HEALTH_LEECH)
|
||||
scripted = true;
|
||||
}
|
||||
// Done fixed damage bonus auras
|
||||
int32 DoneAdvertisedBenefit = SpellBaseHealingBonusDone(spellProto->GetSchoolMask());
|
||||
|
||||
// Check for table values
|
||||
SpellBonusEntry const* bonus = !scripted ? sSpellMgr->GetSpellBonusData(spellProto->Id) : NULL;
|
||||
SpellBonusEntry const* bonus = sSpellMgr->GetSpellBonusData(spellProto->Id);
|
||||
float coeff = 0;
|
||||
float factorMod = 1.0f;
|
||||
if (bonus)
|
||||
@@ -11338,94 +11293,53 @@ uint32 Unit::SpellHealingBonus(Unit* victim, SpellInfo const* spellProto, uint32
|
||||
(spellProto->IsRangedWeaponSpell() && spellProto->DmgClass !=SPELL_DAMAGE_CLASS_MELEE)? RANGED_ATTACK : BASE_ATTACK));
|
||||
}
|
||||
}
|
||||
else // scripted bonus
|
||||
{
|
||||
// Gift of the Naaru
|
||||
if (spellProto->SpellFamilyFlags[2] & 0x80000000 && spellProto->SpellIconID == 329)
|
||||
{
|
||||
scripted = true;
|
||||
int32 apBonus = int32(std::max(GetTotalAttackPowerValue(BASE_ATTACK), GetTotalAttackPowerValue(RANGED_ATTACK)));
|
||||
if (apBonus > DoneAdvertisedBenefit)
|
||||
DoneTotal += int32(apBonus * 0.22f); // 22% of AP per tick
|
||||
else
|
||||
DoneTotal += int32(DoneAdvertisedBenefit * 0.377f); // 37.7% of BH per tick
|
||||
}
|
||||
// Earthliving - 0.45% of normal hot coeff
|
||||
else if (spellProto->SpellFamilyName == SPELLFAMILY_SHAMAN && spellProto->SpellFamilyFlags[1] & 0x80000)
|
||||
factorMod *= 0.45f;
|
||||
// Already set to scripted? so not uses healing bonus coefficient
|
||||
// No heal coeff for SPELL_DAMAGE_CLASS_NONE class spells by default
|
||||
else if (scripted || spellProto->DmgClass == SPELL_DAMAGE_CLASS_NONE)
|
||||
{
|
||||
scripted = true;
|
||||
coeff = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
// Default calculation
|
||||
if (DoneAdvertisedBenefit || TakenAdvertisedBenefit)
|
||||
if (DoneAdvertisedBenefit)
|
||||
{
|
||||
if ((!bonus && !scripted) || coeff < 0)
|
||||
{
|
||||
// Damage Done from spell damage bonus
|
||||
int32 CastingTime = !spellProto->IsChanneled() ? spellProto->CalcCastTime() : spellProto->GetDuration();
|
||||
// Damage over Time spells bonus calculation
|
||||
float DotFactor = 1.0f;
|
||||
if (damagetype == DOT)
|
||||
{
|
||||
int32 DotDuration = spellProto->GetDuration();
|
||||
// 200% limit
|
||||
if (DotDuration > 0)
|
||||
{
|
||||
if (DotDuration > 30000) DotDuration = 30000;
|
||||
if (!spellProto->IsChanneled()) DotFactor = DotDuration / 15000.0f;
|
||||
uint32 x = 0;
|
||||
for (uint8 j = 0; j < MAX_SPELL_EFFECTS; j++)
|
||||
{
|
||||
if (spellProto->Effects[j].Effect == SPELL_EFFECT_APPLY_AURA && (
|
||||
spellProto->Effects[j].ApplyAuraName == SPELL_AURA_PERIODIC_DAMAGE ||
|
||||
spellProto->Effects[j].ApplyAuraName == SPELL_AURA_PERIODIC_LEECH))
|
||||
{
|
||||
x = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int32 DotTicks = 6;
|
||||
if (spellProto->Effects[x].Amplitude != 0)
|
||||
DotTicks = DotDuration / spellProto->Effects[x].Amplitude;
|
||||
if (DotTicks)
|
||||
{
|
||||
DoneAdvertisedBenefit = DoneAdvertisedBenefit * int32(stack) / DotTicks;
|
||||
TakenAdvertisedBenefit = TakenAdvertisedBenefit * int32(stack) / DotTicks;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Distribute Damage over multiple effects, reduce by AoE
|
||||
CastingTime = GetCastingTimeForBonus(spellProto, damagetype, CastingTime);
|
||||
// 50% for damage and healing spells for leech spells from damage bonus and 0% from healing
|
||||
for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j)
|
||||
{
|
||||
if (spellProto->Effects[j].Effect == SPELL_EFFECT_HEALTH_LEECH ||
|
||||
(spellProto->Effects[j].Effect == SPELL_EFFECT_APPLY_AURA && spellProto->Effects[j].ApplyAuraName == SPELL_AURA_PERIODIC_LEECH))
|
||||
{
|
||||
CastingTime /= 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// As wowwiki says: C = (Cast Time / 3.5) * 1.88 (for healing spells)
|
||||
coeff = (CastingTime / 3500.0f) * DotFactor * 1.88f;
|
||||
}
|
||||
if (!bonus || coeff < 0)
|
||||
coeff = CalculateDefaultCoefficient(spellProto, damagetype) * int32(stack) * 1.88f; // As wowwiki says: C = (Cast Time / 3.5) * 1.88 (for healing spells)
|
||||
|
||||
factorMod *= CalculateLevelPenalty(spellProto) * stack;
|
||||
// level penalty still applied on Taken bonus - is it blizzlike?
|
||||
TakenTotal += int32(TakenAdvertisedBenefit * factorMod);
|
||||
|
||||
if (Player* modOwner = GetSpellModOwner())
|
||||
{
|
||||
coeff *= 100.0f;
|
||||
modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_BONUS_MULTIPLIER, coeff);
|
||||
coeff /= 100.0f;
|
||||
}
|
||||
DoneTotal += int32(DoneAdvertisedBenefit * coeff * factorMod);
|
||||
|
||||
// Gift of the Naaru
|
||||
if (spellProto->SpellFamilyFlags[2] & 0x80000000 && spellProto->SpellIconID == 329)
|
||||
{
|
||||
int32 apBonus = int32(std::max(GetTotalAttackPowerValue(BASE_ATTACK), GetTotalAttackPowerValue(RANGED_ATTACK)));
|
||||
if (apBonus > DoneAdvertisedBenefit)
|
||||
DoneTotal += int32(apBonus * 0.22f); // 22% of AP per tick
|
||||
else
|
||||
DoneTotal += int32(DoneAdvertisedBenefit * 0.377f); // 37.7% of BH per tick
|
||||
}
|
||||
else
|
||||
{
|
||||
// Earthliving - 0.45% of normal hot coeff
|
||||
if (spellProto->SpellFamilyName == SPELLFAMILY_SHAMAN && spellProto->SpellFamilyFlags[1] & 0x80000)
|
||||
factorMod *= 0.45f;
|
||||
|
||||
DoneTotal += int32(DoneAdvertisedBenefit * coeff * factorMod);
|
||||
}
|
||||
}
|
||||
|
||||
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
|
||||
{
|
||||
switch (spellProto->Effects[i].ApplyAuraName)
|
||||
{
|
||||
// Bonus healing does not apply to these spells
|
||||
case SPELL_AURA_PERIODIC_LEECH:
|
||||
case SPELL_AURA_PERIODIC_HEALTH_FUNNEL:
|
||||
DoneTotal = 0;
|
||||
break;
|
||||
}
|
||||
if (spellProto->Effects[i].Effect == SPELL_EFFECT_HEALTH_LEECH)
|
||||
DoneTotal = 0;
|
||||
}
|
||||
|
||||
// use float as more appropriate for negative values and percent applying
|
||||
@@ -11434,53 +11348,106 @@ uint32 Unit::SpellHealingBonus(Unit* victim, SpellInfo const* spellProto, uint32
|
||||
if (Player* modOwner = GetSpellModOwner())
|
||||
modOwner->ApplySpellMod(spellProto->Id, damagetype == DOT ? SPELLMOD_DOT : SPELLMOD_DAMAGE, heal);
|
||||
|
||||
return uint32(std::max(heal, 0.0f));
|
||||
}
|
||||
|
||||
uint32 Unit::SpellHealingBonusTaken(SpellInfo const *spellProto, uint32 healamount, DamageEffectType damagetype, uint32 stack)
|
||||
{
|
||||
float TakenTotalMod = 1.0f;
|
||||
|
||||
// Healing taken percent
|
||||
float minval = (float)GetMaxNegativeAuraModifier(SPELL_AURA_MOD_HEALING_PCT);
|
||||
if (minval)
|
||||
AddPctF(TakenTotalMod, minval);
|
||||
|
||||
float maxval = (float)GetMaxPositiveAuraModifier(SPELL_AURA_MOD_HEALING_PCT);
|
||||
if (maxval)
|
||||
AddPctF(TakenTotalMod, maxval);
|
||||
|
||||
// Tenacity increase healing % taken
|
||||
if (AuraEffect const* Tenacity = GetAuraEffect(58549, 0))
|
||||
AddPctN(TakenTotalMod, Tenacity->GetAmount());
|
||||
|
||||
// Healing Done
|
||||
int32 TakenTotal = 0;
|
||||
|
||||
// Taken fixed damage bonus auras
|
||||
int32 TakenAdvertisedBenefit = SpellBaseHealingBonusTaken(spellProto->GetSchoolMask());
|
||||
|
||||
// Nourish cast
|
||||
if (spellProto->SpellFamilyName == SPELLFAMILY_DRUID && spellProto->SpellFamilyFlags[1] & 0x2000000)
|
||||
{
|
||||
// Rejuvenation, Regrowth, Lifebloom, or Wild Growth
|
||||
if (victim->GetAuraEffect(SPELL_AURA_PERIODIC_HEAL, SPELLFAMILY_DRUID, 0x50, 0x4000010, 0))
|
||||
if (GetAuraEffect(SPELL_AURA_PERIODIC_HEAL, SPELLFAMILY_DRUID, 0x50, 0x4000010, 0))
|
||||
// increase healing by 20%
|
||||
TakenTotalMod *= 1.2f;
|
||||
}
|
||||
|
||||
// Taken mods
|
||||
|
||||
// Tenacity increase healing % taken
|
||||
if (AuraEffect const* Tenacity = victim->GetAuraEffect(58549, 0))
|
||||
AddPctN(TakenTotalMod, Tenacity->GetAmount());
|
||||
|
||||
// Healing taken percent
|
||||
float minval = (float)victim->GetMaxNegativeAuraModifier(SPELL_AURA_MOD_HEALING_PCT);
|
||||
if (minval)
|
||||
AddPctF(TakenTotalMod, minval);
|
||||
|
||||
float maxval = (float)victim->GetMaxPositiveAuraModifier(SPELL_AURA_MOD_HEALING_PCT);
|
||||
if (maxval)
|
||||
AddPctF(TakenTotalMod, maxval);
|
||||
|
||||
if (damagetype == DOT)
|
||||
{
|
||||
// Healing over time taken percent
|
||||
float minval_hot = (float)victim->GetMaxNegativeAuraModifier(SPELL_AURA_MOD_HOT_PCT);
|
||||
float minval_hot = (float)GetMaxNegativeAuraModifier(SPELL_AURA_MOD_HOT_PCT);
|
||||
if (minval_hot)
|
||||
AddPctF(TakenTotalMod, minval_hot);
|
||||
|
||||
float maxval_hot = (float)victim->GetMaxPositiveAuraModifier(SPELL_AURA_MOD_HOT_PCT);
|
||||
float maxval_hot = (float)GetMaxPositiveAuraModifier(SPELL_AURA_MOD_HOT_PCT);
|
||||
if (maxval_hot)
|
||||
AddPctF(TakenTotalMod, maxval_hot);
|
||||
}
|
||||
|
||||
AuraEffectList const& mHealingGet= victim->GetAuraEffectsByType(SPELL_AURA_MOD_HEALING_RECEIVED);
|
||||
// Check for table values
|
||||
SpellBonusEntry const* bonus = sSpellMgr->GetSpellBonusData(spellProto->Id);
|
||||
float coeff = 0;
|
||||
float factorMod = 1.0f;
|
||||
if (bonus)
|
||||
coeff = (damagetype == DOT) ? bonus->dot_damage : bonus->direct_damage;
|
||||
|
||||
// Default calculation
|
||||
if (TakenAdvertisedBenefit)
|
||||
{
|
||||
if (!bonus || coeff < 0)
|
||||
coeff = CalculateDefaultCoefficient(spellProto, damagetype) * int32(stack) * 1.88f; // As wowwiki says: C = (Cast Time / 3.5) * 1.88 (for healing spells)
|
||||
|
||||
factorMod *= CalculateLevelPenalty(spellProto) * int32(stack);
|
||||
if (Player* modOwner = GetSpellModOwner())
|
||||
{
|
||||
coeff *= 100.0f;
|
||||
modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_BONUS_MULTIPLIER, coeff);
|
||||
coeff /= 100.0f;
|
||||
}
|
||||
|
||||
// Earthliving - 0.45% of normal hot coeff
|
||||
if (spellProto->SpellFamilyName == SPELLFAMILY_SHAMAN && spellProto->SpellFamilyFlags[1] & 0x80000)
|
||||
factorMod *= 0.45f;
|
||||
|
||||
TakenTotal += int32(TakenAdvertisedBenefit * coeff * factorMod);
|
||||
}
|
||||
|
||||
AuraEffectList const& mHealingGet= GetAuraEffectsByType(SPELL_AURA_MOD_HEALING_RECEIVED);
|
||||
for (AuraEffectList::const_iterator i = mHealingGet.begin(); i != mHealingGet.end(); ++i)
|
||||
if (GetGUID() == (*i)->GetCasterGUID() && (*i)->IsAffectedOnSpell(spellProto))
|
||||
AddPctN(TakenTotalMod, (*i)->GetAmount());
|
||||
|
||||
heal = (int32(heal) + TakenTotal) * TakenTotalMod;
|
||||
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
|
||||
{
|
||||
switch (spellProto->Effects[i].ApplyAuraName)
|
||||
{
|
||||
// Bonus healing does not apply to these spells
|
||||
case SPELL_AURA_PERIODIC_LEECH:
|
||||
case SPELL_AURA_PERIODIC_HEALTH_FUNNEL:
|
||||
TakenTotal = 0;
|
||||
break;
|
||||
}
|
||||
if (spellProto->Effects[i].Effect == SPELL_EFFECT_HEALTH_LEECH)
|
||||
TakenTotal = 0;
|
||||
}
|
||||
|
||||
float heal = (int32(healamount) + TakenTotal) * TakenTotalMod;
|
||||
|
||||
return uint32(std::max(heal, 0.0f));
|
||||
}
|
||||
|
||||
int32 Unit::SpellBaseHealingBonus(SpellSchoolMask schoolMask)
|
||||
int32 Unit::SpellBaseHealingBonusDone(SpellSchoolMask schoolMask)
|
||||
{
|
||||
int32 AdvertisedBenefit = 0;
|
||||
|
||||
@@ -11513,13 +11480,15 @@ int32 Unit::SpellBaseHealingBonus(SpellSchoolMask schoolMask)
|
||||
return AdvertisedBenefit;
|
||||
}
|
||||
|
||||
int32 Unit::SpellBaseHealingBonusForVictim(SpellSchoolMask schoolMask, Unit* victim)
|
||||
int32 Unit::SpellBaseHealingBonusTaken(SpellSchoolMask schoolMask)
|
||||
{
|
||||
int32 AdvertisedBenefit = 0;
|
||||
AuraEffectList const& mDamageTaken = victim->GetAuraEffectsByType(SPELL_AURA_MOD_HEALING);
|
||||
|
||||
AuraEffectList const& mDamageTaken = GetAuraEffectsByType(SPELL_AURA_MOD_HEALING);
|
||||
for (AuraEffectList::const_iterator i = mDamageTaken.begin(); i != mDamageTaken.end(); ++i)
|
||||
if (((*i)->GetMiscValue() & schoolMask) != 0)
|
||||
AdvertisedBenefit += (*i)->GetAmount();
|
||||
|
||||
return AdvertisedBenefit;
|
||||
}
|
||||
|
||||
@@ -11662,21 +11631,20 @@ bool Unit::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) cons
|
||||
return false;
|
||||
}
|
||||
|
||||
void Unit::MeleeDamageBonus(Unit* victim, uint32 *pdamage, WeaponAttackType attType, SpellInfo const* spellProto)
|
||||
uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType attType, SpellInfo const* spellProto)
|
||||
{
|
||||
if (!victim)
|
||||
return;
|
||||
return 0;
|
||||
|
||||
if (*pdamage == 0)
|
||||
return;
|
||||
if (pdamage == 0)
|
||||
return 0;
|
||||
|
||||
uint32 creatureTypeMask = victim->GetCreatureTypeMask();
|
||||
|
||||
// Taken/Done fixed damage bonus auras
|
||||
// Done fixed damage bonus auras
|
||||
int32 DoneFlatBenefit = 0;
|
||||
int32 TakenFlatBenefit = 0;
|
||||
|
||||
// ..done (for creature type by mask) in taken
|
||||
// ..done
|
||||
AuraEffectList const& mDamageDoneCreature = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_DONE_CREATURE);
|
||||
for (AuraEffectList::const_iterator i = mDamageDoneCreature.begin(); i != mDamageDoneCreature.end(); ++i)
|
||||
if (creatureTypeMask & uint32((*i)->GetMiscValue()))
|
||||
@@ -11722,20 +11690,8 @@ void Unit::MeleeDamageBonus(Unit* victim, uint32 *pdamage, WeaponAttackType attT
|
||||
DoneFlatBenefit += int32(APbonus/14.0f * GetAPMultiplier(attType, normalized));
|
||||
}
|
||||
|
||||
// ..taken
|
||||
AuraEffectList const& mDamageTaken = victim->GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_TAKEN);
|
||||
for (AuraEffectList::const_iterator i = mDamageTaken.begin(); i != mDamageTaken.end(); ++i)
|
||||
if ((*i)->GetMiscValue() & GetMeleeDamageSchoolMask())
|
||||
TakenFlatBenefit += (*i)->GetAmount();
|
||||
|
||||
if (attType != RANGED_ATTACK)
|
||||
TakenFlatBenefit += victim->GetTotalAuraModifier(SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN);
|
||||
else
|
||||
TakenFlatBenefit += victim->GetTotalAuraModifier(SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN);
|
||||
|
||||
// Done/Taken total percent damage auras
|
||||
// Done total percent damage auras
|
||||
float DoneTotalMod = 1.0f;
|
||||
float TakenTotalMod = 1.0f;
|
||||
|
||||
// ..done
|
||||
AuraEffectList const& mModDamagePercentDone = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE);
|
||||
@@ -11841,11 +11797,43 @@ void Unit::MeleeDamageBonus(Unit* victim, uint32 *pdamage, WeaponAttackType attT
|
||||
break;
|
||||
}
|
||||
|
||||
float tmpDamage = float(int32(pdamage) + DoneFlatBenefit) * DoneTotalMod;
|
||||
|
||||
// apply spellmod to Done damage
|
||||
if (spellProto)
|
||||
if (Player* modOwner = GetSpellModOwner())
|
||||
modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_DAMAGE, tmpDamage);
|
||||
|
||||
// bonus result can be negative
|
||||
return uint32(std::max(tmpDamage, 0.0f));
|
||||
}
|
||||
|
||||
uint32 Unit::MeleeDamageBonusTaken(uint32 pdamage, WeaponAttackType attType, SpellInfo const *spellProto)
|
||||
{
|
||||
if (pdamage == 0)
|
||||
return 0;
|
||||
|
||||
int32 TakenFlatBenefit = 0;
|
||||
|
||||
// ..taken
|
||||
TakenTotalMod *= victim->GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, GetMeleeDamageSchoolMask());
|
||||
AuraEffectList const& mDamageTaken = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_TAKEN);
|
||||
for (AuraEffectList::const_iterator i = mDamageTaken.begin(); i != mDamageTaken.end(); ++i)
|
||||
if ((*i)->GetMiscValue() & GetMeleeDamageSchoolMask())
|
||||
TakenFlatBenefit += (*i)->GetAmount();
|
||||
|
||||
if (attType != RANGED_ATTACK)
|
||||
TakenFlatBenefit += GetTotalAuraModifier(SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN);
|
||||
else
|
||||
TakenFlatBenefit += GetTotalAuraModifier(SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN);
|
||||
|
||||
// Taken total percent damage auras
|
||||
float TakenTotalMod = 1.0f;
|
||||
|
||||
// ..taken
|
||||
TakenTotalMod *= GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, GetMeleeDamageSchoolMask());
|
||||
|
||||
// From caster spells
|
||||
AuraEffectList const& mOwnerTaken = victim->GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_FROM_CASTER);
|
||||
AuraEffectList const& mOwnerTaken = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_FROM_CASTER);
|
||||
for (AuraEffectList::const_iterator i = mOwnerTaken.begin(); i != mOwnerTaken.end(); ++i)
|
||||
if ((*i)->GetCasterGUID() == GetGUID() && (*i)->IsAffectedOnSpell(spellProto))
|
||||
AddPctN(TakenTotalMod, (*i)->GetAmount());
|
||||
@@ -11862,7 +11850,7 @@ void Unit::MeleeDamageBonus(Unit* victim, uint32 *pdamage, WeaponAttackType attT
|
||||
|
||||
if (mechanicMask)
|
||||
{
|
||||
AuraEffectList const& mDamageDoneMechanic = victim->GetAuraEffectsByType(SPELL_AURA_MOD_MECHANIC_DAMAGE_TAKEN_PERCENT);
|
||||
AuraEffectList const& mDamageDoneMechanic = GetAuraEffectsByType(SPELL_AURA_MOD_MECHANIC_DAMAGE_TAKEN_PERCENT);
|
||||
for (AuraEffectList::const_iterator i = mDamageDoneMechanic.begin(); i != mDamageDoneMechanic.end(); ++i)
|
||||
if (mechanicMask & uint32(1<<((*i)->GetMiscValue())))
|
||||
AddPctN(TakenTotalMod, (*i)->GetAmount());
|
||||
@@ -11870,7 +11858,7 @@ void Unit::MeleeDamageBonus(Unit* victim, uint32 *pdamage, WeaponAttackType attT
|
||||
}
|
||||
|
||||
// .. taken pct: dummy auras
|
||||
AuraEffectList const& mDummyAuras = victim->GetAuraEffectsByType(SPELL_AURA_DUMMY);
|
||||
AuraEffectList const& mDummyAuras = GetAuraEffectsByType(SPELL_AURA_DUMMY);
|
||||
for (AuraEffectList::const_iterator i = mDummyAuras.begin(); i != mDummyAuras.end(); ++i)
|
||||
{
|
||||
switch ((*i)->GetSpellInfo()->SpellIconID)
|
||||
@@ -11879,9 +11867,9 @@ void Unit::MeleeDamageBonus(Unit* victim, uint32 *pdamage, WeaponAttackType attT
|
||||
case 2109:
|
||||
if ((*i)->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL)
|
||||
{
|
||||
if (victim->GetTypeId() != TYPEID_PLAYER)
|
||||
if (GetTypeId() != TYPEID_PLAYER)
|
||||
continue;
|
||||
float mod = victim->ToPlayer()->GetRatingBonusValue(CR_CRIT_TAKEN_MELEE) * (-8.0f);
|
||||
float mod = ToPlayer()->GetRatingBonusValue(CR_CRIT_TAKEN_MELEE) * (-8.0f);
|
||||
AddPctF(TakenTotalMod, std::max(mod, float((*i)->GetAmount())));
|
||||
}
|
||||
break;
|
||||
@@ -11889,38 +11877,31 @@ void Unit::MeleeDamageBonus(Unit* victim, uint32 *pdamage, WeaponAttackType attT
|
||||
}
|
||||
|
||||
// .. taken pct: class scripts
|
||||
/*AuraEffectList const& mclassScritAuras = GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
|
||||
for (AuraEffectList::const_iterator i = mclassScritAuras.begin(); i != mclassScritAuras.end(); ++i)
|
||||
{
|
||||
switch ((*i)->GetMiscValue())
|
||||
{
|
||||
}
|
||||
}*/
|
||||
//*AuraEffectList const& mclassScritAuras = GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
|
||||
//for (AuraEffectList::const_iterator i = mclassScritAuras.begin(); i != mclassScritAuras.end(); ++i)
|
||||
//{
|
||||
// switch ((*i)->GetMiscValue())
|
||||
// {
|
||||
// }
|
||||
//}*/
|
||||
|
||||
if (attType != RANGED_ATTACK)
|
||||
{
|
||||
AuraEffectList const& mModMeleeDamageTakenPercent = victim->GetAuraEffectsByType(SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN_PCT);
|
||||
AuraEffectList const& mModMeleeDamageTakenPercent = GetAuraEffectsByType(SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN_PCT);
|
||||
for (AuraEffectList::const_iterator i = mModMeleeDamageTakenPercent.begin(); i != mModMeleeDamageTakenPercent.end(); ++i)
|
||||
AddPctN(TakenTotalMod, (*i)->GetAmount());
|
||||
}
|
||||
else
|
||||
{
|
||||
AuraEffectList const& mModRangedDamageTakenPercent = victim->GetAuraEffectsByType(SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN_PCT);
|
||||
AuraEffectList const& mModRangedDamageTakenPercent = GetAuraEffectsByType(SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN_PCT);
|
||||
for (AuraEffectList::const_iterator i = mModRangedDamageTakenPercent.begin(); i != mModRangedDamageTakenPercent.end(); ++i)
|
||||
AddPctN(TakenTotalMod, (*i)->GetAmount());
|
||||
}
|
||||
|
||||
float tmpDamage = float(int32(*pdamage) + DoneFlatBenefit) * DoneTotalMod;
|
||||
|
||||
// apply spellmod to Done damage
|
||||
if (spellProto)
|
||||
if (Player* modOwner = GetSpellModOwner())
|
||||
modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_DAMAGE, tmpDamage);
|
||||
|
||||
tmpDamage = (tmpDamage + TakenFlatBenefit) * TakenTotalMod;
|
||||
float tmpDamage = (float(pdamage) + TakenFlatBenefit) * TakenTotalMod;
|
||||
|
||||
// bonus result can be negative
|
||||
*pdamage = uint32(std::max(tmpDamage, 0.0f));
|
||||
return uint32(std::max(tmpDamage, 0.0f));
|
||||
}
|
||||
|
||||
void Unit::ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply)
|
||||
@@ -14501,7 +14482,8 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u
|
||||
|
||||
sLog->outDebug(LOG_FILTER_SPELLS_AURAS, "ProcDamageAndSpell: doing %u damage from spell id %u (triggered by %s aura of spell %u)", triggeredByAura->GetAmount(), spellInfo->Id, (isVictim?"a victim's":"an attacker's"), triggeredByAura->GetId());
|
||||
SpellNonMeleeDamage damageInfo(this, target, spellInfo->Id, spellInfo->SchoolMask);
|
||||
uint32 newDamage = SpellDamageBonus(target, spellInfo, triggeredByAura->GetAmount(), SPELL_DIRECT_DAMAGE);
|
||||
uint32 newDamage = SpellDamageBonusDone(target, spellInfo, triggeredByAura->GetAmount(), SPELL_DIRECT_DAMAGE);
|
||||
newDamage = target->SpellDamageBonusTaken(spellInfo, newDamage, SPELL_DIRECT_DAMAGE);
|
||||
CalculateSpellDamageTaken(&damageInfo, newDamage, spellInfo);
|
||||
DealDamageMods(damageInfo.target, damageInfo.damage, &damageInfo.absorb);
|
||||
SendSpellNonMeleeDamageLog(&damageInfo);
|
||||
@@ -15028,7 +15010,7 @@ void Unit::ApplyCastTimePercentMod(float val, bool apply)
|
||||
ApplyPercentModFloatValue(UNIT_MOD_CAST_SPEED, -val, apply);
|
||||
}
|
||||
|
||||
uint32 Unit::GetCastingTimeForBonus(SpellInfo const* spellProto, DamageEffectType damagetype, uint32 CastingTime)
|
||||
uint32 Unit::GetCastingTimeForBonus(SpellInfo const* spellProto, DamageEffectType damagetype, uint32 CastingTime) const
|
||||
{
|
||||
// Not apply this to creature casted spells with casttime == 0
|
||||
if (CastingTime == 0 && GetTypeId() == TYPEID_UNIT && !ToCreature()->isPet())
|
||||
@@ -15101,20 +15083,21 @@ uint32 Unit::GetCastingTimeForBonus(SpellInfo const* spellProto, DamageEffectTyp
|
||||
if (AreaEffect)
|
||||
CastingTime /= 2;
|
||||
|
||||
// -5% of total per any additional effect
|
||||
for (uint8 i = 0; i < effects; ++i)
|
||||
// 50% for damage and healing spells for leech spells from damage bonus and 0% from healing
|
||||
for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j)
|
||||
{
|
||||
if (CastingTime > 175)
|
||||
if (spellProto->Effects[j].Effect == SPELL_EFFECT_HEALTH_LEECH ||
|
||||
(spellProto->Effects[j].Effect == SPELL_EFFECT_APPLY_AURA && spellProto->Effects[j].ApplyAuraName == SPELL_AURA_PERIODIC_LEECH))
|
||||
{
|
||||
CastingTime -= 175;
|
||||
}
|
||||
else
|
||||
{
|
||||
CastingTime = 0;
|
||||
CastingTime /= 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// -5% of total per any additional effect
|
||||
for (uint8 i = 0; i < effects; ++i)
|
||||
CastingTime *= 0.95f;
|
||||
|
||||
return CastingTime;
|
||||
}
|
||||
|
||||
@@ -15145,6 +15128,29 @@ void Unit::UpdateAuraForGroup(uint8 slot)
|
||||
}
|
||||
}
|
||||
|
||||
float Unit::CalculateDefaultCoefficient(SpellInfo const *spellInfo, DamageEffectType damagetype) const
|
||||
{
|
||||
// Damage over Time spells bonus calculation
|
||||
float DotFactor = 1.0f;
|
||||
if (damagetype == DOT)
|
||||
{
|
||||
|
||||
int32 DotDuration = spellInfo->GetDuration();
|
||||
if (!spellInfo->IsChanneled() && DotDuration > 0)
|
||||
DotFactor = DotDuration / 15000.0f;
|
||||
|
||||
if (uint32 DotTicks = spellInfo->GetMaxTicks())
|
||||
DotFactor /= DotTicks;
|
||||
}
|
||||
|
||||
int32 CastingTime = spellInfo->IsChanneled() ? spellInfo->GetDuration() : spellInfo->CalcCastTime();
|
||||
// Distribute Damage over multiple effects, reduce by AoE
|
||||
CastingTime = GetCastingTimeForBonus(spellInfo, damagetype, CastingTime);
|
||||
|
||||
// As wowwiki says: C = (Cast Time / 3.5)
|
||||
return (CastingTime / 3500.0f) * DotFactor;
|
||||
}
|
||||
|
||||
float Unit::GetAPMultiplier(WeaponAttackType attType, bool normalized)
|
||||
{
|
||||
if (!normalized || GetTypeId() != TYPEID_PLAYER)
|
||||
|
||||
Reference in new issue
Block a user