本文整理汇总了C++中Item::GetArtifactPowers方法的典型用法代码示例。如果您正苦于以下问题:C++ Item::GetArtifactPowers方法的具体用法?C++ Item::GetArtifactPowers怎么用?C++ Item::GetArtifactPowers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Item
的用法示例。
在下文中一共展示了Item::GetArtifactPowers方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleConfirmArtifactRespec
void WorldSession::HandleConfirmArtifactRespec(WorldPackets::Artifact::ConfirmArtifactRespec& confirmArtifactRespec)
{
if (!_player->GetNPCIfCanInteractWith(confirmArtifactRespec.NpcGUID, UNIT_NPC_FLAG_ARTIFACT_POWER_RESPEC))
return;
Item* artifact = _player->GetItemByGuid(confirmArtifactRespec.ArtifactGUID);
if (!artifact)
return;
uint64 xpCost = 0;
if (GtArtifactLevelXPEntry const* cost = sArtifactLevelXPGameTable.GetRow(artifact->GetTotalPurchasedArtifactPowers() + 1))
xpCost = uint64(artifact->GetModifier(ITEM_MODIFIER_ARTIFACT_TIER) == 1 ? cost->XP2 : cost->XP);
if (xpCost > artifact->GetUInt64Value(ITEM_FIELD_ARTIFACT_XP))
return;
uint64 newAmount = artifact->GetUInt64Value(ITEM_FIELD_ARTIFACT_XP) - xpCost;
for (uint32 i = 0; i <= artifact->GetTotalPurchasedArtifactPowers(); ++i)
if (GtArtifactLevelXPEntry const* cost = sArtifactLevelXPGameTable.GetRow(i))
newAmount += uint64(artifact->GetModifier(ITEM_MODIFIER_ARTIFACT_TIER) == 1 ? cost->XP2 : cost->XP);
for (ItemDynamicFieldArtifactPowers const& artifactPower : artifact->GetArtifactPowers())
{
uint8 oldPurchasedRank = artifactPower.PurchasedRank;
if (!oldPurchasedRank)
continue;
ItemDynamicFieldArtifactPowers newPower = artifactPower;
newPower.PurchasedRank -= oldPurchasedRank;
newPower.CurrentRankWithBonus -= oldPurchasedRank;
artifact->SetArtifactPower(&newPower);
if (artifact->IsEquipped())
if (ArtifactPowerRankEntry const* artifactPowerRank = sDB2Manager.GetArtifactPowerRank(artifactPower.ArtifactPowerId, 0))
_player->ApplyArtifactPowerRank(artifact, artifactPowerRank, false);
}
for (ItemDynamicFieldArtifactPowers const& power : artifact->GetArtifactPowers())
{
ArtifactPowerEntry const* scaledArtifactPowerEntry = sArtifactPowerStore.AssertEntry(power.ArtifactPowerId);
if (!(scaledArtifactPowerEntry->Flags & ARTIFACT_POWER_FLAG_SCALES_WITH_NUM_POWERS))
continue;
ArtifactPowerRankEntry const* scaledArtifactPowerRank = sDB2Manager.GetArtifactPowerRank(scaledArtifactPowerEntry->ID, 0);
if (!scaledArtifactPowerRank)
continue;
ItemDynamicFieldArtifactPowers newScaledPower = power;
newScaledPower.CurrentRankWithBonus = 0;
artifact->SetArtifactPower(&newScaledPower);
_player->ApplyArtifactPowerRank(artifact, scaledArtifactPowerRank, false);
}
artifact->SetUInt64Value(ITEM_FIELD_ARTIFACT_XP, newAmount);
artifact->SetState(ITEM_CHANGED, _player);
}
示例2: HandleArtifactAddPower
void WorldSession::HandleArtifactAddPower(WorldPackets::Artifact::ArtifactAddPower& artifactAddPower)
{
if (!_player->GetGameObjectIfCanInteractWith(artifactAddPower.ForgeGUID, GAMEOBJECT_TYPE_ARTIFACT_FORGE))
return;
Item* artifact = _player->GetItemByGuid(artifactAddPower.ArtifactGUID);
if (!artifact)
return;
uint64 xpCost = 0;
if (GtArtifactLevelXPEntry const* cost = sArtifactLevelXPGameTable.GetRow(artifact->GetTotalPurchasedArtifactPowers() + 1))
xpCost = uint64(artifact->GetModifier(ITEM_MODIFIER_ARTIFACT_TIER) == 1 ? cost->XP2 : cost->XP);
if (xpCost > artifact->GetUInt64Value(ITEM_FIELD_ARTIFACT_XP))
return;
if (artifactAddPower.PowerChoices.empty())
return;
ItemDynamicFieldArtifactPowers const* artifactPower = artifact->GetArtifactPower(artifactAddPower.PowerChoices[0].ArtifactPowerID);
if (!artifactPower)
return;
ArtifactPowerEntry const* artifactPowerEntry = sArtifactPowerStore.LookupEntry(artifactPower->ArtifactPowerId);
if (!artifactPowerEntry)
return;
if (artifactAddPower.PowerChoices[0].Rank != artifactPower->PurchasedRank + 1 ||
artifactAddPower.PowerChoices[0].Rank > artifactPowerEntry->MaxPurchasableRank)
return;
if (std::unordered_set<uint32> const* artifactPowerLinks = sDB2Manager.GetArtifactPowerLinks(artifactPower->ArtifactPowerId))
{
bool hasAnyLink = false;
for (uint32 artifactPowerLinkId : *artifactPowerLinks)
{
ArtifactPowerEntry const* artifactPowerLink = sArtifactPowerStore.LookupEntry(artifactPowerLinkId);
if (!artifactPowerLink)
continue;
ItemDynamicFieldArtifactPowers const* artifactPowerLinkLearned = artifact->GetArtifactPower(artifactPowerLinkId);
if (!artifactPowerLinkLearned)
continue;
if (artifactPowerLinkLearned->PurchasedRank >= artifactPowerLink->MaxPurchasableRank)
{
hasAnyLink = true;
break;
}
}
if (!hasAnyLink)
return;
}
ArtifactPowerRankEntry const* artifactPowerRank = sDB2Manager.GetArtifactPowerRank(artifactPower->ArtifactPowerId, artifactPower->CurrentRankWithBonus + 1 - 1); // need data for next rank, but -1 because of how db2 data is structured
if (!artifactPowerRank)
return;
ItemDynamicFieldArtifactPowers newPower = *artifactPower;
++newPower.PurchasedRank;
++newPower.CurrentRankWithBonus;
artifact->SetArtifactPower(&newPower);
if (artifact->IsEquipped())
{
_player->ApplyArtifactPowerRank(artifact, artifactPowerRank, true);
for (ItemDynamicFieldArtifactPowers const& power : artifact->GetArtifactPowers())
{
ArtifactPowerEntry const* scaledArtifactPowerEntry = sArtifactPowerStore.AssertEntry(power.ArtifactPowerId);
if (!(scaledArtifactPowerEntry->Flags & ARTIFACT_POWER_FLAG_SCALES_WITH_NUM_POWERS))
continue;
ArtifactPowerRankEntry const* scaledArtifactPowerRank = sDB2Manager.GetArtifactPowerRank(scaledArtifactPowerEntry->ID, 0);
if (!scaledArtifactPowerRank)
continue;
ItemDynamicFieldArtifactPowers newScaledPower = power;
++newScaledPower.CurrentRankWithBonus;
artifact->SetArtifactPower(&newScaledPower);
_player->ApplyArtifactPowerRank(artifact, scaledArtifactPowerRank, false);
_player->ApplyArtifactPowerRank(artifact, scaledArtifactPowerRank, true);
}
}
artifact->SetUInt64Value(ITEM_FIELD_ARTIFACT_XP, artifact->GetUInt64Value(ITEM_FIELD_ARTIFACT_XP) - xpCost);
artifact->SetState(ITEM_CHANGED, _player);
}