Skip to content

Commit

Permalink
[2292] Restore ScriptedPetAI's eysight. Merge pull request scriptdev2#4
Browse files Browse the repository at this point in the history
Also make the interface between ScriptedPetAI and MaNGOS safer.

Signed-off-by: Schmoozerd <schmoozerd@scriptdev2.com>
  • Loading branch information
Vinolentus authored and Schmoozerd committed Sep 24, 2011
1 parent 64befa3 commit 1f40c57
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
6 changes: 6 additions & 0 deletions base/pet_ai.cpp
Expand Up @@ -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())
Expand Down
14 changes: 8 additions & 6 deletions base/pet_ai.h
Expand Up @@ -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() {}

Expand Down
2 changes: 1 addition & 1 deletion 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.