diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 0adb7ea4d..8c1f08748 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -54,6 +54,7 @@ #include "ScriptCalls.h" #include "SkillDiscovery.h" #include "Formulas.h" +#include "GridNotifiers.h" pEffect SpellEffects[TOTAL_SPELL_EFFECTS]= { @@ -5502,15 +5503,54 @@ void Spell::EffectScriptEffect(SpellEffectIndex eff_idx) if (pTarget->hasUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE)) pTarget->GetMotionMaster()->MovementExpired(); + // trigger cast of quest complete script (see code for this spell below) + pTarget->CastSpell(pTarget, 44462, true); + pTarget->GetMotionMaster()->MovePoint(0, m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ()); } return; } - // or if we are first time used item + // or if it is first time used item, cast summon and despawn the target m_caster->CastSpell(pTarget, pSpell, true); pTarget->ForcedDespawn(); + + // TODO: here we should get pointer to the just summoned and make it move. + // without, it will be one extra use of quest item + } + + return; + } + case 44462: // Cast Quest Complete on Master + { + if (m_caster->GetTypeId() != TYPEID_UNIT) + return; + + Creature* pQuestCow = NULL; + + float range = 20.0f; + + // search for a reef cow nearby + MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck u_check(*m_caster, 24797, true, range); + MaNGOS::CreatureLastSearcher searcher(m_caster, pQuestCow, u_check); + + Cell::VisitGridObjects(m_caster, searcher, range); + + // no cows found, so return + if (!pQuestCow) + return; + + if (!((Creature*)m_caster)->isTemporarySummon()) + return; + + if (const SpellEntry *pSpell = sSpellStore.LookupEntry(m_spellInfo->CalculateSimpleValue(eff_idx))) + { + TemporarySummon* pSummon = (TemporarySummon*)m_caster; + + // all ok, so make summoner cast the quest complete + if (Unit* pSummoner = pSummon->GetSummoner()) + pSummoner->CastSpell(pSummoner, pSpell, true); } return; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index cb314279b..80d27f4e7 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "9815" + #define REVISION_NR "9816" #endif // __REVISION_NR_H__