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
2012-04-06 12:26:45 -04:00
parent b5dc7bc45b
commit b843688fa8
6 changed files with 95 additions and 10 deletions
+13 -2
View File
@@ -3101,11 +3101,22 @@ void Spell::cast(bool skipCheck)
return;
}
// now that we've done the basic check, now run the scripts
// should be done before the spell is actually executed
if (Player* playerCaster = m_caster->ToPlayer())
{
// now that we've done the basic check, now run the scripts
// should be done before the spell is actually executed
sScriptMgr->OnPlayerSpellCast(playerCaster, this, skipCheck);
// Let any pets know we've attacked something. As of 3.0.2 pets begin
// attacking their owner's target immediately
if (Pet* playerPet = playerCaster->GetPet())
{
if (playerPet->isAlive() && playerPet->isControlled() && (m_targets.GetTargetMask() & TARGET_FLAG_UNIT))
{
playerPet->AI()->OwnerAttacked(m_targets.GetObjectTarget()->ToUnit());
}
}
}
SetExecutedCurrently(true);
if (m_caster->GetTypeId() != TYPEID_PLAYER && m_targets.GetUnitTarget() && m_targets.GetUnitTarget() != m_caster)