diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/game/SharedDefines.h | 2 | ||||
| -rw-r--r-- | src/game/Spell.cpp | 44 | ||||
| -rw-r--r-- | src/game/Spell.h | 4 | ||||
| -rw-r--r-- | src/game/SpellEffects.cpp | 26 |
4 files changed, 43 insertions, 33 deletions
diff --git a/src/game/SharedDefines.h b/src/game/SharedDefines.h index 9553592c82c..7d6adb159d9 100644 --- a/src/game/SharedDefines.h +++ b/src/game/SharedDefines.h @@ -673,7 +673,7 @@ enum SpellEffects SPELL_EFFECT_141 = 141, SPELL_EFFECT_TRIGGER_SPELL_WITH_VALUE = 142, SPELL_EFFECT_APPLY_AREA_AURA_OWNER = 143, - SPELL_EFFECT_144 = 144, + SPELL_EFFECT_KNOCK_BACK_2 = 144, SPELL_EFFECT_145 = 145, SPELL_EFFECT_ACTIVATE_RUNE = 146, SPELL_EFFECT_QUEST_FAIL = 147, diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 428aca13f8c..58b1465d1f9 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -1154,6 +1154,12 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask) if(m_caster->GetTypeId() == TYPEID_UNIT && ((Creature*)m_caster)->AI()) ((Creature*)m_caster)->AI()->SpellHitTarget(unit, m_spellInfo); + for(ChanceTriggerSpells::const_iterator i = m_ChanceTriggerSpells.begin(); i != m_ChanceTriggerSpells.end(); ++i) + { + if(roll_chance_i(i->second)) + m_caster->CastSpell(unit, i->first, true); + } + if(m_customAttr & SPELL_ATTR_CU_LINK_HIT) { if(const std::vector<int32> *spell_triggered = spellmgr.GetSpellLinked(m_spellInfo->Id + SPELL_LINK_HIT)) @@ -2047,17 +2053,14 @@ void Spell::prepare(SpellCastTargets const* targets, Aura* triggeredByAura) if(isSpellBreakStealth(m_spellInfo) ) m_caster->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_CAST); + m_caster->SetCurrentCastedSpell( this ); + m_selfContainer = &(m_caster->m_currentSpells[GetCurrentContainer()]); + SendSpellStart(); + 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(); } } @@ -2244,25 +2247,14 @@ void Spell::cast(bool skipCheck) { 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); - chance *= (*i)->GetStackAmount(); - if(roll_chance_i(chance)) - { - if(SpellEntry const *spellInfo = sSpellStore.LookupEntry(auraSpellInfo->EffectTriggerSpell[auraSpellIdx])) - m_TriggerSpells.push_back(spellInfo); - } - } - } + SpellEntry const *auraSpellInfo = (*i)->GetSpellProto(); + uint32 auraSpellIdx = (*i)->GetEffIndex(); + if(SpellEntry const *spellInfo = sSpellStore.LookupEntry(auraSpellInfo->EffectTriggerSpell[auraSpellIdx])) + { + // Calculate chance at that moment (can be depend for example from combo points) + int32 chance = m_caster->CalculateSpellDamage(auraSpellInfo, auraSpellIdx, (*i)->GetBasePoints(), NULL); + m_ChanceTriggerSpells.push_back(std::make_pair(spellInfo, chance * (*i)->GetStackAmount())); + } } // combo points should not be taken before SPELL_AURA_ADD_TARGET_TRIGGER auras are handled diff --git a/src/game/Spell.h b/src/game/Spell.h index 9bfc2ce686c..9f29d3bf8d7 100644 --- a/src/game/Spell.h +++ b/src/game/Spell.h @@ -596,8 +596,10 @@ class Spell // ------------------------------------------- //List For Triggered Spells - typedef std::list<SpellEntry const*> TriggerSpells; + typedef std::vector<SpellEntry const*> TriggerSpells; TriggerSpells m_TriggerSpells; + typedef std::vector< std::pair<SpellEntry const*, int32> > ChanceTriggerSpells; + ChanceTriggerSpells m_ChanceTriggerSpells; uint32 m_spellState; uint32 m_timer; diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index d4e131ae37e..a700595a8ac 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -208,7 +208,7 @@ pEffect SpellEffects[TOTAL_SPELL_EFFECTS]= &Spell::EffectNULL, //141 SPELL_EFFECT_141 damage and reduce speed? &Spell::EffectTriggerSpellWithValue, //142 SPELL_EFFECT_TRIGGER_SPELL_WITH_VALUE &Spell::EffectApplyAreaAura, //143 SPELL_EFFECT_APPLY_AREA_AURA_OWNER - &Spell::EffectNULL, //144 SPELL_EFFECT_144 Spectral Blast + &Spell::EffectKnockBack, //144 SPELL_EFFECT_KNOCK_BACK_2 Spectral Blast &Spell::EffectNULL, //145 SPELL_EFFECT_145 Black Hole Effect &Spell::EffectActivateRune, //146 SPELL_EFFECT_ACTIVATE_RUNE &Spell::EffectQuestFail, //147 SPELL_EFFECT_QUEST_FAIL quest fail @@ -6190,17 +6190,33 @@ void Spell::EffectSummonCritter(uint32 i) void Spell::EffectKnockBack(uint32 i) { - if(!unitTarget || !m_caster) + if(!unitTarget) return; // Effect only works on players if(unitTarget->GetTypeId()!=TYPEID_PLAYER) return; - float vsin = sin(m_caster->GetAngle(unitTarget)); - float vcos = cos(m_caster->GetAngle(unitTarget)); + float x, y; + if(m_targets.HasDest()) + { + x = m_targets.m_destX; + y = m_targets.m_destY; + } + else + { + x = m_caster->GetPositionX(); + y = m_caster->GetPositionX(); + } + + float dx = unitTarget->GetPositionX() - x; + float dy = unitTarget->GetPositionY() - y; + float dist = sqrt((dx*dx) + (dy*dy)); + + float vsin = dx / dist; + float vcos = dy / dist; float speedxy = float(m_spellInfo->EffectMiscValue[i])/10; - float speedz = float(damage/-10); + float speedz = float(damage/-10); WorldPacket data(SMSG_MOVE_KNOCK_BACK, (8+4+4+4+4+4)); data.append(unitTarget->GetPackGUID()); |
