本文整理汇总了C++中ObjectGuid::IsGameObject方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectGuid::IsGameObject方法的具体用法?C++ ObjectGuid::IsGameObject怎么用?C++ ObjectGuid::IsGameObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectGuid
的用法示例。
在下文中一共展示了ObjectGuid::IsGameObject方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleAutostoreLootItemOpcode
void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket& recvData)
{
TC_LOG_DEBUG("network", "WORLD: CMSG_AUTOSTORE_LOOT_ITEM");
Player* player = GetPlayer();
ObjectGuid lguid = player->GetLootGUID();
Loot* loot = NULL;
uint8 lootSlot = 0;
recvData >> lootSlot;
if (lguid.IsGameObject())
{
GameObject* go = player->GetMap()->GetGameObject(lguid);
// not check distance for GO in case owned GO (fishing bobber case, for example) or Fishing hole GO
if (!go || ((go->GetOwnerGUID() != _player->GetGUID() && go->GetGoType() != GAMEOBJECT_TYPE_FISHINGHOLE) && !go->IsWithinDistInMap(_player, INTERACTION_DISTANCE)))
{
player->SendLootRelease(lguid);
return;
}
loot = &go->loot;
}
else if (lguid.IsItem())
{
Item* pItem = player->GetItemByGuid(lguid);
if (!pItem)
{
player->SendLootRelease(lguid);
return;
}
loot = &pItem->loot;
}
else if (lguid.IsCorpse())
{
Corpse* bones = ObjectAccessor::GetCorpse(*player, lguid);
if (!bones)
{
player->SendLootRelease(lguid);
return;
}
loot = &bones->loot;
}
else
{
Creature* creature = GetPlayer()->GetMap()->GetCreature(lguid);
bool lootAllowed = creature && creature->IsAlive() == (player->getClass() == CLASS_ROGUE && creature->loot.loot_type == LOOT_PICKPOCKETING);
if (!lootAllowed || !creature->IsWithinDistInMap(_player, INTERACTION_DISTANCE))
{
player->SendLootError(lguid, lootAllowed ? LOOT_ERROR_TOO_FAR : LOOT_ERROR_DIDNT_KILL);
return;
}
loot = &creature->loot;
}
player->StoreLootItem(lootSlot, loot);
// If player is removing the last LootItem, delete the empty container.
if (loot->isLooted() && lguid.IsItem())
player->GetSession()->DoLootRelease(lguid);
}
示例2: 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.IsCreatureOrVehicle())
{
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)
{
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;
}
示例3: DoLootRelease
void WorldSession::DoLootRelease(ObjectGuid lguid)
{
Player *player = GetPlayer();
Loot *loot;
player->SetLootGUID(ObjectGuid::Empty);
player->SendLootRelease(lguid);
player->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_LOOTING);
if (!player->IsInWorld())
return;
if (lguid.IsGameObject())
{
GameObject* go = GetPlayer()->GetMap()->GetGameObject(lguid);
// not check distance for GO in case owned GO (fishing bobber case, for example) or Fishing hole GO
if (!go || ((go->GetOwnerGUID() != _player->GetGUID() && go->GetGoType() != GAMEOBJECT_TYPE_FISHINGHOLE) && !go->IsWithinDistInMap(_player, INTERACTION_DISTANCE)))
return;
loot = &go->loot;
if (go->GetGoType() == GAMEOBJECT_TYPE_DOOR)
{
// locked doors are opened with spelleffect openlock, prevent remove its as looted
go->UseDoorOrButton();
}
else if (loot->isLooted() || go->GetGoType() == GAMEOBJECT_TYPE_FISHINGNODE)
{
if (go->GetGoType() == GAMEOBJECT_TYPE_FISHINGHOLE)
{ // The fishing hole used once more
go->AddUse(); // if the max usage is reached, will be despawned in next tick
if (go->GetUseCount() >= go->GetGOValue()->FishingHole.MaxOpens)
go->SetLootState(GO_JUST_DEACTIVATED);
else
go->SetLootState(GO_READY);
}
else
go->SetLootState(GO_JUST_DEACTIVATED);
loot->clear();
}
else
{
// not fully looted object
go->SetLootState(GO_ACTIVATED, player);
// if the round robin player release, reset it.
if (player->GetGUID() == loot->roundRobinPlayer)
loot->roundRobinPlayer.Clear();
}
}
else if (lguid.IsCorpse()) // ONLY remove insignia at BG
{
Corpse* corpse = ObjectAccessor::GetCorpse(*player, lguid);
if (!corpse || !corpse->IsWithinDistInMap(_player, INTERACTION_DISTANCE))
return;
loot = &corpse->loot;
if (loot->isLooted())
{
loot->clear();
corpse->RemoveFlag(CORPSE_FIELD_DYNAMIC_FLAGS, CORPSE_DYNFLAG_LOOTABLE);
}
}
else if (lguid.IsItem())
{
Item* pItem = player->GetItemByGuid(lguid);
if (!pItem)
return;
ItemTemplate const* proto = pItem->GetTemplate();
// destroy only 5 items from stack in case prospecting and milling
if (proto->Flags & (ITEM_PROTO_FLAG_PROSPECTABLE | ITEM_PROTO_FLAG_MILLABLE))
{
pItem->m_lootGenerated = false;
pItem->loot.clear();
uint32 count = pItem->GetCount();
// >=5 checked in spell code, but will work for cheating cases also with removing from another stacks.
if (count > 5)
count = 5;
player->DestroyItemCount(pItem, count, true);
}
else
{
// Only delete item if no loot or money (unlooted loot is saved to db) or if it isn't an openable item
if (pItem->loot.isLooted() || !(proto->Flags & ITEM_PROTO_FLAG_OPENABLE))
player->DestroyItem(pItem->GetBagSlot(), pItem->GetSlot(), true);
}
return; // item can be looted only single player
}
else
{
Creature* creature = GetPlayer()->GetMap()->GetCreature(lguid);
//.........这里部分代码省略.........
示例4: HandleQuestgiverStatusMultipleQuery
void WorldSession::HandleQuestgiverStatusMultipleQuery(WorldPacket& /*recvPacket*/)
{
DEBUG_LOG("WORLD: Received CMSG_QUESTGIVER_STATUS_MULTIPLE_QUERY");
uint32 count = 0;
WorldPacket data(SMSG_QUESTGIVER_STATUS_MULTIPLE, 4);
data << uint32(count); // placeholder
for(GuidSet::const_iterator itr = _player->GetClientGuids().begin(); itr != _player->GetClientGuids().end(); ++itr)
{
uint8 dialogStatus = DIALOG_STATUS_NONE;
ObjectGuid guid = *itr;
if (guid.IsEmpty())
continue;
if (guid.IsAnyTypeCreature())
{
// need also pet quests case support
Creature* questgiver = GetPlayer()->GetMap() ? GetPlayer()->GetMap()->GetAnyTypeCreature(guid) : NULL;
if (!questgiver || questgiver->IsHostileTo(_player))
continue;
if (!questgiver->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER))
continue;
dialogStatus = sScriptMgr.GetDialogStatus(_player, questgiver);
if (dialogStatus == DIALOG_STATUS_UNDEFINED)
dialogStatus = getDialogStatus(_player, questgiver, DIALOG_STATUS_NONE);
data << guid;
data << uint8(dialogStatus);
++count;
}
else if (guid.IsGameObject())
{
GameObject* questgiver = GetPlayer()->GetMap() ? GetPlayer()->GetMap()->GetGameObject(guid) : NULL;
if (!questgiver)
continue;
if (questgiver->GetGoType() != GAMEOBJECT_TYPE_QUESTGIVER)
continue;
dialogStatus = sScriptMgr.GetDialogStatus(_player, questgiver);
if (dialogStatus == DIALOG_STATUS_UNDEFINED)
dialogStatus = getDialogStatus(_player, questgiver, DIALOG_STATUS_NONE);
data << guid;
data << uint8(dialogStatus);
++count;
}
}
data.put<uint32>(0, count); // write real count
SendPacket(&data);
}
示例5: EffectScriptEffect
bool EffectScriptEffect(Unit* pCaster, uint32 uiSpellId, SpellEffectIndex uiEffIndex, Creature* pCreatureTarget, ObjectGuid originalCasterGuid) override
{
if ((uiSpellId == SPELL_INTROSPECTION_BLUE || uiSpellId == SPELL_INTROSPECTION_GREEN || uiSpellId == SPELL_INTROSPECTION_RED ||
uiSpellId == SPELL_INTROSPECTION_YELLOW) && uiEffIndex == EFFECT_INDEX_1)
{
if (pCreatureTarget->GetEntry() == NPC_SIMON_GAME_BUNNY && pCaster->GetTypeId() == TYPEID_PLAYER && originalCasterGuid.IsGameObject())
{
pCreatureTarget->AI()->SendAIEvent(AI_EVENT_CUSTOM_C, pCaster, pCreatureTarget, uiSpellId);
}
return true;
}
return false;
}
示例6: 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 = sObjectAccessor.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;
}
示例7: HandleMasterIncomingPacket
//.........这里部分代码省略.........
// 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())
{
if (bot->CanUseItem(pProto) == EQUIP_ERR_OK && bot->GetPlayerbotAI()->IsItemUseful(lootItem.itemid))
choice = 1; // Need
else if (bot->HasSkill(SKILL_ENCHANTING))
choice = 3; // Disenchant