当前位置: 首页>>代码示例>>C++>>正文


C++ ObjectDistanceOrder函数代码示例

本文整理汇总了C++中ObjectDistanceOrder函数的典型用法代码示例。如果您正苦于以下问题:C++ ObjectDistanceOrder函数的具体用法?C++ ObjectDistanceOrder怎么用?C++ ObjectDistanceOrder使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ObjectDistanceOrder函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DoFindNewEgg

    // Function to search for new rookery egg in range
    void DoFindNewEgg()
    {
        GameObjectList lEggsInRange;
        GetGameObjectListWithEntryInGrid(lEggsInRange, m_creature, GO_ROOKERY_EGG, 20.0f);

        if (lEggsInRange.empty())   // No GO found
            return;

        lEggsInRange.sort(ObjectDistanceOrder(m_creature));
        GameObject* pNearestEgg = nullptr;

        // Always need to find new ones
        for (GameObjectList::const_iterator itr = lEggsInRange.begin(); itr != lEggsInRange.end(); ++itr)
        {
            if (!((*itr)->HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE)))
            {
                pNearestEgg = *itr;
                break;
            }
        }

        if (!pNearestEgg)
            return;

        float fX, fY, fZ;
        pNearestEgg->GetContactPoint(m_creature, fX, fY, fZ, 1.0f);
        m_creature->SetWalk(false);
        m_creature->GetMotionMaster()->MovePoint(1, fX, fY, fZ);
        m_bIsMovementActive = true;
    }
开发者ID:MantisLord,项目名称:mangos-tbc,代码行数:31,代码来源:instance_blackrock_spire.cpp

示例2: SummonAdds

    void SummonAdds(bool bRightSide, uint32 uiSummonEntry)
    {
        std::list<Creature*> lSummonList;
        m_pInstance->GetGothSummonPointCreatures(lSummonList, bRightSide);

        if (lSummonList.empty())
            return;

        uint8 uiCount = 2;

        switch(uiSummonEntry)
        {
            case NPC_UNREL_TRAINEE:
                lSummonList.sort(ObjectDistanceOrder(m_creature));
                break;
            case NPC_UNREL_DEATH_KNIGHT:
            case NPC_UNREL_RIDER:
                uiCount = 1;
                lSummonList.sort(ObjectDistanceOrderReversed(m_creature));
                break;
        }

        for(std::list<Creature*>::iterator itr = lSummonList.begin(); itr != lSummonList.end(); ++itr)
        {
            if (uiCount == 0)
                break;

            m_creature->SummonCreature(uiSummonEntry, (*itr)->GetPositionX(), (*itr)->GetPositionY(), (*itr)->GetPositionZ(), (*itr)->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
            --uiCount;
        }
    }
开发者ID:cbcs,项目名称:ChgSD2,代码行数:31,代码来源:boss_gothik.cpp

示例3: DoFindNewTubber

    // Function to search for new tubber in range
    void DoFindNewTubber()
    {
        std::list<GameObject*> lTubbersInRange;
        GetGameObjectListWithEntryInGrid(lTubbersInRange, m_creature, GO_BLUELEAF_TUBBER, 40.0f);

        if (lTubbersInRange.empty())
            return;

        lTubbersInRange.sort(ObjectDistanceOrder(m_creature));
        GameObject* pNearestTubber = nullptr;

        // Always need to find new ones
        for (std::list<GameObject*>::const_iterator itr = lTubbersInRange.begin(); itr != lTubbersInRange.end(); ++itr)
        {
            if (!(*itr)->isSpawned() && (*itr)->HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_INTERACT_COND) && (*itr)->IsWithinLOSInMap(m_creature))
            {
                pNearestTubber = *itr;
                break;
            }
        }

        if (!pNearestTubber)
            return;
        m_targetTubberGuid = pNearestTubber->GetObjectGuid();

        float fX, fY, fZ;
        pNearestTubber->GetContactPoint(m_creature, fX, fY, fZ);
        m_creature->GetMotionMaster()->MovePoint(1, fX, fY, fZ);
        m_bIsMovementActive = true;
    }
开发者ID:natedahl32,项目名称:portalclassic,代码行数:31,代码来源:razorfen_kraul.cpp

