*Allow to change creature's sight distance because 50 yards are too small for some scripts.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-08-23 14:16:03 -05:00
parent ce0a3afc19
commit 4a85a779c1
3 changed files with 7 additions and 9 deletions
+3 -5
View File
@@ -153,6 +153,9 @@ m_creatureInfo(NULL), m_reactState(REACT_AGGRESSIVE), m_formation(NULL), m_summo
m_GlobalCooldown = 0;
DisableReputationGain = false;
//m_unit_movement_flags = MONSTER_MOVE_WALK;
m_SightDistance = sWorld.getConfig(CONFIG_SIGHT_MONSTER);
m_CombatDistance = MELEE_RANGE;
}
Creature::~Creature()
@@ -1697,11 +1700,6 @@ bool Creature::canSeeOrDetect(Unit const* u, bool detect, bool inVisibleList, bo
return true;
}
bool Creature::IsWithinSightDist(Unit const* u) const
{
return IsWithinDistInMap(u, sWorld.getConfig(CONFIG_SIGHT_MONSTER));
}
bool Creature::canStartAttack(Unit const* who, bool force) const
{
if(isCivilian())
+1 -1
View File
@@ -649,7 +649,6 @@ class TRINITY_DLL_SPEC Creature : public Unit
uint32 m_GlobalCooldown;
bool canSeeOrDetect(Unit const* u, bool detect, bool inVisibleList = false, bool is3dDistance = true) const;
bool IsWithinSightDist(Unit const* u) const;
bool canStartAttack(Unit const* u, bool force) const;
float GetAttackDistance(Unit const* pl) const;
@@ -746,6 +745,7 @@ class TRINITY_DLL_SPEC Creature : public Unit
static float _GetDamageMod(int32 Rank);
float m_SightDistance, m_CombatDistance;
protected:
bool CreateFromProto(uint32 guidlow,uint32 Entry,uint32 team, const CreatureData *data = NULL);
bool InitEntry(uint32 entry, uint32 team=ALLIANCE, const CreatureData* data=NULL);
+3 -3
View File
@@ -45,7 +45,7 @@ inline void PlayerCreatureRelocationWorker(Player* pl, Creature* c)
// Creature AI reaction
if(c->HasReactState(REACT_AGGRESSIVE) && !c->hasUnitState(UNIT_STAT_SIGHTLESS))
{
if( c->IsAIEnabled && c->IsWithinSightDist(pl) && !c->IsInEvadeMode() )
if( c->IsAIEnabled && c->_IsWithinDist(pl, c->m_SightDistance, true) && !c->IsInEvadeMode() )
c->AI()->MoveInLineOfSight(pl);
}
}
@@ -54,13 +54,13 @@ inline void CreatureCreatureRelocationWorker(Creature* c1, Creature* c2)
{
if(c1->HasReactState(REACT_AGGRESSIVE) && !c1->hasUnitState(UNIT_STAT_SIGHTLESS))
{
if( c1->IsAIEnabled && c1->IsWithinSightDist(c2) && !c1->IsInEvadeMode() )
if( c1->IsAIEnabled && c1->_IsWithinDist(c2, c1->m_SightDistance, true) && !c1->IsInEvadeMode() )
c1->AI()->MoveInLineOfSight(c2);
}
if(c2->HasReactState(REACT_AGGRESSIVE) && !c2->hasUnitState(UNIT_STAT_SIGHTLESS))
{
if( c2->IsAIEnabled && c1->IsWithinSightDist(c2) && !c2->IsInEvadeMode() )
if( c2->IsAIEnabled && c1->_IsWithinDist(c2, c2->m_SightDistance, true) && !c2->IsInEvadeMode() )
c2->AI()->MoveInLineOfSight(c1);
}
}