mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-23 10:26:28 +01:00
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
|
||||
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.
|
||||
// predicate shall extend std::unary_function<Unit *, bool>
|
||||
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)
|
||||
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
|
||||
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)
|
||||
{
|
||||
if (pVictim->GetTypeId() == TYPEID_UNIT && pVictim->ToCreature()->IsAIEnabled)
|
||||
pVictim->ToCreature()->AI()->DamageTaken(this, damage);
|
||||
if (pVictim->IsAIEnabled)
|
||||
pVictim->GetAI()->DamageTaken(this, damage);
|
||||
|
||||
if (GetTypeId() == TYPEID_UNIT && this->ToCreature()->IsAIEnabled)
|
||||
this->ToCreature()->AI()->DamageDealt(pVictim, damage, damagetype);
|
||||
if (IsAIEnabled)
|
||||
GetAI()->DamageDealt(pVictim, damage, damagetype);
|
||||
|
||||
if (damagetype != NODAMAGE)
|
||||
{
|
||||
@@ -9892,8 +9892,11 @@ 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 (pVictim->IsAIEnabled)
|
||||
pVictim->GetAI()->HealReceived(this, addhealth);
|
||||
|
||||
if (IsAIEnabled)
|
||||
GetAI()->HealDone(pVictim, addhealth);
|
||||
|
||||
if (addhealth)
|
||||
gain = pVictim->ModifyHealth(int32(addhealth));
|
||||
|
||||
@@ -1106,6 +1106,9 @@ class Unit : public WorldObject
|
||||
|
||||
virtual ~Unit ();
|
||||
|
||||
UnitAI* GetAI() { return i_AI; }
|
||||
void SetAI(UnitAI* newAI) { i_AI = newAI; }
|
||||
|
||||
void AddToWorld();
|
||||
void RemoveFromWorld();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user