//Gets the first found attacker of Unit
Unit *PlayerbotClassAI::GetAttackerOf(Unit *pAttacked)
{
    if (!pAttacked) { pAttacked = m_bot; if (!pAttacked) { return NULL; } }
    Unit::AttackerSet fAttackerSet = pAttacked->getAttackers();
    if (fAttackerSet.size() <= 0) { return NULL; }
    return (*fAttackerSet.begin());
}
//Gets the first found attacker of Unit if not nearestToAttacked > finds the one nearest to bot
Unit *PlayerbotClassAI::GetNearestAttackerOf(Unit *pAttacked, bool nearestToAttacked)
{
    if (!pAttacked) { pAttacked = m_bot; if (!pAttacked) return NULL;}

    Unit::AttackerSet fAttackerSet = pAttacked->getAttackers();
    if (fAttackerSet.size() <= 0) { return NULL; }

    Unit *nearestTo = m_bot;
    if (nearestToAttacked) { nearestTo = pAttacked; }

    Unit *curAtt = NULL;
    float minDist = 30;


    for (Unit::AttackerSet::const_iterator itr = fAttackerSet.begin(); itr != fAttackerSet.end(); ++itr)
    {
        Unit *tAtt = (*itr);
        if (!tAtt) break; // Something is wrong.. How can a non existing mob attack?
        if (tAtt->isDead()) break;
        if (m_bot->GetDistance(tAtt) >= minDist) continue; //Get the nearest one
        curAtt = tAtt;
        minDist = tAtt->GetDistance(nearestTo);
    }
    return curAtt;

}
//Gets if the unit is under attack by # of attackers
bool PlayerbotClassAI::isUnderAttack(Unit *pAttacked,const uint8 &minNumberOfAttackers)
{
    if (!pAttacked) { pAttacked = m_bot; if (!pAttacked) { return false; } }
    Unit::AttackerSet fAttackerSet = pAttacked->getAttackers();
    if (fAttackerSet.size() >= minNumberOfAttackers) { return true; }
    return false;
}