diff options
-rw-r--r-- | src/game/SharedDefines.h | 2 | ||||
-rw-r--r-- | src/game/SpellAuras.cpp | 37 | ||||
-rw-r--r-- | src/game/SpellAuras.h | 2 | ||||
-rw-r--r-- | src/game/Unit.cpp | 58 | ||||
-rw-r--r-- | src/game/Unit.h | 2 |
5 files changed, 52 insertions, 49 deletions
diff --git a/src/game/SharedDefines.h b/src/game/SharedDefines.h index 13d02702bb8..56e3214538f 100644 --- a/src/game/SharedDefines.h +++ b/src/game/SharedDefines.h @@ -249,7 +249,7 @@ enum SpellCategory #define SPELL_ATTR_CASTABLE_WHILE_SITTING 0x08000000 // 27 castable while sitting #define SPELL_ATTR_CANT_USED_IN_COMBAT 0x10000000 // 28 Cannot be used in combat #define SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY 0x20000000 // 29 unaffected by invulnerability (hmm possible not...) -#define SPELL_ATTR_BREAKABLE_BY_DAMAGE 0x40000000 // 30 breakable by damage? +#define SPELL_ATTR_BREAKABLE_BY_DAMAGE 0x40000000 // 30 #define SPELL_ATTR_CANT_CANCEL 0x80000000 // 31 positive aura can't be canceled #define SPELL_ATTR_EX_DISMISS_PET 0x00000001 // 0 dismiss pet and not allow to summon new one? diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 333759358a4..3b98301cb2e 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -486,6 +486,9 @@ m_target(parentAura->GetTarget()), m_tickNumber(0) else m_amount = m_currentBasePoints + 1; + if (int32 amount = CalculateCrowdControlAuraAmount(caster)) + m_amount = amount; + if (!m_amount && castItem && castItem->GetItemSuffixFactor()) { ItemRandomSuffixEntry const *item_rand_suffix = sItemRandomSuffixStore.LookupEntry(abs(castItem->GetItemRandomPropertyId())); @@ -7421,3 +7424,37 @@ void AuraEffect::HandleReflectSpells( bool Apply, bool Real , bool /*changeAmoun } } +int32 AuraEffect::CalculateCrowdControlAuraAmount(Unit * caster) +{ + // Damage cap for CC effects + if (!m_spellProto->procFlags) + return 0; + + if (m_auraName !=SPELL_AURA_MOD_CONFUSE && + m_auraName !=SPELL_AURA_MOD_FEAR && + m_auraName !=SPELL_AURA_MOD_STUN && + m_auraName !=SPELL_AURA_MOD_ROOT) + return 0; + + int32 damageCap = (int32)(m_target->GetCreateHealth()*0.10f); + + if (!caster) + return damageCap; + + // Glyphs increasing damage cap + Unit::AuraEffectList const& overrideClassScripts = caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + for(Unit::AuraEffectList::const_iterator itr = overrideClassScripts.begin();itr != overrideClassScripts.end(); ++itr) + { + if((*itr)->isAffectedOnSpell(m_spellProto)) + { + // Glyph of Fear + if ((*itr)->GetMiscValue() == 7801) + { + damageCap += (int32)(damageCap*(*itr)->GetAmount()/100.0f); + break; + } + } + } + return damageCap; +} + diff --git a/src/game/SpellAuras.h b/src/game/SpellAuras.h index 987c8b0db25..db747da3c54 100644 --- a/src/game/SpellAuras.h +++ b/src/game/SpellAuras.h @@ -335,6 +335,8 @@ class TRINITY_DLL_SPEC AuraEffect void HandleReflectSpells( bool Apply, bool Real , bool changeAmount); void HandleModArmorPenetrationPct(bool Apply, bool Real, bool changeAmount); + int32 CalculateCrowdControlAuraAmount(Unit * caster); + // add/remove SPELL_AURA_MOD_SHAPESHIFT (36) linked auras void HandleShapeshiftBoosts(bool apply); diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 0254d255f2c..4db0b95774d 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -577,29 +577,6 @@ bool Unit::HasAuraTypeWithFamilyFlags(AuraType auraType, uint32 familyName, uint return false; } -/* Called by DealDamage for auras that have a chance to be dispelled on damage taken. */ -void Unit::RemoveSpellbyDamageTaken(uint32 damage, uint32 spell) -{ - // The chance to dispel an aura depends on the damage taken with respect to the casters level. - uint32 max_dmg = getLevel() > 8 ? 25 * getLevel() - 150 : 50; - float chance = float(damage) / max_dmg * 100.0f; - - std::queue < std::pair < uint32, uint64 > > remove_list; - - for (AuraList::iterator iter = m_ccAuras.begin(); iter != m_ccAuras.end();++iter) - { - if((!spell || (*iter)->GetId() != spell) && roll_chance_f(chance)) - { - remove_list.push(std::make_pair((*iter)->GetId(), (*iter)->GetCasterGUID() ) ); - } - } - - for(;remove_list.size();remove_list.pop()) - { - RemoveAura(remove_list.front().first, remove_list.front().second, AURA_REMOVE_BY_ENEMY_SPELL); - } -} - void Unit::DealDamageMods(Unit *pVictim, uint32 &damage, uint32* absorb) { if (!pVictim->isAlive() || pVictim->hasUnitState(UNIT_STAT_UNATTACKABLE) || pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode()) @@ -646,7 +623,6 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa { // interrupting auras with AURA_INTERRUPT_FLAG_DAMAGE before checking !damage (absorbed damage breaks that type of auras) pVictim->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_TAKE_DAMAGE, spellProto ? spellProto->Id : 0); - pVictim->RemoveSpellbyDamageTaken(damage, spellProto ? spellProto->Id : 0); } if(!damage) @@ -3879,11 +3855,6 @@ bool Unit::AddAura(Aura *Aur, bool handleEffects) m_interruptableAuras.push_back(Aur); AddInterruptMask(aurSpellInfo->AuraInterruptFlags); } - if((aurSpellInfo->Attributes & SPELL_ATTR_BREAKABLE_BY_DAMAGE - && !Aur->IsAuraType(SPELL_AURA_MOD_POSSESS))) //only dummy aura is breakable - { - m_ccAuras.push_back(Aur); - } if (handleEffects) Aur->HandleEffects(true); @@ -4198,12 +4169,6 @@ void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode) UpdateInterruptMask(); } - if((Aur->GetSpellProto()->Attributes & SPELL_ATTR_BREAKABLE_BY_DAMAGE - && !Aur->IsAuraType(SPELL_AURA_MOD_POSSESS))) //only dummy aura is breakable - { - m_ccAuras.remove(Aur); - } - Aur->SetRemoveMode(mode); sLog.outDebug("Aura %u now is remove mode %d", Aur->GetId(), mode); @@ -12809,25 +12774,26 @@ void Unit::ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag if (procSpell) takeCharges=true; break; - // These auras may not have charges - that means they have chance to remove based on dmg + // CC Auras which use their amount amount to drop + // Are there any more auras which need this? + case SPELL_AURA_MOD_CONFUSE: case SPELL_AURA_MOD_FEAR: case SPELL_AURA_MOD_STUN: case SPELL_AURA_MOD_ROOT: - if (!useCharges && isVictim && damage && !i->spellProcEvent) + if (isVictim && damage) { - // The chance to dispel an aura depends on the damage taken with respect to the casters level. - uint32 max_dmg = getLevel() > 8 ? 25 * getLevel() - 150 : 50; - float chance = float(damage) / max_dmg * 100.0f; - if (roll_chance_f(chance)) + int32 damageLeft = triggeredByAura->GetAmount(); + // No damage left + if (damageLeft < damage ) RemoveAura(i->aura); + else + triggeredByAura->SetAmount(damageLeft-damage); } - else - takeCharges=true; break; - /*case SPELL_AURA_ADD_FLAT_MODIFIER: - case SPELL_AURA_ADD_PCT_MODIFIER: + //case SPELL_AURA_ADD_FLAT_MODIFIER: + //case SPELL_AURA_ADD_PCT_MODIFIER: // HandleSpellModAuraProc - break;*/ + //break; default: // nothing do, just charges counter takeCharges=true; diff --git a/src/game/Unit.h b/src/game/Unit.h index 8cc65138d9e..67a8b427287 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1195,7 +1195,6 @@ class TRINITY_DLL_SPEC Unit : public WorldObject void Unmount(); uint16 GetMaxSkillValueForLevel(Unit const* target = NULL) const { return (target ? getLevelForTarget(target) : getLevel()) * 5; } - void RemoveSpellbyDamageTaken(uint32 damage, uint32 spell); void DealDamageMods(Unit *pVictim, uint32 &damage, uint32* absorb); uint32 DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDamage = NULL, DamageEffectType damagetype = DIRECT_DAMAGE, SpellSchoolMask damageSchoolMask = SPELL_SCHOOL_MASK_NORMAL, SpellEntry const *spellProto = NULL, bool durabilityLoss = true); void Kill(Unit *pVictim, bool durabilityLoss = true); @@ -1841,7 +1840,6 @@ class TRINITY_DLL_SPEC Unit : public WorldObject AuraEffectList m_modAuras[TOTAL_AURAS]; AuraList m_scAuras; // casted singlecast auras AuraList m_interruptableAuras; - AuraList m_ccAuras; AuraList m_removedAuras; uint32 m_interruptMask; |