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


C++ ObjectGuid::IsCreature方法代码示例

本文整理汇总了C++中ObjectGuid::IsCreature方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectGuid::IsCreature方法的具体用法?C++ ObjectGuid::IsCreature怎么用?C++ ObjectGuid::IsCreature使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ObjectGuid的用法示例。


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

示例1: CanInteractWithQuestGiver

bool WorldSession::CanInteractWithQuestGiver(ObjectGuid guid, char const* descr) const
{
    if (guid.IsCreature())
    {
        Creature* pCreature = _player->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_QUESTGIVER);
        if (!pCreature)
        {
            DEBUG_LOG("WORLD: %s - %s cannot interact with %s.", descr, _player->GetGuidStr().c_str(), guid.GetString().c_str());
            return false;
        }
    }
    else if (guid.IsGameObject())
    {
        GameObject* pGo = _player->GetGameObjectIfCanInteractWith(guid, GAMEOBJECT_TYPE_QUESTGIVER);
        if (!pGo)
        {
            DEBUG_LOG("WORLD: %s - %s cannot interact with %s.", descr, _player->GetGuidStr().c_str(), guid.GetString().c_str());
            return false;
        }
    }
    else if (!_player->isAlive())
    {
        DEBUG_LOG("WORLD: %s - %s is dead, requested guid was %s", descr, _player->GetGuidStr().c_str(), guid.GetString().c_str());
        return false;
    }

    return true;
}
开发者ID:MantisLord,项目名称:mangos-tbc,代码行数:28,代码来源:QuestHandler.cpp

示例2: HandleNpcBotResetCommand

 static bool HandleNpcBotResetCommand(ChatHandler* handler, const char* /*args*/)
 {
     Player* owner = handler->GetSession()->GetPlayer();
     Player* master = NULL;
     bool all = false;
     ObjectGuid guid = owner->GetTarget();
     if (!guid)
     {
         handler->PSendSysMessage(".npcbot reset");
         handler->PSendSysMessage("Reset selected npcbot, or all npcbots if used on self");
         handler->SetSentErrorMessage(true);
         return false;
     }
     if (guid.IsPlayer())
     {
         master = owner;
         all = true;
     }
     else if (guid.IsCreature())
     {
         if (Creature* cre = ObjectAccessor::GetCreature(*owner, guid))
             master = cre->GetBotOwner();
     }
     if (master && master->GetGUID() == owner->GetGUID())
     {
         if (!master->HaveBot())
         {
             handler->PSendSysMessage("Npcbots are not found!");
             handler->SetSentErrorMessage(true);
             return false;
         }
         if (all)
             master->RemoveAllBots(BOT_REMOVE_DISMISS);
         else
             master->GetBotMgr()->RemoveBot(guid, BOT_REMOVE_DISMISS);
         handler->SetSentErrorMessage(true);
         return true;
     }
     handler->PSendSysMessage(".npcbot reset");
     handler->PSendSysMessage("Reset selected npcbot. Cannot be used in combat");
     handler->SetSentErrorMessage(true);
     return false;
 }
开发者ID:fannyfinal,项目名称:LordPsyanBots,代码行数:43,代码来源:botcommands.cpp

示例3: HandleLootMasterGiveOpcode

void WorldSession::HandleLootMasterGiveOpcode( WorldPacket & recv_data )
{
    uint8 slotid;
    ObjectGuid lootguid;
    ObjectGuid target_playerguid;

    recv_data >> lootguid >> slotid >> target_playerguid;

    if (!_player->GetGroup() || _player->GetGroup()->GetLooterGuid() != _player->GetObjectGuid())
    {
        _player->SendLootRelease(GetPlayer()->GetLootGUID());
        return;
    }

    Player *target = ObjectAccessor::FindPlayer(target_playerguid);
    if (!target)
        return;

    DEBUG_LOG("WorldSession::HandleLootMasterGiveOpcode (CMSG_LOOT_MASTER_GIVE, 0x02A3) Target = %s [%s].", target_playerguid.GetString().c_str(), target->GetName());

    if (_player->GetLootGUID() != lootguid.GetRawValue())
        return;

    Loot *pLoot = NULL;

    if(lootguid.IsCreature())
    {
        Creature *pCreature = GetPlayer()->GetMap()->GetCreature(lootguid);
        if(!pCreature)
            return;

        pLoot = &pCreature->loot;
    }
    else if(lootguid.IsGameobject())
    {
        GameObject *pGO = GetPlayer()->GetMap()->GetGameObject(lootguid);
        if(!pGO)
            return;

        pLoot = &pGO->loot;
    }
    else
        return;

    if (slotid > pLoot->items.size())
    {
        DEBUG_LOG("AutoLootItem: Player %s might be using a hack! (slot %d, size %lu)",GetPlayer()->GetName(), slotid, (unsigned long)pLoot->items.size());
        return;
    }

    LootItem& item = pLoot->items[slotid];

    ItemPosCountVec dest;
    uint8 msg = target->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, item.itemid, item.count );
    if ( msg != EQUIP_ERR_OK )
    {
        target->SendEquipError( msg, NULL, NULL, item.itemid );

        // send duplicate of error massage to master looter
        _player->SendEquipError( msg, NULL, NULL, item.itemid );
        return;
    }

    // now move item from loot to target inventory
    Item * newitem = target->StoreNewItem( dest, item.itemid, true, item.randomPropertyId );
    target->SendNewItem(newitem, uint32(item.count), false, false, true );
    target->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM, item.itemid, item.count);
    target->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_TYPE, pLoot->loot_type, item.count);
    target->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_EPIC_ITEM, item.itemid, item.count);

    // mark as looted
    item.count=0;
    item.is_looted=true;

    pLoot->NotifyItemRemoved(slotid);
    --pLoot->unlootedCount;
}
开发者ID:Wowka321,项目名称:mangos,代码行数:77,代码来源:LootHandler.cpp

