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/Creature.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/Creature.cpp')
-rw-r--r-- | src/game/Creature.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index f817e8a57c9..7f249b36fbd 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -2039,6 +2039,25 @@ void Creature::CallAssistance() } } +void Creature::CallForHelp(float fRadius) +{ + if (fRadius <= 0.0f || !getVictim() || isPet() || isCharmed()) + return; + + CellPair p(MaNGOS::ComputeCellPair(GetPositionX(), GetPositionY())); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + + MaNGOS::CallOfHelpCreatureInRangeDo u_do(this, getVictim(), fRadius); + MaNGOS::CreatureWorker<MaNGOS::CallOfHelpCreatureInRangeDo> worker(this, 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, *GetMap()); +} + bool Creature::CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction /*= true*/) const { // is it true? |