示例4: SelectNearbyShallowGrave

        uint64 SelectNearbyShallowGrave()
        {
            Unit *searcher = instance->GetUnit(ObjectGuid(m_uiGraveyardSearcherGuid));
            // Get the list of usable graves (not used already by players)
            std::list<GameObject*> lGravesInRange;

            for (GuidList::const_iterator itr = m_lShallowGravesGuidList.begin(); itr != m_lShallowGravesGuidList.end(); ++itr)
            {
                GameObject* pGo = searcher->GetMap()->GetGameObject(*itr);
                // Go spawned and no looting in process
                if (pGo && pGo->isSpawned() && pGo->getLootState() == GO_READY)
                {
                    lGravesInRange.push_back(pGo);
                }
            }

            if (lGravesInRange.empty())
            {
                return 0;
            }

            // Sort the graves
            lGravesInRange.sort(ObjectDistanceOrder(searcher));

            return (*lGravesInRange.begin())->GetObjectGuid().GetRawValue();
        }
开发者ID:Chuck5ta,项目名称:ScriptDev3,代码行数:26,代码来源:instance_zulfarrak.cpp

示例5: UpdateAI

    void UpdateAI(const uint32 uiDiff) override
    {
        if (m_uiStartTimer)
        {
            if (m_uiStartTimer <= uiDiff)
            {
                // get all the ogres in range
                std::list<Creature*> lOgreList;
                for (uint8 i = 0; i < countof(aOgreEntries); ++i)
                    GetCreatureListWithEntryInGrid(lOgreList, m_creature,  aOgreEntries[i], 30.0f);

                if (lOgreList.empty())
                {
                    m_uiStartTimer = 5000;
                    return;
                }

                // sort by distance and get only the closest
                lOgreList.sort(ObjectDistanceOrder(m_creature));

                std::list<Creature*>::const_iterator ogreItr = lOgreList.begin();
                Creature* pOgre = NULL;

                do
                {
                    if ((*ogreItr)->isAlive() && !(*ogreItr)->HasAura(SPELL_INTOXICATION))
                        pOgre = *ogreItr;

                    ++ogreItr;
                }
                while (!pOgre && ogreItr != lOgreList.end());

                if (!pOgre)
                {
                    m_uiStartTimer = 5000;
                    return;
                }

                // Move ogre to the point
                float fX, fY, fZ;
                pOgre->GetMotionMaster()->MoveIdle();
                pOgre->SetWalk(false, true);
                m_creature->GetContactPoint(pOgre, fX, fY, fZ);
                pOgre->GetMotionMaster()->MovePoint(0, fX, fY, fZ);

                switch (urand(0, 2))
                {
                    case 0: DoScriptText(SAY_BREW_1, pOgre); break;
                    case 1: DoScriptText(SAY_BREW_2, pOgre); break;
                    case 2: DoScriptText(SAY_BREW_3, pOgre); break;
                }

                m_selectedOgreGuid = pOgre->GetObjectGuid();
                m_uiStartTimer = 0;
                m_bHasValidOgre = true;
            }
            else
                m_uiStartTimer -= uiDiff;
        }
    }
开发者ID:BThallid,项目名称:mangos,代码行数:60,代码来源:blades_edge_mountains.cpp

示例6: CastFixate

    void CastFixate()
    {
        ThreatList const& tList = m_creature->getThreatManager().getThreatList();
        if (tList.empty())
            return;                                         // No point continuing if empty threatlist.

        std::list<Unit*> targets;

        for (ThreatList::const_iterator itr = tList.begin();itr != tList.end(); ++itr)
        {
            Unit* pUnit = Unit::GetUnit((*m_creature), (*itr)->getUnitGuid());
                                                            // Only alive players
            if (pUnit && pUnit->isAlive() && (pUnit->GetTypeId() == TYPEID_PLAYER))
                targets.push_back(pUnit);
        }

        if (targets.empty())
            return;                                         // No targets added for some reason. No point continuing.

        targets.sort(ObjectDistanceOrder(m_creature));      // Sort players by distance.
        targets.resize(1);                                  // Only need closest target.
        Unit* target = targets.front();                     // Get the first target.

        // Add threat equivalent to threat on victim.
        m_creature->AddThreat(target, m_creature->getThreatManager().getThreat(m_creature->getVictim()));
        DoCastSpellIfCan(target, SPELL_FIXATE);
    }
