本文整理汇总了C++中Item::GetChildItem方法的典型用法代码示例。如果您正苦于以下问题:C++ Item::GetChildItem方法的具体用法?C++ Item::GetChildItem怎么用?C++ Item::GetChildItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Item
的用法示例。
在下文中一共展示了Item::GetChildItem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleArtifactSetAppearance
void WorldSession::HandleArtifactSetAppearance(WorldPackets::Artifact::ArtifactSetAppearance& artifactSetAppearance)
{
if (!_player->GetGameObjectIfCanInteractWith(artifactSetAppearance.ForgeGUID, GAMEOBJECT_TYPE_ARTIFACT_FORGE))
return;
ArtifactAppearanceEntry const* artifactAppearance = sArtifactAppearanceStore.LookupEntry(artifactSetAppearance.ArtifactAppearanceID);
if (!artifactAppearance)
return;
Item* artifact = _player->GetItemByGuid(artifactSetAppearance.ArtifactGUID);
if (!artifact)
return;
ArtifactAppearanceSetEntry const* artifactAppearanceSet = sArtifactAppearanceSetStore.LookupEntry(artifactAppearance->ArtifactAppearanceSetID);
if (!artifactAppearanceSet || artifactAppearanceSet->ArtifactID != artifact->GetTemplate()->GetArtifactID())
return;
if (PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(artifactAppearance->UnlockPlayerConditionID))
if (!sConditionMgr->IsPlayerMeetingCondition(_player, playerCondition))
return;
artifact->SetAppearanceModId(artifactAppearance->ItemAppearanceModifierID);
artifact->SetModifier(ITEM_MODIFIER_ARTIFACT_APPEARANCE_ID, artifactAppearance->ID);
artifact->SetState(ITEM_CHANGED, _player);
Item* childItem = _player->GetChildItemByGuid(artifact->GetChildItem());
if (childItem)
{
childItem->SetAppearanceModId(artifactAppearance->ItemAppearanceModifierID);
childItem->SetState(ITEM_CHANGED, _player);
}
if (artifact->IsEquipped())
{
// change weapon appearance
_player->SetVisibleItemSlot(artifact->GetSlot(), artifact);
if (childItem)
_player->SetVisibleItemSlot(childItem->GetSlot(), childItem);
// change druid form appearance
if (artifactAppearance->OverrideShapeshiftDisplayID && artifactAppearance->OverrideShapeshiftFormID && _player->GetShapeshiftForm() == ShapeshiftForm(artifactAppearance->OverrideShapeshiftFormID))
_player->RestoreDisplayId();
}
}
示例2: HandleSocketGems
//.........这里部分代码省略.........
}
// unique limit type item
int32 limit_newcount = 0;
if (iGemProto->GetItemLimitCategory())
{
if (ItemLimitCategoryEntry const* limitEntry = sItemLimitCategoryStore.LookupEntry(iGemProto->GetItemLimitCategory()))
{
// NOTE: limitEntry->mode is not checked because if item has limit then it is applied in equip case
for (int j = 0; j < MAX_GEM_SOCKETS; ++j)
{
if (gems[j])
{
// new gem
if (iGemProto->GetItemLimitCategory() == gems[j]->GetTemplate()->GetItemLimitCategory())
++limit_newcount;
}
else if (oldGemData[j])
{
// existing gem
if (ItemTemplate const* jProto = sObjectMgr->GetItemTemplate(oldGemData[j]->ItemId))
if (iGemProto->GetItemLimitCategory() == jProto->GetItemLimitCategory())
++limit_newcount;
}
}
if (limit_newcount > 0 && uint32(limit_newcount) > limitEntry->Quantity)
{
_player->SendEquipError(EQUIP_ERR_ITEM_UNIQUE_EQUIPPABLE_SOCKETED, itemTarget, NULL);
return;
}
}
}
// for equipped item check all equipment for duplicate equipped gems
if (itemTarget->IsEquipped())
{
if (InventoryResult res = _player->CanEquipUniqueItem(gems[i], slot, std::max(limit_newcount, 0)))
{
_player->SendEquipError(res, itemTarget, NULL);
return;
}
}
}
bool SocketBonusActivated = itemTarget->GemsFitSockets(); //save state of socketbonus
_player->ToggleMetaGemsActive(slot, false); //turn off all metagems (except for the target item)
//if a meta gem is being equipped, all information has to be written to the item before testing if the conditions for the gem are met
//remove ALL mods - gem can change item level
if (itemTarget->IsEquipped())
_player->_ApplyItemMods(itemTarget, itemTarget->GetSlot(), false);
for (uint16 i = 0; i < MAX_GEM_SOCKETS; ++i)
{
if (gems[i])
{
uint32 gemScalingLevel = _player->getLevel();
if (uint32 fixedLevel = gems[i]->GetModifier(ITEM_MODIFIER_SCALING_STAT_DISTRIBUTION_FIXED_LEVEL))
gemScalingLevel = fixedLevel;
itemTarget->SetGem(i, &gemData[i], gemScalingLevel);
if (gemProperties[i] && gemProperties[i]->EnchantID)
itemTarget->SetEnchantment(EnchantmentSlot(SOCK_ENCHANTMENT_SLOT + i), gemProperties[i]->EnchantID, 0, 0, _player->GetGUID());
uint32 gemCount = 1;
_player->DestroyItemCount(gems[i], gemCount, true);
}
}
if (itemTarget->IsEquipped())
_player->_ApplyItemMods(itemTarget, itemTarget->GetSlot(), true);
if (Item* childItem = _player->GetChildItemByGuid(itemTarget->GetChildItem()))
{
if (childItem->IsEquipped())
_player->_ApplyItemMods(childItem, childItem->GetSlot(), false);
childItem->CopyArtifactDataFromParent(itemTarget);
if (childItem->IsEquipped())
_player->_ApplyItemMods(childItem, childItem->GetSlot(), true);
}
bool SocketBonusToBeActivated = itemTarget->GemsFitSockets();//current socketbonus state
if (SocketBonusActivated ^ SocketBonusToBeActivated) //if there was a change...
{
_player->ApplyEnchantment(itemTarget, BONUS_ENCHANTMENT_SLOT, false);
itemTarget->SetEnchantment(BONUS_ENCHANTMENT_SLOT, (SocketBonusToBeActivated ? itemTarget->GetTemplate()->GetSocketBonus() : 0), 0, 0, _player->GetGUID());
_player->ApplyEnchantment(itemTarget, BONUS_ENCHANTMENT_SLOT, true);
//it is not displayed, client has an inbuilt system to determine if the bonus is activated
}
_player->ToggleMetaGemsActive(slot, true); //turn on all metagems (except for target item)
_player->RemoveTradeableItem(itemTarget);
itemTarget->ClearSoulboundTradeable(_player); // clear tradeable flag
itemTarget->SendUpdateSockets();
}
示例3: HandleAutoEquipItemOpcode
void WorldSession::HandleAutoEquipItemOpcode(WorldPackets::Item::AutoEquipItem& autoEquipItem)
{
if (autoEquipItem.Inv.Items.size() != 1)
{
TC_LOG_ERROR("network", "HandleAutoEquipItemOpcode - Invalid itemCount (" SZFMTD ")", autoEquipItem.Inv.Items.size());
return;
}
TC_LOG_DEBUG("network", "HandleAutoEquipItemOpcode: receive PackSlot: %u, Slot: %u",
autoEquipItem.PackSlot, autoEquipItem.Slot);
Item* srcItem = _player->GetItemByPos(autoEquipItem.PackSlot, autoEquipItem.Slot);
if (!srcItem)
return; // only at cheat
uint16 dest;
InventoryResult msg = _player->CanEquipItem(NULL_SLOT, dest, srcItem, !srcItem->IsBag());
if (msg != EQUIP_ERR_OK)
{
_player->SendEquipError(msg, srcItem);
return;
}
uint16 src = srcItem->GetPos();
if (dest == src) // prevent equip in same slot, only at cheat
return;
Item* dstItem = _player->GetItemByPos(dest);
if (!dstItem) // empty slot, simple case
{
if (!srcItem->GetChildItem().IsEmpty())
{
InventoryResult childEquipResult = _player->CanEquipChildItem(srcItem);
if (childEquipResult != EQUIP_ERR_OK)
{
_player->SendEquipError(msg, srcItem);
return;
}
}
_player->RemoveItem(autoEquipItem.PackSlot, autoEquipItem.Slot, true);
_player->EquipItem(dest, srcItem, true);
if (!srcItem->GetChildItem().IsEmpty())
_player->EquipChildItem(autoEquipItem.PackSlot, autoEquipItem.Slot, srcItem);
_player->AutoUnequipOffhandIfNeed();
}
else // have currently equipped item, not simple case
{
uint8 dstbag = dstItem->GetBagSlot();
uint8 dstslot = dstItem->GetSlot();
msg = _player->CanUnequipItem(dest, !srcItem->IsBag());
if (msg != EQUIP_ERR_OK)
{
_player->SendEquipError(msg, dstItem);
return;
}
if (!dstItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_CHILD))
{
// check dest->src move possibility
ItemPosCountVec sSrc;
uint16 eSrc = 0;
if (_player->IsInventoryPos(src))
{
msg = _player->CanStoreItem(autoEquipItem.PackSlot, autoEquipItem.Slot, sSrc, dstItem, true);
if (msg != EQUIP_ERR_OK)
msg = _player->CanStoreItem(autoEquipItem.PackSlot, NULL_SLOT, sSrc, dstItem, true);
if (msg != EQUIP_ERR_OK)
msg = _player->CanStoreItem(NULL_BAG, NULL_SLOT, sSrc, dstItem, true);
}
else if (_player->IsBankPos(src))
{
msg = _player->CanBankItem(autoEquipItem.PackSlot, autoEquipItem.Slot, sSrc, dstItem, true);
if (msg != EQUIP_ERR_OK)
msg = _player->CanBankItem(autoEquipItem.PackSlot, NULL_SLOT, sSrc, dstItem, true);
if (msg != EQUIP_ERR_OK)
msg = _player->CanBankItem(NULL_BAG, NULL_SLOT, sSrc, dstItem, true);
}
else if (_player->IsEquipmentPos(src))
{
msg = _player->CanEquipItem(autoEquipItem.Slot, eSrc, dstItem, true);
if (msg == EQUIP_ERR_OK)
msg = _player->CanUnequipItem(eSrc, true);
}
if (msg == EQUIP_ERR_OK && Player::IsEquipmentPos(dest) && !srcItem->GetChildItem().IsEmpty())
msg = _player->CanEquipChildItem(srcItem);
if (msg != EQUIP_ERR_OK)
{
_player->SendEquipError(msg, dstItem, srcItem);
return;
}
// now do moves, remove...
_player->RemoveItem(dstbag, dstslot, false);
_player->RemoveItem(autoEquipItem.PackSlot, autoEquipItem.Slot, false);
//.........这里部分代码省略.........