Skip to content

Commit

Permalink
Core/Spells: Bonuses from SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN should …
Browse files Browse the repository at this point in the history
…be multiplicative
  • Loading branch information
tobmaps committed Jul 23, 2011
1 parent d06d174 commit bb0634c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 31 deletions.
39 changes: 10 additions & 29 deletions src/server/game/Entities/Unit/Unit.cpp
Expand Up @@ -10756,20 +10756,11 @@ uint32 Unit::SpellDamageBonus(Unit* victim, SpellEntry const* spellProto, uint32
}

// ..taken
int32 maxPositiveMod = 0; // max of the positive amount aura (that increase the damage taken)
int32 sumNegativeMod = 0; // sum the negative amount aura (that reduce the damage taken)
AuraEffectList const& mModDamagePercentTaken = victim->GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN);
for (AuraEffectList::const_iterator i = mModDamagePercentTaken.begin(); i != mModDamagePercentTaken.end(); ++i)
if ((*i)->GetMiscValue() & GetSpellSchoolMask(spellProto))
{
if ((*i)->GetAmount() > 0)
{
if ((*i)->GetAmount() > maxPositiveMod)
maxPositiveMod = (*i)->GetAmount();
}
else
sumNegativeMod += (*i)->GetAmount();
}
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, GetSpellSchoolMask(spellProto));

// .. taken pct: dummy auras
AuraEffectList const& mDummyAuras = victim->GetAuraEffectsByType(SPELL_AURA_DUMMY);
Expand All @@ -10784,18 +10775,13 @@ uint32 Unit::SpellDamageBonus(Unit* victim, SpellEntry const* spellProto, uint32
if (victim->GetTypeId() != TYPEID_PLAYER)
continue;
float mod = victim->ToPlayer()->GetRatingBonusValue(CR_CRIT_TAKEN_MELEE) * (-8.0f);
if (mod < (*i)->GetAmount())
mod = (float)(*i)->GetAmount();
sumNegativeMod += int32(mod);
AddPctF(TakenTotalMod, std::max(mod, float((*i)->GetAmount())));
}
break;
// Ebon Plague
case 1933:
if ((*i)->GetMiscValue() & (spellProto ? GetSpellSchoolMask(spellProto) : 0))
{
if ((*i)->GetAmount() > maxPositiveMod)
maxPositiveMod = (*i)->GetAmount();
}
AddPctN(TakenTotalMod, (*i)->GetAmount());
break;
}
}
Expand All @@ -10804,19 +10790,17 @@ uint32 Unit::SpellDamageBonus(Unit* victim, SpellEntry const* spellProto, uint32
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))
sumNegativeMod += (*i)->GetAmount();
AddPctN(TakenTotalMod, (*i)->GetAmount());

// Mod damage from spell mechanic
if (uint32 mechanicMask = GetAllSpellMechanicMask(spellProto))
{
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())))
sumNegativeMod += (*i)->GetAmount();
AddPctN(TakenTotalMod, (*i)->GetAmount());
}

float TakenTotalMod = (sumNegativeMod + maxPositiveMod + 100.0f) / 100.0f;

// Taken/Done fixed damage bonus auras
int32 DoneAdvertisedBenefit = SpellBaseDamageBonus(GetSpellSchoolMask(spellProto));
int32 TakenAdvertisedBenefit = SpellBaseDamageBonusForVictim(GetSpellSchoolMask(spellProto), victim);
Expand Down Expand Up @@ -11937,10 +11921,7 @@ void Unit::MeleeDamageBonus(Unit* victim, uint32 *pdamage, WeaponAttackType attT
}

// ..taken
AuraEffectList const& mModDamagePercentTaken = victim->GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN);
for (AuraEffectList::const_iterator i = mModDamagePercentTaken.begin(); i != mModDamagePercentTaken.end(); ++i)
if ((*i)->GetMiscValue() & GetMeleeDamageSchoolMask())
AddPctN(TakenTotalMod, (*i)->GetAmount());
TakenTotalMod *= victim->GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, GetMeleeDamageSchoolMask());

// From caster spells
AuraEffectList const& mOwnerTaken = victim->GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_FROM_CASTER);
Expand Down
4 changes: 2 additions & 2 deletions src/server/scripts/World/areatrigger_scripts.cpp
Expand Up @@ -339,8 +339,8 @@ enum eWaygate
AT_SHOLAZAR = 5046,
AT_UNGORO = 5047,

QUEST_THE_MAKERS_OVERLOOK = 12613,
QUEST_THE_MAKERS_PERCH = 12559,
QUEST_THE_MAKERS_OVERLOOK = 12613,
QUEST_THE_MAKERS_PERCH = 12559,
};

class AreaTrigger_at_sholazar_waygate : public AreaTriggerScript
Expand Down

4 comments on commit bb0634c

@3kids
Copy link

@3kids 3kids commented on bb0634c Jul 23, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@DrTenma
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+2

@steel2p
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not all auras should be multiplicative. Auras with one rank line should apply only the highest rank. Now you broke Ebon Plague and Crypt Fever stacking.

@tobmaps
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, not all auras should stack, but it should be handled like "disable effect of weak aura at more powerful aura apply and enable again when powerful fades", it shouldn't be there. But for now i can only recommend you to use this workaround https://gist.github.com/1279062 (didn't tested yet, but should work)

Please sign in to comment.