开发者ID:wowfrank,项目名称:diamondcore,代码行数:27,代码来源:boss_reliquary_of_souls.cpp

示例7: UpdateAI

    void UpdateAI(const uint32 uiDiff) override
    {
        if (m_uiStartTimer)
        {
            if (m_uiStartTimer <= uiDiff)
            {
                // get all the bats list in range; note: this will compare the 2D distance
                std::list<Creature*> lBatsList;
                GetCreatureListWithEntryInGrid(lBatsList, m_creature, NPC_DARKCLAW_BAT, 10.0f);

                if (lBatsList.empty())
                {
                    m_uiStartTimer = 5000;
                    return;
                }

                // sort by distance and get only the closest
                lBatsList.sort(ObjectDistanceOrder(m_creature));

                std::list<Creature*>::const_iterator batItr = lBatsList.begin();
                Creature* pBat = NULL;

                do
                {
                    // check for alive and out of combat only
                    if ((*batItr)->isAlive() && !(*batItr)->getVictim())
                        pBat = *batItr;

                    ++batItr;
                }
                while (!pBat && batItr != lBatsList.end());

                if (!pBat)
                {
                    m_uiStartTimer = 5000;
                    return;
                }

                // Move bat to the point
                float fX, fY, fZ;
                pBat->SetWalk(false);
                pBat->GetMotionMaster()->Clear();
                m_creature->GetContactPoint(pBat, fX, fY, fZ);
                pBat->GetMotionMaster()->MovePoint(0, fX, fY, fZ);

                m_selectedBatGuid = pBat->GetObjectGuid();
                m_uiStartTimer = 0;
                m_bHasValidBat = true;
            }
            else
                m_uiStartTimer -= uiDiff;
        }
    }
开发者ID:AwkwardDev,项目名称:mangos-d3,代码行数:53,代码来源:howling_fjord.cpp

示例8: PrepareSummonPlaces

    void PrepareSummonPlaces()
    {
        std::list<Creature*> lSummonList;
        m_pInstance->GetGothSummonPointCreatures(lSummonList, true);

        if (lSummonList.empty())
        {
            return;
        }

        // Trainees and Rider
        uint8 index = 0;
        uint8 uiTraineeCount = 3;
        lSummonList.sort(ObjectDistanceOrder(m_creature));
        for (std::list<Creature*>::iterator itr = lSummonList.begin(); itr != lSummonList.end(); ++itr)
        {
            if (*itr)
            {
                if (uiTraineeCount == 0)
                {
                    break;
                }
                if (index == 1)
                {
                    m_lRiderSummonPosGuids.push_back((*itr)->GetObjectGuid());
                }
                else
                {
                    m_lTraineeSummonPosGuids.push_back((*itr)->GetObjectGuid());
                    --uiTraineeCount;
                }
                index++;
            }
        }

        // DeathKnights
        uint8 uiDeathKnightCount = 2;
        lSummonList.sort(ObjectDistanceOrderReversed(m_creature));
        for (std::list<Creature*>::iterator itr = lSummonList.begin(); itr != lSummonList.end(); ++itr)
        {
            if (*itr)
            {
                if (uiDeathKnightCount == 0)
                {
                    break;
                }
                m_lDeathKnightSummonPosGuids.push_back((*itr)->GetObjectGuid());
                --uiDeathKnightCount;
            }
        }
    }
开发者ID:Hammerdrinker,项目名称:scripts,代码行数:51,代码来源:boss_gothik.cpp

示例9: GetClosestLowerBunny

    // function to return the closest ground Bunny
    Creature* GetClosestLowerBunny(Creature* pSource)
    {
        if (m_lLowerBunniesGuids.empty())
            return NULL;

        std::list<Creature*> lBunnies;
        for (GuidList::const_iterator itr = m_lLowerBunniesGuids.begin(); itr != m_lLowerBunniesGuids.end(); ++itr)
        {
            if (Creature* pBunny = m_creature->GetMap()->GetCreature(*itr))
                lBunnies.push_back(pBunny);
        }

        lBunnies.sort(ObjectDistanceOrder(pSource));
        return lBunnies.front();
    }
