Core/Scripts: Moved HealReceived from CreatureAI to UnitAI and added HealDone and removed creature-only restriction
--HG-- branch : trunk
This commit is contained in:
@@ -74,6 +74,12 @@ class UnitAI
|
|||||||
// for attack reaction use AttackedBy called for not DOT damage in Unit::DealDamage also
|
// for attack reaction use AttackedBy called for not DOT damage in Unit::DealDamage also
|
||||||
virtual void DamageTaken(Unit* /*attacker*/, uint32& /*damage*/) {}
|
virtual void DamageTaken(Unit* /*attacker*/, uint32& /*damage*/) {}
|
||||||
|
|
||||||
|
// Called when the creature receives heal
|
||||||
|
virtual void HealReceived(Unit* /*done_by*/, uint32& /*addhealth*/) {}
|
||||||
|
|
||||||
|
// Called when the unit heals
|
||||||
|
virtual void HealDone(Unit* /*done_to*/, uint32& /*addhealth*/) {}
|
||||||
|
|
||||||
// Select the targets satifying the predicate.
|
// Select the targets satifying the predicate.
|
||||||
// predicate shall extend std::unary_function<Unit *, bool>
|
// predicate shall extend std::unary_function<Unit *, bool>
|
||||||
template<class PREDICATE> Unit* SelectTarget(SelectAggroTarget targetType, uint32 position, PREDICATE predicate)
|
template<class PREDICATE> Unit* SelectTarget(SelectAggroTarget targetType, uint32 position, PREDICATE predicate)
|
||||||
|
|||||||
@@ -93,9 +93,6 @@ class CreatureAI : public UnitAI
|
|||||||
// Called for reaction at enter to combat if not in combat yet (enemy can be NULL)
|
// Called for reaction at enter to combat if not in combat yet (enemy can be NULL)
|
||||||
virtual void EnterCombat(Unit* /*enemy*/) {}
|
virtual void EnterCombat(Unit* /*enemy*/) {}
|
||||||
|
|
||||||
// Called when the creature receives heal
|
|
||||||
virtual void HealReceived(Unit* /*done_by*/, uint32& /*addhealth*/) {}
|
|
||||||
|
|
||||||
// Called when the creature is killed
|
// Called when the creature is killed
|
||||||
virtual void JustDied(Unit *) {}
|
virtual void JustDied(Unit *) {}
|
||||||
|
|
||||||
|
|||||||
@@ -545,11 +545,11 @@ void Unit::DealDamageMods(Unit *pVictim, uint32 &damage, uint32* absorb)
|
|||||||
|
|
||||||
uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDamage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask, SpellEntry const *spellProto, bool durabilityLoss)
|
uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDamage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask, SpellEntry const *spellProto, bool durabilityLoss)
|
||||||
{
|
{
|
||||||
if (pVictim->GetTypeId() == TYPEID_UNIT && pVictim->ToCreature()->IsAIEnabled)
|
if (pVictim->IsAIEnabled)
|
||||||
pVictim->ToCreature()->AI()->DamageTaken(this, damage);
|
pVictim->GetAI()->DamageTaken(this, damage);
|
||||||
|
|
||||||
if (GetTypeId() == TYPEID_UNIT && this->ToCreature()->IsAIEnabled)
|
if (IsAIEnabled)
|
||||||
this->ToCreature()->AI()->DamageDealt(pVictim, damage, damagetype);
|
GetAI()->DamageDealt(pVictim, damage, damagetype);
|
||||||
|
|
||||||
if (damagetype != NODAMAGE)
|
if (damagetype != NODAMAGE)
|
||||||
{
|
{
|
||||||
@@ -9892,8 +9892,11 @@ int32 Unit::DealHeal(Unit *pVictim, uint32 addhealth)
|
|||||||
{
|
{
|
||||||
int32 gain = 0;
|
int32 gain = 0;
|
||||||
|
|
||||||
if (pVictim->GetTypeId() == TYPEID_UNIT && pVictim->ToCreature()->IsAIEnabled)
|
if (pVictim->IsAIEnabled)
|
||||||
pVictim->ToCreature()->AI()->HealReceived(this, addhealth);
|
pVictim->GetAI()->HealReceived(this, addhealth);
|
||||||
|
|
||||||
|
if (IsAIEnabled)
|
||||||
|
GetAI()->HealDone(pVictim, addhealth);
|
||||||
|
|
||||||
if (addhealth)
|
if (addhealth)
|
||||||
gain = pVictim->ModifyHealth(int32(addhealth));
|
gain = pVictim->ModifyHealth(int32(addhealth));
|
||||||
|
|||||||
@@ -1106,6 +1106,9 @@ class Unit : public WorldObject
|
|||||||
|
|
||||||
virtual ~Unit ();
|
virtual ~Unit ();
|
||||||
|
|
||||||
|
UnitAI* GetAI() { return i_AI; }
|
||||||
|
void SetAI(UnitAI* newAI) { i_AI = newAI; }
|
||||||
|
|
||||||
void AddToWorld();
|
void AddToWorld();
|
||||||
void RemoveFromWorld();
|
void RemoveFromWorld();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user