Add HealReceived event for Creature AI to be used in scripts

--HG--
branch : trunk
This commit is contained in:
Shocker
2010-08-29 06:01:14 +03:00
parent 2d877bbbfd
commit f81dcf55bb
3 changed files with 7 additions and 0 deletions
+3
View File
@@ -103,6 +103,9 @@ class CreatureAI : public UnitAI
// for attack reaction use AttackedBy called for not DOT damage in Unit::DealDamage also
virtual void DamageTaken(Unit * /*done_by*/, uint32 & /*damage*/) {}
// Called when the creature receives heal
virtual void HealReceived(Unit* /*done_by*/, uint32& /*addhealth*/) {}
// Called when the creature is killed
virtual void JustDied(Unit *) {}
@@ -608,6 +608,7 @@ class CreatureEventAI : public CreatureAI
void MoveInLineOfSight(Unit *who);
void SpellHit(Unit* pUnit, const SpellEntry* pSpell);
void DamageTaken(Unit* done_by, uint32& damage);
void HealReceived(Unit* /*done_by*/, uint32& /*addhealth*/) {}
void UpdateAI(const uint32 diff);
void ReceiveEmote(Player* pPlayer, uint32 text_emote);
static int Permissible(const Creature *);
+3
View File
@@ -9912,6 +9912,9 @@ int32 Unit::DealHeal(Unit *pVictim, uint32 addhealth)
{
int32 gain = 0;
if (pVictim->GetTypeId() == TYPEID_UNIT && pVictim->ToCreature()->IsAIEnabled)
pVictim->ToCreature()->AI()->HealReceived(this, addhealth);
if (addhealth)
gain = pVictim->ModifyHealth(int32(addhealth));