Permalink
Browse files

[2292] Restore ScriptedPetAI's eysight. Merge pull request #4

Also make the interface between ScriptedPetAI and MaNGOS safer.

Signed-off-by: Schmoozerd <schmoozerd@scriptdev2.com>
  • Loading branch information...
1 parent 64befa3 commit 1f40c574efc1d47f6168f84b1e3df43c92f06c1f Vinolentus committed with Sep 24, 2011
Showing with 15 additions and 7 deletions.
  1. +6 −0 base/pet_ai.cpp
  2. +8 −6 base/pet_ai.h
  3. +1 −1 sd2_revision_nr.h
View
6 base/pet_ai.cpp
@@ -15,6 +15,12 @@ EndScriptData */
ScriptedPetAI::ScriptedPetAI(Creature* pCreature) : CreatureAI(pCreature)
{}
+bool ScriptedPetAI::IsVisible(Unit* pWho) const
+{
+ return pWho && m_creature->IsWithinDist(pWho, VISIBLE_RANGE)
+ && pWho->isVisibleForOrDetect(m_creature, m_creature, true);
+}
+
void ScriptedPetAI::MoveInLineOfSight(Unit* pWho)
{
if (m_creature->getVictim())
View
14 base/pet_ai.h
@@ -12,17 +12,19 @@ class MANGOS_DLL_DECL ScriptedPetAI : public CreatureAI
explicit ScriptedPetAI(Creature* pCreature);
~ScriptedPetAI() {}
- void MoveInLineOfSight(Unit* /*pWho*/);
+ void MoveInLineOfSight(Unit* /*pWho*/) override;
- void AttackStart(Unit* /*pWho*/);
+ void AttackStart(Unit* /*pWho*/) override;
- void AttackedBy(Unit* /*pAttacker*/);
+ void AttackedBy(Unit* /*pAttacker*/) override;
- void KilledUnit(Unit* /*pVictim*/) {}
+ bool IsVisible(Unit* /*pWho*/) const override;
- void OwnerKilledUnit(Unit* /*pVictim*/) {}
+ void KilledUnit(Unit* /*pVictim*/) override {}
- void UpdateAI(const uint32 uiDiff);
+ void OwnerKilledUnit(Unit* /*pVictim*/) override {}
+
+ void UpdateAI(const uint32 uiDiff) override;
virtual void Reset() {}
View
2 sd2_revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __SD2_REVISION_NR_H__
#define __SD2_REVISION_NR_H__
- #define SD2_REVISION_NR "2291"
+ #define SD2_REVISION_NR "2292"
#endif // __SD2_REVISION_NR_H__

0 comments on commit 1f40c57

Please sign in to comment.