diff --git a/src/bindings/universal/ScriptMgr.h b/src/bindings/universal/ScriptMgr.h index 37b32c79b..9b6c7755e 100644 --- a/src/bindings/universal/ScriptMgr.h +++ b/src/bindings/universal/ScriptMgr.h @@ -119,6 +119,9 @@ struct MANGOS_DLL_DECL ScriptedAI : public CreatureAI // Called when hit by a spell void SpellHit(Unit *, const SpellEntry*){} + // Called when spell hits creature's target + void SpellHitTarget(WorldObject*, const SpellEntry*) {} + Creature* m_creature; //= Some useful helpers ========================= diff --git a/src/game/CreatureAI.h b/src/game/CreatureAI.h index 3bc4e9b34..dc7bc41f5 100644 --- a/src/game/CreatureAI.h +++ b/src/game/CreatureAI.h @@ -27,6 +27,7 @@ class Unit; class Creature; +class WorldObject; struct SpellEntry; #define TIME_INTERVAL_LOOK 5000 @@ -79,6 +80,9 @@ class MANGOS_DLL_SPEC CreatureAI // Called when hit by a spell virtual void SpellHit(Unit*, const SpellEntry*) {} + // Called when spell hits creature's target + virtual void SpellHitTarget(WorldObject*, const SpellEntry*) {} + // Called when vitim entered water and creature can not enter water virtual bool canReachByRangeAttack(Unit*) { return false; } diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index af53abeae..69c5f378d 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -978,7 +978,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target) // Get original caster (if exist) and calculate damage/healing from him data Unit *caster = m_originalCaster ? m_originalCaster : m_caster; - // Skip if m_originalCaster not avaiable + // Skip if m_originalCaster not available if (!caster) return; @@ -1071,7 +1071,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target) } // Call scripted function for AI if this spell is casted upon a creature (except pets) - if(IS_CREATURE_GUID(target->targetGUID)) + if(unit->GetTypeId()==TYPEID_UNIT) { // cast at creature (or GO) quest objectives update at successful cast finished (+channel finished) // ignore autorepeat/melee casts for speed (not exist quest for spells (hm... ) @@ -1081,6 +1081,10 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target) if(((Creature*)unit)->AI()) ((Creature*)unit)->AI()->SpellHit(m_caster ,m_spellInfo); } + + // Call scripted function for AI if this spell is casted by a creature + if(m_caster->GetTypeId()==TYPEID_UNIT && ((Creature*)m_caster)->AI()) + ((Creature*)m_caster)->AI()->SpellHitTarget(unit,m_spellInfo); } void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask) @@ -1219,6 +1223,10 @@ void Spell::DoAllEffectOnTarget(GOTargetInfo *target) // ignore autorepeat/melee casts for speed (not exist quest for spells (hm... ) if( m_caster->GetTypeId() == TYPEID_PLAYER && !IsAutoRepeat() && !IsNextMeleeSwingSpell() && !IsChannelActive() ) ((Player*)m_caster)->CastedCreatureOrGO(go->GetEntry(),go->GetGUID(),m_spellInfo->Id); + + // Call scripted function for AI if this spell is casted by a creature + if(m_caster->GetTypeId()==TYPEID_UNIT && ((Creature*)m_caster)->AI()) + ((Creature*)m_caster)->AI()->SpellHitTarget(go,m_spellInfo); } void Spell::DoAllEffectOnTarget(ItemTargetInfo *target) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 6c6f7c150..34f9c0976 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 "7585" + #define REVISION_NR "7586" #endif // __REVISION_NR_H__