Example #1
0
void CreatureGroup::AddMember(Creature* member)
{
    if (!member)
        return;

    sLog->outDebug(LOG_FILTER_UNITS, "CreatureGroup::AddMember: Adding unit GUID: %u to group.", member->GetGUIDLow());

    m_members[member] = CreatureGroupMap.find(m_groupID)->second;
    member->SetGroup(this);
}
Example #2
0
void CreatureGroup::AddMember(Creature* member)
{
    sLog->outDebug(LOG_FILTER_UNITS, "CreatureGroup::AddMember: Adding unit GUID: %u.", member->GetGUIDLow());

    //Check if it is a leader
    if (member->GetDBTableGUIDLow() == m_groupID)
    {
        sLog->outDebug(LOG_FILTER_UNITS, "Unit GUID: %u is formation leader. Adding group.", member->GetGUIDLow());
        m_leader = member;
    }

    m_members[member] = CreatureGroupMap.find(member->GetDBTableGUIDLow())->second;
    member->SetFormation(this);
}
Example #3
0
void CreatureGroup::AddMember(Creature *member)
{
    sLog.outDebug("CreatureGroup::AddMember: Adding unit GUIDLow: %u.", member->GetGUIDLow());

    //Check if it is a leader
    if (member->GetDBTableGUIDLow() == m_groupID)
    {
        sLog.outDebug("Unit GUID: %u is formation leader. Adding group.", member->GetGUIDLow());
        m_leader = member;
    }

    CreatureGroupInfoType::iterator iter = CreatureGroupMap.find(member->GetDBTableGUIDLow());

    m_members[member->GetGUID()] = iter->second;
    member->SetFormation(this);
}
Example #4
0
void CreatureGroup::MemberAttackStart(Creature *member, Unit *target)
{
    if (!member || !target)
        return;

    const CreatureGroupInfoType::iterator fInfo = CreatureGroupMap.find(member->GetDBTableGUIDLow());
    if (fInfo == CreatureGroupMap.end() || !fInfo->second)
        return;

    uint8 groupAI = fInfo->second->groupAI;
    if (!groupAI)
        return;

    if (groupAI == 1 && member != m_leader)
        return;

    for (CreatureGroupMemberType::iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
    {
        sLog.outDebug("GROUP ATTACK: group instance id %u calls member instid %u", m_leader ? m_leader->GetInstanceId() : 0, member->GetInstanceId());
        //sLog.outDebug("AI:%u:Group member found: %u, attacked by %s.", groupAI, itr->second->GetGUIDLow(), member->getVictim()->GetName());

        //Skip one check
        if (itr->first == member->GetGUID())
            continue;

        if (Creature *mem = member->GetMap()->GetCreature(itr->first))
        {
            if (!mem->isAlive())
                continue;

            if (mem->getVictim())
                continue;

            if (mem->canAttack(target))
                mem->AI()->AttackStart(target);
        }
    }

    m_Respawned = false;
    m_Evaded = false;
}