Core/Artifact Handle Artifact tiers + Artifact unlock (3rd relic bonus)
This commit is contained in:
@@ -81,7 +81,7 @@ namespace Game.Entities
|
||||
{
|
||||
if (spellInfo.HasEffect(SpellEffectName.GiveArtifactPower))
|
||||
{
|
||||
uint artifactKnowledgeLevel = owner.GetCurrency((uint)CurrencyTypes.ArtifactKnowledge);
|
||||
uint artifactKnowledgeLevel = WorldConfig.GetUIntValue(WorldCfg.CurrencyStartArtifactKnowledge);
|
||||
if (artifactKnowledgeLevel != 0)
|
||||
SetModifier(ItemModifier.ArtifactKnowledgeLevel, artifactKnowledgeLevel + 1);
|
||||
}
|
||||
@@ -112,6 +112,8 @@ namespace Game.Entities
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CheckArtifactRelicSlotUnlock(owner != null ? owner : GetOwner());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -295,6 +297,7 @@ namespace Game.Entities
|
||||
stmt.AddValue(0, GetGUID().GetCounter());
|
||||
stmt.AddValue(1, GetUInt64Value(ItemFields.ArtifactXp));
|
||||
stmt.AddValue(2, GetModifier(ItemModifier.ArtifactAppearanceId));
|
||||
stmt.AddValue(3, GetModifier(ItemModifier.ArtifactTier));
|
||||
trans.Append(stmt);
|
||||
|
||||
foreach (ItemDynamicFieldArtifactPowers artifactPower in GetArtifactPowers())
|
||||
@@ -547,11 +550,15 @@ namespace Game.Entities
|
||||
return true;
|
||||
}
|
||||
|
||||
public void LoadArtifactData(Player owner, ulong xp, uint artifactAppearanceId, List<ItemDynamicFieldArtifactPowers> powers)
|
||||
public void LoadArtifactData(Player owner, ulong xp, uint artifactAppearanceId, uint artifactTier, List<ItemDynamicFieldArtifactPowers> powers)
|
||||
{
|
||||
InitArtifactPowers(GetTemplate().GetArtifactID(), 0);
|
||||
for (byte i = 0; i <= artifactTier; ++i)
|
||||
InitArtifactPowers(GetTemplate().GetArtifactID(), i);
|
||||
|
||||
SetUInt64Value(ItemFields.ArtifactXp, xp);
|
||||
SetModifier(ItemModifier.ArtifactAppearanceId, artifactAppearanceId);
|
||||
SetModifier(ItemModifier.ArtifactTier, artifactTier);
|
||||
|
||||
ArtifactAppearanceRecord artifactAppearance = CliDB.ArtifactAppearanceStorage.LookupByKey(artifactAppearanceId);
|
||||
if (artifactAppearance != null)
|
||||
SetAppearanceModId(artifactAppearance.ItemAppearanceModifierID);
|
||||
@@ -612,6 +619,23 @@ namespace Game.Entities
|
||||
power.CurrentRankWithBonus = (byte)(totalPurchasedRanks + 1);
|
||||
SetArtifactPower(power);
|
||||
}
|
||||
|
||||
CheckArtifactRelicSlotUnlock(owner != null ? owner : GetOwner());
|
||||
}
|
||||
|
||||
public void CheckArtifactRelicSlotUnlock(Player owner)
|
||||
{
|
||||
if (!owner)
|
||||
return;
|
||||
|
||||
byte artifactId = GetTemplate().GetArtifactID();
|
||||
if (artifactId == 0)
|
||||
return;
|
||||
|
||||
foreach (ArtifactUnlockRecord artifactUnlock in CliDB.ArtifactUnlockStorage.Values)
|
||||
if (artifactUnlock.ArtifactID == artifactId)
|
||||
if (owner.MeetPlayerCondition(artifactUnlock.PlayerConditionID))
|
||||
AddBonuses(artifactUnlock.ItemBonusListID);
|
||||
}
|
||||
|
||||
public static void DeleteFromDB(SQLTransaction trans, ulong itemGuid)
|
||||
@@ -2194,6 +2218,9 @@ namespace Game.Entities
|
||||
|
||||
public void AddBonuses(uint bonusListID)
|
||||
{
|
||||
if (HasDynamicValue(ItemDynamicFields.BonusListIds, bonusListID))
|
||||
return;
|
||||
|
||||
var bonuses = Global.DB2Mgr.GetItemBonusList(bonusListID);
|
||||
if (bonuses != null)
|
||||
{
|
||||
@@ -2237,7 +2264,7 @@ namespace Game.Entities
|
||||
SetDynamicStructuredValue(ItemDynamicFields.ArtifactPowers, index, artifactPower);
|
||||
}
|
||||
|
||||
void InitArtifactPowers(byte artifactId, byte artifactTier)
|
||||
public void InitArtifactPowers(byte artifactId, byte artifactTier)
|
||||
{
|
||||
foreach (ArtifactPowerRecord artifactPower in Global.DB2Mgr.GetArtifactPowers(artifactId))
|
||||
{
|
||||
@@ -2250,7 +2277,7 @@ namespace Game.Entities
|
||||
ItemDynamicFieldArtifactPowers powerData = new ItemDynamicFieldArtifactPowers();
|
||||
powerData.ArtifactPowerId = artifactPower.Id;
|
||||
powerData.PurchasedRank = 0;
|
||||
powerData.CurrentRankWithBonus = (byte)(artifactPower.Flags.HasAnyFlag(ArtifactPowerFlag.First) ? 1 : 0);
|
||||
powerData.CurrentRankWithBonus = (byte)((artifactPower.Flags & ArtifactPowerFlag.First) == ArtifactPowerFlag.First ? 1 : 0);
|
||||
SetArtifactPower(powerData, true);
|
||||
}
|
||||
}
|
||||
@@ -2366,7 +2393,7 @@ namespace Game.Entities
|
||||
SetAppearanceModId(parent.GetAppearanceModId());
|
||||
}
|
||||
|
||||
public void GiveArtifactXp(ulong amount, Item sourceItem, uint artifactCategoryId)
|
||||
public void GiveArtifactXp(ulong amount, Item sourceItem, ArtifactCategory artifactCategoryId)
|
||||
{
|
||||
Player owner = GetOwner();
|
||||
if (!owner)
|
||||
@@ -2374,26 +2401,22 @@ namespace Game.Entities
|
||||
|
||||
if (artifactCategoryId != 0)
|
||||
{
|
||||
ArtifactCategoryRecord artifactCategory = CliDB.ArtifactCategoryStorage.LookupByKey(artifactCategoryId);
|
||||
if (artifactCategory != null)
|
||||
{
|
||||
uint artifactKnowledgeLevel = 1;
|
||||
if (sourceItem && sourceItem.GetModifier(ItemModifier.ArtifactKnowledgeLevel) != 0)
|
||||
artifactKnowledgeLevel = sourceItem.GetModifier(ItemModifier.ArtifactKnowledgeLevel);
|
||||
else
|
||||
artifactKnowledgeLevel = owner.GetCurrency(artifactCategory.XpMultCurrencyID) + 1;
|
||||
uint artifactKnowledgeLevel = 1;
|
||||
if (sourceItem != null && sourceItem.GetModifier(ItemModifier.ArtifactKnowledgeLevel) != 0)
|
||||
artifactKnowledgeLevel = sourceItem.GetModifier(ItemModifier.ArtifactKnowledgeLevel);
|
||||
else if (artifactCategoryId == ArtifactCategory.Primary)
|
||||
artifactKnowledgeLevel = WorldConfig.GetUIntValue(WorldCfg.CurrencyStartArtifactKnowledge) + 1;
|
||||
|
||||
GtArtifactKnowledgeMultiplierRecord artifactKnowledge = CliDB.ArtifactKnowledgeMultiplierGameTable.GetRow(artifactKnowledgeLevel);
|
||||
if (artifactKnowledge != null)
|
||||
amount = (ulong)(amount * artifactKnowledge.Multiplier);
|
||||
GtArtifactKnowledgeMultiplierRecord artifactKnowledge = CliDB.ArtifactKnowledgeMultiplierGameTable.GetRow(artifactKnowledgeLevel);
|
||||
if (artifactKnowledge != null)
|
||||
amount = (ulong)(amount * artifactKnowledge.Multiplier);
|
||||
|
||||
if (amount >= 5000)
|
||||
amount = 50 * (amount / 50);
|
||||
else if (amount >= 1000)
|
||||
amount = 25 * (amount / 25);
|
||||
else if (amount >= 50)
|
||||
amount = 5 * (amount / 5);
|
||||
}
|
||||
if (amount >= 5000)
|
||||
amount = 50 * (amount / 50);
|
||||
else if (amount >= 1000)
|
||||
amount = 25 * (amount / 25);
|
||||
else if (amount >= 50)
|
||||
amount = 5 * (amount / 5);
|
||||
}
|
||||
|
||||
SetUInt64Value(ItemFields.ArtifactXp, GetUInt64Value(ItemFields.ArtifactXp) + amount);
|
||||
|
||||
@@ -1401,6 +1401,17 @@ namespace Game.Entities
|
||||
return _dynamicValues[(int)index][offset];
|
||||
}
|
||||
|
||||
public bool HasDynamicValue(object index, uint value)
|
||||
{
|
||||
Cypher.Assert((int)index < _dynamicValuesCount || PrintIndexError(index, false));
|
||||
uint[] values = _dynamicValues[(int)index];
|
||||
for (var i = 0; i < values.Length; ++i)
|
||||
if (values[i] == value)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void AddDynamicValue(object index, uint value)
|
||||
{
|
||||
Cypher.Assert((int)index < _dynamicValuesCount || PrintIndexError(index, true));
|
||||
|
||||
@@ -39,28 +39,32 @@ namespace Game.Entities
|
||||
{
|
||||
void _LoadInventory(SQLResult result, SQLResult artifactsResult, uint timeDiff)
|
||||
{
|
||||
// 0 1 2 3 4
|
||||
// SELECT a.itemGuid, a.xp, a.artifactAppearanceId, ap.artifactPowerId, ap.purchasedRank FROM item_instance_artifact_powers ap LEFT JOIN item_instance_artifact a ON ap.itemGuid = a.itemGuid INNER JOIN character_inventory ci ON ci.item = ap.guid WHERE ci.guid = ?
|
||||
Dictionary<ObjectGuid, Tuple<ulong, uint, List<ItemDynamicFieldArtifactPowers>>> artifactData = new Dictionary<ObjectGuid, Tuple<ulong, uint, List<ItemDynamicFieldArtifactPowers>>>();
|
||||
//MultiMap<ObjectGuid, ItemDynamicFieldArtifactPowers> artifactPowerData = new MultiMap<ObjectGuid, ItemDynamicFieldArtifactPowers>();
|
||||
// 0 1 2 3 4 5
|
||||
// SELECT a.itemGuid, a.xp, a.artifactAppearanceId, a.artifactTierId, ap.artifactPowerId, ap.purchasedRank FROM item_instance_artifact_powers ap LEFT JOIN item_instance_artifact a ON ap.itemGuid = a.itemGuid INNER JOIN character_inventory ci ON ci.item = ap.guid WHERE ci.guid = ?
|
||||
var artifactData = new Dictionary<ObjectGuid, Tuple<ulong, uint, uint, List<ItemDynamicFieldArtifactPowers>>>();
|
||||
if (!artifactsResult.IsEmpty())
|
||||
{
|
||||
do
|
||||
{
|
||||
var artifactDataEntry = Tuple.Create(artifactsResult.Read<ulong>(1), artifactsResult.Read<uint>(2), new List<ItemDynamicFieldArtifactPowers>());
|
||||
var artifactDataEntry = Tuple.Create(artifactsResult.Read<ulong>(1), artifactsResult.Read<uint>(2), artifactsResult.Read<uint>(3), new List<ItemDynamicFieldArtifactPowers>());
|
||||
ItemDynamicFieldArtifactPowers artifactPowerData = new ItemDynamicFieldArtifactPowers();
|
||||
artifactPowerData.ArtifactPowerId = artifactsResult.Read<uint>(3);
|
||||
artifactPowerData.PurchasedRank = artifactsResult.Read<byte>(4);
|
||||
artifactPowerData.ArtifactPowerId = artifactsResult.Read<uint>(4);
|
||||
artifactPowerData.PurchasedRank = artifactsResult.Read<byte>(5);
|
||||
|
||||
ArtifactPowerRecord artifactPower = CliDB.ArtifactPowerStorage.LookupByKey(artifactPowerData.ArtifactPowerId);
|
||||
if (artifactPower != null)
|
||||
{
|
||||
if (artifactPowerData.PurchasedRank > artifactPower.MaxPurchasableRank)
|
||||
artifactPowerData.PurchasedRank = artifactPower.MaxPurchasableRank;
|
||||
uint maxRank = artifactPower.MaxPurchasableRank;
|
||||
// allow ARTIFACT_POWER_FLAG_FINAL to overflow maxrank here - needs to be handled in Item::CheckArtifactUnlock (will refund artifact power)
|
||||
if (artifactPower.Flags.HasAnyFlag(ArtifactPowerFlag.MaxRankWithTier) && artifactPower.Tier < artifactDataEntry.Item3)
|
||||
maxRank += artifactDataEntry.Item3 - artifactPower.Tier;
|
||||
|
||||
artifactPowerData.CurrentRankWithBonus = (byte)(artifactPower.Flags.HasAnyFlag(ArtifactPowerFlag.First) ? 1 : 0);
|
||||
if (artifactPowerData.PurchasedRank > maxRank)
|
||||
artifactPowerData.PurchasedRank = (byte)maxRank;
|
||||
|
||||
artifactDataEntry.Item3.Add(artifactPowerData);
|
||||
artifactPowerData.CurrentRankWithBonus = (byte)((artifactPower.Flags & ArtifactPowerFlag.First) == ArtifactPowerFlag.First ? 1 : 0);
|
||||
|
||||
artifactDataEntry.Item4.Add(artifactPowerData);
|
||||
}
|
||||
|
||||
artifactData[ObjectGuid.Create(HighGuid.Item, artifactsResult.Read<ulong>(0))] = artifactDataEntry;
|
||||
@@ -85,7 +89,7 @@ namespace Game.Entities
|
||||
{
|
||||
var artifactDataPair = artifactData.LookupByKey(item.GetGUID());
|
||||
if (item.GetTemplate().GetArtifactID() != 0 && artifactDataPair != null)
|
||||
item.LoadArtifactData(this, artifactDataPair.Item1, artifactDataPair.Item2, artifactDataPair.Item3);
|
||||
item.LoadArtifactData(this, artifactDataPair.Item1, artifactDataPair.Item2, artifactDataPair.Item3, artifactDataPair.Item4);
|
||||
|
||||
ulong counter = result.Read<ulong>(45);
|
||||
ObjectGuid bagGuid = counter != 0 ? ObjectGuid.Create(HighGuid.Item, counter) : ObjectGuid.Empty;
|
||||
|
||||
@@ -5085,6 +5085,16 @@ namespace Game.Entities
|
||||
SendPacket(displayPlayerChoice);
|
||||
}
|
||||
|
||||
public bool MeetPlayerCondition(uint conditionId)
|
||||
{
|
||||
PlayerConditionRecord playerCondition = CliDB.PlayerConditionStorage.LookupByKey(conditionId);
|
||||
if (playerCondition != null)
|
||||
if (!ConditionManager.IsPlayerMeetingCondition(this, playerCondition))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public float GetCollisionHeight(bool mounted)
|
||||
{
|
||||
if (mounted)
|
||||
@@ -5333,6 +5343,14 @@ namespace Game.Entities
|
||||
|
||||
_ApplyAllLevelScaleItemMods(true); // Moved to above SetFullHealth so player will have full health from Heirlooms
|
||||
|
||||
Aura artifactAura = GetAura(PlayerConst.ArtifactsAllWeaponsGeneralWeaponEquippedPassive);
|
||||
if (artifactAura != null)
|
||||
{
|
||||
Item artifact = GetItemByGuid(artifactAura.GetCastItemGUID());
|
||||
if (artifact != null)
|
||||
artifact.CheckArtifactRelicSlotUnlock(this);
|
||||
}
|
||||
|
||||
// Only health and mana are set to maximum.
|
||||
SetFullHealth();
|
||||
SetFullPower(PowerType.Mana);
|
||||
|
||||
Reference in New Issue
Block a user