开发者ID:jviljoen82,项目名称:ScriptDev3,代码行数:16,代码来源:boss_thorim.cpp

示例10: SetMyForge

    void SetMyForge()
    {
        std::list<GameObject *> lGOList;
        uint32 uiGOBellow = 0;
        uint32 uiGOFire = 0;

        for (uint8 i = 0; i < MAX_FORGE; ++i)
        {
            switch(i)
            {
                case 0: uiGOBellow = GO_BELLOW_1; break;
                case 1: uiGOBellow = GO_BELLOW_2; break;
                case 2: uiGOBellow = GO_BELLOW_3; break;
            }

            if (GameObject* pGOTemp = m_pInstance->GetSingleGameObjectFromStorage(uiGOBellow))
                lGOList.push_back(pGOTemp);
        }

        if (!lGOList.empty())
        {
            if (lGOList.size() != MAX_FORGE)
                error_log("SSC: mob_dragonflayer_forge_master expected %u in lGOList, but does not match.", MAX_FORGE);

            lGOList.sort(ObjectDistanceOrder(m_creature));

            if (lGOList.front()->getLootState() == GO_READY)
                lGOList.front()->UseDoorOrButton(DAY);
            else if (lGOList.front()->getLootState() == GO_ACTIVATED)
                lGOList.front()->ResetDoorOrButton();

            switch(lGOList.front()->GetEntry())
            {
                case GO_BELLOW_1: uiGOFire = GO_FORGEFIRE_1; m_uiForgeEncounterId = TYPE_BELLOW_1; break;
                case GO_BELLOW_2: uiGOFire = GO_FORGEFIRE_2; m_uiForgeEncounterId = TYPE_BELLOW_2; break;
                case GO_BELLOW_3: uiGOFire = GO_FORGEFIRE_3; m_uiForgeEncounterId = TYPE_BELLOW_3; break;
            }

            if (GameObject* pGOTemp = m_pInstance->GetSingleGameObjectFromStorage(uiGOFire))
            {
                if (pGOTemp->getLootState() == GO_READY)
                    pGOTemp->UseDoorOrButton(DAY);
                else if (pGOTemp->getLootState() == GO_ACTIVATED)
                    pGOTemp->ResetDoorOrButton();
            }
        }
    }
开发者ID:Bootz,项目名称:StrawberryCore,代码行数:47,代码来源:utgarde_keep.cpp

示例11: SelectNextEgg

 GameObject* SelectNextEgg()
 {
     std::list<GameObject*> lEggs;
     GetGameObjectListWithEntryInGrid(lEggs, me, GO_EGG, DEFAULT_VISIBILITY_INSTANCE);
     if (lEggs.empty())
         debug_log("SD2: boss_marli, no Eggs with the entry %i were found", GO_EGG);
     else
     {
         lEggs.sort(ObjectDistanceOrder(me));
         for(std::list<GameObject*>::iterator iter = lEggs.begin(); iter != lEggs.end(); ++iter)
         {
             if ((*iter)->GetGoState() == (GO_STATE_READY))
                 return (*iter);
         }
     }
     return NULL;
 }
开发者ID:AwkwardDev,项目名称:MangosFX,代码行数:17,代码来源:boss_marli.cpp

示例12: JustSummoned

    void JustSummoned(Creature* pSummoned) override
    {
        if (pSummoned->GetEntry() == NPC_TECAHUNA)
        {
            m_tecahunaGuid = pSummoned->GetObjectGuid();

            // sort the mummies based on the distance
            std::list<Creature*> lBunniesInRange;
            GetCreatureListWithEntryInGrid(lBunniesInRange, m_creature, NPC_MUMMY_EFFECT_BUNNY, 50.0f);

            lBunniesInRange.sort(ObjectDistanceOrder(pSummoned));

            for (std::list<Creature*>::const_iterator itr = lBunniesInRange.begin(); itr != lBunniesInRange.end(); ++itr)
                m_lImmolationBunnyGuids.push_back((*itr)->GetObjectGuid());
        }
        else if (pSummoned->GetEntry() == NPC_ANCIENT_DRAKKARI_KING)
            pSummoned->AI()->AttackStart(m_creature);
    }