示例4: HandleLootMasterGiveOpcode

void WorldSession::HandleLootMasterGiveOpcode(WorldPacket& recv_data)
{
    uint8 slotid;
    ObjectGuid lootguid;
    ObjectGuid target_playerguid;

    recv_data >> lootguid >> slotid >> target_playerguid;

    if (!_player->GetGroup() || _player->GetGroup()->GetLooterGuid() != _player->GetObjectGuid())
    {
        _player->SendLootRelease(GetPlayer()->GetLootGuid());
        return;
    }

    Player* target = ObjectAccessor::FindPlayer(target_playerguid);
    if (!target)
        { return; }

    DEBUG_LOG("WorldSession::HandleLootMasterGiveOpcode (CMSG_LOOT_MASTER_GIVE, 0x02A3) Target = %s [%s].", target_playerguid.GetString().c_str(), target->GetName());

    if (_player->GetLootGuid() != lootguid)
        { return; }

    Loot* pLoot = NULL;

    if (lootguid.IsCreature())
    {
        Creature* pCreature = GetPlayer()->GetMap()->GetCreature(lootguid);
        if (!pCreature)
            { return; }

        pLoot = &pCreature->loot;
    }
    else if (lootguid.IsGameObject())
    {
        GameObject* pGO = GetPlayer()->GetMap()->GetGameObject(lootguid);
        if (!pGO)
            { return; }

        pLoot = &pGO->loot;
    }
    else
        { return; }

    if (slotid > pLoot->items.size())
    {
        DEBUG_LOG("AutoLootItem: Player %s might be using a hack! (slot %d, size " SIZEFMTD ")", GetPlayer()->GetName(), slotid, pLoot->items.size());
        return;
    }

    LootItem& item = pLoot->items[slotid];

    ItemPosCountVec dest;
    InventoryResult msg = target->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, item.itemid, item.count);
    if (msg != EQUIP_ERR_OK)
    {
        // Assign winner to the item, avoiding other member picks it up.
        item.winner = target->GetObjectGuid();
        target->SendEquipError(msg, NULL, NULL, item.itemid);

        pLoot->NotifyItemRemoved(slotid);

        return;
    }

    // now move item from loot to target inventory
    Item* newitem = target->StoreNewItem(dest, item.itemid, true, item.randomPropertyId);
    target->SendNewItem(newitem, uint32(item.count), false, false, true);

    // Used by Eluna
#ifdef ENABLE_ELUNA
    sEluna->OnLootItem(target, newitem, item.count, lootguid);
#endif /* ENABLE_ELUNA */

    // mark as looted
    item.count = 0;
    item.is_looted = true;

    pLoot->NotifyItemRemoved(slotid);
    --pLoot->unlootedCount;
}
开发者ID:Chuck5ta,项目名称:server-1,代码行数:81,代码来源:LootHandler.cpp

示例5: HandleMasterIncomingPacket


//.........这里部分代码省略.........
            p.rpos(0);    // reset reader
            uint32 quest;
            ObjectGuid npcGUID;
            p >> npcGUID >> quest;

            // DEBUG_LOG ("[PlayerbotMgr]: HandleMasterIncomingPacket - Received CMSG_QUESTGIVER_COMPLETE_QUEST npc = %s, quest = %u", npcGUID.GetString().c_str(), quest);

            WorldObject* pNpc = m_master->GetMap()->GetWorldObject(npcGUID);
            if (!pNpc)
                return;

            // for all master's bots
            for (PlayerBotMap::const_iterator it = GetPlayerBotsBegin(); it != GetPlayerBotsEnd(); ++it)
            {
                Player* const bot = it->second;
                bot->GetPlayerbotAI()->TurnInQuests(pNpc);
            }
            return;
        }

        case CMSG_LOOT_ROLL:
        {
            WorldPacket p(packet);    //WorldPacket packet for CMSG_LOOT_ROLL, (8+4+1)
            ObjectGuid Guid;
            uint32 itemSlot;
            uint8 rollType;
            Loot *loot = NULL;

            p.rpos(0);        //reset packet pointer
            p >> Guid;        //guid of the lootable target
            p >> itemSlot;    //loot index
            p >> rollType;    //need,greed or pass on roll

            if (Guid.IsCreature())
            {
                if (Creature* c = m_master->GetMap()->GetCreature(Guid))
                    loot = &c->loot;
            }
            else if (Guid.IsGameObject())
            {
                if (GameObject* go = m_master->GetMap()->GetGameObject(Guid))
                    loot = &go->loot;
            }

            if (!loot)
                return;

            LootItem& lootItem = loot->items[itemSlot];

            for (PlayerBotMap::const_iterator it = GetPlayerBotsBegin(); it != GetPlayerBotsEnd(); ++it)
            {
                uint32 choice = 0;

                Player* const bot = it->second;
                if (!bot)
                    return;

                Group* group = bot->GetGroup();
                if (!group)
                    return;

                ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(lootItem.itemid);
                if (!pProto)
                    return;

                if (bot->GetPlayerbotAI()->CanStore())
开发者ID:AngelX,项目名称:portal,代码行数:67,代码来源:PlayerbotMgr.cpp


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