*Handle breaking on damage auras by procflags - original patch by thenecromancer

*Implement Glyph of Fear - by thenecromancer

--HG--
branch : trunk
This commit is contained in:
QAston
2009-07-11 15:58:19 +02:00
parent b52b358109
commit bf5447b469
5 changed files with 52 additions and 49 deletions

View File

@@ -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?

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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;

View File

@@ -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;