PeAI update

* Better handle target selection for defensive pets. Adds triggers for when owner is damaged or begins attacking something.

* Defensive pets no longer run off as soon as a mob aggros the owner but rather at first damage to owner or owner first attack

* Pets on stay will continue to attack unless target unreachable
This commit is contained in:
MrSmite committed 2012-04-06 12:26:45 -04:00
1 parent b5dc7bc45b
commit b843688fa8
6 files changed
+95 -10

No files matched your search

+19
View File
@@ -572,6 +572,15 @@ uint32 Unit::DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDam
if (IsAIEnabled)
GetAI()->DamageDealt(victim, damage, damagetype);
// Signal to pets that their owner was attacked
if (victim->GetTypeId() == TYPEID_PLAYER)
{
Pet* pet = victim->ToPlayer()->GetPet();
if (pet && pet->isAlive())
pet->AI()->OwnerDamagedBy(this);
}
if (damagetype != NODAMAGE)
{
// interrupting auras with AURA_INTERRUPT_FLAG_DAMAGE before checking !damage (absorbed damage breaks that type of auras)
@@ -9515,6 +9524,16 @@ bool Unit::Attack(Unit* victim, bool meleeAttack)
if (meleeAttack)
SendMeleeAttackStart(victim);
// Let the pet know we've started attacking someting. Handles melee attacks only
// Spells such as auto-shot and others handled in WorldSession::HandleCastSpellOpcode
if (this->GetTypeId() == TYPEID_PLAYER)
{
Pet* playerPet = this->ToPlayer()->GetPet();
if (playerPet && playerPet->isAlive())
playerPet->AI()->OwnerAttacked(victim);
}
return true;
}