[svn] * Added fleeing and call assistance in script until we move all AI functions to core

--HG--
branch : trunk
This commit is contained in:
Neo2003
2008-10-05 12:10:02 -05:00
parent 0c3db399c5
commit 843f789f58
4 changed files with 60 additions and 3 deletions
+34
View File
@@ -1644,6 +1644,40 @@ bool Creature::IsVisibleInGridForPlayer(Player* pl) const
return false;
}
void Creature::DoFleeToGetAssistance(float radius) // Optional parameter
{
if (!getVictim())
return;
Creature* pCreature = NULL;
CellPair p(MaNGOS::ComputeCellPair(GetPositionX(), GetPositionY()));
Cell cell(p);
cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
MaNGOS::NearestAssistCreatureInCreatureRangeCheck u_check(this,getVictim(),radius);
MaNGOS::CreatureLastSearcher<MaNGOS::NearestAssistCreatureInCreatureRangeCheck> searcher(pCreature, u_check);
TypeContainerVisitor<MaNGOS::CreatureLastSearcher<MaNGOS::NearestAssistCreatureInCreatureRangeCheck>, GridTypeMapContainer > grid_creature_searcher(searcher);
CellLock<GridReadGuard> cell_lock(cell, p);
cell_lock->Visit(cell_lock, grid_creature_searcher, *(GetMap()));
if(!GetMotionMaster()->empty() && (GetMotionMaster()->GetCurrentMovementGeneratorType() != POINT_MOTION_TYPE))
GetMotionMaster()->Clear(false);
if(pCreature == NULL)
{
GetMotionMaster()->MoveIdle();
GetMotionMaster()->MoveFleeing(getVictim());
}
else
{
GetMotionMaster()->MoveIdle();
GetMotionMaster()->MovePoint(0,pCreature->GetPositionX(),pCreature->GetPositionY(),pCreature->GetPositionZ());
}
}
void Creature::CallAssistence()
{
if( !m_AlreadyCallAssistence && getVictim() && !isPet() && !isCharmed())
+1
View File
@@ -510,6 +510,7 @@ class MANGOS_DLL_SPEC Creature : public Unit
void CallAssistence();
void SetNoCallAssistence(bool val) { m_AlreadyCallAssistence = val; }
void DoFleeToGetAssistance(float radius = 50);
MovementGeneratorType GetDefaultMovementType() const { return m_defaultMovementType; }
void SetDefaultMovementType(MovementGeneratorType mgt) { m_defaultMovementType = mgt; }