Пример #1
0
bool ElunaUtil::WorldObjectInRangeCheck::operator()(WorldObject* u)
{
    if (i_typeMask && !u->isType(TypeMask(i_typeMask)))
        return false;
    if (i_entry && u->GetEntry() != i_entry)
        return false;
    if (i_obj->GET_GUID() == u->GET_GUID())
        return false;
    if (!i_obj->IsWithinDistInMap(u, i_range))
        return false;
    if (Unit* unit = u->ToUnit())
    {
#ifdef CMANGOS
        if (!unit->isAlive())
            return false;
#else
        if (!unit->IsAlive())
            return false;
#endif
        if (i_hostile)
        {
            if (const Unit* obj = i_obj->ToUnit())
            {
                if ((i_hostile == 1) != obj->IsHostileTo(unit))
                    return false;
            }
        }
    }
    if (i_nearest)
        i_range = i_obj->GetDistance(u);
    return true;
}
Пример #2
0
bool ElunaUtil::WorldObjectInRangeCheck::operator()(WorldObject* u)
{
    if (i_typeMask && !u->isType(TypeMask(i_typeMask)))
        return false;
    if (i_entry && u->GetEntry() != i_entry)
        return false;
    if (i_obj->GET_GUID() == u->GET_GUID())
        return false;
    if (!i_obj->IsWithinDistInMap(u, i_range))
        return false;
    Unit const* target = u->ToUnit();
    if (!target)
        if (GameObject const* go = u->ToGameObject())
            target = go->GetOwner();
    if (target)
    {
#ifdef CMANGOS
        if (i_dead && (i_dead == 1) != target->isAlive())
            return false;
#else
        if (i_dead && (i_dead == 1) != target->IsAlive())
            return false;
#endif
        if (i_hostile)
        {
            if (!i_obj_unit)
            {
                if (i_obj_fact)
                {
#ifdef TRINITY
                    if ((i_obj_fact->IsHostileTo(*target->GetFactionTemplateEntry())) != (i_hostile == 1))
                        return false;
#else
                    if ((i_obj_fact->IsHostileTo(*target->getFactionTemplateEntry())) != (i_hostile == 1))
                        return false;
#endif
                }
                else if (i_hostile == 1)
                    return false;
            }
            else if ((i_hostile == 1) != i_obj_unit->IsHostileTo(target))
                return false;
        }
    }
    if (i_nearest)
        i_range = i_obj->GetDistance(u);
    return true;
}
Пример #3
0
void Camera::SetView(WorldObject* obj, bool update_far_sight_field /*= true*/)
{
    MANGOS_ASSERT(obj);

    if (obj->GetObjectGuid() == m_sourceGuid)
        return;

    WorldObject* m_source = IsInitialized() ? GetBody() : NULL;

    if (IsInitialized() && !m_owner.IsInMap(obj))
    {
        sLog.outError("Camera::SetView, viewpoint is not in map with camera's owner");
        Reset();
        return;
    }

    if (!obj->isType(TypeMask(TYPEMASK_DYNAMICOBJECT | TYPEMASK_UNIT)))
    {
        sLog.outError("Camera::SetView, viewpoint type is not available for client");
        Reset();
        return;
    }

    // detach and deregister from active objects if there are no more reasons to be active
    if (m_source)
    {
        m_source->GetViewPoint().Detach(GetOwner()->GetObjectGuid());
        if (!m_source->isActiveObject() && m_source->GetMap())
            m_source->GetMap()->RemoveFromActive(m_source);
    }

    DEBUG_FILTER_LOG(LOG_FILTER_VISIBILITY_CHANGES, "Camera::SetView %s changed camera base from %s to %s",
        GetOwner()->GetObjectGuid().GetString().c_str(),
        IsInitialized() ? m_sourceGuid.GetString().c_str() : "<none>",
        obj->GetObjectGuid().GetString().c_str());

    m_sourceGuid = obj->GetObjectGuid();

    if (!obj->isActiveObject() && obj->GetMap())
        obj->GetMap()->AddToActive(obj);

    obj->GetViewPoint().Attach(GetOwner()->GetObjectGuid());

    if (update_far_sight_field)
        m_owner.SetGuidValue(PLAYER_FARSIGHT, (m_sourceGuid == m_owner.GetObjectGuid() ? ObjectGuid() : m_sourceGuid));

    UpdateForCurrentViewPoint();
}
Пример #4
0
void Camera::SetView(WorldObject* obj, bool update_far_sight_field /*= true*/)
{
    MANGOS_ASSERT(obj);

    if (m_source == obj)
        return;

    if (!m_owner.IsInMap(obj))
    {
        sLog.outError("Camera::SetView, viewpoint is not in map with camera's owner");
        return;
    }

    if (!obj->isType(TypeMask(TYPEMASK_DYNAMICOBJECT | TYPEMASK_UNIT)))
    {
        sLog.outError("Camera::SetView, viewpoint type is not available for client");
        return;
    }

    // detach and deregister from active objects if there are no more reasons to be active
    m_source->GetViewPoint().Detach(this);
    if (!m_source->isActiveObject())
        m_source->GetMap()->RemoveFromActive(m_source);

    m_source = obj;

    if (!m_source->isActiveObject())
        m_source->GetMap()->AddToActive(m_source);

    m_source->GetViewPoint().Attach(this);

    if (update_far_sight_field)
        m_owner.SetGuidValue(PLAYER_FARSIGHT, (m_source == &m_owner ? ObjectGuid() : m_source->GetObjectGuid()));

    UpdateForCurrentViewPoint();
    m_owner.SendForcedObjectUpdate();
}