public override string ToString() { return("LightningStaff " + ArtifactPower.ToString()); }
void HandleArtifactAddPower(ArtifactAddPower artifactAddPower) { if (!_player.GetGameObjectIfCanInteractWith(artifactAddPower.ForgeGUID, GameObjectTypes.ItemForge)) { return; } Item artifact = _player.GetItemByGuid(artifactAddPower.ArtifactGUID); if (!artifact) { return; } uint currentArtifactTier = artifact.GetModifier(ItemModifier.ArtifactTier); ulong xpCost = 0; GtArtifactLevelXPRecord cost = CliDB.ArtifactLevelXPGameTable.GetRow(artifact.GetTotalPurchasedArtifactPowers() + 1); if (cost != null) { xpCost = (ulong)(currentArtifactTier == PlayerConst.MaxArtifactTier ? cost.XP2 : cost.XP); } if (xpCost > artifact.m_itemData.ArtifactXP) { return; } if (artifactAddPower.PowerChoices.Empty()) { return; } ArtifactPower artifactPower = artifact.GetArtifactPower(artifactAddPower.PowerChoices[0].ArtifactPowerID); if (artifactPower == null) { return; } ArtifactPowerRecord artifactPowerEntry = CliDB.ArtifactPowerStorage.LookupByKey(artifactPower.ArtifactPowerId); if (artifactPowerEntry == null) { return; } if (artifactPowerEntry.Tier > currentArtifactTier) { return; } uint maxRank = artifactPowerEntry.MaxPurchasableRank; if (artifactPowerEntry.Tier < currentArtifactTier) { if (artifactPowerEntry.Flags.HasAnyFlag(ArtifactPowerFlag.Final)) { maxRank = 1; } else if (artifactPowerEntry.Flags.HasAnyFlag(ArtifactPowerFlag.MaxRankWithTier)) { maxRank += currentArtifactTier - artifactPowerEntry.Tier; } } if (artifactAddPower.PowerChoices[0].Rank != artifactPower.PurchasedRank + 1 || artifactAddPower.PowerChoices[0].Rank > maxRank) { return; } if (!artifactPowerEntry.Flags.HasAnyFlag(ArtifactPowerFlag.NoLinkRequired)) { var artifactPowerLinks = Global.DB2Mgr.GetArtifactPowerLinks(artifactPower.ArtifactPowerId); if (artifactPowerLinks != null) { bool hasAnyLink = false; foreach (uint artifactPowerLinkId in artifactPowerLinks) { ArtifactPowerRecord artifactPowerLink = CliDB.ArtifactPowerStorage.LookupByKey(artifactPowerLinkId); if (artifactPowerLink == null) { continue; } ArtifactPower artifactPowerLinkLearned = artifact.GetArtifactPower(artifactPowerLinkId); if (artifactPowerLinkLearned == null) { continue; } if (artifactPowerLinkLearned.PurchasedRank >= artifactPowerLink.MaxPurchasableRank) { hasAnyLink = true; break; } } if (!hasAnyLink) { return; } } } ArtifactPowerRankRecord artifactPowerRank = Global.DB2Mgr.GetArtifactPowerRank(artifactPower.ArtifactPowerId, (byte)(artifactPower.CurrentRankWithBonus + 1 - 1)); // need data for next rank, but -1 because of how db2 data is structured if (artifactPowerRank == null) { return; } artifact.SetArtifactPower(artifactPower.ArtifactPowerId, (byte)(artifactPower.PurchasedRank + 1), (byte)(artifactPower.CurrentRankWithBonus + 1)); if (artifact.IsEquipped()) { _player.ApplyArtifactPowerRank(artifact, artifactPowerRank, true); foreach (ArtifactPower power in artifact.m_itemData.ArtifactPowers) { ArtifactPowerRecord scaledArtifactPowerEntry = CliDB.ArtifactPowerStorage.LookupByKey(power.ArtifactPowerId); if (!scaledArtifactPowerEntry.Flags.HasAnyFlag(ArtifactPowerFlag.ScalesWithNumPowers)) { continue; } ArtifactPowerRankRecord scaledArtifactPowerRank = Global.DB2Mgr.GetArtifactPowerRank(scaledArtifactPowerEntry.Id, 0); if (scaledArtifactPowerRank == null) { continue; } artifact.SetArtifactPower(power.ArtifactPowerId, power.PurchasedRank, (byte)(power.CurrentRankWithBonus + 1)); _player.ApplyArtifactPowerRank(artifact, scaledArtifactPowerRank, false); _player.ApplyArtifactPowerRank(artifact, scaledArtifactPowerRank, true); } } artifact.SetArtifactXP(artifact.m_itemData.ArtifactXP - xpCost); artifact.SetState(ItemUpdateState.Changed, _player); uint totalPurchasedArtifactPower = artifact.GetTotalPurchasedArtifactPowers(); uint artifactTier = 0; foreach (ArtifactTierRecord tier in CliDB.ArtifactTierStorage.Values) { if (artifactPowerEntry.Flags.HasAnyFlag(ArtifactPowerFlag.Final) && artifactPowerEntry.Tier < PlayerConst.MaxArtifactTier) { artifactTier = artifactPowerEntry.Tier + 1u; break; } if (totalPurchasedArtifactPower < tier.MaxNumTraits) { artifactTier = tier.ArtifactTier; break; } } artifactTier = Math.Max(artifactTier, currentArtifactTier); for (uint i = currentArtifactTier; i <= artifactTier; ++i) { artifact.InitArtifactPowers(artifact.GetTemplate().GetArtifactID(), (byte)i); } artifact.SetModifier(ItemModifier.ArtifactTier, artifactTier); }
public override string ToString() { return("PoisonousSaliva " + ArtifactPower.ToString()); }