diff options
author | Treeston <treeston.mmoc@gmail.com> | 2017-06-07 02:33:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-07 02:33:47 +0200 |
commit | 1660bb7d27d6f42b49012a6b57e3c2b2eab20fd3 (patch) | |
tree | cf63a9cb6e89e621d7ae8b901684bc98a40a7e08 /src/server/game/AI/CreatureAI.cpp | |
parent | 2335b9de1a46a409c714a1dc89cbd0565545e70e (diff) |
Pet/Guardian AI hook re-organizing (#19824)
* Pet/Guardian AI hook re-organizing:
- Adjust OwnerAttacked/OwnerAttackedBy hooks on CreatureAI to fire for all owned units, not just player pets. This should allow guardians to more reliably recognize valid targets.
- Kill off the AttackedBy hook. While it was defined in CreatureAI.h as virtual, it was only ever invoked for player pets in specific situations. This makes it classic developer bait.
- Adjust PetAI to use DamageTaken instead of AttackedBy.
- Adjust behavior of AttackStart on PetAI to compensate.
Diffstat (limited to 'src/server/game/AI/CreatureAI.cpp')
-rw-r--r-- | src/server/game/AI/CreatureAI.cpp | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp index 9bc5a397ea5..281795c0ed1 100644 --- a/src/server/game/AI/CreatureAI.cpp +++ b/src/server/game/AI/CreatureAI.cpp @@ -132,15 +132,22 @@ void CreatureAI::MoveInLineOfSight(Unit* who) if (me->GetVictim()) return; - if (me->GetCreatureType() == CREATURE_TYPE_NON_COMBAT_PET) // non-combat pets should just stand there and look good;) - return; - if (me->HasReactState(REACT_AGGRESSIVE) && me->CanStartAttack(who, false)) AttackStart(who); - //else if (who->GetVictim() && me->IsFriendlyTo(who) - // && me->IsWithinDistInMap(who, sWorld->getIntConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS)) - // && me->CanStartAttack(who->GetVictim(), true)) /// @todo if we use true, it will not attack it when it arrives - // me->GetMotionMaster()->MoveChase(who->GetVictim()); +} + +void CreatureAI::_OnOwnerCombatInteraction(Unit* target) +{ + if (!target || !me->IsAlive()) + return; + + if (!me->HasReactState(REACT_PASSIVE) && me->CanStartAttack(target, true)) + { + if (me->IsInCombat()) + me->AddThreat(target, 0.0f); + else + AttackStart(target); + } } // Distract creature, if player gets too close while stealthed/prowling @@ -196,12 +203,6 @@ void CreatureAI::EnterEvadeMode(EvadeReason why) me->GetVehicleKit()->Reset(true); } -/*void CreatureAI::AttackedBy(Unit* attacker) -{ - if (!me->GetVictim()) - AttackStart(attacker); -}*/ - void CreatureAI::SetGazeOn(Unit* target) { if (me->IsValidAttackTarget(target)) |