diff options
author | megamage <none@none> | 2008-11-20 20:28:17 -0600 |
---|---|---|
committer | megamage <none@none> | 2008-11-20 20:28:17 -0600 |
commit | 5528b7c512ef7968b11ea93a48364a58b629b18b (patch) | |
tree | 92dde452da86b70d73af90c3acfecf64b4bc04ca /src/game/GridNotifiers.h | |
parent | 2c95ee4b31962198e3e6803bf56fe604724a2111 (diff) |
*Fix the bug that updatepacket is not sent to players.
*TODO: move creature::update to map::update. This requires that move activeobjectlist to map.
--HG--
branch : trunk
Diffstat (limited to 'src/game/GridNotifiers.h')
-rw-r--r-- | src/game/GridNotifiers.h | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/src/game/GridNotifiers.h b/src/game/GridNotifiers.h index 972c209964c..57abea4d5a2 100644 --- a/src/game/GridNotifiers.h +++ b/src/game/GridNotifiers.h @@ -698,19 +698,41 @@ namespace Trinity // Creature checks - class InAttackDistanceFromAnyHostileCreatureCheck + class NearestHostileUnitInAttackDistanceCheck { public: - explicit InAttackDistanceFromAnyHostileCreatureCheck(Unit* funit) : i_funit(funit) {} - bool operator()(Creature* u) + explicit NearestHostileUnitInAttackDistanceCheck(Creature* creature, float dist = 0) : m_creature(creature) { - if(u->isAlive() && u->IsHostileTo(i_funit) && i_funit->IsWithinDistInMap(u, u->GetAttackDistance(i_funit))) - return true; + m_range = (dist == 0 ? 9999 : dist); + m_force = (dist == 0 ? false : true); + } + bool operator()(Unit* u) + { + if(!u->isAlive() || !m_creature->IsHostileTo(u)) + return false; - return false; + float dist; + if(m_force) dist = m_range; + else + { + dist = m_creature->GetAttackDistance(u); + if(dist > m_range) dist = m_range; + } + if(!m_creature->IsWithinDistInMap(u, dist)) + return false; + + if(!m_creature->canSeeOrDetect(u, true, false)) + return false; + + m_range = m_creature->GetDistance(u); + return true; } + float GetLastRange() const { return m_range; } private: - Unit* const i_funit; + Creature* const m_creature; + float m_range; + bool m_force; + NearestHostileUnitInAttackDistanceCheck(NearestHostileUnitInAttackDistanceCheck const&); }; class NearestAssistCreatureInCreatureRangeCheck |