diff options
author | megamage <none@none> | 2009-06-04 16:10:26 -0500 |
---|---|---|
committer | megamage <none@none> | 2009-06-04 16:10:26 -0500 |
commit | 8bb75918a85263493fca49be1993d373f8d2b5fa (patch) | |
tree | 0953d145ee5d25faea83968bdaca5611577e6f4a /src/game/CreatureEventAI.cpp | |
parent | 45516c5e58dc9cab70d9e3c024f30e9a4342f6a3 (diff) |
[7951] Mope call for help code to function form Event AI code to allow use it from C++ scripts also. Author: NoFantasy
--HG--
branch : trunk
Diffstat (limited to 'src/game/CreatureEventAI.cpp')
-rw-r--r-- | src/game/CreatureEventAI.cpp | 51 |
1 files changed, 1 insertions, 50 deletions
diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp index e2c51f40804..834741fd2ae 100644 --- a/src/game/CreatureEventAI.cpp +++ b/src/game/CreatureEventAI.cpp @@ -29,43 +29,8 @@ #include "GameEventMgr.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" -#include "WorldPacket.h" #include "InstanceData.h" -namespace MaNGOS -{ - class CallOfHelpCreatureInRangeDo // do attack at call of help to friendly crearture - { - public: - CallOfHelpCreatureInRangeDo(Unit* funit, Unit* enemy, float range) - : i_funit(funit), i_enemy(enemy), i_range(range) - {} - void operator()(Creature* u) - { - if (u == i_funit) - return; - - if (!u->CanAssistTo(i_funit, i_enemy, false)) - return; - - // too far - if( !i_funit->IsWithinDistInMap(u, i_range) ) - return; - - // only if see assisted creature - if( !i_funit->IsWithinLOSInMap(u) ) - return; - - if(u->AI()) - u->AI()->AttackStart(i_enemy); - } - private: - Unit* const i_funit; - Unit* const i_enemy; - float i_range; - }; -} - bool CreatureEventAIHolder::UpdateRepeatTimer( Creature* creature, uint32 repeatMin, uint32 repeatMax ) { if (repeatMin == repeatMax) @@ -765,21 +730,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 break; case ACTION_T_CALL_FOR_HELP: { - if (!m_creature->getVictim()) - return; - - CellPair p(MaNGOS::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - MaNGOS::CallOfHelpCreatureInRangeDo u_do(m_creature, m_creature->getVictim(), action.call_for_help.radius); - MaNGOS::CreatureWorker<MaNGOS::CallOfHelpCreatureInRangeDo> worker(m_creature, u_do); - - TypeContainerVisitor<MaNGOS::CreatureWorker<MaNGOS::CallOfHelpCreatureInRangeDo>, GridTypeMapContainer > grid_creature_searcher(worker); - - CellLock<GridReadGuard> cell_lock(cell, p); - cell_lock->Visit(cell_lock, grid_creature_searcher, *m_creature->GetMap()); + m_creature->CallForHelp(action.call_for_help.radius); break; } break; |