[7586] New caster AI::SpellHitTarget call at casted spell landing to target (player/creature/pet/go)

Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
Lightguard 2009-03-30 00:41:44 +04:00 committed by VladimirMangos
parent f726bd69a5
commit 4717f68984
4 changed files with 18 additions and 3 deletions

View file

@ -119,6 +119,9 @@ struct MANGOS_DLL_DECL ScriptedAI : public CreatureAI
// Called when hit by a spell // Called when hit by a spell
void SpellHit(Unit *, const SpellEntry*){} void SpellHit(Unit *, const SpellEntry*){}
// Called when spell hits creature's target
void SpellHitTarget(WorldObject*, const SpellEntry*) {}
Creature* m_creature; Creature* m_creature;
//= Some useful helpers ========================= //= Some useful helpers =========================

View file

@ -27,6 +27,7 @@
class Unit; class Unit;
class Creature; class Creature;
class WorldObject;
struct SpellEntry; struct SpellEntry;
#define TIME_INTERVAL_LOOK 5000 #define TIME_INTERVAL_LOOK 5000
@ -79,6 +80,9 @@ class MANGOS_DLL_SPEC CreatureAI
// Called when hit by a spell // Called when hit by a spell
virtual void SpellHit(Unit*, const SpellEntry*) {} 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 // Called when vitim entered water and creature can not enter water
virtual bool canReachByRangeAttack(Unit*) { return false; } virtual bool canReachByRangeAttack(Unit*) { return false; }

View file

@ -978,7 +978,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target)
// Get original caster (if exist) and calculate damage/healing from him data // Get original caster (if exist) and calculate damage/healing from him data
Unit *caster = m_originalCaster ? m_originalCaster : m_caster; Unit *caster = m_originalCaster ? m_originalCaster : m_caster;
// Skip if m_originalCaster not avaiable // Skip if m_originalCaster not available
if (!caster) if (!caster)
return; 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) // 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) // 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... ) // 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()) if(((Creature*)unit)->AI())
((Creature*)unit)->AI()->SpellHit(m_caster ,m_spellInfo); ((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) 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... ) // ignore autorepeat/melee casts for speed (not exist quest for spells (hm... )
if( m_caster->GetTypeId() == TYPEID_PLAYER && !IsAutoRepeat() && !IsNextMeleeSwingSpell() && !IsChannelActive() ) if( m_caster->GetTypeId() == TYPEID_PLAYER && !IsAutoRepeat() && !IsNextMeleeSwingSpell() && !IsChannelActive() )
((Player*)m_caster)->CastedCreatureOrGO(go->GetEntry(),go->GetGUID(),m_spellInfo->Id); ((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) void Spell::DoAllEffectOnTarget(ItemTargetInfo *target)

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "7585" #define REVISION_NR "7586"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__