开发者ID:dvdvideo1234,项目名称:mangos-wotlk,代码行数:18,代码来源:grizzly_hills.cpp

示例13: GetClosestDwarfNotInCombat

Creature* instance_uldaman::GetClosestDwarfNotInCombat(Creature* pSearcher)
{
    std::list<Creature*> lTemp;

    for (GuidList::const_iterator itr = m_lWardens.begin(); itr != m_lWardens.end(); ++itr)
    {
        Creature* pTemp = instance->GetCreature(*itr);

        if (pTemp && pTemp->IsAlive() && !pTemp->getVictim())
            lTemp.push_back(pTemp);
    }

    if (lTemp.empty())
        return NULL;

    lTemp.sort(ObjectDistanceOrder(pSearcher));
    return lTemp.front();
}
开发者ID:Evildead666,项目名称:scripts,代码行数:18,代码来源:instance_uldaman.cpp

示例14: PrepareSummonPlaces

    void PrepareSummonPlaces()
    {
        CreatureList lSummonList;
        m_pInstance->GetGothSummonPointCreatures(lSummonList, true);

        if (lSummonList.empty())
            return;

        // Trainees and Rider
        uint8 index = 0;
        uint8 uiTraineeCount = 3;
        lSummonList.sort(ObjectDistanceOrder(m_creature));
        for (auto& itr : lSummonList)
        {
            if (itr)
            {
                if (uiTraineeCount == 0)
                    break;
                if (index == 1)
                    m_lRiderSummonPosGuids.push_back(itr->GetObjectGuid());
                else
                {
                    m_lTraineeSummonPosGuids.push_back(itr->GetObjectGuid());
                    --uiTraineeCount;
                }
                index++;
            }
        }

        // DeathKnights
        uint8 uiDeathKnightCount = 2;
        lSummonList.sort(ObjectDistanceOrderReversed(m_creature));
        for (auto& itr : lSummonList)
        {
            if (itr)
            {
                if (uiDeathKnightCount == 0)
                    break;
                m_lDeathKnightSummonPosGuids.push_back(itr->GetObjectGuid());
                --uiDeathKnightCount;
            }
        }
    }
开发者ID:Ghaster,项目名称:mangos-classic,代码行数:43,代码来源:boss_gothik.cpp

示例15: DoFindNewCrystal

    // Function to search for new tubber in range
    void DoFindNewCrystal(Player* pMaster)
    {
        GameObjectList lCrystalsInRange;
        for (unsigned int i : aGOList)
        {
            GetGameObjectListWithEntryInGrid(lCrystalsInRange, m_creature, i, 40.0f);
            // If a crystal was found in range, stop the search here, else try with another GO
            if (!lCrystalsInRange.empty())
                break;
        }

        if (lCrystalsInRange.empty())   // Definely no GO found
        {
            m_creature->PlayDirectSound(SOUND_GROWL);
            return;
        }
        lCrystalsInRange.sort(ObjectDistanceOrder(m_creature));
        GameObject* pNearestCrystal = nullptr;

        // Always need to find new ones
        for (GameObjectList::const_iterator itr = lCrystalsInRange.begin(); itr != lCrystalsInRange.end(); ++itr)
        {
            if ((*itr)->HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_INTERACT_COND))
            {
                pNearestCrystal = *itr;
                break;
            }
        }

        if (!pNearestCrystal)
        {
            m_creature->PlayDirectSound(SOUND_GROWL);
            return;
        }
        float fX, fY, fZ;
        pNearestCrystal->GetContactPoint(m_creature, fX, fY, fZ, 3.0f);
        m_creature->SetWalk(false);
        m_creature->GetMotionMaster()->MovePoint(1, fX, fY, fZ);
        m_bIsMovementActive = true;
    }
开发者ID:Phatcat,项目名称:mangos-wotlk,代码行数:41,代码来源:azshara.cpp


注:本文中的ObjectDistanceOrder函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。