aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormegamage <none@none>2009-08-23 14:16:03 -0500
committermegamage <none@none>2009-08-23 14:16:03 -0500
commit4a85a779c1c3fc26b0b7a61115fc2e5b47d1840f (patch)
treee64921d83ef3c485c3634ad437237ec94d113fc4
parentce0a3afc1997e45e12342071db0029fcc3716118 (diff)
*Allow to change creature's sight distance because 50 yards are too small for some scripts.
--HG-- branch : trunk
-rw-r--r--src/game/Creature.cpp8
-rw-r--r--src/game/Creature.h2
-rw-r--r--src/game/GridNotifiersImpl.h6
3 files changed, 7 insertions, 9 deletions
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp
index a9eb6041488..ba16888141b 100644
--- a/src/game/Creature.cpp
+++ b/src/game/Creature.cpp
@@ -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())
diff --git a/src/game/Creature.h b/src/game/Creature.h
index fdab5157bd4..7f8d6040129 100644
--- a/src/game/Creature.h
+++ b/src/game/Creature.h
@@ -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);
diff --git a/src/game/GridNotifiersImpl.h b/src/game/GridNotifiersImpl.h
index 211bca9cd3c..f2970805eab 100644
--- a/src/game/GridNotifiersImpl.h
+++ b/src/game/GridNotifiersImpl.h
@@ -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);
}
}