--HG--
branch : trunk
This commit is contained in:
megamage
2009-02-02 17:39:42 -06:00
3 changed files with 52 additions and 38 deletions
+41 -32
View File
@@ -2030,8 +2030,7 @@ void Spell::prepare(SpellCastTargets const* targets, Aura* triggeredByAura)
// set timer base at cast time
ReSetTimer();
//item: first cast may destroy item and second cast causes crash
if(m_IsTriggeredSpell || !m_casttime && !m_spellInfo->StartRecoveryTime && !m_castItemGUID && GetCurrentContainer() == CURRENT_GENERIC_SPELL)
if(m_IsTriggeredSpell)
cast(true);
else
{
@@ -2040,11 +2039,18 @@ void Spell::prepare(SpellCastTargets const* targets, Aura* triggeredByAura)
if(isSpellBreakStealth(m_spellInfo) )
m_caster->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_CAST);
if(!m_casttime && !m_spellInfo->StartRecoveryTime
&& !m_castItemGUID //item: first cast may destroy item and second cast causes crash
&& GetCurrentContainer() == CURRENT_GENERIC_SPELL)
cast(true);
else
{
m_caster->SetCurrentCastedSpell( this );
m_selfContainer = &(m_caster->m_currentSpells[GetCurrentContainer()]);
SendSpellStart();
}
}
}
void Spell::cancel(bool report)
{
@@ -2147,9 +2153,6 @@ void Spell::cast(bool skipCheck)
FillTargetMap();
if(m_customAttr & SPELL_ATTR_CU_DIRECT_DAMAGE)
CalculateDamageDoneForAllTargets();
if(m_spellInfo->SpellFamilyName)
{
if (m_spellInfo->excludeCasterAuraSpell)
@@ -2205,12 +2208,15 @@ void Spell::cast(bool skipCheck)
SendCastResult(castResult);
SendSpellGo(); // we must send smsg_spell_go packet before m_castItem delete in TakeCastItem()...
// Okay, everything is prepared. Now we need to distinguish between immediate and evented delayed spells
if (m_spellInfo->speed > 0.0f && !IsChanneledSpell(m_spellInfo))
{
if(m_customAttr & SPELL_ATTR_CU_DIRECT_DAMAGE)
CalculateDamageDoneForAllTargets();
if(m_customAttr & SPELL_ATTR_CU_CHARGE)
EffectCharge(0);
// Okay, everything is prepared. Now we need to distinguish between immediate and evented delayed spells
if (m_spellInfo->speed > 0.0f && !IsChanneledSpell(m_spellInfo))
{
// Remove used for cast item if need (it can be already NULL after TakeReagents call
// in case delayed spell remove item at cast delay start
TakeCastItem();
@@ -2226,6 +2232,32 @@ void Spell::cast(bool skipCheck)
handle_immediate();
}
//are there any spells need to be triggered after hit?
// handle SPELL_AURA_ADD_TARGET_TRIGGER auras
Unit::AuraList const& targetTriggers = m_caster->GetAurasByType(SPELL_AURA_ADD_TARGET_TRIGGER);
for(Unit::AuraList::const_iterator i = targetTriggers.begin(); i != targetTriggers.end(); ++i)
{
if (!(*i)->isAffectedOnSpell(m_spellInfo))
continue;
for(std::list<TargetInfo>::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit)
if( ihit->missCondition == SPELL_MISS_NONE )
{
// check m_caster->GetGUID() let load auras at login and speedup most often case
Unit *unit = m_caster->GetGUID()== ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID);
if (unit && unit->isAlive())
{
SpellEntry const *auraSpellInfo = (*i)->GetSpellProto();
uint32 auraSpellIdx = (*i)->GetEffIndex();
// Calculate chance at that moment (can be depend for example from combo points)
int32 chance = m_caster->CalculateSpellDamage(auraSpellInfo, auraSpellIdx, (*i)->GetBasePoints(),unit);
if(roll_chance_i(chance))
for (int j=0; j != (*i)->GetStackAmount(); ++j)
m_caster->CastSpell(unit, auraSpellInfo->EffectTriggerSpell[auraSpellIdx], true, NULL, (*i));
}
}
}
// combo points should not be taken before SPELL_AURA_ADD_TARGET_TRIGGER auras are handled
if(!m_IsTriggeredSpell)
{
TakePower();
@@ -2619,30 +2651,6 @@ void Spell::finish(bool ok)
if (m_caster->GetTypeId() == TYPEID_PLAYER)
((Player*)m_caster)->RemoveSpellMods(this);
// handle SPELL_AURA_ADD_TARGET_TRIGGER auras
Unit::AuraList const& targetTriggers = m_caster->GetAurasByType(SPELL_AURA_ADD_TARGET_TRIGGER);
for(Unit::AuraList::const_iterator i = targetTriggers.begin(); i != targetTriggers.end(); ++i)
{
if (!(*i)->isAffectedOnSpell(m_spellInfo))
continue;
for(std::list<TargetInfo>::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit)
if( ihit->missCondition == SPELL_MISS_NONE )
{
// check m_caster->GetGUID() let load auras at login and speedup most often case
Unit *unit = m_caster->GetGUID()== ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID);
if (unit && unit->isAlive())
{
SpellEntry const *auraSpellInfo = (*i)->GetSpellProto();
uint32 auraSpellIdx = (*i)->GetEffIndex();
// Calculate chance at that moment (can be depend for example from combo points)
int32 chance = m_caster->CalculateSpellDamage(auraSpellInfo, auraSpellIdx, (*i)->GetBasePoints(),unit);
if(roll_chance_i(chance))
for (int j=0; j != (*i)->GetStackAmount(); ++j)
m_caster->CastSpell(unit, auraSpellInfo->EffectTriggerSpell[auraSpellIdx], true, NULL, (*i));
}
}
}
// Heal caster for all health leech from all targets
if (m_healthLeech)
{
@@ -2660,6 +2668,7 @@ void Spell::finish(bool ok)
}
// call triggered spell only at successful cast (after clear combo points -> for add some if need)
// I assume what he means is that some triggered spells may add combo points
if(!m_TriggerSpells.empty())
TriggerSpell();
+1 -1
View File
@@ -2232,7 +2232,7 @@ void SpellMgr::LoadSpellCustomAttr()
mSpellCustomAttr[i] |= SPELL_ATTR_CU_DIRECT_DAMAGE;
break;
case SPELL_EFFECT_CHARGE:
if(!spellInfo->speed)
if(!spellInfo->speed && !spellInfo->SpellFamilyName)
spellInfo->speed = SPEED_CHARGE;
mSpellCustomAttr[i] |= SPELL_ATTR_CU_CHARGE;
case SPELL_EFFECT_TRIGGER_SPELL:
+7 -2
View File
@@ -9275,9 +9275,9 @@ bool Unit::canDetectInvisibilityOf(Unit const* u) const
{
if(m_invisibilityMask & u->m_invisibilityMask) // same group
return true;
AuraList const& auras = GetAurasByType(SPELL_AURA_MOD_STALKED); // Hunter mark
AuraList const& auras = u->GetAurasByType(SPELL_AURA_MOD_STALKED); // Hunter mark
for(AuraList::const_iterator iter = auras.begin(); iter != auras.end(); ++iter)
if((*iter)->GetCasterGUID()==u->GetGUID())
if((*iter)->GetCasterGUID()==GetGUID())
return true;
if(uint32 mask = (m_detectInvisibilityMask & u->m_invisibilityMask))
@@ -9327,6 +9327,11 @@ bool Unit::canDetectStealthOf(Unit const* target, float distance) const
if(HasAuraType(SPELL_AURA_DETECT_STEALTH))
return true;
AuraList const& auras = target->GetAurasByType(SPELL_AURA_MOD_STALKED); // Hunter mark
for(AuraList::const_iterator iter = auras.begin(); iter != auras.end(); ++iter)
if((*iter)->GetCasterGUID()==GetGUID())
return true;
//Visible distance based on stealth value (stealth rank 4 300MOD, 10.5 - 3 = 7.5)
float visibleDistance = 10.5f - target->GetTotalAuraModifier(SPELL_AURA_MOD_STEALTH) / 100.0f;
//Visible distance is modified by -Level Diff (every level diff = 1.0f in visible distance)